dzlonline / the_synth Goto Github PK
View Code? Open in Web Editor NEWA simple to use 4 polyphonic wavetable synthesizer library for Arduino.
A simple to use 4 polyphonic wavetable synthesizer library for Arduino.
What's the license on this code? I'd like to try it in a GPL3 project...
There is an unneeded noTone() call in song.ino.
Don't know if you are interested, but I got in touch with user df99 that made a comment at your Instructable about this project and made a modification so it will work correctly using the Uno or Leonardo.
Are you interested?
Hi.
Sorry, this is not an issue at all.
Some time ago I ported your library to run with Arduino DUE.
Years ago before that I changed your library to be able to use a 12 bit spi dac with arduino nano. I build a synth/sequencer with that and used it a lot.
Due has more power, tones of GPIO and on board dual DAC so I tried it and It was quite easy.
With DUE I used "DueTimer" library to call audio driver interrupt and direct dac write to put samples out.
I added more tables and even a filter from mozzi library. I got at least 16 voice polyphony and built a drum machine: some pots, two RGB matrix leds as screen and a resistive touch panel on top. Sound is amazing and very fun to play. I was very happy with the result.
If you want I can share the library with DUE support.
Also try to port to esp32 and I2S DAC but sound is not as good as I got with DUE. My skills are not as good as I wish :(
I saw you were developing a library for ESP32 in your blog but still no code.
Can you share it? It would be fantastic ;)
Thank you
I just got this working on my project - it's a sequencer that constructs and plays chords and chord progressions, based on another project I found online. ( https://youtu.be/bd3h9vR5jO8 )
https://github.com/prosper00/arpeggiator - it's messy spaghetti code at present, but it does work.
I made a couple minor changes, to get it to cooperate with other stuff going on on the CPU.
Hi, very good project!
I use your synth with arduino Pro-mini 5V/16MHz and keypad to generate DTMF tones.
My Pro-Mini is connected to a MEGA2560 via Serial port.
But I have a problem:
If MEGA and Pro-Mini powered by their own power supply and connected each other via GND/TX/RX pins -> OK
If MEGA and Pro-Mini powered by the same power supply and connected each other via 5V/GND/TX/RX pins -> no OK. I have a noise in speaker.
How can I resolve that?
Thanks in advance.
Hello everyone!
I'm trying to use this synth in an arduino UNO and, even in all examples, the only output I have in the osciloscope is a saw wave! I'm loading examples using the suggested connection with the supposed resistors and capacitors.
Anyone knows what's the problem?
Hi @dzlonline, thnx for this library! Great work!
I'm creating a simple copy cat of the Synth Module Chord Organ by Music Thing Modular --> In my approach, it creates 4 voice chords in different shapes and a certain root note. Based on your library, which was awesomely easy to implement! 👍🏻
Still, I have a steady noise or crackling in the result. Especially with lower root notes.
Do you have an idea how I can fix this?
Here's the current state of my project:
Thank you in advance!
Steffen.
It might help some people if you document the different pin numbers that your code uses when it's run the Mega. On the Mega2560 CHB mode uses pin 9 (tested) and I think CHA mode uses pin 10. No changes to the code are needed--just the pins to connect the speaker to.
Hi,
this is not really an issue but I couldn't find these information anywhere.
I'm currently studying media technology in second semester and we have a class where we build a synth.
We would like to use your project as base and modify it to our needs. Since you don't have any license files attached I want to make sure that this is fine to you.
The project won't be distributed or published, it's just an internal project.
It would be great if you could let me know if this use of your code is okay for you.
Thanks in advance
Greetings from Germany
just add this file to your library, you will get colors in no time! (restart required)
keywords.txt
Is it theoretically possible (i.e. possible with the Arduino's processor) to add more voices to the output?
Hello, I was surprised with your design with just a .h file and no .cpp file. This way one cannot implement real modularity (e.g. Let's say I would make a DTMF library and a music player library which would both use yours. I wouldn't be able to use them both in the same program. Is there a reason you implemented it that way ?
Hello,
I'm working on a small arduino synth-project which contains a diy pcb with an atmega8 and a 16Mhz crystal on it.
When I try to compile the my code, which works fine on an Arduino Uno gives me the following error:
(It's actually a fork on this library: https://github.com/ChrisMicro/the_synth)
Arduino:` 1.8.19 (Mac OS X), Board: "ATmega8, No bootloader, EEPROM retained, BOD 2.7V, LTO enabled, External 16 MHz"
In file included from /Users/xx/Documents/Arduino/P13_TinySynthKeys_Wavetable_ardu/P13_TinySynthKeys_Wavetable_ardu.ino:2:0:
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h: In function 'void __vector_6()':
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:72:2: error: 'OCR2A' was not declared in this scope
OCR2A = OCR2B = Output;
^~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:72:2: note: suggested alternative: 'OCR2'
OCR2A = OCR2B = Output;
^~~~~
OCR2
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:72:10: error: 'OCR2B' was not declared in this scope
OCR2A = OCR2B = Output;
^~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:72:10: note: suggested alternative: 'OCR2'
OCR2A = OCR2B = Output;
^~~~~
OCR2
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h: In member function 'void synth::begin()':
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:157:2: error: 'TCCR1C' was not declared in this scope
TCCR1C = 0x00;
^~~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:157:2: note: suggested alternative: 'TCCR1A'
TCCR1C = 0x00;
^~~~~~
TCCR1A
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:159:6: error: 'TIMSK1' was not declared in this scope
SET(TIMSK1, OCIE1A); //-Start audio interrupt
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:35:19: note: in definition of macro 'SET'
#define SET(x,y) (x |=(1<<y)) //-Bit set/clear macros
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:159:6: note: suggested alternative: 'TIMSK'
SET(TIMSK1, OCIE1A); //-Start audio interrupt
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:35:19: note: in definition of macro 'SET'
#define SET(x,y) (x |=(1<<y)) //-Bit set/clear macros
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:162:2: error: 'TCCR2A' was not declared in this scope
TCCR2A = 0x83; //-8 bit audio PWM
^~~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:162:2: note: suggested alternative: 'TCCR1A'
TCCR2A = 0x83; //-8 bit audio PWM
^~~~~~
TCCR1A
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:163:2: error: 'TCCR2B' was not declared in this scope
TCCR2B = 0x01; // |
^~~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:163:2: note: suggested alternative: 'TCCR1B'
TCCR2B = 0x01; // |
^~~~~~
TCCR1B
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:164:2: error: 'OCR2A' was not declared in this scope
OCR2A = 127; //-+
^~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:164:2: note: suggested alternative: 'OCR2'
OCR2A = 127; //-+
^~~~~
OCR2
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h: In member function 'void synth::begin(unsigned char)':
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:183:2: error: 'TCCR1C' was not declared in this scope
TCCR1C = 0x00;
^~~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:183:2: note: suggested alternative: 'TCCR1A'
TCCR1C = 0x00;
^~~~~~
TCCR1A
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:185:6: error: 'TIMSK1' was not declared in this scope
SET(TIMSK1, OCIE1A); //-Start audio interrupt
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:35:19: note: in definition of macro 'SET'
#define SET(x,y) (x |=(1<<y)) //-Bit set/clear macros
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:185:6: note: suggested alternative: 'TIMSK'
SET(TIMSK1, OCIE1A); //-Start audio interrupt
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:35:19: note: in definition of macro 'SET'
#define SET(x,y) (x |=(1<<y)) //-Bit set/clear macros
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:193:3: error: 'TCCR2A' was not declared in this scope
TCCR2A = 0xB3; //-8 bit audio PWM
^~~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:193:3: note: suggested alternative: 'TCCR1A'
TCCR2A = 0xB3; //-8 bit audio PWM
^~~~~~
TCCR1A
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:194:3: error: 'TCCR2B' was not declared in this scope
TCCR2B = 0x01; // |
^~~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:194:3: note: suggested alternative: 'TCCR1B'
TCCR2B = 0x01; // |
^~~~~~
TCCR1B
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:195:3: error: 'OCR2A' was not declared in this scope
OCR2A = OCR2B = 127; //-+
^~~~~
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:195:3: note: suggested alternative: 'OCR2'
OCR2A = OCR2B = 127; //-+
^~~~~
OCR2
/Users/Chris/Documents/Arduino/libraries/the_synth/src/synth.h:195:11: error: 'OCR2B' was not declared in this scope
OCR2A = OCR2B = 127; //-+
^~~~~
/Users/Chris/Documents/Arduino/libraries/the_synth/src/synth.h:195:11: note: suggested alternative: 'OCR2'
OCR2A = OCR2B = 127; //-+
^~~~~
OCR2
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h: In member function 'void synth::suspend()':
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:394:10: error: 'TIMSK1' was not declared in this scope
CLR(TIMSK1, OCIE1A); //-Stop audio interrupt
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:36:19: note: in definition of macro 'CLR'
#define CLR(x,y) (x &= (~(1<<y))) // |
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:394:10: note: suggested alternative: 'TIMSK'
CLR(TIMSK1, OCIE1A); //-Stop audio interrupt
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:36:19: note: in definition of macro 'CLR'
#define CLR(x,y) (x &= (~(1<<y))) // |
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h: In member function 'void synth::resume()':
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:398:10: error: 'TIMSK1' was not declared in this scope
SET(TIMSK1, OCIE1A); //-Start audio interrupt
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:35:19: note: in definition of macro 'SET'
#define SET(x,y) (x |=(1<<y)) //-Bit set/clear macros
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:398:10: note: suggested alternative: 'TIMSK'
SET(TIMSK1, OCIE1A); //-Start audio interrupt
^
/Users/xx/Documents/Arduino/libraries/the_synth/src/synth.h:35:19: note: in definition of macro 'SET'
#define SET(x,y) (x |=(1<<y)) //-Bit set/clear macros
^
exit status 1
Fehler beim Kompilieren für das Board ATmega8.
I think the registers of the Atmega328 and Atmega8 are different... What do I have to know about the processor to get this library working on an Atmega8? The Library is really great it would be a charm if I could get it working on my project...
Thank you :)
Yup, this library only works on the Arduino Uno after 2018. Now it doesn't work on the Arduino MEGA2560. Something changed but I'm not sure what
Could you check to see if your library works on the Arduino MEGA2560, please?
I have a really stupid question: I can set the note for a voice with mTrigger(), but I don't see an API to stop one particular voice. Am I missing something, or is the API missing?
Is there a way to control volume, without extra hardware?
Hi @dzlonline,
Thank you for sharing this awesome project!
I have been using your library without any issues on different nano boards. I recently got my hands on a couple of atmega328p PU (28DIP) chips.
After boot loading and uploading the sketch it all works well until I connect the audio out pin (in my case, pin 3, using CHB).
I know the sketch is running well without the audio input connected because the code runs an LED sequence (sequencer steps) and it works. I modify the tempo with a delay function in the sketch and turning the tempo potentiometer affects the LED sequence tempo accordingly.
Moreover, sometimes I connect the audio pin out and I do get some notes. Sometimes just one and it freezes, sometimes a full sequence and then it freezes...
I have tried different chips and get the same result. I was wondering if this can be related to the way the Synth.h is setting up the board.
@troisiemetype, reading the reported issues before creating one, I found a thread with you that made me think you can also have a good idea about what is happening here.
Thanks!
I've been using this without issue on my uno. Trying to get it to work with a mega2560 but sound isn't being output. I read in this issue: #6 that you just need to connect to pin 9 or 10, neither seem to work for me. Any ideas as to why or how you would port this for a mega? Thanks
Hello!
Been really enjoying this project. Had no idea Arduino could make such great sounds. I've been experimenting converting single cycle .wavs to c arrays and testing different waves with the voices. Theres an awesome project where you can check out all kinds of single cycle waveforms and then use a simple c program called wav2c to convert them to c arrays: Was wondering -- is there a way to have the synth engine cycle through longer waves? I know it's capped it 128 or 256 (can't seem to figure out which). If i wanted the engine to play longer arrays via another non-PROGMEM source -- like an SD card or somewhere with more space for longer arrays. I know in essence I could have each voice trigger a different wave in sequence thus creating a single 4x wave -- but hoping to have it uniform with a single voice.
Is there a way to do that? Even expanding the wavetable length x 2 (512) would make it to the moon!!
I played around with your awesome library and created my own. Just thought I'd share it with you:
https://github.com/nathanRamaNoodles/MusicWithoutDelay-LIbrary
The sound of tvout is bad :(
https://playground.arduino.cc/Main/TVout
Hey, great Project.
I want to use an mcp4728 I2C DAC chip to increase sound quality, do you think it would be hard to adapt the code to that?
As someone not that familiar with embedded I am not sure where the relevant bits of code are that would have to be replaced
When trying to compile some example, I get the following error.
/usr/share/arduino/libraries/synth/tables.h:59:23: error: variable ‘SinTable’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/synth/tables.h:319:28: error: variable ‘TriangleTable’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/synth/tables.h:579:27: error: variable ‘SquareTable’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/synth/tables.h:839:23: error: variable ‘SawTable’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/synth/tables.h:1099:24: error: variable ‘RampTable’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/synth/tables.h:1359:25: error: variable ‘NoiseTable’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/synth/tables.h:1619:19: error: variable ‘Env0’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/synth/tables.h:1753:19: error: variable ‘Env1’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/synth/tables.h:1888:19: error: variable ‘Env2’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/synth/tables.h:2023:19: error: variable ‘Env3’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
make: *** [.build/uno/src/sketch.o] Error 1
I have avr-gcc 4.7.2 installed on debian. which version of avr-gcc are you using?
Any idea how to fix this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.