• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: drawing a waveform
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing a waveform


  • Subject: Re: drawing a waveform
  • From: Gregory Wieber <email@hidden>
  • Date: Mon, 4 Oct 2010 13:06:17 -0700

Check out the ASBD you're using to see what format the data is in --  I think the weirdness is that you are displaying integer information as floats (just a guess).  

On Mon, Oct 4, 2010 at 12:56 PM, Michael Hanna <email@hidden> wrote:
I'm trying to get values from a CoreAudio AudioQueueBufferRef so that I can draw a waveform. I've tried this, but I get very odd numbers. Am I doing this correctly? I realize doing this in the render callback is a bad idea but I'm just starting and I want to just see what values to expect. I understand that the values would be based on the data format. Or would it? Would it either be the AudioStreamBasicDescription from the AudioFile or would it be the AudioStreamPacketDescription here in the AudioQueue callback? Or neither? Example values to follow, any help would be appreciated.. Michael


static const UInt32 kNumberBuffers = 3;
static const double kBufferDurationSeconds = 0.1;

static const UInt32 kMaxBufferSize = 0x10000; // limit size to 64K
static const UInt32 kMinBufferSize = 0x4000; // limit size to 16K

…………
void YKK_AudioQueueBufferCallback(void * inUserData,
                                  AudioQueueRef inAQ,
                                  AudioQueueBufferRef inCompleteAQBuffer) {  
YKK_AudioQueueFilePlayer *player = (YKK_AudioQueueFilePlayer*)inUserData;
if (player->_done) return;  
UInt32 numBytes;
UInt32 nPackets = player->_numPacketsToRead;
// Read nPackets worth of data into buffer
OSStatus result =  AudioFileReadPackets(player->_audioFile, false, &numBytes, player->_packetDescs, player->_currentPacket, &nPackets, inCompleteAQBuffer->mAudioData);

for (int k=0; k<kNumberBuffers; k++) {
printf("buf data %d:%f\n", k, ((float*)(inCompleteAQBuffer->mAudioData))[k]);
}


…………



output:

2010-09-30 12:37:49.269 AudioQueuePlayer[58261:a0f] bufferByteSize 17640 mNumPacketsToRead 4410

buf data 0:-175451483378078104778744325153086242816.000000

buf data 1:-170137786156860620076891292551293698048.000000

buf data 2:-174122214817473981602499670198303326208.000000

buf data 0:-317685247603679649803964800039986921472.000000

buf data 1:-309709818781741343611530685836550995968.000000

buf data 2:-312368376185359193615690419693368115200.000000

buf data 0:-142230863841028222836349850429966778368.000000

buf data 1:-142230914547052231965525910298094993408.000000

buf data 2:-140901716974881721570127739158691577856.000000

buf data 0:0.000000

buf data 1:0.000000

buf data 2:0.000000

buf data 0:nan

buf data 1:nan

buf data 2:nan

buf data 0:0.000000

buf data 1:0.000000

buf data 2:0.000000

buf data 0:-293759711587020066338468143477976727552.000000

buf data 1:-281796598777727012527322608093699768320.000000

buf data 2:-269833384556385940457824952973166379008.000000

buf data 0:0.000000


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >drawing a waveform (From: Michael Hanna <email@hidden>)

  • Prev by Date: drawing a waveform
  • Next by Date: Is it safe to use memset() & memcpy() in my callback?
  • Previous by thread: drawing a waveform
  • Next by thread: Is it safe to use memset() & memcpy() in my callback?
  • Index(es):
    • Date
    • Thread