Author Topic: No audio with multiple soundfonts loading system (BASSMIDI)  (Read 607 times)

KaleidonKep99

  • Posts: 150
I recently added a multiple soundfonts loading system to my MIDI converter.

Here's the problem.
When it starts converting the MIDI, it doesn't use the soundfonts at all, it stays muted.

Here's the piece of code (C#):
Code: [Select]
...
                            BASS_MIDI_FONT[] fonts = new BASS_MIDI_FONT[3];
                            // Test
                            int preset1val = KeppyMIDIConverter.SoundfontDialog.BankPresetValue.preset1val; // Which is selected in the soundfont loading window
                            int preset2val = KeppyMIDIConverter.SoundfontDialog.BankPresetValue.preset2val; // Which is selected in the soundfont loading window
                            int preset3val = KeppyMIDIConverter.SoundfontDialog.BankPresetValue.preset3val; // Which is selected in the soundfont loading window
                            int bank1val = KeppyMIDIConverter.SoundfontDialog.BankPresetValue.bank1val; // Which is selected in the soundfont loading window
                            int bank2val = KeppyMIDIConverter.SoundfontDialog.BankPresetValue.bank2val; // Which is selected in the soundfont loading window
                            int bank3val = KeppyMIDIConverter.SoundfontDialog.BankPresetValue.bank3val; // Which is selected in the soundfont loading window
                            // Font 1
                            fonts[0].font = font1;
                            if (bank1val == -1 & preset1val == -1)
                            {
                                fonts[0].preset = -1;
                                fonts[0].bank = 0;
                            }
                            else
                            {
                                fonts[0].preset = preset1val;
                                fonts[0].bank = bank1val;
                            }
                            // Font 2
                            fonts[1].font = font2;
                            if (bank2val == -1 & preset2val == -1)
                            {
                                fonts[1].preset = -1;
                                fonts[1].bank = 0;
                            }
                            else
                            {
                                fonts[1].preset = preset2val;
                                fonts[1].bank = bank2val;
                            }
                            // Font 3
                            fonts[2].font = font3;
                            if (bank3val == -1 & preset3val == -1)
                            {
                                fonts[2].preset = -1;
                                fonts[2].bank = 0;
                            }
                            else
                            {
                                fonts[2].preset = preset3val;
                                fonts[2].bank = bank3val;
                            }
                            // Load soundfonts
                            BassMidi.BASS_MIDI_StreamSetFonts(Globals._recHandle, fonts, 3);
                            BassMidi.BASS_MIDI_StreamLoadSamples(Globals._recHandle);
...
How can I fix the problem?

KaleidonKep99

  • Posts: 150
Oh crap, I am literally an idiot.

I forgot to add these lines to the code, it works now...
Code: [Select]
...
                            // Load soundfonts
                            BassMidi.BASS_MIDI_StreamSetFonts(Globals._recHandle, fonts, 1); // This...
                            BassMidi.BASS_MIDI_StreamSetFonts(Globals._recHandle, fonts, 2); // And this...
                            BassMidi.BASS_MIDI_StreamSetFonts(Globals._recHandle, fonts, 3);
                            BassMidi.BASS_MIDI_StreamLoadSamples(Globals._recHandle);
...
Damnit. Sorry for making this useless post!

Ian @ un4seen

  • Administrator
  • Posts: 20393
It shouldn't be necessary to call BASS_MIDI_StreamSetFonts 3 times; the single call in your original code should be fine. If it's not working properly, please check the return value to see whether it's reporting success.

KaleidonKep99

  • Posts: 150
It shouldn't be necessary to call BASS_MIDI_StreamSetFonts 3 times; the single call in your original code should be fine. If it's not working properly, please check the return value to see whether it's reporting success.
If I call BASS_MIDI_StreamSetFonts two times by setting the last int respectively to 2 and 3, the first soundfont doesn't get loaded.
I don't know if it's a recent bug in the new BASSMIDI DLL.

Also, it reports BASS_OK.

Ian @ un4seen

  • Administrator
  • Posts: 20393
That's strange. Please try calling BASS_MIDI_StreamGetFonts afterwards and see if you get back the same soundfont config as you just set (also check that it returns 3). Pass it a different array (or clear the existing "fonts" array first) to make sure you're not just looking at untouched memory.

KaleidonKep99

  • Posts: 150
BASSMIDI 2.4.9.24 doesn't have this problem anymore.

Sorry for answering this late!