This commit is contained in:
josc146 2023-11-29 21:21:14 +08:00
parent 04fbb38861
commit 0d0a3f15cc
4 changed files with 25 additions and 3 deletions

View File

@ -295,5 +295,10 @@
"Sax": "サックス", "Sax": "サックス",
"Flute": "フルート", "Flute": "フルート",
"Lead": "リード", "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デバイスを選択してください"
} }

View File

@ -295,5 +295,10 @@
"Sax": "萨克斯", "Sax": "萨克斯",
"Flute": "长笛", "Flute": "长笛",
"Lead": "主音", "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设备"
} }

View File

@ -365,6 +365,11 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
if (commonStore.recordingTrackId === track.id) { if (commonStore.recordingTrackId === track.id) {
commonStore.setRecordingTrackId(''); commonStore.setRecordingTrackId('');
} else { } else {
if (commonStore.activeMidiDeviceIndex === -1) {
toast(t('Please select a MIDI device first'), { type: 'warning' });
return;
}
dropRecordingTime = true; dropRecordingTime = true;
setSelectedTrackId(track.id); setSelectedTrackId(track.id);
@ -393,6 +398,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
appearance="subtle" onClick={() => { appearance="subtle" onClick={() => {
const tracks = commonStore.tracks.slice().filter(t => t.id !== track.id); const tracks = commonStore.tracks.slice().filter(t => t.id !== track.id);
commonStore.setTracks(tracks); commonStore.setTracks(tracks);
refreshTracksTotalTime();
}} /> }} />
</div> </div>
<div className="relative grow overflow-hidden"> <div className="relative grow overflow-hidden">
@ -431,7 +437,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
<Card size="small" appearance="outline" style={{ minHeight: '150px', maxHeight: '200px' }}> <Card size="small" appearance="outline" style={{ minHeight: '150px', maxHeight: '200px' }}>
<div className="flex flex-col gap-1 overflow-hidden"> <div className="flex flex-col gap-1 overflow-hidden">
<Text size={100}>{`${t('Start Time')}: ${selectedTrack.offsetTime} ms`}</Text> <Text size={100}>{`${t('Start Time')}: ${selectedTrack.offsetTime} ms`}</Text>
<Text size={100}>{`${t('Content Time')}: ${selectedTrack.contentTime} ms`}</Text> <Text size={100}>{`${t('Content Duration')}: ${selectedTrack.contentTime} ms`}</Text>
<div className="overflow-y-auto overflow-x-hidden" ref={contentPreviewRef}> <div className="overflow-y-auto overflow-x-hidden" ref={contentPreviewRef}>
{selectedTrackId === commonStore.recordingTrackId {selectedTrackId === commonStore.recordingTrackId
? commonStore.recordingContent ? commonStore.recordingContent

View File

@ -482,6 +482,12 @@ export function getHfDownloadUrl(url: string) {
} }
export function refreshTracksTotalTime() { 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 endTimes = commonStore.tracks.map(t => t.offsetTime + t.contentTime);
const totalTime = Math.max(...endTimes) + tracksMinimalTotalTime; const totalTime = Math.max(...endTimes) + tracksMinimalTotalTime;
if (commonStore.trackPlayStartTime > totalTime) if (commonStore.trackPlayStartTime > totalTime)