diff options
Diffstat (limited to 'tools/mq_editor/mq_synth.js')
| -rw-r--r-- | tools/mq_editor/mq_synth.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/mq_editor/mq_synth.js b/tools/mq_editor/mq_synth.js index 6fa2a09..1eec709 100644 --- a/tools/mq_editor/mq_synth.js +++ b/tools/mq_editor/mq_synth.js @@ -25,10 +25,13 @@ function randFloat(seed, min, max) { // replicas: {offsets, decay_alpha, jitter, spread_above, spread_below} // integratePhase: true = accumulate 2π*f/SR per sample (correct for varying freq) // false = 2π*f*t (simpler, only correct for constant freq) -function synthesizeMQ(partials, sampleRate, duration, integratePhase = true) { +function synthesizeMQ(partials, sampleRate, duration, integratePhase = true, options = {}) { const numSamples = Math.floor(sampleRate * duration); const pcm = new Float32Array(numSamples); + const jitterMult = options.disableJitter ? 0 : 1; + const spreadMult = options.disableSpread ? 0 : 1; + const defaultReplicas = { offsets: [1.0], decay_alpha: 0.1, @@ -50,8 +53,8 @@ function synthesizeMQ(partials, sampleRate, duration, integratePhase = true) { const replicaData = []; for (let r = 0; r < offsets.length; ++r) { // Fixed per-replica spread (frequency detuning) and initial phase (jitter) - const spread = randFloat(p * 67890 + r * 999, -spread_below, spread_above); - const initPhase = randFloat(p * 67890 + r, 0.0, 1.0) * jitter * 2.0 * Math.PI; + const spread = spreadMult * randFloat(p * 67890 + r * 999, -spread_below, spread_above); + const initPhase = randFloat(p * 67890 + r, 0.0, 1.0) * (jitter * jitterMult) * 2.0 * Math.PI; replicaData.push({ratio: offsets[r], spread, phase: initPhase}); } |
