0
0

I’ve been trying to figure out how to play a MIDI file with FMOD on the iPhone, but I’ve run into a stumbling block — I can’t seem to load the DLS file.

Here’s the code that I’ve been using (both the DLS file and the MIDI file exist in the project):
[code:iz707hpn]char buffer[200] = {0};

[[NSString stringWithFormat:@"%@/gs_instruments.dls", [[NSBundle mainBundle] resourcePath]] getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];


NSLog(@"The dls name: %@",[NSString stringWithCString:buffer encoding:NSASCIIStringEncoding]);

soundExInfo.dlsname  = "gs_instruments.dls";

NSLog(@"Going to try to create sound:");

[[NSString stringWithFormat:@"%@/walkingincircles12511.mid", [[NSBundle mainBundle] resourcePath]] getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];

result = system->createSound(buffer, FMOD_SOFTWARE | FMOD_CREATESTREAM, &soundExInfo, &sound);
ERRCHECK(result);[/code:iz707hpn]

And the output it gives:[code:iz707hpn]The dls name: /Users/jn/Library/Application Support/iPhone Simulator/4.3/Applications/FEAFF208-4203-4635-BB54-0F48DE323BD8/EarTraining2.app/gs_instruments.dls
2011-05-01 15:34:13.793 EarTraining2[10936:207] Going to try to create sound:
FMOD error! (69) A resource that the plugin requires cannot be found. (ie the DLS file for MIDI playback) [/code:iz707hpn]

Can anyone point me in the right direction?

  • You must to post comments
0
0

Wonderful — I had left that line in by mistake (you can see I was originally setting it from the buffer variable), which wasn’t working, and your solution solved both issues. Thanks so much

  • You must to post comments
0
0

I think the problems is here:
[code:tjyi72jc]
soundExInfo.dlsname = "gs_instruments.dls";
[/code:tjyi72jc]
You need to specify the whole path to your dls file, not only the name of the file:
[code:tjyi72jc]
soundExInfo.dlsname = [[[NSBundle mainBundle] pathForResource:@"gs_instruments" ofType:@"dls"] cStringUsingEncoding:NSASCIIStringEncoding];
[/code:tjyi72jc]

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.