File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ public class SFF
27
27
public int OffsetHz { get ; private set ; }
28
28
public int MelBinCount { get ; private set ; }
29
29
public bool Decibels { get ; private set ; }
30
+ public bool IsMel { get { return MelBinCount > 0 ; } }
30
31
31
32
// FFT details
32
33
public int FftHeight { get { return Ffts [ 0 ] . Length ; } }
@@ -220,5 +221,20 @@ public void Save(string filePath)
220
221
// write file to disk
221
222
File . WriteAllBytes ( filePath , fileBytes ) ;
222
223
}
224
+
225
+ public ( double timeSec , double freqHz , double magRms ) GetPixelInfo ( int x , int y )
226
+ {
227
+ double timeSec = ( double ) x * StepSize / SampleRate ;
228
+
229
+ double maxFreq = SampleRate / 2 ;
230
+ double maxMel = FftSharp . Transform . MelFromFreq ( maxFreq ) ;
231
+ double frac = ( FftHeight - y ) / ( double ) FftHeight ;
232
+ double freq = IsMel ? FftSharp . Transform . MelToFreq ( frac * maxMel ) : frac * maxFreq ;
233
+
234
+ double mag = double . NaN ;
235
+ try { mag = Ffts [ x ] [ FftHeight - y - 1 ] ; } catch { }
236
+
237
+ return ( timeSec , freq , mag ) ;
238
+ }
223
239
}
224
240
}
You can’t perform that action at this time.
0 commit comments