Author Topic: BASSMIDI using Swift  (Read 267 times)

brom43

  • Posts: 18
BASSMIDI using Swift
« on: 27 May '24 - 21:08 »
I want to use BASS to simply play a MIDI file in a new app using Swift (for either macOS or iOS).  Does anyone have any sample Swift code to get me started?

Ian @ un4seen

  • Administrator
  • Posts: 25872
Re: BASSMIDI using Swift
« Reply #1 on: 30 May '24 - 18:08 »
I'm not a Swift user myself, so I'm not sure about specifics, but I guess you would start by adding bassmidi.h to your existing bridging header for bass.h?

Code: [Select]
#include "bass.h"
#include "bassmidi.h"

Regarding playing a MIDI file, you will need a soundfont to provide the instrument sounds. There are a couple available from the BASS page (alongside the BASSMIDI download). Multiple soundfonts can be stacked (eg. different soundfonts for different instruments), but if you only want to use one, then the simplest way to do that is via the BASS_CONFIG_MIDI_DEFFONT option.