Closed thejpster closed 5 years ago
https://sensorium.github.io/Mozzi/ is a synthesizer for Arduino which may work as a reference. Has some output schematics too.
See https://GitHub.com/thejpster/monotron-synth. Needs connecting to a PWM and running from the video interrupt. Not sure how to make it safe to generate samples under interrupt and change parameters in the main thread.
Maybe the synth should be optional, incase they want to provide their own synth and just supply pcm samples?
So, the LM4F120 has Timers, but they can't do up/down symmetrical PWM. The TM4C123 has Timers, plus two PWM peripherals which can do up/down.
So... I think we're going to have to switch to the TM4C123 as the official platform.
Also, www.rakits.co.uk gave me a neat little amplifier, so I need to get that built up.
Audio support is merged, and I tried it with the Rakits amplifier. Well, sound comes out, but it's very noisy. Interestingly, if I unplug the VGA cable, the noise drops right down.
If I get the chance, I'll unpack my oscilloscope and see what frequency the noise is, which should give some clue to its source. Otherwise I'll just ignore it for now, and think about the ABI for driving the synth.
ABI for driving the synth is in. Snake can go 'bip bip bip boooop'.
We have some timers spare, and I'm sure we can generate some audio.
Once a scan line (so 37.680 kHz) set the PWM to output a level between 0 and 255. Add some filtering and buffering on the output pin and voila - 37.680 kHz 8-bit PCM mono audio. But as we have no room for samples, we probably need an API that lets you play beeps (square waves? maybe even triangle waves using some very basic maths?) at a given frequency for a given number of frames.
We probably want to set the audio output at the end of the scan-line to avoid delaying the video. Maybe calculate at the end of the scan-line and load at the start of the next scan-line.