Re: extAudioFileCreateURL and ExtAudioFileWrite problem
Re: extAudioFileCreateURL and ExtAudioFileWrite problem
- Subject: Re: extAudioFileCreateURL and ExtAudioFileWrite problem
- From: William Stewart <email@hidden>
- Date: Mon, 15 Jun 2009 12:28:30 -0700
There is an example code in /Developer/Examples/CoreAudio called
CAAUOuputCapturer.h (or something like that) and it should be pretty
straight forward to adapt that code
Bill
On Jun 15, 2009, at 10:05 AM, Tony Sheng wrote:
Hi, I embeded some codes in my audio unit in order to write audio
files to disk.
I tried to use ExtAudioFileCreateWithURL and ExtAudioFileWrite
function. It goes through the compiler without any error. but still no
wave file generated. The following code is to write three second sine
wave into an audio file named 'jon.wav':
for the .h file:
#define mysize 132300
#include <ExtendedAudioFile.h>
ExtAudioFileRef myWav;
AudioStreamBasicDescription WaveDescript;
float sample[mysize];
for the .cpp file:
//define audio format:
WaveDescript.mFormatID = kAudioFormatLinearPCM;
WaveDescript.mFormatFlags = kAudioFormatFlagIsSignedInteger |
kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsPacked;
WaveDescript.mSampleRate = 44100;
WaveDescript.mChannelsPerFrame = 1;
WaveDescript.mFramesPerPacket = 1;
WaveDescript.mBytesPerPacket = 4;
WaveDescript.mBytesPerFrame = 4;
WaveDescript.mBitsPerChannel = 16;
WaveDescript.mReserved = 0;
OSStatus retCode;
//define wave file name here:
CFStringRef waveFileName = CFSTR("file://jon.wav");
CFURLRef waveFilePathName = CFURLCreateWithString(NULL,
waveFileName, NULL);
//create new audio object
retCode =ExtAudioFileCreateWithURL(waveFilePathName,
kAudioFileWAVEType,&WaveDescript, NULL, 1, &myWav);
//generate sine wave here:
for (int i = 0; i < mysize; i++) {
sample[i]=sin(float(i)/mysize*M_PI*1500);
}
//warp sine wave into buffer:
AudioBuffer mybuffer = {1, mysize, &sample[0]};
AudioBufferList mybufferlist = {1, mybuffer};
//write wave files here:
retCode = ExtAudioFileWrite(myWav, mysize, &mybufferlist);
retCode = ExtAudioFileDispose(myWav);
I cannot tell any fault from the complier, but it just writes nothing
onto disk. Can anyone help to find error causing the problem.
Many thanks
Tony
_______________________________________________
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
_______________________________________________
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