@@ -53,7 +53,7 @@ function dataLoad(chunks, startFrameIndex, fieldIndex, curve, buffer) {
5353 var chunk = chunks [ chunkIndex ] ;
5454 for ( ; frameIndex < chunk . frames . length ; frameIndex ++ ) {
5555 var fieldValue = chunk . frames [ frameIndex ] [ fieldIndex ] ;
56- bufferData [ i ++ ] = ( curve . lookup ( fieldValue ) ) ;
56+ bufferData [ i ++ ] = ( curve . lookupRaw ( fieldValue ) ) ;
5757
5858 if ( i >= buffer . length )
5959 break dataCollectionLoop;
@@ -91,7 +91,7 @@ function draw() {
9191 canvasCtx . fillStyle = 'rgba(255, 255, 255, .25)' ; /* white */
9292 canvasCtx . fillRect ( 0 , 0 , WIDTH , HEIGHT ) ;
9393
94- var barWidth = ( WIDTH / PLOTTED_BUFFER_LENGTH ) ; // * 2.5;
94+ var barWidth = ( WIDTH / PLOTTED_BUFFER_LENGTH ) - 1 ; // * 2.5;
9595 var barHeight ;
9696 var x = 0 ;
9797
@@ -101,17 +101,43 @@ function draw() {
101101 canvasCtx . fillStyle = 'rgba(0,255,0,0.3)' ; /* green */
102102 canvasCtx . fillRect ( x , HEIGHT - barHeight , barWidth , barHeight ) ;
103103
104- x += barWidth ;
104+ x += barWidth + 1 ;
105105 }
106- drawAxisLabel ( '#' + leftPad ( audioIterations , "0" , 7 ) , WIDTH - 8 , HEIGHT - 10 ) ;
106+ drawGridLines ( options . analyserSampleRate , LEFT , TOP , WIDTH , HEIGHT ) ;
107+ drawAxisLabel ( '#' + leftPad ( audioIterations , "0" , 7 ) , WIDTH - 8 , HEIGHT - 10 , 'right' ) ;
107108 canvasCtx . restore ( ) ;
108109 }
109110
111+ function drawGridLines ( sampleRate , LEFT , TOP , WIDTH , HEIGHT ) {
112+
113+ var ticks = 5 ;
114+ var frequencyInterval = ( sampleRate / ticks ) / 4 ;
115+ var frequency = 0 ;
116+
117+ for ( var i = 0 ; i <= ticks ; i ++ ) {
118+ canvasCtx . beginPath ( ) ;
119+ canvasCtx . lineWidth = 1 ;
120+ canvasCtx . strokeStyle = "rgba(255,255,255,0.25)" ;
121+
122+ canvasCtx . moveTo ( i * ( WIDTH / ticks ) , 0 ) ;
123+ canvasCtx . lineTo ( i * ( WIDTH / ticks ) , HEIGHT ) ;
124+
125+ canvasCtx . stroke ( ) ;
126+ drawAxisLabel ( ( frequency ) + "Hz" , i * ( WIDTH / ticks ) , HEIGHT * 1.05 , 'center' ) ;
127+ frequency += frequencyInterval ;
128+ }
129+ }
110130
111- function drawAxisLabel ( axisLabel , X , Y ) {
131+ function drawAxisLabel ( axisLabel , X , Y , align ) {
112132 canvasCtx . font = drawingParams . fontSizeFrameLabel + "pt " + DEFAULT_FONT_FACE ;
113133 canvasCtx . fillStyle = "rgba(255,255,255,0.9)" ;
114- canvasCtx . textAlign = 'right' ;
134+ if ( align ) {
135+ canvasCtx . textAlign = align ;
136+ } else
137+ {
138+ canvasCtx . textAlign = 'center' ;
139+ }
140+
115141
116142 canvasCtx . fillText ( axisLabel , X , Y ) ;
117143 }
0 commit comments