fix: piano roll tab không phát âm thanh - bỏ sessionBeatOffset để note phát theo item-relative khớp playhead (item ở vị trí != 0 trước đây schedule note ở now+startTime -> câm)
This commit is contained in:
@@ -15705,15 +15705,13 @@ const App = () => {
|
||||
const synthEngine = track ? track.synth_engine : undefined;
|
||||
var allTracks = activeTracksRef.current || [];
|
||||
var mainCh = track ? assignTrackMidiChannel(track, allTracks) : 0;
|
||||
// Compute session beat offset from target item
|
||||
var sessionBeatOffset = 0;
|
||||
var targetTrk = allTracks.find(function(t) { return t.id === st.trackId; });
|
||||
if (targetTrk) {
|
||||
var targetIt = (targetTrk.midiItems || []).find(function(m) { return m.id === st.target_id; });
|
||||
if (targetIt) sessionBeatOffset = (targetIt.startTime / ((60.0 / bpmVal) * 4)) * 4;
|
||||
}
|
||||
// The piano-roll playhead (st.currentTime) and transport are item-relative:
|
||||
// 0 = item start. Notes must be scheduled relative to the item too, otherwise
|
||||
// items placed later in the project play `item.startTime` seconds in the
|
||||
// future (silence when pressing play). Ghost notes are already relative to
|
||||
// the item window, so no absolute-session offset is applied anywhere here.
|
||||
midiNotes.forEach(note => {
|
||||
const noteOnBeat = (note.start_beat || 0) + sessionBeatOffset;
|
||||
const noteOnBeat = note.start_beat || 0;
|
||||
const noteDurBeat = note.duration_beats || 1;
|
||||
const noteStartSec = noteOnBeat * secondsPerBeat;
|
||||
const noteDurSec = noteDurBeat * secondsPerBeat;
|
||||
@@ -15737,7 +15735,7 @@ const App = () => {
|
||||
var ghostDest = getOrCreateTrackNode(ghostTrack, context);
|
||||
var ghostCh = ghostTrack ? assignTrackMidiChannel(ghostTrack, allTracks) : 0;
|
||||
layer.notes.forEach(function(note) {
|
||||
var beat = (note.start_beat || 0) + sessionBeatOffset;
|
||||
var beat = note.start_beat || 0;
|
||||
var dur = note.duration_beats || 1;
|
||||
var startSec = beat * secondsPerBeat;
|
||||
var durSec = dur * secondsPerBeat;
|
||||
|
||||
Reference in New Issue
Block a user