Hello, I am new here but I have already made a few projects on the arduino. I am on the hunt currently on how to make a specific sound on an arduino with a piezzo buzzer.
My code generates something similar in terms of pitch and timing... but it is very harsh when compared to the link above. Is there an easy way to modulate a tone or make it softer?
So after I looked up modulation as it pertains to audio I understand now
My new code:(It makes a sin wave but also modulates the pitch really fast up and down.)
void loop() {
b=b+1; //for the sine wave
a=a+mod; //for the pitch modulation
if(a>40){mod=-mod;}
if(a<1){mod=-mod;} //these loop modulation back and forth
c=75*sin(.004*b)+1600+a*5; //all the numbers added up.
tone(13,c);
}
Hi,
If you precalculate all the sin wave values and store them in an array, you can congratulate yourself on building your first wave table synthesizer.
Here is a link to one I have done some work on recently -
Here is a link for adding an audio amp to your project to make much better and louder audio from your Arduino -
There also are some clips of various peoples Auduinos (arduino based granualar) synth at the end of the second link
All of these are a good base for music or sound effect production.
I'm not completely sure what the function does above but I see a 2000 that I assume to be Hz with a rising action.
I make my living as an audio engineer. If I want to make someone's ears bleed 2000-3000 is where I'd start. At this frequency sin waves can be more harsh than other options which, for whatever reason, sound more pleasant with upper harmonics. If you have access to square or saw I'd look at those and I'd look to get to lower frequency registers, if possible.
The frequency response of the piezo is going to be limited for sure and that may make things tricky in that you may not ever heard a fundamental frequency of 500Hz or something.