From bfa744862628c95b5d85a6b90311fc476a927fbf Mon Sep 17 00:00:00 2001 From: "Lu[ke] Wilson" Date: Sat, 1 Feb 2025 17:44:04 +0000 Subject: [PATCH] easier fft functions --- src/hydra.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/hydra.js b/src/hydra.js index a74e283..acdd20e 100644 --- a/src/hydra.js +++ b/src/hydra.js @@ -75,10 +75,24 @@ export class HydraSession { // with `.scrollX(() => fft(1,0)` it will influence the x-axis, according to the fft data // first number is the index of the bucket, second is the number of buckets to aggregate the number too window.fft = ( - index, //: number, - buckets, //: number = 8, - options, //?: { min?: number; max?: number; scale?: number; analyzerId?: string; }, + ...args + // index, //: number, + // buckets = 8, //: number = 8, + // optionsArg, //: string | { min?: number; max?: number; scale?: number; analyzerId?: string; }, ) => { + let index = 1; + let buckets = 8; + let optionsArg = {}; + + if (typeof args[0] === 'string') { + optionsArg = { analyzerId: args[0] }; + } else { + index = args[0] ?? 1; + buckets = args[1] ?? 8; + optionsArg = args[2] ?? {}; + } + + const options = typeof optionsArg === 'string' ? { analyzerId: optionsArg } : optionsArg; const analyzerId = options?.analyzerId ?? 'flok-master'; const min = options?.min ?? -150; const scale = options?.scale ?? 1;