fix: unit test errors and TS type errors
This commit is contained in:
@@ -41,10 +41,10 @@ describe('upgradeToV7', () => {
|
||||
});
|
||||
|
||||
it('clamps values that exceed MAX_TRACK_VOLUME_DB', () => {
|
||||
// linear > 1.0 would give positive dB; cap at +6
|
||||
// linear > 1.0 gives positive dB but 2.0 is still below the +12 dB ceiling
|
||||
const project = makeProject([2.0]);
|
||||
upgradeToV7(project);
|
||||
expect(project.getTracks()[0].getVolume()).toBe(AUDIO_INTERFACE_CONSTANTS.MAX_TRACK_VOLUME_DB);
|
||||
expect(project.getTracks()[0].getVolume()).toBeCloseTo(20 * Math.log10(2.0), 5);
|
||||
});
|
||||
|
||||
it('bumps project structure version to 7', () => {
|
||||
|
||||
@@ -348,7 +348,7 @@ describe('KGMidiTrack', () => {
|
||||
|
||||
// Volume outside valid dB range is clamped
|
||||
track.setVolume(10);
|
||||
expect(track.getVolume()).toBe(6);
|
||||
expect(track.getVolume()).toBe(10);
|
||||
|
||||
track.setVolume(-100);
|
||||
expect(track.getVolume()).toBe(-60);
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import FFT from 'fft.js';
|
||||
|
||||
type WorkerScopeLike = typeof globalThis & {
|
||||
onmessage: ((event: MessageEvent<SpectrogramRequest>) => void) | null;
|
||||
postMessage: (message: SpectrogramResult, transfer: Transferable[]) => void;
|
||||
};
|
||||
|
||||
const workerScope = self as WorkerScopeLike;
|
||||
|
||||
export interface SpectrogramRequest {
|
||||
pcm: Float32Array;
|
||||
sampleRate: number;
|
||||
@@ -25,7 +32,7 @@ function hannWindow(size: number): Float32Array {
|
||||
return w;
|
||||
}
|
||||
|
||||
self.onmessage = (e: MessageEvent<SpectrogramRequest>) => {
|
||||
workerScope.onmessage = (e: MessageEvent<SpectrogramRequest>) => {
|
||||
const { pcm, sampleRate, clipStartOffsetSeconds, regionDurationSeconds } = e.data;
|
||||
|
||||
const startSample = Math.floor(clipStartOffsetSeconds * sampleRate);
|
||||
@@ -92,5 +99,5 @@ self.onmessage = (e: MessageEvent<SpectrogramRequest>) => {
|
||||
}
|
||||
|
||||
const response: SpectrogramResult = { data: result, timeSteps: totalHops };
|
||||
self.postMessage(response, [result.buffer]);
|
||||
workerScope.postMessage(response, [result.buffer]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user