• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to set the bank for the kAudioUnitSubType_MIDISynth AU
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to set the bank for the kAudioUnitSubType_MIDISynth AU


  • Subject: Re: How to set the bank for the kAudioUnitSubType_MIDISynth AU
  • From: Dmitry Klochkov via Coreaudio-api <email@hidden>
  • Date: Mon, 14 Oct 2019 11:06:41 +0300

Ok, I got it working somehow, but still can not fully understand what is
going on there.

I tried changing the bank number assigned to the drum preset inside the
soundfont using Polyphone app. The sound bank was set to 128 and I set it
to 1.
And then when I tried to load this updated soundfont into the AUMIDISynth I
got the following error messages:

*BankEntry::LoadInstrument: Unable to find patch 0 bank 0x78/0*

*EXCEPTION (-10851): "LoadInstrument: Failed to load patch from bank"*

*DLS/SF2 bank load failed*


So I reverted updated bank number back to 128 and instead of sending a bank
select message with value 128, I sent it with value 0x78(which is 120 in
decimal). And voila! She preset loaded!


Also to got the bank selection working I need to update my code so it
doesn't send bank select using two messages(MSB and LSB) but only sends the
provided bank value as MSB


MusicDeviceMIDIEvent(instrumentUnit, 0xB0 | channel, 0, bank, 0)



So I am wondering is there any meaningful explanation why bank number 128
became 120 after the soundfont was loaded into AUMIDISynth?




Best wishes,

Dmitry

On Sun, Oct 13, 2019 at 10:01 PM Dmitry Klochkov <email@hidden> wrote:

> I am using kAudioUnitSubType_MIDISynth Audio Unit in my iOS app.
>
> I successfully loaded Fluid R3 GM soundfont into it and I figured out how
> to select a preset for a specific channel.
>
> I am able to use all presets of the soundfont from the bank 0. But the
> percussion presets, which I also what to use, are in the bank 128 (as I see
> in the Polyphone app).
>
> I could not find any documentation on how to do it. I tried to send bank
> select messages to the unit, but had no success with it.
>
> Here is the method I currently use to set the preset and the bank:
>
> -(*void*) setPreset:(UInt32) preset bank:(UInt32) bank forChannel:(UInt8)
> channel forInstrumentUnit:(AudioUnit) instrumentUnit {
>
>
>
>     // set the instrumentUnit into mode when it loads the requested
> preset into memory
>
>     UInt32 preloadEnabled = 1;
>
>     OSStatus err = AudioUnitSetProperty(
>
>                                instrumentUnit,
>
>                                kAUMIDISynthProperty_EnablePreload,
>
>                                kAudioUnitScope_Global,
>
>                                0,
>
>                                &preloadEnabled,
>
>                                *sizeof*(preloadEnabled));
>
>
>
>     *if* (err) {
>
>         NSLog(@"Unable to set enablePreload property: %@", @(err));
>
>     }
>
>
>     // Send bank load message MSB
>
> UInt32 ccCommand = 0xB0 | channel;
>
> UInt32 bankMsb = bank >> 7;
>
> err = MusicDeviceMIDIEvent(instrumentUnit, ccCommand, 0, bankMsb, 0);
>
> *if* (err) {
>
> NSLog(@"Failed to load preset: %@ in %s.", @(err), *__PRETTY_FUNCTION__*);
>
> }
>
> UInt32 bankLsb = bank & 0x7F;
>
> err = MusicDeviceMIDIEvent(instrumentUnit, ccCommand, 0x20, bankLsb, 0);
>
>
> *if* (err) {
>
> NSLog(@"Failed to load preset: %@ in %s.", @(err), *__PRETTY_FUNCTION__*);
>
> }
>
>
>
>
>
>     // request preset on the channel to load it into memory(but it is not
> activated here)
>
> UInt32 pcCommand = 0xC0 | channel;
>
> err = MusicDeviceMIDIEvent(instrumentUnit, pcCommand, preset, 0, 0);
>
> *if* (err) {
>
> NSLog(@"Failed to load preset: %@ in %s.", @(err), *__PRETTY_FUNCTION__*);
>
> }
>
>
>
>     // set instrumentUnit into regular mode when the requested preset is
> activetad for the specified channel
>
>     preloadEnabled = 0; //disable preload property
>
>     err = AudioUnitSetProperty(
>
>                                instrumentUnit,
>
>                                kAUMIDISynthProperty_EnablePreload,
>
>                                kAudioUnitScope_Global,
>
>                                0,
>
>                                &preloadEnabled,
>
>                                *sizeof*(preloadEnabled));
>
>
>
>     *if* (err) {
>
>         NSLog(@"Unable to set enablePreload property: %@", @(err));
>
>     }
>
>
>
>     // repeat programm change command to actually activate the presed for
> the channel after it has been loaded in the previous steps
>
>     err = MusicDeviceMIDIEvent(instrumentUnit, pcCommand, preset, 0, 0);
>
>
>
>     *if* (err) {
>
>         NSLog(@"Failed to activate preset: %@ in %s.", @(err),
> *__PRETTY_FUNCTION__*);
>
>     }
>
> }
>
>
> Could you please tell if the MIDISynth unit supports soundfonts with
> multiple banks, and what is the correct way to set a bank for a specific
> channel?
>
>
> Best regards,
>
> Dmitry
>
>
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to set the bank for the kAudioUnitSubType_MIDISynth AU
      • From: Sven Thoennissen via Coreaudio-api <email@hidden>
References: 
 >How to set the bank for the kAudioUnitSubType_MIDISynth AU (From: Dmitry Klochkov via Coreaudio-api <email@hidden>)

  • Prev by Date: How to set the bank for the kAudioUnitSubType_MIDISynth AU
  • Next by Date: Re: How to set the bank for the kAudioUnitSubType_MIDISynth AU
  • Previous by thread: How to set the bank for the kAudioUnitSubType_MIDISynth AU
  • Next by thread: Re: How to set the bank for the kAudioUnitSubType_MIDISynth AU
  • Index(es):
    • Date
    • Thread