Skip to content

Commit

Permalink
remove mel/hz calculation for separate fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarek committed Oct 24, 2023
1 parent a119d95 commit 4b46a75
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions src/lenses/SpectrogramLens/Spectrogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,4 @@ const amplitudeToDb = (amplitude: number, ref: number, amin: number) => {
return log_spec;
};

const hzToMel = (freq: number) => {
// Fill in the linear part
const f_min = 0.0;
const f_sp = 200.0 / 3;

let mel = (freq - f_min) / f_sp;

// Fill in the log-scale part
const min_log_hz = 1000.0; // beginning of log region (Hz)
const min_log_mel = (min_log_hz - f_min) / f_sp; // same (Mels)
const logstep = Math.log(6.4) / 27.0; // step size for log region

if (freq >= min_log_hz) {
mel = min_log_mel + Math.log(freq / min_log_hz) / logstep;
}

return mel;
};

const melToHz = (mel: number) => {
const f_min = 0.0;
const f_sp = 200.0 / 3;
let freq = f_min + f_sp * mel;

// And now the nonlinear scale
const min_log_hz = 1000.0; // beginning of log region (Hz)
const min_log_mel = (min_log_hz - f_min) / f_sp; // same (Mels)
const logstep = Math.log(6.4) / 27.0; // step size for log region

if (mel >= min_log_mel) {
// If we have scalar data, check directly
freq = min_log_hz * Math.exp(logstep * (mel - min_log_mel));
}
return freq;
};

export { unitType, freqType, fixWindow, amplitudeToDb, hzToMel, melToHz };
export { unitType, freqType, fixWindow, amplitudeToDb };

0 comments on commit 4b46a75

Please sign in to comment.