Created
August 12, 2014 12:03
-
-
Save genedelisa/c9e1c9693eb47b26773a 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