I have Fluidsynth set up on Void Linux. When using /usr/share/soundfonts/default.sf2, and loading the file like this:
my_midi := MIX.LoadAudio(mixer, "test.mid", false)
my file plays back fine.
But when trying to set the soundfont, it fails with this:
Couldn’t load midi file: Audio data is in unknown/unsupported/corrupt format
corrupted size vs. prev_size in fastbins
My code:
audio_device = SDL.OpenAudioDevice(SDL.AUDIO_DEVICE_DEFAULT_PLAYBACK, nil)
mixer := MIX.CreateMixerDevice(SDL.AUDIO_DEVICE_DEFAULT_PLAYBACK, nil)
track := MIX.CreateTrack(mixer)
SDL.SetHint("SDL_MIXER_SOUNDFONT", "/home/void/dev/odinsand/soundfont.sf2")
props := SDL.CreateProperties()
midi_io := SDL.IOFromFile("/home/void/dev/odinsand/test2.mid", "rb")
SDL.SetPointerProperty(props,
MIX.PROP_AUDIO_LOAD_IOSTREAM_POINTER,
midi_io)
SDL.SetBooleanProperty(props, MIX.PROP_AUDIO_LOAD_CLOSEIO_BOOLEAN, true)
SDL.SetStringProperty(props, MIX.PROP_AUDIO_DECODER_STRING, "MIDI")
SDL.SetStringProperty(props,
"SDL_mixer.decoder.fluidsynth.soundfont_path",
"/home/void/dev/odinsand/soundfont.sf2");
my_midi := MIX.LoadAudioWithProperties(props)
if my_midi == nil {
fmt.eprintfln("Couldn't load midi file: %s", SDL.GetError())
}
SDL.DestroyProperties(props)
_ = MIX.SetTrackAudio(track, my_midi)
_ = MIX.PlayTrack(track, 0)