Author Topic: BASS_MIDI_FONT_MEM not work on OSX!  (Read 129 times)

promusicbisceglie

  • Posts: 25
BASS_MIDI_FONT_MEM not work on OSX!
« on: 22 Jul '24 - 09:50 »
Hello, i must load soundfonts from memory instead of file (due a custom encription of mine sounds)
I use , and work for windows  ,
sf[0].Font := BASS_MIDI_FontInit(Pchar(sf_mem),BASS_MIDI_FONT_MEM );
where sf_mem is an array of byte
Well it good, but if i use the same on OSX this crash with
RUNTIME ERROR 231 at {..address..}
I'm using delphi rad studio 10.4
Any solution?
I found the method  BASS_MIDI_FontInitUser but this is almost undocumented, any example (possibily in delphi) of usage of it for just load soundfonts from an array of bytes?

Ian @ un4seen

  • Administrator
  • Posts: 26015
Re: BASS_MIDI_FONT_MEM not work on OSX!
« Reply #1 on: 22 Jul '24 - 18:02 »
The BASS_MIDI_FONT_MEM option should work the same on macOS as on other platforms. Is the crash in the BASS_MIDI_FontInit call or after it returns? If after, perhaps the soundfont's memory has been freed? Note that BASS_MIDI_FontInit doesn't copy the provided memory block, so it needs to remain valid until BASS_MIDI_FontFree is called to free the soundfont. A corrupt soundfont file could also result in a crash when using BASS_MIDI_FONT_MEM.

BASS_MIDI_FontInitUser is a safer way to use soundfonts that aren't in the filesystem. The only difference compared to BASS_MIDI_FontInit is that you provide a BASS_FILEPROCS structure instead of a filename (or pointer with BASS_MIDI_FONT_MEM). Please see the BASS_FILEPROCS documentation for an example of how it can be used.

promusicbisceglie

  • Posts: 25
Re: BASS_MIDI_FONT_MEM not work on OSX!
« Reply #2 on: 22 Jul '24 - 18:41 »
OK i resolved using BytesToString function..
I write how, this can be useful for other user
sf[0].Font := BASS_MIDI_FontInit(PCHAR(BytesToString(sf_mem[0])),BASS_MIDI_FONT_MEM);
now it read my soundfonts from a series of bytearrays
Thank you