8 Replies
      Latest reply: Sep 2, 2016 9:27 AM by SoundOfMind RSS
      krishnamurthy Level 1 Level 1 (0 points)

        My use case is to play a MIDI file using a backing SF2 instrument. I have a SF2 file that contains sound samples for just one ethnic instrument. However, I am not able to successfully load that soundbank into the AVAudioUnitSampler instance.

         

        I have been able to successfully load a popular GM soundfont (using the sample code found on the internet). Below is the code snippet that works fine.

        _sf2URL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"GeneralUser GS MuseScore v1.442"ofType:@"sf2"]];
        [_sampler loadSoundBankInstrumentAtURL:_sf2URL program:6 bankMSB: kAUSampler_DefaultMelodicBankMSB bankLSB:0error:&error];
        

         

        However, for my sf2 file, the load fails. So, I am pretty confident that the issue is with supplying the right values for the below parameters of the loadSoundankInstrumentAtURL method:

         

        a) Program number
        b) Soundbank MSB

        c) Soundbank LSB

         

        I tried several combinations, but none worked. I would like to understand a proven approach to get the right values for these parameters. May be to use a soundfont editor and look for some specific values in there?

         

        Appreciate your help.

        • Re: AVAudioUnitSampler SF2 SoundBank Load Failure
          SoundOfMind Apple Staff Apple Staff (70 points)

          Please paste here the text of any errors you see in the system log when you run this command, thanks.

           

          -DS

            • Re: AVAudioUnitSampler SF2 SoundBank Load Failure
              krishnamurthy Level 1 Level 1 (0 points)

              @SoundOfMind, please find the error message below:

              SoundFontDemo[12264:1028008] 18:23:16.475 ERROR:    93: BankEntry::LoadInstrument: Unable to find patch 7 bank 0x79/0

              SoundFontDemo[12264:1028008] 18:23:16.477 ERROR:    486: DLS/SF2 bank load failed

              SoundFontDemo[12264:1028008] 18:23:16.478 ERROR:    AVAudioUnitSampler.mm:163: -[AVAudioUnitSampler loadSoundBankInstrumentAtURL:program:bankMSB:bankLSB:error:]: error -10851

               

              Thanks and I would like to understand how to find the right values for program/bankLSB/bankMSB, given a SF2 file.

                • Re: AVAudioUnitSampler SF2 SoundBank Load Failure
                  SoundOfMind Apple Staff Apple Staff (70 points)

                  It looks like you correctly passed 0x79 for the bank MSB (there is a constant, kAUSampler_DefaultMelodicBankMSB, for this, in the AU headers).  BankLSB should be 0 unless you know you have a bank with instrument variations.

                   

                  Unless your SF2 bank file is a complete GM-compatible bank (i.e., it has an instrument for every program number from 0 to 127), there is the possibility that you are requesting a program that does not exist in a (sparse) bank.  Does this call to loadSoundBankInstrumentAtURL:program:bankMSB:bankLSB:error fail on this bank for ALL program numbers?  How about other bank files?

                   

                  -DS

                    • Re: AVAudioUnitSampler SF2 SoundBank Load Failure
                      krishnamurthy Level 1 Level 1 (0 points)

                      Keeping the BankLSB and BankMSB values constant, I ran the loadSoundBankInstrumentAtURL function in a loop to provide it values 0 to 127. In all the cases,   the same error was observed.

                       

                      So, may be even the bankLSB and MSB values could be wrong.

                       

                      The SF2 file that I have is certainly a sparse bank, with only one instrument in it.

                       

                      Would it help if I share the SF2 file itself for you to help suggest the right values for the program-number, bank LSB and bank MSB that will not lead to load-failure? Else, if I get a method to inspect these files and arrive at the right values myself, that'd be great too.

                       

                      Kindly advise.