Added the message pinao system reusing a react context for simplicity and emitting note timing messages when scoro gives the result

This commit is contained in:
Clément Le Bihan
2023-09-13 16:26:04 +02:00
parent 607c35b621
commit cea6d8d0bc
6 changed files with 147 additions and 56 deletions
+40
View File
@@ -0,0 +1,40 @@
import { Note } from 'opensheetmusicdisplay';
export type PianoCursorNote = {
note: Note;
duration: number;
};
export type PianoCursorPosition = {
// offset in pixels
x: number;
// timestamp in ms
timing: number;
timestamp: number;
notes: PianoCursorNote[];
};
export type UpdateInfo = {
currentTimestamp: number;
status: 'playing' | 'paused' | 'stopped';
};
export enum NoteTiming {
Perfect = 'Perfect',
Great = 'Great',
Good = 'Good',
Missed = 'Missed',
Wrong = 'Wrong',
}
export type PianoCanvasMsg = {
type: 'noteTiming' | 'score' | 'gameUpdate';
data: UpdateInfo | NoteTiming | number;
};
export type PianoCanvasContext = {
messages: Array<PianoCanvasMsg>;
// Timestamp of the play session, in miliseconds
timestamp: number;
pressedKeys: Map<number, number>;
};