Can someone point me to a working version of Matt Gallagher\'s Tone Generator?
http://www.cocoawithlove.com/assets/objc-era/ToneGenerator.zip
As Matt says, it h
Of course Gene De Lisa is right. The "unit" variable needs to be declared outside of viewDidLoad so it doesn't get deallocated right away. Also, "unit.enableSpeaker()" needs to be before "unit.startToneForDuration(0.5)". However even with those 2 changes I got no sound. After more head scratching I found two scaling errors in hotpaw2's ToneOutputUnit.swift (in github).
1) In the function startToneForDuration the line "toneCount = Int32(round( time / sampleRate ))" should be "toneCount = Int32(time * sampleRate)".
2) And in the function setToneVolume the line "v0 = vol / 32768.0" should be "v0 = vol * 32768.0".
With those two changes it works and produces a tone with volume and duration that seem reasonable.
@Hotpaw2: I hope you will update your version in github. It's a nicely written class that will help others.