This is the fourth synthesizer cable Iβve built, the first three being based on the ATtiny85. I have been looking into ARM chips but havenβt gotten to grips with them just yet. Instead, I decided go back to the ATtiny2313, which has a quarter of the memories of the tiny85, but a hardware UART port and more pins.
Itβs quite a simple idea really β generate square waves by toggling the digital outputs on many pins, and sum them in analogue. This doesnβt really save much processing power compared to the polyphony I used for standalone midi playback on the tiny85, which was just adding / subtracting values being sent to the PLL PWM output. But I couldnβt think of a way for realtime playing with that system when the same chip had to interpret midi messages in software. The hardware UART simplifies the task. I looked, but couldnβt immediately see any chip with both a UART and a PLL. So, this tactic seemed the easiest approach to a polyphonic synth cable.
It may have been easier to implement wavetable lookup with antialiasing, certainly if I went for a chip with hardware multiplication. But for pin toggling square waves, the only way to get them in tune is to operate at ludicrously high sample rates. Thatβs easy if youβre using the hardware timer/waveform generation system, which has an effective sample rate of many megahertz, but that canβt be used for more than a couple of pins. Using a 20Mhz crystal, I initially ran an interrupt at about 500kHz, in which each of the 16-bit counters are incremented and the necessary pins toggled.
This worked very well but has no scope for pitch bend or modulation. I wanted to bend everything by changing the interrupt frequency, but it was running at such a small division of the master clock that the bend resolution was unacceptably low. I settled for a compromise: I slowed the samplerate down, dividing the cpu clock by about 130, that lets me bend with about 5-bit resolution. This is just about good enough to be usable for simple slides and so on. The downside is that the highest note that can be played in tune is reduced to about 3 octaves above middle C. I think itβs an acceptable compromise, although it wouldβve been nice to have just one more octave.
Iβve not yet added modulation. The resolution will probably be very low unless we compromise the pitch range furtherβ¦ I may try adding it later.
Now, for the fun bit: construction. To fit it into a midi jack is not trivial, even with a surface-mount chip. And we have to squeeze a crystal in there too.
Crystal needs load capacitors (although actually, it usually works without. But better to be safe since weβre already undervolting it for this frequency when midi-powering it). Along the bottom you can see Iβve started to add SMD resistors. I avoided soldering the leftmost ones directly since we want some flexibility there β thatβs where the test clip fits for reprogramming.
Will it all fit into the jack? Err yes. Yes. I wasnβt worried.
Length is a concern though, and I sawed off the backs of the pins to minimize protrusion. Thereβs the filter cap for the data line, which I forgot to put on the schematic at the top of this page. And it probably isnβt needed with the hardware UART as it claims to perform a digital lowpass filter anyway.
For more detail: Polyphonic Synth Cable