• 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: Internal Microphone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Internal Microphone


  • Subject: Re: Internal Microphone
  • From: Michael Thornburgh <email@hidden>
  • Date: Wed, 14 Apr 2004 20:35:44 -0700

On Apr 14, 2004, at 11:28 AM, Ashish Jain wrote:

Hi all,
I have just joined the group. I am working on a I am having difficulty figuring out getting sound data continously from internal microphone. I wanted to obtain the sound so that I could do live analysis, need it for building my own speech recognition system. I am aware that Apple already has an inbuilt speech recognition system, but I want to use different techniques.
In short need a way to get sound data in bytes if possible float and an ability to process it.

Can somebody help me with finding an easy technique for accessing voice from the internal microphone ?

Ashish


if you are using Objective-C, then MTCoreAudio can make this super easy. the following example will supply chunks of FRAMES_TO_PROCESS samples (from the first channel of the default input device, at the device's current sampling rate) to DoMyProcessing(). just fill in your processing there. there's a 2-second buffer, and DoMyProcessing() gets called on the main thread, so you don't have to be concerned about timing, memory allocation, or other safe-at-IOProc-time things in DoMyProcessing().

MTCoreAudio is at http://aldebaran.armory.com/~zenomt/macosx/MTCoreAudio/

-mike

---

#import <unistd.h>
#import <stdio.h>
#import <MTCoreAudio/MTCoreAudio.h>

#define FRAMES_TO_PROCESS 512
#define SECONDS_TO_BUFFER 2
double sampleRate;


Boolean DoMyProcessing ( Float32 * samples, unsigned numSamples )
{
// do your work here

return TRUE; // return FALSE to end processing
}


OSStatus recordIOProc (
AudioDeviceID inDevice,
const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime,
void* inClientData
)
{
MTAudioBuffer * theBuffer = inClientData;
[theBuffer writeFromAudioBufferList:inInputData maxFrames:SIZE_MAX rateScalar:1.0 waitForRoom:NO];
return noErr;
}

main()
{
NSAutoreleasePool * pool = [NSAutoreleasePool new];
MTCoreAudioDevice * inDevice = [MTCoreAudioDevice defaultInputDevice];
MTAudioBuffer * anAudioBuffer;
AudioBufferList * aBufferList = MTAudioBufferListNew ( 1, FRAMES_TO_PROCESS, NO ); // 1 channel
unsigned numFramesRead;

sampleRate = [inDevice nominalSampleRate];
anAudioBuffer = [[MTAudioBuffer alloc] initWithCapacityFrames:(sampleRate * SECONDS_TO_BUFFER) channels:1];

[inDevice setIOProc:recordIOProc withClientData:anAudioBuffer];
[inDevice deviceStart];

do
{
numFramesRead = [anAudioBuffer readToAudioBufferList:aBufferList maxFrames:SIZE_MAX waitForData:YES];
} while ( numFramesRead && DoMyProcessing ( aBufferList->mBuffers[0].mData, numFramesRead ));

[pool release];
[anAudioBuffer release];
MTAudioBufferListDispose ( aBufferList );
return 0;
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • mDataByteSize == 0?
      • From: john <email@hidden>
References: 
 >Compiler error with lastest CA-SDK and CW 9.2 (From: "Michael Kleps [reFX]" <email@hidden>)
 >Internal Microphone (From: Ashish Jain <email@hidden>)

  • Prev by Date: Re: A Couple of Midi Tempo and TimeSig Questions
  • Next by Date: Re: A Couple of Midi Tempo and TimeSig Questions
  • Previous by thread: Re: Internal Microphone
  • Next by thread: mDataByteSize == 0?
  • Index(es):
    • Date
    • Thread