Commit Graph

345 Commits

Author SHA1 Message Date
3dtours ab4b91a158 fix: shift+scroll velocity changes all selected notes
When selectedNoteIds.length > 0, shift+scroll on any note changes
velocity for all selected notes. Also fixed hit-test to subtract
renderBeatOffset for correct positioning in session mode.
2026-07-27 19:36:54 +07:00
3dtours db45efe53c fix: sync piano roll playhead with main timeline position
handleEditMidiInTab now sets currentTime relative to item start:
currentTime = Math.max(0, mainTimelineCurrentTime - midiItem.startTime)
so playhead reflects the main timeline position instead of bar 0.
2026-07-27 19:29:51 +07:00
3dtours fd23b8c4b0 fix: align CC lane velocity label with keybed column
Added 120px spacer before the CC label div so it aligns with
the piano key column (60px) after the track column (120px).
2026-07-27 19:28:51 +07:00
3dtours 1d3c7a7955 fix: preserve playhead session position across dropdown switch
handleSwitchMidiItem now computes new currentTime from the delta
between old and new renderBeatOffset, keeping the playhead at
the same session-absolute time instead of resetting to bar 0.
2026-07-27 19:28:01 +07:00
3dtours 3ed62b3343 fix: subtract renderBeatOffset from mouse beat for correct positioning
- handleGridMouseDown/move: beat = x/pixelsPerBeat - renderBeatOffset
  so hit-testing and note creation use item-relative coordinates
- CC mouse handlers: same offset subtraction
- Ruler click: clickTime subtracts renderBeatOffset so st.currentTime
  remains item-relative
2026-07-27 19:25:29 +07:00
3dtours 3a775fdda7 fix: track button toggle bug — init Set with all track IDs
When activePlayTrackIds was null (default: all play), clicking a track
created an empty Set and deleted nothing. Now initializes with all
track IDs, so click toggles the clicked track off/on correctly.
2026-07-27 18:37:25 +07:00
3dtours 509e171c20 fix: ghost border, track buttons clickable, per-track instrument silent
- Remove dashed border from ghost notes (fill-only at 25% opacity)
- Track column: replaced div overlay with natural flex child; use
  <button> elements with border-l-2 indicator; removed pointer-events
- Ghost playback: skip layers with no instrument assigned (silent)
  instead of playing with default piano
2026-07-27 18:37:25 +07:00
3dtours 0500d16bc7 feat: track column buttons, ghost playback, per-track channels
- Track column: centered 12px buttons, purple active / yellow highlight
- Ghost playback: ghostLayers synced to st.ghostPlayLayers via useEffect;
  schedulePianoRollMidi plays ghost notes from active tracks
- Per-track MIDI channels: each track gets a unique channel based on
  its index, enabling separate instruments per track
2026-07-27 18:37:25 +07:00
3dtours a98dd58744 fix: renderBeatOffset in beats (multiply by timeSigNum)
renderBeatOffset was in bars but used as beat offset in rendering.
Multiplying by timeSigNum=4 converts to beats so items appear at
correct session-absolute positions.
2026-07-27 18:03:44 +07:00
3dtours 1ba9e8379f feat(piano-roll): session bar0, fixed track column, renderBeatOffset
- sessionStartBar = 0 always; notes rendered at session-absolute positions
- renderBeatOffset aligns active/ghost notes to session timeline
- Track column uses absolute overlay with pointer-events for always-visible
- Removed auto-scroll (viewport starts at bar 0 in session mode)
- Grid spacer (120px) aligns grid with ruler track header
2026-07-27 17:57:47 +07:00
3dtours b9113f8a06 fix: dropdown switch keeps ghost notes from other tracks only; track column toggles MIDI play
- handleSwitchMidiItem no longer saves/sets previous item as ghost
- Removed ghostTrackFilter/filteredGhostLayers
- Track column shows clickable track names that toggle play state
- activePlayTrackIds Set controls which tracks' MIDI are playable
2026-07-27 17:40:31 +07:00
3dtours 91ddc3cb6f fix: move ghost decls before totalBeats to fix TDZ 2026-07-27 17:34:14 +07:00
3dtours fb0cd248ad feat(piano-roll): context menu flip, track column, session duration
- Context menu flips upward near viewport bottom edge
- Track column (120px) left of keybed: checkboxes per track to
  filter ghost notes; active track highlighted
