我用AudioKit的MIDISampler演奏一些音符。我用的是带很多乐器的配音字体。
在研究了文档和源代码之后,我没有找到一种方法来进行程序更改,以便从声音字体中选择一种不同的工具。
有什么想法吗?
var instrument = MIDISampler(name: "Instrument 1")
let soundFontUrl = Bundle.main.url(forResource: "soundfont", withExtension: "sf2")!
try! instrument.loadInstrument(url: soundFontUrl)
...
// TODO: Do program change.
instrument.play(noteNumber: 60, velocity: 80, channel: 0)编辑:我想像这样的东西可能会起作用。但事实并非如此。
let channel:UInt8 = 0
let program:UInt8 = 33
self.instrument.samplerUnit.sendProgramChange(program, onChannel: channel)发布于 2022-07-31 17:42:44
MIDISampler扩展了AppleSampler,它有一些特定于SoundFont的方法。尝试loadSoundFont方法。https://github.com/AudioKit/AudioKit/blob/110d2dfa0b798f76349922fdd1d23d660a16dc37/Sources/AudioKit/Nodes/Playback/Apple%20Sampler/AppleSampler%2BSoundFonts.swift
https://stackoverflow.com/questions/73182319
复制相似问题