i'm having no luck loading sound font file (.sf2) in ios app. tried using apple's code tech note tn2283
- (osstatus) loadfromdlsorsoundfont: (nsurl *)bankurl withpatch: (int)presetnumber { osstatus result = noerr; // fill out instrument data structure ausamplerinstrumentdata instdata; instdata.bankurl = (cfurlref) bankurl; instdata.instrumenttype = kinstrumenttype_dlspreset; instdata.bankmsb = kausampler_defaultmelodicbankmsb; instdata.banklsb = kausampler_defaultbanklsb; instdata.presetid = (uint8) presetnumber; // set kausamplerproperty_loadpresetfrombank property result = audiounitsetproperty(self.mysamplerunit, kausamplerproperty_loadinstrument, kaudiounitscope_global, 0, &instdata, sizeof(instdata)); // check errors nscassert (result == noerr, @"unable set preset property on sampler. error code:%d '%.4s'", (int) result, (const char *)&result); return result; } but compiler complains 'no member named 'bankurl' in struct ausamplerinstrumentdata' true, struct not contain 'bankurl' member??
i came across following code, apple believe
- (osstatus)loadsoundfont:(nsurl *)bankurl withpatch:(int)presetnumber { osstatus result = noerr; // fill out bank preset data structure ausamplerbankpresetdata bpdata; bpdata.bankurl = (__bridge cfurlref) bankurl; bpdata.bankmsb = kausampler_defaultmelodicbankmsb; bpdata.banklsb = kausampler_defaultbanklsb; bpdata.presetid = (uint8) presetnumber; // set kausamplerproperty_loadpresetfrombank property result = audiounitsetproperty(self.samplerunit, kausamplerproperty_loadpresetfrombank, kaudiounitscope_global, 0, &bpdata, sizeof(bpdata)); // check errors nscassert (result == noerr, @"unable set preset property on sampler. error code:%d '%.4s'", (int) result, (const char *)&result); return result; } this looks correct when attempt load sound font using method such follows
nsurl *sfurl = [[nsbundle mainbundle] urlforresource:@"yamaha dx7piano" withextension:@"sf2"]; [self loadsoundfont:url withpatch:0]; it throws error "unable set preset property on sampler.." did lead me think there error in how specified patch number, such supplying non-existent patch number. did discover nsurl supplying null, tried specifying url follows:
nsstring *resources = [[nsbundle mainbundle] resourcepath]; nsurl *sfurl = [nsurl fileurlwithpath:[nsstring stringwithformat:@"%@/%@",resources,@"yamaha dx7piano.sf2"]]; this has got me step closer. think supplying valid url sound font file in app bundle. still not working. compiler tells me
error: [0x19a824310] 486: dls/sf2 bank load failed
there piece of puzzle missing , can't see what.??
well found solution. sound font wasn't loading. wasn't loadoing because not added app bundle correctly. had dragged resources had add 'copy bundle resources' in project 'build phases'.
Comments
Post a Comment