display mainInstrument of track
This commit is contained in:
@@ -22,7 +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';
|
||||
import { InstrumentTypeNameMap, tracksMinimalTotalTime } from '../types/composition';
|
||||
|
||||
export type Cache = {
|
||||
version: string
|
||||
@@ -504,11 +504,23 @@ export function flushMidiRecordingContent() {
|
||||
.reduce((sum, current) =>
|
||||
sum + (current.messageType === 'ElapsedTime' ? current.value : 0)
|
||||
, 0);
|
||||
|
||||
const sortedInstrumentFrequency = Object.entries(commonStore.recordingRawContent
|
||||
.filter(c => c.messageType === 'NoteOn')
|
||||
.map(c => c.instrument)
|
||||
.reduce((frequencyCount, current) => (frequencyCount[current] = (frequencyCount[current] || 0) + 1, frequencyCount)
|
||||
, {} as { [key: string]: number }))
|
||||
.sort((a, b) => b[1] - a[1]);
|
||||
let mainInstrument: string = '';
|
||||
if (sortedInstrumentFrequency.length > 0)
|
||||
mainInstrument = InstrumentTypeNameMap[Number(sortedInstrumentFrequency[0][0])];
|
||||
|
||||
tracks[recordingTrackIndex] = {
|
||||
...recordingTrack,
|
||||
content: commonStore.recordingContent,
|
||||
rawContent: commonStore.recordingRawContent,
|
||||
contentTime: contentTime
|
||||
contentTime: contentTime,
|
||||
mainInstrument: mainInstrument
|
||||
};
|
||||
commonStore.setTracks(tracks);
|
||||
refreshTracksTotalTime();
|
||||
|
||||
Reference in New Issue
Block a user