Skip to content

Commit 14f1f8e

Browse files
author
Gary Keeble
committed
Use the blackbox logging rate to modify frequency
The frequency range on the analyser axis relates to the loop time but also the logging rate;
1 parent cefee05 commit 14f1f8e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

js/graph_spectrum.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ try {
3636
source.start();
3737

3838
var spectrumAnalyser = audioCtx.createAnalyser();
39-
spectrumAnalyser.fftSize = 512;
39+
spectrumAnalyser.fftSize = 256;
4040
spectrumAnalyser.smoothingTimeConstant = 0.8;
4141
spectrumAnalyser.minDecibels = -100;
4242
spectrumAnalyser.maxDecibels = -30;
@@ -162,7 +162,7 @@ try {
162162

163163
/* only plot the lower half of the FFT, as the top half
164164
never seems to have any values in it - too high frequency perhaps. */
165-
var PLOTTED_BUFFER_LENGTH = bufferLength / 2;
165+
var PLOTTED_BUFFER_LENGTH = bufferLength; // / 2;
166166

167167
canvasCtx.translate(LEFT, TOP);
168168

@@ -200,7 +200,7 @@ try {
200200
function drawGridLines(sampleRate, LEFT, TOP, WIDTH, HEIGHT, MARGIN) {
201201

202202
var ticks = 5;
203-
var frequencyInterval = (sampleRate / ticks) / 4;
203+
var frequencyInterval = (sampleRate / ticks) / 2;
204204
var frequency = 0;
205205

206206
for(var i=0; i<=ticks; i++) {
@@ -213,7 +213,7 @@ try {
213213

214214
canvasCtx.stroke();
215215
var textAlign = (i==0)?'left':((i==ticks)?'right':'center');
216-
drawAxisLabel((frequency)+"Hz", i * (WIDTH / ticks), HEIGHT + MARGIN, textAlign);
216+
drawAxisLabel((frequency.toFixed(0))+"Hz", i * (WIDTH / ticks), HEIGHT + MARGIN, textAlign);
217217
frequency += frequencyInterval;
218218
}
219219
}

js/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,11 @@ function BlackboxLogViewer() {
465465
analyserSampleRate:2000/*Hz*/, // the loop time for the log
466466
};
467467

468-
if(flightLog.getSysConfig().loopTime != null) {graphOptions.analyserSampleRate = 1000000 / flightLog.getSysConfig().loopTime; }
468+
if((flightLog.getSysConfig().loopTime != null) &&
469+
(flightLog.getSysConfig().frameIntervalPNum != null) &&
470+
(flightLog.getSysConfig().frameIntervalPDenom != null) ) {
471+
graphOptions.analyserSampleRate = 1000000 / (flightLog.getSysConfig().loopTime * flightLog.getSysConfig().frameIntervalPDenom / flightLog.getSysConfig().frameIntervalPNum);
472+
}
469473

470474
graph = new FlightLogGrapher(flightLog, activeGraphConfig, canvas, craftCanvas, analyserCanvas, graphOptions);
471475

0 commit comments

Comments
 (0)