AudioKit / AudioKitUI

Controls and Visualization for AudioKit apps
MIT License
187 stars 52 forks source link

sampler.loadSoundFont not working #76

Closed KittenYang closed 7 months ago

KittenYang commented 7 months ago

macOS Version(s) Used to Build

macOS 13 Ventura

Xcode Version(s)

Xcode 14

Description

public func loadSequencerFile(fileURL: URL) {
        sequencer.loadMIDIFile(fromURL: fileURL)
        if sequencer.allTempoEvents.isNotEmpty {
            lastTempo = sequencer.allTempoEvents[0].1
        } else {
            lastTempo = sequencer.tempo
        }
        sequencer.setGlobalMIDIOutput(sampler.midiIn)
        do {
            try sampler.loadSoundFont("UprightPianoKW-20190703", preset: 0, bank: 0)
        } catch {
        }
    }

I replace the SoundFont with custom .sf2 file, and the url is not nil. But in the demo MIDITrack.swift still play the default beeper sound. How can I load custom .sf2 file?

Crash Logs, Screenshots or Other Attachments (if applicable)

No response

KittenYang commented 7 months ago

I figured it out, must turn on the background modes for audio!!

截屏2023-11-27 02 29 22