- Session mode: canvas extends to full session duration
- Filtered ghost layers via ghostTrackFilter state (Set of track IDs)
- Fixed bar label seek in session mode (was using wrong offset)
2026-07-27 17:32:06 +07:00
3dtours 53a27b5af4 fix: move ghostLayers decl before useLayoutEffect to fix TDZ 2026-07-27 17:15:04 +07:00
3dtours 035d75e504 feat(piano-roll): ghost notes + dropdown item switcher + session sync
- MIDI ghost notes: all non-selected items rendered at 25% opacity
- Dropdown at tab title: switch active edit target across all tracks
- Session Sync mode (default): viewport aligned to session bars
- Isolated mode toggle: bar 0, no ghost notes
- Ghost toggle: show/hide ghost layer (only in session mode)
- Auto-scroll to session position in session sync mode
- Bar labels show absolute session bar numbers
2026-07-27 17:08:59 +07:00
3dtours 095a0680e8 fix(build): remove extra brace at L6795, Babel build now succeeds; feat(ai-copilot): rows=4, resize-y, cursor-aware ArrowUp/Down 2026-07-27 16:36:26 +07:00
3dtours 4ed0b1e5be fix(ai-copilot): patch trực tiếp app.precompiled.js rows=4 + cursor check cho ArrowUp/Down 2026-07-27 16:21:24 +07:00
3dtours cb23d36bc8 fix: multi-track ARM + activeNotes map cho stopNote
1. precompiled: find(t=>isArmed) → filter(t=>isArmed) loop all tracks
2. soundfontPlayer: _activeNotes[ch:pitch] = mappedCh lưu khi noteOn
3. stopNote lookup mappedCh từ _activeNotes thay vì dùng MIDI ch 0
→ Fix: đổi SF track → channel mới → noteOff vẫn tìm đúng voice
2026-07-27 15:48:34 +07:00
3dtours d9ad60768e fix: patch precompiled JS - thêm stopNote + duration 60000
app.precompiled.js được build từ app.jsx cũ (10:54), thiếu:
- SonicSF.stopNote() trong MIDI note-off handler → note không tắt
- duration 500ms (quá ngắn, nên 60000ms = hold)
Patch thủ công bằng Python replace trên minified code.
2026-07-27 15:24:33 +07:00
3dtours 5c47b68a9d fix: single Synth button opens instrument modal, fix init race condition
- Remove small Synth button (already done earlier)
- Large Synth button now calls openInstrumentSelector (instrument modal)
- Fix _initPromise stale cache: reset to null when init fails
- Module not loaded yet → retries on next select instead of stuck
2026-07-27 10:54:58 +07:00
3dtours cf61b8431d revert: restore small Synth button to dropdown (preserve SF3 flow) 2026-07-27 10:49:42 +07:00
3dtours e5bd442b7c fix: small Synth button opens instrument modal (not SF list dropdown) 2026-07-27 10:40:20 +07:00
3dtours 55a27b5957 fix: remove sf.source references causing ReferenceError in PluginManagerModal 2026-07-27 10:35:42 +07:00
3dtours 3a6b44e195 feat: Synth button opens modal with flat instrument list from all SFs
- openInstrumentSelector builds flat list of all instrument presets
- Modal shows all instruments with search bar
- Each preset shows sf name + program name
- Remove old two-step (SF list -> presets) navigation
- Fix pre-existing closing paren mismatch in PluginManagerModal
2026-07-27 10:11:44 +07:00
3dtours 7544ee2e5f feat: eager soundfont catalog scan at startup, cache presets locally
- App startup fetches full catalog with all instrument presets
- Merges presets into instrumentSelectorData.soundfonts
- Synth button shows presets from cache (no per-SF API call)
- Fallback: if cache miss, fetch individual SF presets on demand
2026-07-27 09:28:34 +07:00
3dtours d04442ad45 fix: click on ruler moves playhead only (no zero-width selection)
- Remove setSelectionStart/End from simple click (non-drag) path
- Only handleMouseMove (drag) creates/modifies selection
- Sub-tab already correct (no selection set on click)
2026-07-27 09:19:18 +07:00
3dtours dff2c81848 fix: sub-tab ruler drag creates local selection, separate from main
- Add isDraggingSubTabRef/subTabDragStartRef for section-tab drag
- Ctrl+Click on sub-tab ruler clears sub-tab selection
- Sub-tab mousedown: set playhead + start drag
- Sub-tab mousemove/mouseup: update st.selectionStart/End locally
- Section-tab selection doesn't affect main session selection
2026-07-27 09:14:34 +07:00
3dtours ef891e9e04 fix: set selectionFollowsTempo based on which ruler is clicked
- Time Ruler click → setSelectionFollowsTempo(false) → time-based
- Tempo Track Lane click → setSelectionFollowsTempo(true) → tempo-based
- Also handles sub-tab ruler (EDITOR tabs)
- Manual toggle button ♪T/⏱T still works for override
2026-07-27 08:59:50 +07:00
3dtours 06480516eb fix: equal bar widths + selection tempo/time toggle
- WaveformLane bar grid: integer beat loop (bn*beatDuration) instead
  of accumulating t += beatDuration — no floating point drift
