Context: Making Sounds with Piezos
Table of contents
Primer on Sound
First, it’s important to understand a little about sound and how sound works…
While written for Processing (a creative coding language for computer graphics), this article provides an excellent primer on sound synthesis. Start by reading: Sound by R. Luke DuBois and Wilm Thoben up to Example 1, 2: Synthesizer
Making this easier
Download pitches.h. Add it to your project folder and include it in your main code file by adding the following line at the top:
#include "pitches.h"
What does this do?
In the previous example we had to manually write the frequency for each tone we wanted to create
int melody[] = {1908,2551,2551,2273,2551,0,2024,1908};
The pitches includes a set of definitions that make it much easier to reference notes. With pitches.h
included we can write this as:
int melody[] = {NOTE_C4,NOTE_G3,NOTE_G3,NOTE_A3,NOTE_G3,0,NOTE_B3,NOTE_C4};
Find out more
-
Get inspiration from Hackster Projects using Piezos and Arduino Audio Projects
-
Skill Builder: Advanced Arduino Sound Synthesis on Make Magazine