Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3679186
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:25:47+00:00 2026-05-19T03:25:47+00:00

I am currently working on an audio DSP App development. The project requires direct

  • 0

I am currently working on an audio DSP App development. The project requires direct access and modification of audio data. Right now I can successfully access and modify the raw audio data using AudioQueue but encounters error during playback. The output audio after any modification turns out be noise.

In short, the code is something like this:

(Modified from Speakhere sample code. The rest remains unchanged.)

void AQPlayer::AQBufferCallback(void *                  inUserData,
                            AudioQueueRef           inAQ,
                            AudioQueueBufferRef     inCompleteAQBuffer) 
{
AQPlayer *THIS = (AQPlayer *)inUserData;

if (THIS->mIsDone) return;

UInt32 numBytes;
UInt32 nPackets = THIS->GetNumPacketsToRead();
OSStatus result = AudioFileReadPackets(THIS->GetAudioFileID(), 
                                       false, 
                                       &numBytes, 
                                       inCompleteAQBuffer->mPacketDescriptions, 
                                       THIS->GetCurrentPacket(), 
                                       &nPackets, 
                                       inCompleteAQBuffer->mAudioData);
if (result)
    printf("AudioFileReadPackets failed: %d", (int)result);
if (nPackets > 0) {
    inCompleteAQBuffer->mAudioDataByteSize = numBytes;      
    inCompleteAQBuffer->mPacketDescriptionCount = nPackets;     

//My modification starts from here
//Modifying audio data

SInt16 *testBuffer = (SInt16*)inCompleteAQBuffer->mAudioData;   
for (int i = 0; i < (inCompleteAQBuffer->mAudioDataByteSize)/sizeof(SInt16); i++)
    {           
        //printf("before modification %d", (int)*testBuffer);   
        *testBuffer = (SInt16) *testBuffer/2; //Say some simple modification
        //printf("after modification %d", (int)*testBuffer);    

        testBuffer++;
        }

AudioQueueEnqueueBuffer(inAQ, inCompleteAQBuffer, 0, NULL);

}

During debugging, the data in buffer is displayed as expected, but the actual output is nothing but noise.

Here are some other strange behaviors of the code that makes both the whole team crazy:

  1. If there is no change to the data (add/sub by 0, multiply by 1) or the whole buffer is assigned to a constant (say 0, then the audio will be muted), the playback behaves normally (Of course!) But if I perform anything more than it, it still turns out to be noise.

  2. In the case I hardcode a single tone as test audio, the output noise spreads into another channel also.

So where is the bug in this code? Or if I am on the wrong track, what is the correct approach to modify the audio data and perform playback CORRECTLY? Any insight will be sincerely appreciated.

Thank you very much 🙂

Cheers,

Manca

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:25:48+00:00Added an answer on May 19, 2026 at 3:25 am

    are you SURE the sample format is SInt16? And how many channels are there? You seem to treat the audio as a single channel short stream, but suppose the format is actually dual channel Float32 or so, and you do the modifications there, than the effect would be exactly as you describe, including the noise on other channels.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an audio-intensive app for the iPhone. I'm currently calling a number
I am currently working on a project and my goal is to locate text
I'm currently working on creating a new C# project that needs to interact with
I am currently working on a project with specific requirements. A brief overview of
The system I am currently working on requires some role-based security, which is well
I'm currently working at a small web development company, we mostly do campaign sites
I'm currently working on the iPhone with Audio Units and I'm playing four tracks
I'm currently working on an application which requires transmission of speech encoded to a
Currently I am working on the application for which I have to use audio
Currently I am working on iPad. I would like to retrieve system audio files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.