chipKIT® Development Platform

Inspired by Arduino™

Mini Sampling Synth

Created Sun, 05 Jun 2011 09:15:31 +0000 by pburgess


pburgess

Sun, 05 Jun 2011 09:15:31 +0000

I was trying to come up with a "killer app" that would show off the chipKIT's unique abilities rather than just a faster Arduino demo. The extra MIPS are a given...how about something using the extra RAM and flash space? So I've put together this little demo of a polyphonic sampling synthesizer with reverb effects. The extra parts are all passives from Radio Shack...there are no special ICs or shields required.

A few sound samples are compiled in with the code and stored in the internal flash...the Uno can hold about 8 seconds of 8-bit, 16 KHz audio, and the Max about 30 seconds. While there are Arduino shields for this sort of thing (using SD cards), that's an added expense, and they can only play one sample at a time, whereas this is polyphonic. Inputs are piezo transducers (allowing the volume of each sound to vary with force). Audio out is via PWM DAC using an RC filter.

At some point I'll work up a video and post a walkthrough (on Hack a Day if the editor feels it's worthwhile, else I'll post it here). Code needs a little cleanup first. I've taken a couple liberties there, including changes to analogRead() to permit faster ADC readings, and bypassing analogWrite() to access the PIC32 PWM at maximum speed.

[attachment=0]chipkit-synth.jpg[/attachment]


jasonk

Sun, 05 Jun 2011 21:31:17 +0000

That's awesome, I can't wait to see (and hear) the video!


jasonk

Wed, 08 Jun 2011 17:01:05 +0000

The video is amazing :D http://hackaday.com/2011/06/08/chipkit-sketch-mini-polyphonic-sampling-synth/


pburgess

Wed, 08 Jun 2011 17:28:04 +0000

Thanks! Actually I thought the video was a little embarrassing. :)

Article just went live this morning: http://hackaday.com/2011/06/08/chipkit-sketch-mini-polyphonic-sampling-synth/

I'm looking forward to seeing where other folks might take the idea.


Addidis

Fri, 10 Jun 2011 22:08:44 +0000

Any chance you can expand on how you converted the audio to .h?


pburgess

Sat, 11 Jun 2011 02:02:32 +0000

Addidis: there's a command-line utility for doing the conversion...not wanting to spam up the article with mountains of code, it's not shown there, but can be found in the full project ZIP file: http://www.paintyourdragon.com/Synth.zip

Look for 'convert.c', and the Makefile shows the syntax.

Important to note that this ONLY converts 8-bit uncompressed WAVs (doesn't even do error checking), it's not a do-it-all utility, though it could be expanded. I used Adobe Soundbooth to convert to that format, or it's possible to batch convert in iTunes after configuring that program's import parameters.


Archie64

Sat, 11 Jun 2011 15:53:38 +0000

Hi This is really great, I have a couple of questions for you though - I have been thinking of developing something similar for my modular synth setup - what I have in mind is a midi controlled digital oscillator which would read in a midi value, convert it to a frequency, and then read a single waveform from memory and output it repeatedly at the appropriate frequency. My questions are thus: Is it possible to increase the rsolution of the samples to 16 bit, 44Khz? and would it be possible to store the waveforms in selectable form ie single sine waves, saw waves and also perhaps sampled waveforms (similar to a PPG syth but without the transistion through the various waveforms) Also would it be possible to do this polyphonically or cascaded through multiple outputs which could then be combined together (probably getting ahead of myself there) This controller seems to be just what I am looking for but I just need to up the fidelity somewhat. Your thoughts on this would be gratefully recieved.

Cheers Ray :D


pburgess

Sat, 11 Jun 2011 18:25:19 +0000

Hi Ray,

44.1 KHz wouldn't be a problem, but this particular technique can't really be pushed beyond 8 or possibly 9 bits. Using PWM this way is inherently a hack and will never be audiophile-grade.

There are some DAC chips that can be interfaced with the SPI bus. The Adafruit Wave Shield is a good example using an inexpensive 12-bit DAC in a DIP package...though again, not audiophile-grade, but maybe a good learning experience. TI (and probably others) makes a stereo 24-bit DAC that should do all that and also make toast, but it's a surface-mount package and requires some external components, and I've not had an opportunity to mess around with it.

As the demo shows, polyphony (through software) is no problem. The big limitation would be the space available for 16-bit samples at a high frequency...only a few seconds' worth even on the Max32. So not meaning to be a downer, but this might not be the right tool for the job. Retro "chip tune" stuff though, totally. :)


Addidis

Mon, 13 Jun 2011 10:34:09 +0000

Using the wav to .h file converter (for windows users who want an easy way to use this) :

I am sure there are ways that don't take 4 or 5 hours to install but for the sake of making this simple I will trade complexity for a 4 or 5 hour install. (cygwin is very useful and used in many programming tutorials)

Install cygwin. http://www.cygwin.com/ During install it will ask you what to install, save your self the headache later and click all at the top and let it install every thing.

My antivirus had a few strokes installing this but I just forced it threw in normal mode. Check up on the install in case yours requires you to ok it as well or 5 hours turns into 25. 4 or 5 hours pass.

Again to make this simple copy the "wavs" folder (from the synth download) to C: right in the root directory. If your confused about how to use this then you probably are going to have trouble navigating to the right folder so make it easy and put it in the root directory.

On your desktop there should be a cygwin icon (its green) open it.

This is the command line . In the cygwin window , type "cd c:/wavs" with no " and press enter type "make all" It will spit out a sounds.h file into the folder wavs.

To change the sounds edit the makefile in a text editor and edit where it says the wav names. Its pretty easy to figure out once you de-magic the whole concept of a command line utility into something you understand. All of the wavs your converting need to conform to the notes in convert.c and must be in the same wavs folder as the makefile and the convert.c or bad things happen. Use headphones the first time you play it my first few were nothing but speaker blowing squeals .

Now that you have recreated what Phil has done to convert files that are already in the right format (convert his files and try them first) , your probably installing itunes and looking for some way to convert files to that format. You will probably find the next link helpful at this point. All the tutorials I could find for itunes used previous versions and the options are all moved around.

http://audio.online-convert.com/convert-to-wav


pburgess

Mon, 13 Jun 2011 19:45:59 +0000

Addidis, you are a gentleman! Thank you for posting this walk-through of the process.

I'm mostly a UNIX guy. Manage OK as a "normal user" with Windows, but have never gotten into the coding side. Had a hunch this would work with something like Cygwin, so I really appreciate your putting it to the test. Also the online WAV converter, awesome find!

This info would be helpful for anyone who comes upon the HaD article...would be very happy if you could comment there with this info, or if it's easier for you, I'll duplicate it there and would totally give credit for the source.

Thanks again. And pet the kitty for me! :)


Addidis

Mon, 13 Jun 2011 21:14:01 +0000

lol my cat runs for the door every time i push the button .

TBH i expected to get flamed for my lack of effort and apparent disdain for capitols , spelling, grammar and punctuation in that post . Its also probably wasting hours and hours.

I suppose I should clean it up if your going to go copy pasting it lol.

Go ahead, you can post with formatting , so you might as well do it. PS you should give me a hand getting the wave shield examples compiling now :D


Joselon

Thu, 14 Nov 2013 15:12:25 +0000

This might be a stupid question...(Noob here) I have been trying to make this project work for the last week and I don´t seem to find the solution. I am using a chipkit max32, do you think the problem is that I am not using the Uno?