Re: Newbie: trying to log samples
Re: Newbie: trying to log samples
- Subject: Re: Newbie: trying to log samples
- From: Michael Hanna <email@hidden>
- Date: Thu, 3 Feb 2005 13:24:29 -0500
Thanks Mike. That helped a lot. Now I'm outputting an array of floats, however a weird thing is happening. If I printout, say, the first 32 samples, I get 8 samples in the first part of my printout array and the rest zeroes. Or if I printout the first 256 samples, I get 64 significant numbers and the rest zeroes. Why are there missing samples and why this 4:1 ratio of significant data to none? How could my observing of the samples affect the output? This isn't quantum audio!! Or is it?? :) Near the end of my printout array I also get this very low number such as:
2005-02-03 08:00:44.833 Recordotron[4466] aSample 0 -0.015533
2005-02-03 08:00:44.833 Recordotron[4466] aSample 1 -0.015167
2005-02-03 08:00:44.833 Recordotron[4466] aSample 2 -0.015167
2005-02-03 08:00:44.833 Recordotron[4466] aSample 3 -0.015411
2005-02-03 08:00:44.833 Recordotron[4466] aSample 4 0.000000
2005-02-03 08:00:44.833 Recordotron[4466] aSample 5 0.000000
2005-02-03 08:00:44.833 Recordotron[4466] aSample 6 0.000000
2005-02-03 08:00:44.833 Recordotron[4466] aSample 7 0.000000
2005-02-03 08:00:44.833 Recordotron[4466] aSample 8 -188346713687045477874404425728.000000
2005-02-03 08:00:44.833 Recordotron[4466] aSample 9 0.000000
2005-02-03 08:00:44.833 Recordotron[4466] aSample 10 0.000000
2005-02-03 08:00:44.833 Recordotron[4466] aSample 11 0.000000
2005-02-03 08:00:44.834 Recordotron[4466] aSample 12 0.000000
2005-02-03 08:00:44.834 Recordotron[4466] aSample 13 0.000000
2005-02-03 08:00:44.834 Recordotron[4466] aSample 14 0.000000
2005-02-03 08:00:44.834 Recordotron[4466] aSample 15 0.000000
I'm a little confused as to why this is also..
regards,
Michael
<x-tad-smaller>#define SOUND_PRINTOUT_SIZE (2 * 128)</x-tad-smaller><x-tad-smaller>
</x-tad-smaller>
<x-tad-smaller>static</x-tad-smaller><x-tad-smaller> </x-tad-smaller>
<x-tad-smaller>unsigned</x-tad-smaller><x-tad-smaller> </x-tad-smaller>
<x-tad-smaller>char</x-tad-smaller><x-tad-smaller> g_soundBuffer[SOUND_BUFFER_SIZE];
</x-tad-smaller>...
<x-tad-smaller>- (OSStatus) readCycleForDevice: (MTCoreAudioDevice *) theDevice
timeStamp: (</x-tad-smaller>
<x-tad-smaller>const</x-tad-smaller><x-tad-smaller> AudioTimeStamp *) now
inputData: (</x-tad-smaller>
<x-tad-smaller>const</x-tad-smaller><x-tad-smaller> AudioBufferList *) inputData
inputTime: (</x-tad-smaller>
<x-tad-smaller>const</x-tad-smaller><x-tad-smaller> AudioTimeStamp *) inputTime
outputData: (AudioBufferList *) outputData
outputTime: (</x-tad-smaller>
<x-tad-smaller>const</x-tad-smaller><x-tad-smaller> AudioTimeStamp *) outputTime
clientData: (</x-tad-smaller>
<x-tad-smaller>void</x-tad-smaller><x-tad-smaller> *) clientData
{
</x-tad-smaller>
<x-tad-smaller>float</x-tad-smaller><x-tad-smaller> aSample[SOUND_PRINTOUT_SIZE];
</x-tad-smaller>
<x-tad-smaller>int</x-tad-smaller><x-tad-smaller> i;
</x-tad-smaller>
<x-tad-smaller>// peer into the data</x-tad-smaller><x-tad-smaller>
</x-tad-smaller>
<x-tad-smaller>const</x-tad-smaller><x-tad-smaller> AudioBuffer *buffer;
buffer = &inputData->mBuffers[</x-tad-smaller>
<x-tad-smaller>0</x-tad-smaller><x-tad-smaller>];
</x-tad-smaller>
<x-tad-smaller>if</x-tad-smaller><x-tad-smaller> (g_lastIndex + buffer->mDataByteSize > SOUND_BUFFER_SIZE) {
[</x-tad-smaller>
<x-tad-smaller>self</x-tad-smaller><x-tad-smaller> performSelectorOnMainThread: </x-tad-smaller>
<x-tad-smaller>@selector</x-tad-smaller><x-tad-smaller>(stopRecording:)
withObject: </x-tad-smaller>
<x-tad-smaller>self</x-tad-smaller><x-tad-smaller>
waitUntilDone: </x-tad-smaller>
<x-tad-smaller>NO</x-tad-smaller><x-tad-smaller>];
} </x-tad-smaller>
<x-tad-smaller>else</x-tad-smaller><x-tad-smaller> {
memcpy (aSample, buffer->mData, SOUND_PRINTOUT_SIZE); </x-tad-smaller>
<x-tad-smaller>// grab 128 frames, 256 words</x-tad-smaller><x-tad-smaller>
</x-tad-smaller>
<x-tad-smaller>for</x-tad-smaller><x-tad-smaller>(i = </x-tad-smaller>
<x-tad-smaller>0</x-tad-smaller><x-tad-smaller>; i < SOUND_PRINTOUT_SIZE ; i++)
{
NSLog(</x-tad-smaller>
<x-tad-smaller>@"aSample %d %f\n"</x-tad-smaller><x-tad-smaller>,i , aSample[i]); </x-tad-smaller>
<x-tad-smaller>// output as a signed 32-bit float</x-tad-smaller><x-tad-smaller>
}
memcpy (g_soundBuffer + g_lastIndex,
buffer->mData, buffer->mDataByteSize);
g_lastIndex += buffer->mDataByteSize;
}
</x-tad-smaller>
<x-tad-smaller>return</x-tad-smaller><x-tad-smaller> (noErr);
</x-tad-smaller>
_______________________________________________
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