Is My Project Possible?

Hello all. I've been programming for a very long time, but this is the first time I've done anything with hardware. The project I've decided to take on is fairly large - the thing is, I don't even know what to buy for it or if it's even possible.

The main premise of the project is that I am going to create my own musical keyboard. I want to be able to output it to headphones or speakers, and want to be able to reprogram the sounds created by each key. I figured I would have a Duemilanove board be the central part of the keyboard, taking input from the buttons I put under each key and turning it into an analog signal and outputting it to the headphones.

The problem is, I have a fairly tight budget - the upper limit is around $100. I want to make sure I purchase stuff I actually need, too. In all, what sort of things would you recommend I buy? I realize I know almost nothing about what I'm getting into.

It is definitely possibly but it is large for a first project.

How many keys are you going to switch? There will be a fair amount of wiring. Hopefully you won't get discouraged halfway through an 88-note keyboard :frowning:
You probably should google "keyboard scanning" for some circuit diagrams. A lot
of scanners do a matrix configuration to minimize I/O lines.
To avoid all of the wiring a lot of people use a low-cost keyboard as a MIDI
output device.

There are a number of sound generation sketches. I did a numerically controlled oscillator example for one of my boards (see Loading... ). It generates four channels
of analog output.

(* jcl *)


www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org

If you want to generate the sound with the arduino then I would suggest that it is not possible. And before anyone jumps on me, that is it would not be a very good quality of sound output. This is due to the limited resolution on the D/A, lack of memory to store the sounds, and lack of processing power to output the sounds.

In response to Grumpy_Mike, I honestly don't need sound that is at the pinnacle of quality. I'll probably using more 8bit soundsets, so that's not really a problem.

Besides sound your application includes scanning. Unless you add other logic
you are probably going to have scan each key every mS or so. If you have a lot of keys
this could get time consuming.

(* jcl *)

What do you mean by scanning? I apologize for my lack of knowledge on the subject. :-/

You have one pushbutton under each key. You have to periodically determine whether
the pushbutton is on or off. Periodically monitoring is called scanning.

IIRC keyboards typically scan all keys every mS or so. I could be a little off on
the exact number. I haven't looked into this in a while.

(* jcl *)

http://www.wiblocks.com

If I were you, I would definitely -not- go the route of wiring up a keyboard; depending on how well you want it to work (and how you want it to react), it could eat up your entire budge. Instead, I would visit a local thrift/second-hand store, and see if I could find an old cheapo synthesizer. Depending on the item and where you find it, and how well it still works, you shouldn't have to spend more than $20.00 (unless it is a larger-size synth).

Make sure whatever one you find -doesn't- have MIDI IN/OUT - why? Because those keyboards, if they work, should be reserved for the budding (or poor) MIDI artists out there. Also, research the heck out of whatever cheapo synth you buy; there are a few out there that are considered "classic" (especially among bender crowd - but also among collectors), and if you tear one of those up, you will only end up crying when you find it is worth waaaay more than what you paid for it.

You might pick up a couple to expand the available octave range if the ones you find are of the smaller variety (and if you can find two or more the same size; or go tiered?); what you won't find on these keyboards, though, is advanced features like velocity control and other such things you find on better synthesizers (but that's OK - you couldn't build such things into a playable home-brew keyboard anyway for $100.00).

Once you have your cheapo-synth, and you know it isn't anything anyone cares about (or maybe you don't care; just realize, though that such an act of "restruction" would be considered by some akin to taking a crayon to an original copy of the Magna Carta), then you at least have a pre-made keyboard, plus a lot of other parts you could use in your custom synthesizer (including a sound chip and amplifier, if you care to interface to them!).

Oh - did I mention "Circuit Bending"? You may want to look into that scene; while in some cases they have done the above "sacrilege" against certain keyboards and electronics (especially speak-n-spells; then again, there were a ton made, so whatever), some of their techniques might be of interest to you.

I generally agree with Grumpy_Mike, and he has educated me on some things (and maybe he will here, too) - but I don't think sound generation is outside the scope of an Arduino. I have nothing to back this up (its on my "someday" list), but I think the Arduino would be more than capable of generating 8-bit single channel FM, or possibly 12-bit dual-channel FM (6 bits per channel), using simplified wave tables and ASDR envelopes (DDS - direct digital synthesis). Depending on how well you write the code, you might be able to have multiple voices mixed on the output. Output of the sound could happen either via a DAC (a simple resistor ladder DAC would be fine); you could also possibly output the sound using PWM and filtering.

What it couldn't do, though, is all of that plus keyboard scanning; I do think it could act as the synthesizer sound source, alone, though. Alternatively (and perhaps within your budget as well), you could interface with a sound chip like this one:

You might also find specs on-line for the sound chip in the original synthesizer; you have a number of options available ultimately.

