/* Fundamental freq of this octave. Others: 220, 440, 880, 1760 * Octiave multiplier is: 2.0 ^ n/12.0; Where n means the nth note * in the octave. E.g. A => n=0; A# => n=1; B => n=2, and so on. */ float octave = 440.0; float a0 = octave * 1.000; float b0 = (octave * 1.122); float c = (octave * 1.189); float d = (octave * 1.335); float e = (octave * 1.489); float f = (octave * 1.587); float g = (octave * 1.782); float a = (octave * 2.000); float b = (octave * 2.0 * 1.122); float c2 = (octave * 2.0 * 1.189); /* Note times: q - quarter, h - half, w - whole */ float tempo = 0.25; /* Duration of a quarter note */ float q = tempo; /* Quarter note */ float h = (2.0 * tempo); /* Half note */ float dh = (3.0 * tempo); /* Dotted half */ int note_display = 0; /* Global chooses whether to display note or not */ void note(float freq, float dur) { if (note_display) printf("Piezo Test freq%f\n", freq); tone(freq,dur); } void cof() { note(c,q); note(f,q); note(g,q); note(a,q); note(g,dh); note(e,5.0 * q); note(c,q); note(f,q); note(g,q); note(a,q); note(g,8.0 * q); note(c,q); note(f,q); note(g,q); note(a,q); note(g,dh); note(e,5.0 * q); note(g,q); note(f,q); note(e,q); note(c,q); note(c,5.0 * q); note(c2,q); note(b,q); note(a,q); note(g,q); note(b,h); note(g,q); note(a,h); note(f,q); note(g,h); note(c2,q); note(b,q); note(a,q); note(g,q); note(b,8.0 * q); note(c2,q); note(b,q); note(a,q); note(g,q); note(b,h); note(g,q); note(a,h); note(f,q); note(g,h); note(g,q); note(f,q); note(e,q); note(c,q); note(c,7.0 * q); }