This experimental page started off experimenting with the CANVAS for drawing and audio.
This page uses IIR filters to look for tones.
 
 
 
 
 | 
 |
 
| 
x scale: 
 
  |
Y scale:  |
var tonesA="697,770,852,941,1209,1336,1477,1633,1300".split(",") var map ="123A456B789C*0#D"
Decoded:
found
http://jaggedplanet.com/iir/iir-explorer.asp#:~:text=IIR%20Filter%20Explorer%20The%20IIR%20Filter%20Explorer%20is,order%2C%20in%20low-pass%2C%20high-pass%2C%20band-pass%20and%20notch%20configurations.
// Table B.1/V.18 − Line-to-DTE code conversion (DTMF to 7-bit)
Hello. GA Hello. GA Hello. GA Hello. GA Hello. GA Hello. GA  
"##32#4#4#5#90##*3##*10##32#4#4#5#90##*3##*10##32#4#4#5#90##*3##*10##32#4#4#5#90##*3##*10##32#4#4#5#90##*3##*10##32#4#4#5#90##*3##*10"
   input --- filters --- comparators --- 
   
 8000 samples per seconds
 
 The filter function uses an iir filter.
 The energy is measured using the delayed output squared.
  // take 4 samples 
  opA[ i ] = 
    z[0]*z[0] 
	+z[1]*z[1]
	+z[2]*z[2] 
	+z[3]*z[3] 
 
 One of the filters resonated with amplitude about half of the other one so it is doubled.
 
/*
*
* iir filter.
*
*
--X---[ z-1 ]----[z-1]-----
  |            |           |
  |				k	       -1
  |            |           |
  \------------------------
*
*
from wikipedia:-
Nterms defined here
Kterm selected here
ω = 2 * π * Kterm / Nterms;
cr = cos(ω);
ci = sin(ω);
coeff = 2 * cr;
sprev = 0;
sprev2 = 0;
for each index n in range 0 to Nterms-1
  s = x[n] + coeff * sprev - sprev2;
  sprev2 = sprev;
  sprev = s;
end
power = sprev2*sprev2 + sprev*sprev - coeff*sprev*sprev2 ;
*
*/
/*
* https://sites.google.com/site/hobbydebraj/goertzel-algorithm-dtmf-detection
*/
var z1= "0,0,0,0".split(",") 
var z2= "0,0,0,0".split(",") 
var k1= "0.5,-0.7,0.2,0.2".split(",")
    k1[0] = 2.0*Math.cos(  2.0*Math.PI*(980*1.0/RC=3492.0) )
    k1[1] = 0.7
	
var k2= "0.5,-0.7,0.2,0.2".split(",")
    k2[0] = 2.0*Math.cos(  2.0*Math.PI*(1180*1.0/RC=3492.0) )
    k2[1] = 0.7
 
 function iir2_ts( i, ip,z, k, opA ){
  z[3]=z[2]*1.0
  z[2]=z[1]*1.0
  z[1]=z[0]*1.0
  z[0]= ip*1  +k[0]*z[1]   +k[1]*z[2]
  
  // take 4 samples 
  opA[ i ] = 
    z[0]*z[0] 
	+z[1]*z[1]
	+z[2]*z[2] 
	+z[3]*z[3] 
}