diff --git a/frontend/src/_locales/ja/main.json b/frontend/src/_locales/ja/main.json index 0302694..feeaf49 100644 --- a/frontend/src/_locales/ja/main.json +++ b/frontend/src/_locales/ja/main.json @@ -295,5 +295,10 @@ "Sax": "サックス", "Flute": "フルート", "Lead": "リード", - "Pad": "パッド" + "Pad": "パッド", + "MIDI Input": "MIDI入力", + "Select the MIDI input device to be used.": "使用するMIDI入力デバイスを選択します。", + "Start Time": "開始時間", + "Content Duration": "内容の長さ", + "Please select a MIDI device first": "まずMIDIデバイスを選択してください" } \ No newline at end of file diff --git a/frontend/src/_locales/zh-hans/main.json b/frontend/src/_locales/zh-hans/main.json index 3d3d895..00d441b 100644 --- a/frontend/src/_locales/zh-hans/main.json +++ b/frontend/src/_locales/zh-hans/main.json @@ -295,5 +295,10 @@ "Sax": "萨克斯", "Flute": "长笛", "Lead": "主音", - "Pad": "和音" + "Pad": "和音", + "MIDI Input": "MIDI输入", + "Select the MIDI input device to be used.": "选择要使用的MIDI输入设备", + "Start Time": "开始时间", + "Content Duration": "内容时长", + "Please select a MIDI device first": "请先选择一个MIDI设备" } \ No newline at end of file diff --git a/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx b/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx index 09f672c..1de65ef 100644 --- a/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx +++ b/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx @@ -365,6 +365,11 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer(( if (commonStore.recordingTrackId === track.id) { commonStore.setRecordingTrackId(''); } else { + if (commonStore.activeMidiDeviceIndex === -1) { + toast(t('Please select a MIDI device first'), { type: 'warning' }); + return; + } + dropRecordingTime = true; setSelectedTrackId(track.id); @@ -393,6 +398,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer(( appearance="subtle" onClick={() => { const tracks = commonStore.tracks.slice().filter(t => t.id !== track.id); commonStore.setTracks(tracks); + refreshTracksTotalTime(); }} />
@@ -431,7 +437,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
{`${t('Start Time')}: ${selectedTrack.offsetTime} ms`} - {`${t('Content Time')}: ${selectedTrack.contentTime} ms`} + {`${t('Content Duration')}: ${selectedTrack.contentTime} ms`}
{selectedTrackId === commonStore.recordingTrackId ? commonStore.recordingContent diff --git a/frontend/src/utils/index.tsx b/frontend/src/utils/index.tsx index 1d875c6..1408cc7 100644 --- a/frontend/src/utils/index.tsx +++ b/frontend/src/utils/index.tsx @@ -482,6 +482,12 @@ export function getHfDownloadUrl(url: string) { } export function refreshTracksTotalTime() { + if (commonStore.tracks.length === 0) { + commonStore.setTrackTotalTime(tracksMinimalTotalTime); + commonStore.setTrackCurrentTime(0); + commonStore.setTrackPlayStartTime(0); + return; + } const endTimes = commonStore.tracks.map(t => t.offsetTime + t.contentTime); const totalTime = Math.max(...endTimes) + tracksMinimalTotalTime; if (commonStore.trackPlayStartTime > totalTime)