mitxela.com forum
Welcome. Please log in or register.

ATmega328P polyphonic square wav synth
Zipdox Posted: 22 Jun 2020, 12:06 PM
Avatar


Member
Posts: 2
Joined: 22-June 20
Hi, I'm working on a polyphonic MIDI square wave synth with the ATmega328P to use as a tesla coil interrupter. It has to output on a single pin to attach to an optical transmitter.

He're a link to my post on another forum:
https://highvoltageforum.net/index.php?topic=998.0

The issue I'm facing right now is that I can't play more than 2 notes simultaneously or it stop processing MIDI interrupts.

Any help solving this issue and cleaning my spaghetti could would be appreciated.

-------------
[top]
DAVID Posted: 23 Jun 2020, 05:06 AM
Avatar
avrs + midi = best diy synths

Member
Posts: 226
Joined: 10-September 17
The problem with your code it´s that it relies too much on floating point calculations. The atmega328p might be very good in many occasions but when it comes in to those types of calculations it is tremendously slow. I would recommend using integers for that.

The second problem I can see is that OCR2A is set to 0 and the TCCR2B register has a prescaler of 1 meaning that the Compare match interrupt 2 is running 16 mhz, so the CPU might not like that.

You could try out my code that I made a while ago about an 8 voice polyphonic synth which features 6 waveforms https://github.com/theawsomeavr/Arduino-NES-synth
Feel free to modify it to suit your needs.

Last edit by DAVID at 23 Jun 2020, 05:06 AM

-------------
[top]
DAVID Posted: 23 Jun 2020, 05:06 AM
Avatar
avrs + midi = best diy synths

Member
Posts: 226
Joined: 10-September 17
Also while making midi synths the MIDI library has been (at least for me) quite a resource intensive library and it takes like 2 kb of memory

-------------
[top]
Zipdox Posted: 23 Jun 2020, 10:06 PM
Avatar


Member
Posts: 2
Joined: 22-June 20
I don't know how familiar you are with Tesla coils, but they require a 1 bit interrupt signal (either on or off) to determine when to oscillate. To play music this requires square waves with short duty cycles to not overload the MOSFETs / IGBTs. So to make it polyphonic you essentially just overlap multiple short duty cycle square waves. Do you think you'd be able to help me out with that? I'm quite bad at C.

-------------
[top]

Sign in to post a reply.