• 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: Capturing Raw Audio
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Capturing Raw Audio


  • Subject: Re: Capturing Raw Audio
  • From: email@hidden (Patrick Beard)
  • Date: Thu, 5 Jun 2003 16:26:04 -0700

On Tuesday, June 3, 2003, at 02:02 PM, Joseph Catalano wrote:

I'm looking for the simplest way to read in audio and write it to a file as raw bytes. I have a device for interfacing a Mic with USB and it shows up in the Sounds panel of System Preferences. The goal is to pass this though a DSP algorithm to do some speech recognition research. I just don't know how to get access to the audio data as it comes in.

There are 2 ways to do this on Mac OS X, using the legacy SPBRecord API, or using CoreAudio. They both work, but I find that the CoreAudio APIs are simpler to use. The basic approach with CoreAudio is to install an IOProc using the audio device that you get by calling

AudioDeviceID defaultInputDevice;
UInt32 propertySize = sizeof(defaultInputDevice);
AudioHardwareGetProperty(AudioDeviceID, &propertySize, &defaultInputDevice);

After you install the IOProc with AudioDeviceAddIOProc, the IOProc will be called with successive buffers of samples, and it's your job to save these buffers in a file. I use another thread to do the file I/O, and send it audio buffers using MP thread queues.

Check out

http://homepage.mac.com/pcbeard/Audio.tar.gz

for some sample code. It includes a simple Objective C class

@interface AudioRecorder : NSObject {
}
+ (OSStatus)recordToFile:(NSURL*)fileURL;
+ (OSStatus)stopRecording;
+ (OSStatus)getLevels:(AudioLevels)levels;
@end

which does recording to a file, plus some rudimentary level metering.

- Patrick
_______________________________________________
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:
    • Re: Capturing Raw Audio
      • From: Robert Grant <email@hidden>
References: 
 >Capturing Raw Audio (From: Joseph Catalano <email@hidden>)

  • Prev by Date: Re: Soft play-thru question
  • Next by Date: Re: Select a carbon window within a Cocoa application
  • Previous by thread: Capturing Raw Audio
  • Next by thread: Re: Capturing Raw Audio
  • Index(es):
    • Date
    • Thread