How to make good sound? (starter kit + speaker)

I have piezo speakers (different sizes)+ lots of resistors +..

  1. Arduino 2009 Duemilanove ATMEGA168 Board
  2. 16x2 HD44780 White character & Blue BL LCD
  3. 400 Points Breadboard
  4. 70 pcs Breadboard Wire
  5. 24C16 - 2K I2C CMOS Serial EEPROM
  6. DS1307 - 64 x 8, Serial, I2C Real-Time Clock
  7. 32.768KHz Crystal For DS1307
  8. 74HC595 - 8-bit serial-in, serial or parallel-out shift register with output latches
  9. LM324 - Low Power Quad Operational Amplifier
  10. LM386 - Low voltage audio power amplifier
  11. ULN2003 - 7 channel high current darlington array
  12. 3mm Red LED x 5, Green LED x 5, Yellow LED x 5
  13. 5 x Red Mini Push Button Momentary Switch
  14. 5 x Black Mini Push Button Momentary Switch
  15. Proto & Servo Shield ProtoShield PCB For ARDUINO

Can i make sound that sounds like piano key note for example, or anything that isn't pii pipi pii mm pii? (square wave sound i mean)
I'm quite ok in coding as I use c for years, but i lack knowledge in electronics (all but basics, i also know what is sound from the physics) if that helps

If you want something that sounds better than a square wave, short of resorting to an FM sound chip, you can set up a filter on the output to round the square wave into something more resembling a sine wave.

You can also look into doing DDS (with a similar filter - DDS stands for direct digital synthesis):

http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/

Another options would be a DAC made from resistors; a 6 bit DAC (64 levels) would output a reasonable sounding tone, 8 bit would be better.

You might be able to do this with the latch, since you are going to need the pins on the Arduino to read whatever keyboard you devise.

To find out how to build the DAC and use it, look into old-school "parallel port DAC sound"; it was a technique used by DOS programmers (mainly demo coders) to get good sound output prior to the emergence of the Adlib and SoundBlaster sound cards.

It is fairly simple, and only takes a handful of resistors wired in an R2R ladder (IIRC). People used to build them within parallel port cable dongles; there is an absolute ton of information out there on how they work.

Then you just need to create a small wavetable (an array) containing the data for your wave (sine, triangle, sawtooth, etc) and repeat it out to the shift register, latching over each 8 bits "sample" value to the DAC.

In theory, you could even store a WAV file (without its header) re-sampled at 8 bit mono on an SD card, and play that back out - but that would be an advanced-stage project.

The only thing not covered by the above is how to apply a ASDR (attack-sustain-decay-release) envelope to the waveform as it is output in order to alter it to make it sound like a piano. First, you need to output a tone that sounds more like a piano (sine or triangle would be best to start with; sawtooth is a little harsh, with harmonics similar to a square wave that grate on the ears).

Good luck, hope this helps.

:slight_smile: