I’m confused with the Chapter 2 Side Quest - is the swan supposed to recognize a correct solution to the side quest or does it only give a “success” dialog when you complete the main quest? I think my solution is correct, but the swan only seems to say “you are so close, please try again”. My code for the side quest below (also contains solution to main quest via commented line).
// Touch "Run My Code" to continue your quest...
func performance(owner: Assessable) {
let toneOutput = ToneOutput()
// C4, D4, E4, F4, G4, A4, B4, C5
let cMajorScale = [261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25]
// F4, G4, A4, Bb, C5, D5, E5, F5
let fMajorScale = [349.23, 392.0, 440.0, 466.16, 261.63 * 2, 293.66 * 2, 329.63 * 2, 349.23 * 2]
// var scaleToPlay = cMajorScale.makeIterator() // main quest
var scaleToPlay = fMajorScale.makeIterator() // side quest
Timer.scheduledTimer(withTimeInterval: 0.4, repeats: true) { timer in
guard let frequency = scaleToPlay.next() else {
// Let it be known your performance has ended.
toneOutput.stopTones()
timer.invalidate()
owner.endPerformance()
return
}
let tone = Tone(pitch: frequency, volume: 0.3)
toneOutput.play(tone: tone)
}
}