我正在使用 FMOD 在音频文件中添加效果,并将带有效果的音频保存到文档目录中。我面临的问题是,如果音频停止,FMOD 会继续将数据写入文件。如果音频已经完成,我应该用什么来停止 FMOD 写入数据?下面是我的代码...
- (void)startFMODToAddEffects
{
FMOD_RESULT result = FMOD_OK;
unsigned int version = 0;
/*
Create a System object and initialize
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
fprintf(stderr, "You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
exit(-1);
}
char buffer[200] = {0};
NSString *tFileName=[NSString stringWithFormat:@"%@/Part2.m4a", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];
[tFileName getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];
char cDest[200] = {0};
NSString *fileName=[NSString stringWithFormat:@"%@/Part2WithEffect.wav", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];
[fileName getCString:cDest maxLength:200 encoding:NSASCIIStringEncoding];
result = system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER);
ERRCHECK(result);
result = system->init(32, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, cDest);
ERRCHECK(result);
result = system->createStream(buffer, FMOD_SOFTWARE, NULL, &sound);
ERRCHECK(result);
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
ERRCHECK(result);
result = system->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &dsplowpass);
ERRCHECK(result);
result = system->addDSP(dsplowpass, NULL);
ERRCHECK(result);
}