• 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
Newbie: trying to log samples
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie: trying to log samples


  • Subject: Newbie: trying to log samples
  • From: Michael Hanna <email@hidden>
  • Date: Thu, 3 Feb 2005 01:55:07 -0500

hi, I'm trying to log the samples coming from the microphone. This code is from the net that uses the MTCoreAudio. buffer->mDataByteSize %u gives me 4096 bytes, so I'm assuming that I'm being fed 4096 bytes, or 2048 samples per cycle(each sample being 2 bytes long, or 16-bit).


I added the unsigned char aSample[2] (want to see if I can get the first sample out of the buffer as a starting point). Then once the data is read-in, I memcpy the first sample to the aSample array. Then I log it to the console as an unsigned 16-bit. However my output is the same over and over:

2005-02-03 01:44:45.577 Recordotron[4074] aSample 5392
2005-02-03 01:44:45.588 Recordotron[4074] aSample 5392
2005-02-03 01:44:45.600 Recordotron[4074] aSample 5392

Clearly I'm not doing something right, but I'm not sure what! :)
Any help at all would be appreciated.

Michael

- (OSStatus) readCycleForDevice: (MTCoreAudioDevice *) theDevice
timeStamp: (const AudioTimeStamp *) now
inputData: (const AudioBufferList *) inputData
inputTime: (const AudioTimeStamp *) inputTime
outputData: (AudioBufferList *) outputData
outputTime: (const AudioTimeStamp *) outputTime
clientData: (void *) clientData
{

unsigned char aSample[2];

// peer into the data

const AudioBuffer *buffer;
buffer = &inputData->mBuffers[0];

//NSLog(@"buffer->mDataByteSize %u", buffer->mDataByteSize);
// will this sample put us over the line? If so, dump the data
// and tell the UI to stop the recording and disable the Stop
// button. We don't stop the actual reading from here
// because it seems to leave some stale locks in the MTCoreAudio
// guts.

if (g_lastIndex + buffer->mDataByteSize > SOUND_BUFFER_SIZE) {
[self performSelectorOnMainThread: @selector(stopRecording:)
withObject: self
waitUntilDone: NO];

} else {

memcpy (aSample + 2, buffer->mData, 2); // grab 2 bytes(one sample)
NSLog(@"aSample %hi", aSample); // output as an unsigned 16-bit integer
// append the data to the end of our buffer
memcpy (g_soundBuffer + g_lastIndex,
buffer->mData, buffer->mDataByteSize);
g_lastIndex += buffer->mDataByteSize;



}

return (noErr);

} // readCycleForDevice

_______________________________________________
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
  • Follow-Ups:
    • Re: Newbie: trying to log samples
      • From: Michael Thornburgh <email@hidden>
  • Prev by Date: Re: k8BitOffsetBinaryFormat in ASBD question
  • Next by Date: Re: Newbie: trying to log samples
  • Previous by thread: Re: problems compiling SDK PublicUtility classes
  • Next by thread: Re: Newbie: trying to log samples
  • Index(es):
    • Date
    • Thread