ohnoitsaninja
Well-known member
I've been working on this for a while, but it's sat dormant for too long so I needed to get this out in the world before it's forgotten in the back of a drawer. I'm not publishing all the code now, as there are several programs involved and it all needs to be cleaned up better. I have an alternative NN trainer program in C with AVX2 and multithreading too that trains much faster, but the processing sketch has some nice graphics. What I can give out if anyone wants is the base code for just a teensy-LC usb-midi synth, as I have not found any complete examples anywhere yet. The ANN code is a heavily modified version of what's here. The ANN is optimized for fixed point 32-bit ints. More info in youtube description and annotations.
It was a very fun project, learned a lot, and I hope to expand on it greatly some day.
To be completely honest, the only reason I used teensy instead of making into a VST is because I couldn't get the VST sdk worked out and compiling. I had some LCs laying around, and I knew that it could work. It should say something about the ease of use with programming teensy and the excellent libraries, when it's easier to program an embedded synth than one inside your desktop.
While there are both artificial and real neural networks that have been used to compose music on other instruments, as far as I have been able to find, this is the first endeavor towards an actual neural network based instrument.
While I'm here, there was a few issues I ran into that I haven't been able to figure out. The DAC is 12-bit, so 0-4096, it would make sense for my AC signal to bounce around 2048, I have never been able to get it to work properly this way, however treating it like 11-bit and using 1024 as my virtual ac ground works fine. A bigger problem, depending on how ableton is setup to send usbmidi data, it can completely overwhelm the teensylc with messages to the point where it stops working, there isn't a usbMIDI.flush() and Serial.flush() doesn't help, adding more while(usbMIDI.read()) throughout the code didn't help either.
Source for a basic Teensy-LC Synthesizer
https://github.com/ohnoitsaninja/Teensy-LC-basic-usbMidi-synth/blob/master/basicSynth.ino
Last edited: