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

@@ -1,5 +1,7 @@
import { NoteSequence } from '@magenta/music/esm/protobuf';
export const tracksMinimalTotalTime = 5000;
export type CompositionParams = {
prompt: string,
maxResponseToken: number,
@@ -13,6 +15,69 @@ export type CompositionParams = {
export type Track = {
id: string;
content: string;
rawContent: MidiMessage[];
offsetTime: number;
contentTime: number;
};
};
export type MidiPort = {
name: string;
}
export type MessageType = 'NoteOff' | 'NoteOn' | 'ElapsedTime' | 'ControlChange';
export type MidiMessage = {
messageType: MessageType;
channel: number;
note: number;
velocity: number;
control: number;
value: number;
}
export enum InstrumentType {
Piano,
Percussion,
Drum,
Tuba,
Marimba,
Bass,
Guitar,
Violin,
Trumpet,
Sax,
Flute,
Lead,
Pad,
}
export const InstrumentTypeNameMap = [
'Piano',
'Percussion',
'Drum',
'Tuba',
'Marimba',
'Bass',
'Guitar',
'Violin',
'Trumpet',
'Sax',
'Flute',
'Lead',
'Pad'
];
export const InstrumentTypeTokenMap = [
'pi',
'p',
'd',
't',
'm',
'b',
'g',
'v',
'tr',
's',
'f',
'l',
'pa'
];