MIDI Recording and details improvement

This commit is contained in:
josc146
2023-11-29 14:05:58 +08:00
parent 14a13d5768
commit b625b8a6d1
13 changed files with 520 additions and 28 deletions

View File

@@ -22,6 +22,7 @@ import { DownloadStatus } from '../types/downloads';
import { ModelSourceItem } from '../types/models';
import { Language, Languages, SettingsType } from '../types/settings';
import { DataProcessParameters, LoraFinetuneParameters } from '../types/train';
import { tracksMinimalTotalTime } from '../types/composition';
export type Cache = {
version: string
@@ -480,6 +481,36 @@ export function getHfDownloadUrl(url: string) {
return url;
}
export function refreshTracksTotalTime() {
const endTimes = commonStore.tracks.map(t => t.offsetTime + t.contentTime);
const totalTime = Math.max(...endTimes) + tracksMinimalTotalTime;
if (commonStore.trackPlayStartTime > totalTime)
commonStore.setTrackPlayStartTime(totalTime);
commonStore.setTrackTotalTime(totalTime);
}
export function flushMidiRecordingContent() {
const recordingTrackIndex = commonStore.tracks.findIndex(t => t.id === commonStore.recordingTrackId);
if (recordingTrackIndex >= 0) {
const recordingTrack = commonStore.tracks[recordingTrackIndex];
const tracks = commonStore.tracks.slice();
const contentTime = commonStore.recordingRawContent
.reduce((sum, current) =>
sum + (current.messageType === 'ElapsedTime' ? current.value : 0)
, 0);
tracks[recordingTrackIndex] = {
...recordingTrack,
content: commonStore.recordingContent,
rawContent: commonStore.recordingRawContent,
contentTime: contentTime
};
commonStore.setTracks(tracks);
refreshTracksTotalTime();
}
commonStore.setRecordingContent('');
commonStore.setRecordingRawContent([]);
}
export function getSupportedCustomCudaFile(isBeta: boolean) {
if ([' 10', ' 16', ' 20', ' 30', 'MX', 'Tesla P', 'Quadro P', 'NVIDIA P', 'TITAN X', 'TITAN RTX', 'RTX A',
'Quadro RTX 4000', 'Quadro RTX 5000', 'Tesla T4', 'NVIDIA A10', 'NVIDIA A40'].some(v => commonStore.status.device_name.includes(v)))