File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -29,18 +29,20 @@ <h1>Hear the Traffic</h1>
2929
3030 let ac = null ;
3131 let osc = null ;
32+ let freq = 30 ;
3233
3334 const update = ( ) => {
3435 fetch ( 'https://metrics.nc.menhera.org/_traffic.json' ) . then ( async ( res ) => {
3536 if ( ! res . ok ) return ;
3637 const data = await res . json ( ) ;
37- realData = data ;
38+ freq = data [ 0 ] * 2 ;
39+ realData = [ 0 , ... data . slice ( 7 , 126 ) ] ;
3840
3941 if ( osc ) {
4042 let len = realData . length ;
4143 const imagData = new Array ( len ) . fill ( 0 ) ;
4244 const periodicWave = ac . createPeriodicWave ( realData , imagData ) ;
43- osc . frequency . value = realData [ 0 ] * 2 ;
45+ osc . frequency . value = freq ;
4446 osc . setPeriodicWave ( periodicWave ) ;
4547 }
4648 } ) . catch ( ( e ) => {
@@ -53,7 +55,7 @@ <h1>Hear the Traffic</h1>
5355 function sound_start ( ) {
5456 ac = new AudioContext ( ) ;
5557 osc = ac . createOscillator ( ) ;
56- osc . frequency . value = realData [ 0 ] * 2 ;
58+ osc . frequency . value = freq ;
5759 let len = realData . length ;
5860 const imagData = new Array ( len ) . fill ( 0 ) ;
5961 const periodicWave = ac . createPeriodicWave ( realData , imagData ) ;
You can’t perform that action at this time.
0 commit comments