From a68bebac2a2f330bf16e372f599e59b4a8c546fe Mon Sep 17 00:00:00 2001 From: 3dtours Date: Tue, 28 Jul 2026 21:04:32 +0700 Subject: [PATCH] fix: AI Suggestion for MIDI Item rearrange --- app/storage/sonicforge.db | Bin 77824 -> 77824 bytes md/44_MIXER_EQUALIZER.md | 532 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 532 insertions(+) create mode 100644 md/44_MIXER_EQUALIZER.md diff --git a/app/storage/sonicforge.db b/app/storage/sonicforge.db index 91acb676488971ad22e29a8738ceada0959e002d..ce2fe1e53800be4a99a2837278e3bbdbc04f68d7 100644 GIT binary patch delta 2610 zcma)8Z%i9?7^WLZ9frSUu-viiI1$MLtoNsPS7c(zvSgAiY|H$jqf{u}Wus*kr_7-6 z&5zT^FKS{iF&g8(kYzD3i|h|ff?;ufF`3Rm1o__#d==>u&IXN!!6q6_S{TkVEWVrqF5q$Qi3oQ%G4#_KUoSXN{Xj!FD zK39sNwS3Tv<&YnRF>v=KEdKT$Djz?OukRJ0aH$Z}kC}S?6vz96igNxfww4VCx`S*3 zdmtL<4)m%Wj8gYnAj&kqp`PiiJJAF8##hed5dl*h4DKx#qJ4}@Cg%h{hvIPxp{oat z2#>pyG`dzxHsJ&e&QOrAnK%){wb0CPpG$6nd^7cq&zcAHLsd{A__J zcyXP=hs2Ziv0}82Ge)^**DCPkjcP4sq~K6APUE48&Px+>9Jpx;eWUsTGtBG!ZGRd3 z<|{#0&@#5=gs987JXWQ9@xB6^vsR% zQip=0@m<*aC?EV{DAn}iIJo2?jhAt8sU+QaE-lpUe*Mkh6C2OeG1$LIK}l5O{D$8! zb!55C_`7PQ%`le7?YT`l3{-5zZ=ggp%#(h`o`FAZHtO4$iIDK?0tKRMk5bE?3!aH| zsJ(q`16RxT1j1}XJ{bjvvnj{fG(6~W=H2GE<@rxE4G#5R8oaY3H~Xb0qtd}EU42i~ zj@=2LCOTO*Ip)?T?1RE;5w+44kM(+a9o* zek1D9Pe1%ycg2WGdbBZK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A9wU#u zGtZn@l?{U+8qxS=k zuvjB|QGB+Afc>lc0k>)|3^U*%A_N4nu*zI&5t6|*7;xDH>xIKv4~)%v$xX$=glPF( z+9KUP#Ym-RA?H|J?XY5yLvU;|;6@`05HVT}H?MYj$-buJ$=zK^Ekt)!Ql7M{ZK-(Y zo{V!---chW85OoOZt6?WHnM^Xa8sLXQti}}@?N&7(w0;#5hJVL)*aust8v@@V7Rd@ zmP$kK$d?SWHCM-SHLz~n2jAp^?9p&(bUU+Bal{&_1A}*WxxjM=Y3+3CAb>@NTvirKF5LxVf-?gZ@wJ?UN1lXYZav0`fjR zzpHmzt2W89X_#Td2x*!U)+12(y`?%_A`Rk2Gcr_Zf!7UqKew1P5}yK_vwnDGvIfrN znrayxaxT!|mwt&Tt<2Cx*eWFaa|3k_tw2(`^{5hk1x`Y3{vP$Mu#bgrhXb%-h+?tI zgvXiCJM4$YMN-@;eE;F21+GstvCPH?*TU%sRA$XS$xsIG5PgFDIMK?biX~ORAyw&N z-%q^C4K*s-`mmOqWW5APR54E+bdik7OMqhF)?(fz);*XT#^y(cXjAZVCzWM|P@p9n zfMwHEYVkG!B0Nd7a1oF&9M83KQ{fgaF^v#Yi{UV;DqL^as6%;$tPNKS*Bh!Y&d>>A z3E=gDJ#*t9jLD_6lH|&8NUfLre117ykTW?S_~r#3C1CLVgUvoPM>1z>4n|ltyh2`| zCt#jnCjJnRL0WK_ag^5e^jE#K6SV< Speakers + this.mainMasterGain + .connect(this.mainMasterPan) + .connect(this.mainMasterAnalyser) + .connect(this.audioCtx.destination); + + // Map storing track AudioNodes + this.trackNodesMap = new Map(); // trackId -> { inputGain, faderGain, panNode, analyserNode } + this.sectionBusesMap = new Map(); // sectionId -> { subMixGain, subMixPan, outputNode } + } + + /** + * Initializes Audio Nodes for a track on the Main Session + */ + createMainTrackNodes(track) { + const inputGain = this.audioCtx.createGain(); + const faderGain = this.audioCtx.createGain(); + const panNode = this.audioCtx.createStereoPanner(); + const analyserNode = this.audioCtx.createAnalyser(); + analyserNode.fftSize = 64; + + // Track internal signal chain connection: + // InputGain -> FaderGain -> PanNode -> Analyser -> Main Master Gain + inputGain + .connect(faderGain) + .connect(panNode) + .connect(analyserNode) + .connect(this.mainMasterGain); + + const nodeBundle = { inputGain, faderGain, panNode, analyserNode, track }; + this.trackNodesMap.set(track.id, nodeBundle); + + // Update initial Gain/Pan values + this.updateTrackVolumePan(track.id, track.volume_db, track.pan, track.mute); + return nodeBundle; + } + + /** + * Initializes a Sub-Mix Bus for a SECTION-TAB and PIPES it to a Main Session track + * @param {string} sectionId - Section ID + * @param {string} hostTrackId - Main Session Track ID hosting this section + */ + createSectionSubMixBus(sectionId, hostTrackId) { + const subMixGain = this.audioCtx.createGain(); + const subMixPan = this.audioCtx.createStereoPanner(); + + // Section Sub-Mix Bus internal connection + subMixGain.connect(subMixPan); + + // CRITICAL STEP: Locate host track on Main Session to pipe signal + const hostTrackNodes = this.trackNodesMap.get(hostTrackId); + + if (hostTrackNodes) { + // Pipe Output of Section Bus directly into InputGain of Main Track + subMixPan.connect(hostTrackNodes.inputGain); + console.log(`[MixerRouter] Sub-Mix Bus of Section "${sectionId}" successfully PIPED into Main Track "${hostTrackId}"`); + } else { + console.warn(`[MixerRouter] Host Track "${hostTrackId}" not found. Section bus falling back to Master.`); + subMixPan.connect(this.mainMasterGain); + } + + const sectionBundle = { subMixGain, subMixPan, hostTrackId }; + this.sectionBusesMap.set(sectionId, sectionBundle); + return sectionBundle; + } + + /** + * Initializes an INTERNAL track inside a SECTION-TAB + */ + createSectionTrackNodes(sectionId, secTrack) { + const sectionBundle = this.sectionBusesMap.get(sectionId); + if (!sectionBundle) { + throw new Error(`Section Sub-Mix Bus for "${sectionId}" has not been initialized!`); + } + + const inputGain = this.audioCtx.createGain(); + const faderGain = this.audioCtx.createGain(); + const panNode = this.audioCtx.createStereoPanner(); + const analyserNode = this.audioCtx.createAnalyser(); + + // Connect Track in Section to the Section's Sub-Mix Bus + inputGain + .connect(faderGain) + .connect(panNode) + .connect(analyserNode) + .connect(sectionBundle.subMixGain); // Direct to Section Sub-Mix Bus! + + const nodeBundle = { inputGain, faderGain, panNode, analyserNode, secTrack }; + this.trackNodesMap.set(secTrack.id, nodeBundle); + + this.updateTrackVolumePan(secTrack.id, secTrack.volume_db, secTrack.pan, secTrack.mute); + return nodeBundle; + } + + /** + * Updates Volume (dB) & Pan using standard audio formulas + */ + updateTrackVolumePan(trackId, volumeDb, panValue, isMuted) { + const bundle = this.trackNodesMap.get(trackId); + if (!bundle) return; + + // Convert dB to Linear Gain Factor: Gain = 10 ^ (dB / 20) + const linearGain = isMuted ? 0.0 : Math.pow(10, volumeDb / 20.0); + + bundle.faderGain.gain.setTargetAtTime(linearGain, this.audioCtx.currentTime, 0.01); + bundle.panNode.pan.setTargetAtTime(panValue, this.audioCtx.currentTime, 0.01); + } +} + +``` + +--- + +## 5. NESTED MUTE/SOLO LOGIC MATRIX + +When muting or soloing a track on the Main Session or within a Section Tab, the system applies hierarchical rules: + +| User Action | Main Session Impact | Internal Section Tracks Impact | +| --- | --- | --- | +| **Mute Track 2 (Section Host)** on Main Session | Track 2 is muted. Other tracks play normally. | Entire Section is muted (signal is blocked at Track 2's Fader Gain). | +| **Mute Section Track 1** inside Section Tab | No impact on other Main Tracks. | Only Section Track 1 is silenced. Other Section Tracks ($S2, S3$) continue routing to Track 2. | +| **Solo Section Track 1** inside Section Tab | No impact on Main Session. | Mutes $S2, S3$ within the Section. Only $S1$ outputs to Track 2 of the Main Session. | +| **Solo Track 2** on Main Session | Mutes Track 1 and Track 3 on Main Session. | The Section audio stream plays normally to the Main Master Bus. | + +--- + +## 6. STATE-DRIVEN REACT/CANVAS COMPONENT + +Below is the React implementation for the Mixer Console supporting dynamic switching between MAIN SESSION and SECTION-TAB mixers: + +```jsx +// app/static/js/components/MixerConsole.jsx +import React, { useState, useEffect } from 'react'; + +export function MixerConsole({ sessionState, activeTabContext, mixerGraphMgr }) { + // Determine if Mixer is rendering for MAIN SESSION or SECTION-TAB + const isSectionTab = activeTabContext?.type === 'SECTION_TAB'; + + // Retrieve target tracks list for Mixer Console display + const currentTracks = isSectionTab + ? sessionState.section_store[activeTabContext.referenced_section_id]?.tracks || [] + : sessionState.main_session.tracks; + + const currentTitle = isSectionTab + ? `MIXER: SECTION TAB (${activeTabContext.title})` + : "MIXER: MAIN SESSION"; + + return ( +
+ {/* Mixer Header / Tab Indicator */} +
+
+ + {currentTitle} +
+ {isSectionTab && ( + + Routed to Main Track: {activeTabContext.parent_track_name || "Track Host"} + + )} +
+ + {/* Mixer Strips Container */} +
+ {/* 1. MASTER STRIP (Far Left) */} + + +
+ + {/* 2. TRACK STRIPS (Audio Channels) */} + {currentTracks.map((track, idx) => ( + + ))} +
+
+ ); +} + +/** + * Channel Strip Component representing a single Track + */ +function TrackChannelStrip({ track, index, mixerGraphMgr }) { + const [volumeDb, setVolumeDb] = useState(track.volume_db || 0); + const [pan, setPan] = useState(track.pan || 0); + const [isMuted, setIsMuted] = useState(Boolean(track.mute)); + const [isSoloed, setIsSoloed] = useState(Boolean(track.solo)); + + const handleVolumeChange = (e) => { + const newDb = parseFloat(e.target.value); + setVolumeDb(newDb); + track.volume_db = newDb; + mixerGraphMgr?.updateTrackVolumePan(track.id, newDb, pan, isMuted); + }; + + const handleToggleMute = () => { + const newMute = !isMuted; + setIsMuted(newMute); + track.mute = newMute; + mixerGraphMgr?.updateTrackVolumePan(track.id, volumeDb, pan, newMute); + }; + + return ( +
+ {/* 1. Pan Knob */} +
+ + {pan === 0 ? "center" : pan < 0 ? `L${Math.abs(Math.round(pan * 100))}` : `R${Math.round(pan * 100)}`} + + { + const p = parseFloat(e.target.value); + setPan(p); + track.pan = p; + mixerGraphMgr?.updateTrackVolumePan(track.id, volumeDb, p, isMuted); + }} + className="w-12 h-1 accent-indigo-500 cursor-pointer" + /> +
+ + {/* 2. dB Readout */} +
+ {volumeDb <= -60 ? "-inf" : `${volumeDb > 0 ? "+" : ""}${volumeDb.toFixed(1)}dB`} +
+ + {/* 3. Mute / Solo Buttons */} +
+ + +
+ + {/* 4. Fader & Meter Section */} +
+ {/* Fader Slider */} + + + {/* VU Peak Meter Bar */} +
+
+
+
+ + {/* 5. FX & Power Buttons */} +
+ + +
+ + {/* 6. Footer Name */} +
+
{index}. {track.name}
+
{track.type}
+
+
+ ); +} + +/** + * Master Channel Strip Component + */ +function MasterChannelStrip({ isSectionBus, mixerGraphMgr }) { + return ( +
+
+ {isSectionBus ? "SEC BUS" : "MASTER"} +
+ + {/* Peak / RMS Canvas Meter */} +
+ -inf dB +
+ +
+
+ {isSectionBus ? "SUB-MIX" : "MAIN OUT"} +
+
+
+ ); +} + +``` + +--- + +## 7. OPERATIONAL VERIFICATION CHECKLIST + +* [ ] **Main Session Mixer Operations:** +* Adjust Track 1 Fader $\rightarrow$ Track 1 volume increases/decreases as expected. +* Mute Track 1 $\rightarrow$ Track 1 output is silenced. + + +* [ ] **SECTION-TAB Mixer & Routing Operations:** +* Open a SECTION-TAB into a sub-tab $\rightarrow$ Mixer Console dynamically switches header to `MIXER: SECTION TAB` displaying internal section tracks. +* Adjust Section Track 1 Fader $\rightarrow$ Guitar volume within the Section increases/decreases without affecting other Main Tracks. + + +* [ ] **Bus Routing Point Verification:** +* Switch back to MAIN SESSION tab. +* Adjust Track 2 Fader (Track hosting Section Item) $\rightarrow$ Entire SECTION-TAB volume adjusts synchronously. +* Mute Track 2 $\rightarrow$ Entire SECTION-TAB output is silenced completely. \ No newline at end of file