Hello I'm working with AudioKit -- it is a stellar framework and I'm very happy so far just learning it. I'm working through a HelloWorld example and there is code for a UI button that engages an oscillator at a frequency...
My question is: if I want to play two oscillator tones at once, such as 432Hz and a perfect fifth above (ratio of 3:2 so 648Hz) how can I have them both play simultaneously? Is the correct design pattern to have a new node for each "tone" coming along?
class ViewController: UIViewController {
var oscillator = AKOscillator()
var osc2 = AKOscillator()
override func viewDidLoad() {
super.viewDidLoad()
AudioKit.output = oscillator
AudioKit.start()
}
@IBAction func toggleSound(sender: UIButton) {
if oscillator.isPlaying {
oscillator.stop()
sender.setTitle("Play Sine Wave", forState: .Normal)
} else {
oscillator.amplitude = 1 //was:: random(0.5, 1)
oscillator.frequency = 432 //was:: random(220, 880)
osc2.amplitude = 1
osc2.frequency = 648 //3:2 from 432Hz
sender.setTitle("Stop Sine Wave at \(Int(oscillator.frequency))Hz", forState: .Normal)
}
sender.setNeedsDisplay()
}
}
How can I chain the two oscillators together so they can sing together?
AudioKit.output
need? I don't know the library but I would assume it would beAudioKit.output = oscillator + osc2
? – Fils