• 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: getting PCM data from an audio file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting PCM data from an audio file


  • Subject: Re: getting PCM data from an audio file
  • From: Philippe Wicker <email@hidden>
  • Date: Tue, 3 Jun 2003 21:59:30 +0200

On Tuesday, June 3, 2003, at 07:05 AM, Andrew GFunk wrote:

Thanks for trying to help me out Philippe! I thought about the FSRef being NULL. If it were, the call
printf("mSampleRate %g\n", srcFmt.mSampleRate);
shouldn't work, right? It does though. Here's the output of my program:

mSampleRate 44100
2003-06-02 21:56:42.117 audioFileTest1[407] <00000000 >

The second line comes from the following call:
NSLog(@"%@", data);

So I guess the FSRef part of my code is right. Any other ideas?
Or maybe some simple example code on reading audio data?

This code (C/C++) works for me: the aiff file "Misty.aiff" is located in the same directory as the executable.

#include <AudioToolbox/AudioFile.h>

int main(void)
{
FSRef file_ref;
OSStatus result = FSPathMakeRef ((const UInt8 *)"./Misty.aiff", &file_ref, NULL);
UInt32 data_size = sizeof (SInt64);
SInt64 file_data_size ;
AudioFileID file_id ;
result = AudioFileOpen (&file_ref, fsRdPerm, 0, &file_id) ;
if (result != noErr) {
printf("AudioFileOpen error\n") ;
return -1 ;
}

// Read the size of file data
result = AudioFileGetProperty (file_id, kAudioFilePropertyAudioDataByteCount,
&data_size, &file_data_size) ;
if (result != noErr) {
printf("AudioFileGetProperty(Size) error\n") ;
return -1 ;
}

// Read some data
Byte disk_buffer[32000] ;
read_size = 32000 ;
UInt32 where = 0 ; // this is the seek value
result = AudioFileReadBytes(file_id, false, where, &read_size, disk_buffer) ;
// etc .....
}


Thanks,

Philippe Wicker
email@hidden
_______________________________________________
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.

References: 
 >Re: getting PCM data from an audio file (From: "Andrew GFunk" <email@hidden>)

  • Prev by Date: Re: silence a chunk in Audio Unit render function
  • Next by Date: Capturing Raw Audio
  • Previous by thread: Re: getting PCM data from an audio file
  • Next by thread: Apple DLS only audible on first few instruments
  • Index(es):
    • Date
    • Thread