/* * Calculation of a MIDI table of frequencies for timidity * * Process with GNU bc: * $ bc -l equal_temperament.bc * * Copyright (c) 2003 Pedro Lopez-Cabanillas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * trucate a number, returning the integer part of the argument */ define trunc(x) { auto t, tmp_scale tmp_scale=scale(sqrt(2)) scale=0 t=x/1 scale=tmp_scale return t } /* * round a number, truncs or shifts it to the next integer */ define round(x) { return trunc(x+0.5) } /* * round a number to the given precission */ define roundto(x, d) { auto t, tmp_scale tmp_scale=scale(sqrt(2)) scale=d t=round(x*(10^d))/(10^d) scale=tmp_scale return t } /* * twelve root of 2 */ r12of2 = e(l(2)/12) /* * frequency for a piano key * Note: freq(0) = A(-2) */ define freq(x) { return 6.875*(r12of2^x) } /* * print the list of the 128 MIDI freqs * from C(-2) to Ab(10) */ for(i=3; i<131; i++) { trunc(roundto(freq(i), 3)*1000) }