summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/mq_editor/app.js47
1 files changed, 34 insertions, 13 deletions
diff --git a/tools/mq_editor/app.js b/tools/mq_editor/app.js
index 059d700..90f8f7e 100644
--- a/tools/mq_editor/app.js
+++ b/tools/mq_editor/app.js
@@ -302,6 +302,25 @@ function setStatus(msg, type = '') {
status.className = type;
}
+function getSynthParams() {
+ const forceResonator = document.getElementById('forceResonator').checked;
+ const lpK1Raw = parseFloat(document.getElementById('lpK1').value);
+ const hpK2Raw = parseFloat(document.getElementById('hpK2').value);
+ return {
+ integratePhase: document.getElementById('integratePhase').checked,
+ opts: {
+ disableJitter: document.getElementById('disableJitter').checked,
+ disableSpread: document.getElementById('disableSpread').checked,
+ forceResonator,
+ forceRGain: forceResonator && document.getElementById('forceRGain').checked,
+ globalR: parseFloat(document.getElementById('globalR').value),
+ globalGain: parseFloat(document.getElementById('globalGain').value),
+ k1: lpK1Raw < 1.0 ? lpK1Raw : null,
+ k2: hpK2Raw < 1.0 ? hpK2Raw : null,
+ },
+ };
+}
+
// Play synthesized audio
function playSynthesized() {
if (!extractedPartials || extractedPartials.length === 0) {
@@ -318,20 +337,9 @@ function playSynthesized() {
const partialsToUse = extractedPartials.slice(0, keepCount).filter(p => !p.muted);
setStatus(`Synthesizing ${partialsToUse.length}/${extractedPartials.length} partials (${keepPct.value}%)...`, 'info');
- const integratePhase = document.getElementById('integratePhase').checked;
- const disableJitter = document.getElementById('disableJitter').checked;
- const disableSpread = document.getElementById('disableSpread').checked;
- const forceResonator = document.getElementById('forceResonator').checked;
- const lpK1Raw = parseFloat(document.getElementById('lpK1').value);
- const hpK2Raw = parseFloat(document.getElementById('hpK2').value);
- const k1 = lpK1Raw < 1.0 ? lpK1Raw : null;
- const k2 = hpK2Raw < 1.0 ? hpK2Raw : null;
- const forceRGain = forceResonator && document.getElementById('forceRGain').checked;
- const globalR = parseFloat(document.getElementById('globalR').value);
- const globalGain = parseFloat(document.getElementById('globalGain').value);
+ const {integratePhase, opts} = getSynthParams();
const pcm = synthesizeMQ(partialsToUse, audioBuffer.sampleRate, audioBuffer.duration,
- integratePhase, {disableJitter, disableSpread, forceResonator,
- forceRGain, globalR, globalGain, k1, k2});
+ integratePhase, opts);
if (viewer) {
viewer.setSynthStftCache(new STFTCache(pcm, audioBuffer.sampleRate, fftSize, parseInt(hopSize.value)));
@@ -353,6 +361,19 @@ document.addEventListener('keydown', (e) => {
if (!playBtn.disabled) {
playBtn.click();
}
+ } else if (e.code === 'Digit3') {
+ e.preventDefault();
+ const sel = viewer ? viewer.selectedPartial : -1;
+ if (sel < 0 || !extractedPartials || !audioBuffer || !audioContext) return;
+ const partial = extractedPartials[sel];
+ if (!partial) return;
+ stopAudio();
+ const {integratePhase, opts} = getSynthParams();
+ const pcm = synthesizeMQ([partial], audioBuffer.sampleRate, audioBuffer.duration,
+ integratePhase, opts);
+ const buf = audioContext.createBuffer(1, pcm.length, audioBuffer.sampleRate);
+ buf.getChannelData(0).set(pcm);
+ playAudioBuffer(buf, `Playing partial #${sel}...`);
} else if (e.code === 'KeyP') {
e.preventDefault();
if (viewer) viewer.togglePeaks();