The Csound Blog by Jacob Joaquin email jacobjoaquin@gmail.com web http://www.thumbuki.com/csound/blog/ (C)2008 Jacob Joaquin Licensed under Creative Commons (see below) Touch-Tone DTMF Generator Most people would never think of a touch-tone phone as being an additive synthesizer. Though it may be primitive, a phone does generate tones using two sine wave oscillators, which in my humble opinion, qualifies it as such. However, I'm not here to debate the semantics of whether or not a phone is a synthesizer. Instead, I'm here to demonstrate how easy it is to emulate the sounds of the touch-tone phone. A phone sound is known as a DTMF, which stands for "dual-tone multi-frequency." As the name suggests, a DTMF is a mix of two sine waves of different frequencies. It's really that simple. The only other thing we need to know in order to emulate DTMF tones is a list of these frequencies, which Wikipedia provides: Wikipedia - Dual-tone multi-frequency http://en.wikipedia.org/wiki/DTMF The code is mostly straight forward. Instrument 1 accepts frequency values at p-fields 4 and 5, utilizes two sine oscillators, and outputs the mix of these two signals. In the score, I've consolidated the DTMF frequency pairs into single macro definitions for convenience. Now I have Phil Collins stuck in my head. Any guesses as to which song? Permalink http://www.thumbuki.com/20080702/csound-blog-touch-tone-dtmf-generator.html Related Links Csound Blog, A Micro Intro to Macros http://www.thumbuki.com/csound/files/thumbuki20070420.csd NYC Resistor, DTMF tone generator for GBA http://www.nycresistor.com/2008/04/28/dtmf-tone-generator-for-gba/ Wikipedia, Dual-tone multi-frequency http://en.wikipedia.org/wiki/DTMF YouTube, Phil Collins - Don't lose my number http://www.youtube.com/watch?v=LTClsWzUHBo License (cc) Creative Commons Attribution-Noncommercial 3.0 Unported You are free: * to Share -- to copy, distribute and transmit the work * to Remix -- to adapt the work Under the following conditions: * Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). * Noncommercial. You may not use this work for commercial purposes. * For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page. * Any of the above conditions can be waived if you get permission from the copyright holder. * Nothing in this license impairs or restricts the author's moral rights. http://creativecommons.org/licenses/by-nc/3.0/ sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 0dbfs = 1 instr 1 a1 oscils 0.5, p4, 0 a2 oscils 0.5, p5, 0 out a1 + a2 endin # define KEY_1 #697 1209# # define KEY_2 #697 1336# # define KEY_3 #697 1447# # define KEY_A #697 1633# # define KEY_4 #770 1209# # define KEY_5 #770 1336# # define KEY_6 #770 1447# # define KEY_B #770 1633# # define KEY_7 #852 1209# # define KEY_8 #852 1336# # define KEY_9 #852 1447# # define KEY_C #852 1633# # define KEY_STAR #941 1209# # define KEY_0 #941 1336# # define KEY_POUND #941 1447# # define KEY_D #941 1633# # define TONE_BUSY #480 620# # define TONE_DIAL #350 440# # define TONE_RINGBACK #440 480# i 1 0 2 $TONE_DIAL i 1 2 0.3 $KEY_1 i 1 2.6 0.2 $KEY_8 i 1 3.0 0.15 $KEY_0 i 1 3.22 0.17 $KEY_0 i 1 4.15 0.2 $KEY_5 i 1 4.5 0.2 $KEY_5 i 1 4.75 0.17 $KEY_5 i 1 5.5 0.2 $KEY_3 i 1 5.8 0.19 $KEY_8 i 1 6.4 0.21 $KEY_6 i 1 6.7 0.15 $KEY_3 i 1 7.5 2 $TONE_RINGBACK i 1 12.5 2 $TONE_RINGBACK i 1 17.5 2 $TONE_RINGBACK i 1 22.5 2 $TONE_RINGBACK