I have an iPhone app called Tunepal that uses (commercial) FMOD to play back MIDI files. I updated to the latest FMOD api and now all my iPod 2ng gen users are complaining that midi playback no longer works. I just debugged my code and I can confirm that on an iPod touch model MB376LL (running OS 3.1.1, the latest available for this model) midi playback results in silence. No errors, nothing on the console. I have tested the identical code on a latest gen iPod, iPhone 3 and an iPad and the midi playback is working fine
The strange thing is that this definitely used to work with the version of FMOD I was using previously
Any ideas? I think I’ll download an older version of FMOD again and try it out
- skooter500 asked 7 years ago
Thanks for taking the time to check this out. I think I have tracked down the problem. My app uses FMOD for recording also. It used to take up to 5 seconds for FMOD to start recording after the call to
For the first time, so I put this code in my main.mm, just to create s sound, start recording and immediately stop. When I removed this code, MIDI playback started working again with the latest FMOD. Not exactly sure why, but its working now anyway!
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = 1;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = SAMPLE_RATE;
exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * SAMPLE_TIME;
NSLog(@"Staring fmod recording\n");
fmSystem->createSound(NULL, FMOD_2D | FMOD_SOFTWARE | FMOD_OPENUSER, &exinfo, &recordSound);
fmSystem->recordStart(0, recordSound, false);
Just so you are aware, the large time with recordStart is due to the device switching audio session categories. If you don’t have FMOD initialized to use the "record and play" category, it will switch to it on recordStart and switch back on recordStop. For some reason the OS takes a while to process this transition, hence the wait time.
If you want to avoid the wait time, I would recommend starting FMOD with the "play and record" category set via extradriverdata.
There was a change recently to FMOD_CREATESOUNDEXINFO, we added a new member called minmidigranularity. Ideally you should be using memset with sizeof(FMOD_CREATESOUNDEXINFO) for that structure, but if you aren’t perhaps invalid data is getting into that new field causing problems?
Here is my code:
/This must be done to initialize the FMOD_CREATESOUNDEXINFO before midi playback/
memset(&soundExInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
soundExInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
/*Specify the .dls file*/ NSString *dls_path = [[NSBundle mainBundle] pathForResource:@"gs_instruments" ofType:@"dls"]; soundExInfo.dlsname = [dls_path cStringUsingEncoding:NSASCIIStringEncoding]; NSString *testmidi_path = [[NSBundle mainBundle] pathForResource:@"testmidi" ofType:@"midi"]; //const char *path = midiFileName; const char *path = [testmidi_path UTF8String]; result = fmSystem->createSound(path, FMOD_DEFAULT, &soundExInfo, &sound); // FMOD_DEFAULT uses the defaults. These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE. ERRCHECK(result); result = fmSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &channel); paused = false; ERRCHECK(result);
Just as a test, I downloaded the fmodapi 42807 from January 2010 and tried the midi playback on an IOS 3.1.1 device and low and behold it works
Any ideas? Maybe I should set that new parameter to something? As far as I remember, the older versions of FMOD didnt work too well on the iPad, but I dont have my iPad here to test. I have this in my code:
extradriverdata.forceMixWithOthers = true;
Which I have had to comment out to use with the older version of FMOD
Can you link with the logging version of FMOD and provide us with the TTY output, perhaps this will give us more details.
EDIT1: I have tested your code, pointing to my own MIDI file and everything worked on an original iPhone running iOS 3.1. Are you getting any error messages from FMOD?
EDIT2: Also tested on iPod Touch 2nd Gen running iOS 3.1.1, working correct. I don’t think your issue is device dependent.
Please login first to submit.