-
-
Save Ilesh/b0af0b27a8ba8e9ac27c5b922f6883ae to your computer and use it in GitHub Desktop.
Swift MIDI Sampler setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MIDISampler : NSObject { | |
var engine:AVAudioEngine! | |
var playerNode:AVAudioPlayerNode! | |
var mixer:AVAudioMixerNode! | |
var sampler:AVAudioUnitSampler! | |
override init() { | |
super.init() | |
initAudioEngine() | |
} | |
func initAudioEngine () { | |
engine = AVAudioEngine() | |
playerNode = AVAudioPlayerNode() | |
engine.attachNode(playerNode) | |
mixer = engine.mainMixerNode | |
engine.connect(playerNode, to: mixer, format: mixer.outputFormatForBus(0)) | |
// MIDI | |
sampler = AVAudioUnitSampler() | |
engine.attachNode(sampler) | |
engine.connect(sampler, to: engine.outputNode, format: nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment