Showing post Polyfoo arduino synth

Show me everything!

Topics

Polyfoo arduino synth

Polyfoo arduino synth

I wanted to make a synth with a low-fi sound with some kind of polyphony and MIDI interface. Since I am better at software than hardware I wanted to use as little external hardware as possible.

I have tried to make it easy to understand and use. No fancy optimizations more than some simple ones I really had to do to make it work.

How it works is pretty much described in the code comments so download the source if you are interested. The main thing needed is a arduino board (I have one of the older boards called decimilla) and optionally a MIDI-shield. I made a low pass filter using things I happened to have – the filter is so simple so you should be able to make one just by looking at the photo of it. I really do not recommend you to, but I tried to wire MIDI out straight to the rx-pin on the arduino and it worked fine for me. It might though harm your equipment

Arduino synth “Polyfoo” by TobiasTanke

There is also an image that shows that I soldered two wires onto the MIDI-shield (ground and pin 11) to get audio out from the arduino. There is also an image that show the whole thing.

I have connected the synth to a guitar amplifier and straight into my laptop mic/line input. The samples are recorded using my computer audio input. The sound I get when I run it through the guitar amp is a bit fatter.

I have tried out different additions to the synth, like AD-envelope, arpeggiator (with split keyboard function). But I did not like it and the arduino library functions to read digital pins (the buttons on the MIDI-shield) seems to mess up the timing on the interrupt routine. Need to figure out why…

To run the arduino sketch you will have to download (and “install”) the MIDI library.

Posted on topic Things I made with tags , , , , , at 22.10.2010. Some comments.

Attachment #232

Image: Overview-1024px.jpg

Attachment #205

Image: Filter 1024px.jpg

Attachment #212

Download: PolyfooSynth.zip

Attachment #234

Image: sawtooth.jpg

Attachment #235

Image: square.jpg

Attachment #236

Image: triangle.jpg

Attachment #204

Image: Audio out 1024px.jpg

01. Comment by Polyfoo LO-FI Arduino Synth

Pingback from http://www.musheen.com/polyfoo-arduino-synth-1214.html

Pingback posted at 24.10.2010 00:22.

02. Comment by Eimer

I cannot get the Polyfoo to work. :-(

Comment posted at 24.10.2010 19:47.

03. Comment by tobias

Hmmm… I think I need some more information to be able to help you!

Does it compile?
Does it react to MIDI-activity?
Pin D6 (the green led on the MIDI-shield) should toggle when you press or release a key.
If you use the MIDI-shield, remember to use the switch PROG/RUN to toggle between programming and live mode.

Comment posted at 24.10.2010 21:20.

04. Comment by Eimer

I get this error when compiling:

In file included from MidiInterface.cpp:14:
MidiInterface.h:18:18: error: Midi.h: No such file or directory
In file included from MidiInterface.cpp:14:
MidiInterface.h:31: error: expected class-name before ‘{‘ token
MidiInterface.cpp: In constructor ‘MidiInterface::MidiInterface(int, int, HardwareSerial&)’:
MidiInterface.cpp:18: error: class ‘MidiInterface’ does not have any field named ‘Midi’

Comment posted at 27.10.2010 19:44.

05. Comment by tobias

Ok, you will have to download the midi library and put it in your arduino libraries folder. There is a link in the end of the original post.

Comment posted at 28.10.2010 05:38.

06. Comment by Eimer

I have done that, but the arduino software cant find midi.h . I have the problem on both OS X and Win XP.

Comment posted at 30.10.2010 18:05.

07. Comment by tobias

If you can’t use libraries you seem to have some problem that is more related to the Arduino environment than this synth… But if you haven’t already done it, read this page. You can also tro to install it in the arduino system libraries folder rather than the user dito.

Comment posted at 30.10.2010 18:49.

08. Comment by Eimer

I got it to work and it’s awesome!

Comment posted at 02.11.2010 22:45.

09. Comment by tobias

Nice!

Comment posted at 02.11.2010 23:08.

10. Comment by Rsoft

I sadly can’t get it to work. I tried compiling it under Windows with Arduino IDE v18, 20 and 21.
V18 outputs
C:\Users\___\AppData\Local\Temp\build5640009989845292539.tmp\/MidiInterface.h:18:18: error: Midi.h: No such file or directory
C:\Users\___\AppData\Local\Temp\build5640009989845292539.tmp\/MidiInterface.h:32: error: expected class-name before ‘{‘ token
In constructor ‘MidiInterface::MidiInterface(int, int, HardwareSerial&)’:
error: class ‘MidiInterface’ does not have any field named ‘Midi’ In member function ‘int MidiInterface::addPressedKey(unsigned int, unsigned int, unsigned int)’:
In member function ‘void MidiInterface::removePressedKey(int)’:

v20 and 21 output
In file included from MidiInterface.cpp:14:
/MidiInterface.h:18:18: error: Midi.h: No such file or directory
In file included from MidiInterface.cpp:14:
MidiInterface.h:31: error: expected class-name before ‘{‘ token
MidiInterface.cpp: In constructor ‘MidiInterface::MidiInterface(int, int, HardwareSerial&)’:
MidiInterface.cpp:18: error: class ‘MidiInterface’ does not have any field named ‘Midi’

The problem seems to be in MidiInterface.h.
At least I’m pointed to the file by the IDE.
BTW your project looks awesome!

Comment posted at 14.11.2010 11:03.

11. Comment by Rsoft

I forgot to say that I “installed” the MIDI Library and renamed the folder MIDI_Library_v2.5 to MIDI_Library_v25 because the Arduino IDE didn’t want a file/folder name with characters like . or [SPACE]. It doesn’t find Midi.h.
The error is the same as Eimer’s. I just didn’t carefully read the comment. Sorry. Maybe he can help?

Comment posted at 14.11.2010 12:34.

12. Comment by tobias

@Rsoft: The library folder name must be the same as the header name. See: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1276204960

Comment posted at 14.11.2010 20:10.

13. Comment by Rsoft

@tobias: Hello again!
Thank you for your patience. The compiler now no longer outputs the “file not found” message, but all the other errors are still there.
Output:
In file included from MidiInterface.cpp:14:
MidiInterface.h:31: error: expected class-name before ‘{‘ token
MidiInterface.cpp: In constructor ‘MidiInterface::MidiInterface(int, int, HardwareSerial&)’:
MidiInterface.cpp:18: error: class ‘MidiInterface’ does not have any field named ‘Midi’
Could you please upload a hex file compiled for the Duemilanove?
BTW I know how to use AVRdude and used it successfully. :)

Comment posted at 18.11.2010 22:19.

14. Comment by tobias

One thing I can see from your message is that you have HTML escape sequences in your code. This could be a bug in wordpress or your webbrowser or whatever, but just open the files (.h, .cpp and .pde) and check that it use “&” in stead of “&”. For example, it should be “HardwareSerial &” and not “HardwareSerial &”. I can not figure out how you might have got HTML-escape characters in you code… It shouldn’t be any problem to compile and run this code.

Comment posted at 20.11.2010 21:24.

15. Comment by Rsoft

@tobias: I guess you looked at the source code of the website and saw HTML-escaped sequences(like the escaped “&”).
^^Notice that the above ampersand was escaped by WordPress.
So the HTML sequences most likely come from WordPress.

Comment posted at 21.11.2010 11:50.

16. Comment by Eimer

Hi there. I suddenly got it to compile and it works like a charm! Just want you to know. And i have a question: I am trying to implement a pulse on a output for 50 milli seconds when a MIDI note is pressed down, but it scrambles the sound. I will use the pulse to trigger an external decay for amp or filter. Can you help me?

Comment posted at 09.04.2011 22:50.

17. Comment by tobias

@Eimer So you want to use the synth as is but add another output with a short trigger pulse on each keypress?

If you use the delay function something might break. The dsp runs in interrupts from some timer. The delay function will also use a timer, prehaps the same?

If you halt using delay for 50 ms up to 150 bytes of midi data might have been lost.

The preferred solution would be to change the interrupt routine so that when GATE_ON_ARMED is detected also set the pin high and a counter to 1562. Each interrupt the counter should be decreased and when it reach zero the pin should be set to low.

Remember to set up the pin as an output pin. And output the value to the pin using the processor register rather than the digitalWrite function. It is not efficient enough to use in the interrupt routine.

Comment posted at 10.04.2011 10:01.

18. Comment by Eimer

Wowser, this is out of my league. I will give it a try. Thanks for the quick reply.

Comment posted at 10.04.2011 19:34.

19. Comment by Jonny

Hi there, I’m trying to compile the PolyfooSynth, and get the following error when I try to verify the code:

In file included from PolyfooSynth.pde:71:
StableKnob.h:39: error: ‘boolean’ does not name a type
In file included from PolyfooSynth.pde:73:
MidiInterface.h:32: error: expected class-name before ‘{’ token
MidiInterface.h:43: error: ‘boolean’ does not name a type
MidiInterface.h:50: error: ‘boolean’ does not name a type
MidiInterface.h:52: error: ‘boolean’ does not name a type
PolyfooSynth.pde: In function ‘void setup()’:
PolyfooSynth:101: error: ‘class MidiInterface’ has no member named ‘begin’
PolyfooSynth.pde: In function ‘void loop()’:
PolyfooSynth:105: error: ‘class MidiInterface’ has no member named ‘poll’
PolyfooSynth:108: error: ‘class StableKnob’ has no member named ‘poll’
PolyfooSynth:112: error: ‘class StableKnob’ has no member named ‘poll’

I’m pretty new at this, and not sure where to start poking to try fixing the problem. Would you happen to have any suggestions?

Thanks a lot for any help you can give!

Comment posted at 17.02.2013 19:35.

20. Comment by tobias

I have not used this code in a long while, but if you look at the arduino reference the type is still called boolean. But in c++ the type is called bool. Are you trying to compile it without the arduino IDE?

Comment posted at 18.02.2013 10:48.

Leave a comment

Resize me!

Try to resize the browser window and see what happens (I hope you see that the boxes are laid out to match the browser window width). Read about this theme here.

Tags

Meta

Proudly powered by wordpress
Copyright © Tobias Wahlström 2017