- Add selectionFollowsTempo toggle button (♪T/⏱T) in transport bar
- ♪T (tempo): selection recalculates with BPM
- ⏱T (time): selection fixed in seconds regardless of BPM
2026-07-27 08:53:42 +07:00
3dtours af6c77b9ee fix: add bar markers to TimelineRuler aligned with TempoTrackLane
- TimelineRuler draws bar lines at bn * barDuration positions
- Same integer beat loop as TempoTrackLane (bn from firstBarNum)
- Bar number labels at center of ruler
- Time markers still shown below bar markers
- All use same bpm prop → always aligned with tempo track
2026-07-27 08:41:36 +07:00
3dtours 3a84323dd8 fix: force canvas redraw after BPM duration recalculation 2026-07-27 08:36:14 +07:00
3dtours 3c12ce2a22 fix: range loop selection maintains bar count on BPM change
- Add prevBpmRef to track previous BPM
- BPM effect recalculates selectionStart/End using bar count
- startBar = oldStart / oldSecondsPerBar
- newStart = startBar * newSecondsPerBar (same for end)
2026-07-27 08:31:12 +07:00
3dtours f59cc304d4 fix: TempoTrackLane bar spacing drift with floating-point BPM
- Replace t += beatDuration loop (floating accumulation drifts)
- Iterate by integer beat number: t = bn * beatDuration
- Each bar position computed independently, no cumulative error
- Same fix for snapInterval loop
- Fixes unequal bar widths for BPM like 77, 81
2026-07-27 08:25:47 +07:00
3dtours cde29386d2 fix: TempoTrackLane bar spacing by removing broken DOM scrollLeft lookup
- DOM traversal for scrollLeft stops at sticky wrapper (scrollLeft=0)
- Use scrollLeft prop directly instead of traversing parent DOM
- Affects both TimelineRuler and TempoTrackLane canvas effects
- Bars now correctly space when BPM changes
2026-07-27 08:21:16 +07:00
3dtours ea5043c981 fix: auto-compute length_bars for legacy items on BPM change
- Items without length_bars: compute bars from duration/secondsPerBar
- Round to nearest quarter bar for musical accuracy
- Recalculate duration = bars * new secondsPerBar for all items
- Maintains correct bar count for both legacy and new items
2026-07-27 08:10:05 +07:00
3dtours d97f82e93f fix: maintain item duration in bars when BPM changes
- Add length_bars field to midiItems and sections at creation
- useEffect on bpm recalculates duration = length_bars * secondsPerBar
- Fix section creation: use secondsPerBar instead of hardcoded 4s
- Handle existing items without length_bars (no-op)
2026-07-27 08:03:02 +07:00
3dtours f98ade5d58 fix: context menu flips upward when near viewport bottom
- If click.y + 260 > window.innerHeight: position bottom instead of top
- Also clamp left to prevent right-edge overflow
- Menu now appears above the click point when there's no room below
2026-07-27 07:46:06 +07:00
3dtours 993610ca37 fix: AI items at playhead + context menu scrollable within viewport
- Revert AI item startTime to currentTime (playhead position)
- Context menu: maxHeight 60vh + overflow-y-auto, top clamped to
  window.innerHeight - 200 to prevent bottom clipping
