fix: draw clip rect/label always, skip only waveform when buffer null
- clip rect + label + markers drawn even without buffer - shows '(audio chưa được tải)' for unloaded clips - deserialize restores clip duration from duration_bars
This commit is contained in:
+18
-9
@@ -1373,15 +1373,10 @@ const WaveformLane = ({
|
||||
|
||||
if (clips.length > 0) {
|
||||
clips.forEach(clip => {
|
||||
if (!clip.buffer) return;
|
||||
const numChannels = clip.buffer.numberOfChannels || 1;
|
||||
const dataL = clip.buffer.getChannelData(0);
|
||||
const dataR = numChannels >= 2 ? clip.buffer.getChannelData(1) : dataL;
|
||||
const sampleRate = clip.buffer.sampleRate;
|
||||
const totalSamples = dataL.length;
|
||||
const originalDuration = totalSamples / sampleRate;
|
||||
const hasBuffer = !!clip.buffer;
|
||||
const clipSpeed = clip.speed || 1.0;
|
||||
const duration = originalDuration / clipSpeed;
|
||||
const originalDuration = hasBuffer ? clip.buffer.duration / clipSpeed : 4.0;
|
||||
const duration = originalDuration;
|
||||
const clipStartTime = clip.startTime || 0;
|
||||
const clipEndTime = clipStartTime + duration;
|
||||
|
||||
@@ -1392,7 +1387,7 @@ const WaveformLane = ({
|
||||
const xStartLocal = xStartGlobal - scrollLeftVal;
|
||||
const xEndLocal = xStartLocal + wClip;
|
||||
|
||||
// 1. Draw Clip Layer Background & Border
|
||||
// 1. Draw Clip Layer Background & Border (always draw even without buffer)
|
||||
const clipIdentifier = clip.id === 'default' ? 'default_' + track.id : clip.id;
|
||||
const isClipSelected = (selectedClipId && selectedClipId.trackId === track.id && selectedClipId.clipId === clipIdentifier) || (selectedItemIds && selectedItemIds.has(clipIdentifier));
|
||||
ctx.fillStyle = clip.isTemp ? 'rgba(239, 68, 68, 0.25)' : isClipSelected ? track.color ? track.color + '44' : 'rgba(6, 182, 212, 0.30)' : track.color ? track.color + '22' : 'rgba(6, 182, 212, 0.12)';
|
||||
@@ -1430,6 +1425,19 @@ const WaveformLane = ({
|
||||
});
|
||||
}
|
||||
|
||||
if (!hasBuffer) {
|
||||
ctx.fillStyle = 'rgba(255, 255, 255, 0.15)';
|
||||
ctx.font = 'italic 8px sans-serif';
|
||||
ctx.fillText('(audio chưa được tải)', Math.max(xStartLocal + 8, 8), clipTop + clipHeight - 6);
|
||||
return;
|
||||
}
|
||||
|
||||
const numChannels = clip.buffer.numberOfChannels || 1;
|
||||
const dataL = clip.buffer.getChannelData(0);
|
||||
const dataR = numChannels >= 2 ? clip.buffer.getChannelData(1) : dataL;
|
||||
const sampleRate = clip.buffer.sampleRate;
|
||||
const totalSamples = dataL.length;
|
||||
|
||||
// 3. Peak / Vector Waveform Drawing (Sound Forge Dual Stereo Channel Split Match)
|
||||
const drawXStartLocal = Math.max(0, Math.floor(xStartLocal));
|
||||
const drawXEndLocal = Math.min(drawWidth, Math.ceil(xEndLocal));
|
||||
@@ -7637,6 +7645,7 @@ const deserializeTracksList = (schemaTracks, secondsPerBar, sectionStore) => {
|
||||
name: item.name,
|
||||
startTime: item.start_bar * secondsPerBar,
|
||||
speed: 1.0,
|
||||
duration: item.duration_bars * secondsPerBar,
|
||||
serverFileId: clipFileId
|
||||
});
|
||||
} else if (item.type === "MIDI_ITEM") {
|
||||
|
||||
Reference in New Issue
Block a user