I'm new to Arduino and I've been playing around with sound.
I just found this site http://jarv.org/files/midi-avr/arduino_all_piano_tones.html
It has a table for all the piano note frequencies. Now I see that those frequencies have a decimal.
example : C8 (Eighth octave) = 4186.01
But the tone() function only accepts an unsigned int as the frequency parameter.
Could I just drop the decimals and use the rounded values? Will this still sound good?
I've read ton's more about generation audio with an Arduino, including wavetable synthesis combined with envelopes, but for now I've realised that that way of generating sound is too complicated for me. So I'll settle with the tone() function and the Tone library that allows playing 2 tones at the same time...
Also if one presses a piano key, the sound it produces will fade out over time instead of abruptly stopping.
Is this possible to simulate this with the tone() function? Or does that require wavetable synthesis too?
Or could I maybe achieve some effect like this with a circuit at the output useing 555 timers/capacitators/whatever... ?
Yes, drop the decimal point, doubt you will hear any difference.
Envelope - use same key press that start the tone generation to have a 555 create an envelope.
Use the envelope to control a Voltage Controlled Amplifier
When I was in college in early 80's, we could buy chips where the 4 periods could be set up with potentiometers, and used to feed voltage controlled amplifiers to control the envelope of a sound waveform. Maybe static hiss for a snare drum, lower frequency for a bass drum, etc..
This one seems recent, a microcontroller programmed for ADSR:
@memorex: //555 timer
i´ve played around with this two (basic!) schematics:
555 timer as vco: 19.FM - VCO - 555Timer I Ham lesson o' de day
getting cv-voltage with pwm: http://i50.tinypic.com/29ffjoo.png
please note, that using other opamps (like tl072,...) than the lm358 in the cv results in strange behaviors
I try to realize just a VCA using digital potentiometers.
At this moment the toneAC library is being developed.
You need version 1.2 (will be ready soon).
The toneAC library is very small and fast and can control the volume.
So some kind of fade out is possible. But with digital pulsed sound, also the sound changes.
But if you make a fast fade out, it's not a big problem.
It is ment to drive a loudspeaker with two pins of the Arduino, it is not a signal for an amplifier.