• 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: extAudioFileCreateURL and ExtAudioFileWrite problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extAudioFileCreateURL and ExtAudioFileWrite problem


  • Subject: Re: extAudioFileCreateURL and ExtAudioFileWrite problem
  • From: Tony Sheng <email@hidden>
  • Date: Tue, 16 Jun 2009 18:30:22 +0100

Hi Bill and all: 

Thanks. The sample code did seem is what I want. I included that .h file into my project.

But when I trying to call the function from that file, I am confused by the first parameters the function needs to take in:

CAAudioUnitOutputCapturer(AudioUnit au, CFURLRef outputFileURL, AudioFileTypeID fileType, const AudioStreamBasicDescription &format, UInt32 busNumber = 0)


I am not sure here 'AudioUnit au' really is and when I jump to its definition it defines as :

 typedef ComponentInstance AudioUnit;// An audio unit is of type ComponentInstance, defined by the Component Manager.


I tried to put my audio unit name for this parameter but it doesn't work cannot go through the complier. 


Can you help me with this? 


Many thanks 


Tony 



2009/6/15 William Stewart <email@hidden>
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

  • Follow-Ups:
    • Re: extAudioFileCreateURL and ExtAudioFileWrite problem
      • From: Howard Moon <email@hidden>
References: 
 >extAudioFileCreateURL and ExtAudioFileWrite problem (From: Tony Sheng <email@hidden>)
 >Re: extAudioFileCreateURL and ExtAudioFileWrite problem (From: William Stewart <email@hidden>)

  • Prev by Date: Re: AU automation gestures/scroll wheel events
  • Next by Date: Re: AU automation gestures/scroll wheel events
  • Previous by thread: Re: extAudioFileCreateURL and ExtAudioFileWrite problem
  • Next by thread: Re: extAudioFileCreateURL and ExtAudioFileWrite problem
  • Index(es):
    • Date
    • Thread