- Same fix for both main session and sub-tab context menus
2026-07-27 07:42:01 +07:00
3dtours 1764fc29b5 fix: AI tracks auto-align to end of last existing item
- Replace currentTime with auto-calculated maxEnd from existing items
- Each AI generation starts right after the previous one
- Ensures tracks from different generations align in bar columns
2026-07-26 22:14:02 +07:00
3dtours 0f5f494173 fix: AI-generated tracks save synth_engine + pass to applyAITrackInstrument
- Build synth_engine object with type, plugin_id, soundfont_bank,
  soundfont_program, soundfont_id
- Save to targetTrack.synth_engine so schedulePianoRollMidi reads it
- Pass synthEngine as 3rd arg to applyAITrackInstrument (was missing)
- Remove redundant separate loadSoundFont call (applyAITrackInstrument
  chains to selectInstrument which already calls loadSoundFont)
2026-07-26 21:55:47 +07:00
3dtours 7bbe1f3be0 feat: sticky time ruler + tempo lane when scrolling tracks
- Wrap TimelineRuler + TempoTrackLane in sticky-top div
- Same sticky pattern for both main session and sub-tab views
- TCP column already has sticky header (top-0) and tempo row (top-10)
- Background color hides tracks scrolling behind ruler
2026-07-26 21:32:08 +07:00
3dtours bdaa5594bd feat: sync loop button with sub-tab + auto-derive loop boundaries
- Transport Loop button now syncs isLooping with active sub-tab
- Auto-computes loopEnd from midi notes, section clips, or audio duration
- Sub-tab selectionStart=0, selectionEnd=computed boundary on loop enable
- Main timeline also auto-derives loop end from track items/clips
- All three tab types: MAIN SESSION, SECTION-TAB, PIANO ROLL
2026-07-26 21:03:17 +07:00
3dtours 91e228ad6a fix: sfBank/sfProg ReferenceError — move declarations outside closure 2026-07-26 19:41:49 +07:00
3dtours 09231d9b21 fix: explicit selectInstrument for SpessaSynth bank+program routing
Per md/37_FIXVST3_SUGGEST.md:
- Add SonicSF.selectInstrument(channel, bank, program, sfId) method
- Always sends controllerChange(CC0, bank) + programChange(prog) to SpessaSynth
- _playNoteSpessa also sends CC32 (bank LSB) before programChange
- Remove default bank auto-load from init (cleaner startup)
- Fix syntax error (double }} from previous edit)
- playNote Spessa: use program arg + synthEngine bank/program properly
2026-07-26 19:37:29 +07:00
3dtours e843f55483 fix: strip null synth_engine from project JSON
- Frontend serialize: use undefined instead of null for synth_engine
- Backend validate: strip None synth_engine from tracks before schema validation
- Prevents 'None is not of type object' schema error
2026-07-26 18:22:35 +07:00
3dtours 23601007bf fix: SpessaSynth init retry + default SF3 auto-load
- getAudioContext() calls SonicSF.init on every call (not just first)
- soundfontPlayer.init retries after 1s if SpessaSynth module not loaded yet
- Auto-loads sgm_v2.01 SF3 on successful init
- Fixes race condition: module script loads after regular scripts
2026-07-26 17:59:15 +07:00
3dtours 29c4c45791 chore: rebuild precompiled JS bundle after app.jsx changes 2026-07-26 17:56:32 +07:00
3dtours 44e0a6d736 feat: sử dụng synth cho MIDI KEys 2026-07-26 17:36:36 +07:00
3dtours 2ab989132b fix(ui): wire Synth button to VST3 selection and render engine
- UI: setTrackInstrumentWithProgram stores instrumentId + enables MIDI type
- UI: SoundFont preset selection now passes soundfont_bank to server
- Server: render_engine reads instrument_id field (fallback instrument)
- Serialize/deserialize: soundfont_bank, soundfont_program preserved
- Rebuilt app.precompiled.js from app.jsx
2026-07-26 16:25:26 +07:00
3dtours 3e805179c2 feat: sử dụng VST3, Soundfont, pianobook 2026-07-26 16:21:32 +07:00