Good luck with the project; take it in simple, easily digestible chunks and steps, and it should work out!

:slight_smile:

If you are wiling to spend $2-$3 on an experiment to generate sound, and willing to read assembler,
I commend Simple 8-bit-digital-to-analog-converter using a R/2R-network
I built a 6-bit version, using 1% resistors for under £2, and it was a hoot.
The sounds were recognisably different in quality (through a speaker, not a piezo buzzer)

I didn't get as high frequencies as the author, but I wrote the code in good-ole' Arduino C/C++ (with direct port access)

HTH
GB

That'd be pretty intense actually if I just tore apart an old keyboard and used the parts. The only thing is, would I be able to easily give it a different soundset? I mean, I haven't done really any circuit boarding, and it seems like it would kind of be a daunting task.

If none of this pans out, I might just circuit bend a crappy Disney keyboard. :smiley:

The only thing is, would I be able to easily give it a different soundset?

Have you ever programmed a computer to make sounds (what I mean here is generating a waveform and playing it - not using a library or something, but bit-banging a speaker, or even a sound card directly)? If you haven't, then you will have to learn that; fortunately, it is fairly easy if you have the coding chops.

As far as the hardware is concerned, yes, it won't be easy to hook up an Arduino to a keyboard - but you have to start small, just like you did with programming (or at least, I hope you did). Buy an Arduino, a switch, a few other parts (piezo buzzer, resistors, etc) and a breadboard, and start playing with the examples. There are plenty out there on how to use the Tone library, for instance, to make sound and play music. There are plenty of other tutorials out there on how to make other sounds with the Arduino as well. What you won't find much of is how to shape a sound with an ASDR (attack-sustain-decay-release) envelope, which is the heart of FM sound synthesis (allowing a simple sine or triangle wave to become a piano or flute tone, respectively; or noise to become a drum) - but there is plenty of other information about this in PC sound generation (look into old-school demo sound coding using an R2R network on the PC parallel port - you'll find a ton).

Take it slow, one step at a time. Get sound to play; learn how to use a switch to control a program, then combine the two - and there, you have one "key" controlling a single "sound". From there, it is just a matter of expansion...

This won't be an easy or quick project, but it could be one that will teach you a ton of things about hardware interfacing, sound synthesis, control, etc - that you don't get from other projects. Nothing worthwhile is quick or easy - nothing.

:slight_smile:

Ai'ght. Will do.

As a side project, I am going to get around to chip bending a tickle-me-elmo though. :smiley:

Have you ever programmed a computer to make sounds (what I mean here is generating a waveform and playing it - not using a library or something, but bit-banging a speaker, or even a sound card directly)? ...

(look into old-school demo sound coding using an R2R network on the PC parallel port

The link I posted Simple 8-bit-digital-to-analog-converter using a R/2R-network
is an ATmega (AVR) hooked up to a DIY 8-bit R/2R digital to analogue converter (DAC). Takes less than an hour to make on a breadboard.

That author's code generates a range of waveforms. He wrote it is assembler.
I wrote it from scratch using Arduno C/C++, and generated look-up tables with a spreadsheet.
It sounds like you understand how to program, so if you know what an audio wave should look like, it won't take you very long.

After initial experiments, if you want to hear the difference in tone quality, then get a speaker. Almost any speaker is better than a piezo speaker, even a $2 garage sale thing. All the cheap piezo speaker's I've used colour the sound.

Ladyada has a WAV shield. I have not used it, but it looks like a reasonable quality mono digital to analogue converter (DAC) Audio Shield for Arduino
It also has an SD card socket.

(If you want to keep the budget tight, maybe just get the DAC.)

If you go down the WAV shield path, you could put sound data into SD, but there isn't much room in an Arduino's RAM. Sound parameters can be stored in program memory, preserving your precious RAM, so look into 'progmem', but it's not pleasant.

There are a bunch of good-quality stereo DAC's for well under $10, but an ordinary Arduino will struggle to make good use of them and scan any sort of keyboard.

Frankly, if I really wanted to make good quality sound, digitally, I'd look at a different microcontroller with a fast DAC, and/or an I2S interface (to drive the audio interfaces on high-quality ADC/DAC), an high speed SD memory interface, a reasonable amount of RAM, and a lot more arithmetic performance. It'd make experiments and development much easier.

I'd use an ARM, but AVR32, PIC32, Renessas, etc. would be fine. (By the time you've done some experiments, maybe a Cypress ARM-based PSoc 5 will be available on an affordable board. On paper it looks ideal.)

HTH

One more question - if I purchazzy a crappy keyboard and open it up, will I be able to keep everything except for, of course, the microprocessor? And, though I doubt it's possible, could I reprogram the microprocessor?