Hello, I work with AudioKit - it is a star structure, and I am very happy that I just learned it. I am working on a HelloWorld example, and there is code for a user interface button that includes a generator with a frequency ...
My question is: if I want to reproduce immediately two tones of the generator, for example 432 Hz and a perfect fifth level (3: 2 ratio, so 648 Hz), how can I make them play simultaneously at the same time? Does the correct design template have a new node for every “tone” going 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
oscillator.frequency = 432
osc2.amplitude = 1
osc2.frequency = 648
sender.setTitle("Stop Sine Wave at \(Int(oscillator.frequency))Hz", forState: .Normal)
}
sender.setNeedsDisplay()
}
}
How can I combine the two generators together so they can sing together?
source
share