AEAudioFileOutput : how to use ?
Hi,
I'm currently using TAAE2 which is incredibly efficient, but I have a problem with the Offline rendering.
I did not succeed to use AEAudioFileOutput. Should I use the same renderer that the one I use for playing audio ?
Is it possible to have an example of integration ?
Thank you very much
Comments
I use runForDuration, and in the completionBlock I call finishWriting, but when I look the export file, this one is 00:00 seconds long
You'll need to use a different renderer, @alexisdarnat, or at least stop the output unit first, because otherwise you'll be running the same renderer twice at the same time.
@Michael Ah nice ! Thank you, but I still have a problem.
I have juste create a render context
AERenderer *offlineRenderer = [AERenderer new];
And an AEAudioFilePlayerModule :
module = [[AEAudioFilePlayerModule alloc] initWithRenderer:renderer URL:url error:NULL];
offlineRenderer.block = ^(const AERenderContext * _Nonnull context) { AEModuleProcess(module, context); AERenderContextOutput(context, 1); AEBufferStackPop(context->stack, 1); };
And I simply run :
AEAudioFileOutput *outputRender = [[AEAudioFileOutput alloc] initWithRenderer: offlineRenderer URL:url type:AEAudioFileTypeM4A sampleRate: offlineRenderer.sampleRate channelCount: offlineRenderer.numberOfOutputChannels error:nil]; [module playAtTime:0]; [outputRender runForDuration:10.0 completionBlock:^{ NSLog(@"File exported"); } }];
The audio file is well exported, he has the perfect duration, but there is no sound.
I've tried to print out the AudioBuffer list data
context->output->mBuffers->mData
in the offlineRenderer Block, but it seems to be empty, full of "0"Well, I just solve the problem, I used
[module playAtTime:AECurrentTimeInHostTicks()];
instead of using[module playAtTime:0];
That's very strange! I just tried to reproduce the issue and it's working fine on my end. What happens when you put the following into the sample app somewhere, like within the 'start' function in AEAudioController:
@Michael ,@alexisdarnat I am using the same code as above but it is not working in the case when we need to play file after few second
For example If i export 2 audio in one file, one play at 0 seconds and other play at 3 seconds.
and for that i am using
but it is not working. when i export it. it only play the file at 0 seconds and not play the file at 3 second
Below is my full code.
I have the same problem - AEAudioFileOutput does not write any sound if AEAudioFilePlayerModule's playAtTime is used with nonzero shifted time:
[module playAtTime:startTicks]
. To fix it I correct mHostTime within the renderer block:But unfortunately it helps only once. To get AEAudioFileOutput next time working we have to recreate the renderer.
Ah, yes, this is something that probably needs to be addressed in the way timestamps are used. Because it's faster-than-realtime rendering, it doesn't make sense to use host ticks; instead, the time needs to be provided in samples. I'll work on that.
Okay, I've just added some changes that make AEAudioFilePlayerModule take AudioTimeStamps for scheduling.
For example:
Now it works fine. The start of playing at the relative time (through time in samples) this is what I wanted! Great thanks!
Thanks to all.