iOS have a problem, need help!


(vicczhang) #1

hi,
I have a problem,
in Android use this code can get a music file,but in iOS this never get a file,I need help.

code:

void compoundmain(const char* recordPath, const char* outputPath){
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel;
FMOD_RESULT result;

result = FMOD::System_Create(&system);
ERRCHECK(result);
system->setOutput(FMOD_OUTPUTTYPE_COREAUDIO);

result = system->init(32, FMOD_INIT_STREAM_FROM_UPDATE, &outputPath);
ERRCHECK(result);

system->createSound(recordPath, FMOD_DEFAULT, NULL, &sound);
system->playSound(sound, 0, false, &channel);

channel->setPitch(1.5);

// FMOD::DSP *dsp = 0;
unsigned int length = 0;
sound->getLength(&length, FMOD_TIMEUNIT_MS);
unsigned int position = 0;
do{
system->update();
channel->getPosition(&position, FMOD_TIMEUNIT_MS);
}while (position < length);
sound->release();
system->close();
system->release();
}


(Cameron Baron) #2

Have you made sure to set the AudioSession Category for recording?

This information can be found in our Getting started guide in the iOS API docs.


Recording

Much like lock screen and background audio, recording requires a particular AudioSession category to be active at the time of System::recordStart (and must remain active until the recording finishes). The required category is called ‘play and record’ and can be read about in the audio session basics documentation. Note that FMOD is always ‘playing’ audio (even silence) so it is not sufficient to simply use the ‘recording’ category unless you are running the ‘No Sound’ or ‘Wav Writer’ output mode.

Some devices may take some time to switch AudioSession category so it is recommended to set this category at application start time to avoid any hiccups in audio playback.


(vicczhang) #3

I Have been set AudioSession category 。 These days I find the problem。

the problem code is:
result = system->init(32, FMOD_INIT_STREAM_FROM_UPDATE, &outputPath);
ERRCHECK(result);

the outputPath is pointer,The right is ‘char path’ not pointer path。now it can output wav file。


(vicczhang) #4

I Have been set AudioSession category 。 These days I find the problem。

the problem code is:
result = system->init(32, FMOD_INIT_STREAM_FROM_UPDATE, &outputPath);
ERRCHECK(result);

the outputPath is pointer,The right is ‘char path’ not pointer path。now it can output wav file。


(Cameron Baron) #5

Please refer to http://www.fmod.org/questions/question/non-realtime-wav-writer/