Skip to content

Commit 85b8516

Browse files
authored
implement midiMessage timestamp (#29)
1 parent beaa804 commit 85b8516

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

docs/spessa-synth-sequencer/event-types.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The lists list properties of the object.
1313
Called when a MIDI message is sent and externalMIDIPlayback is true.
1414

1515
- message: number[] - the binary MIDI message
16+
- time: number - the synthesizer's current time when this event was sent.
17+
Use this for scheduling MIDI messages to your external MIDI device.
1618

1719
### timeChange
1820

src/sequencer/sequencer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,10 @@ export class SpessaSynthSequencer {
436436
);
437437
return;
438438
}
439-
this.callEvent("midiMessage", { message });
439+
this.callEvent("midiMessage", {
440+
message,
441+
time: this.synth.currentSynthTime
442+
});
440443
}
441444

442445
protected sendMIDIAllOff() {

src/sequencer/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ export interface SequencerEventData {
1010
* The binary MIDI message.
1111
*/
1212
message: Iterable<number>;
13+
14+
/**
15+
* The synthesizer's current time when this event was sent.
16+
* Use this for scheduling MIDI messages to your external MIDI device.
17+
*/
18+
time: number;
1319
};
1420
/**
1521
* Called when the time is changed.

0 commit comments

Comments
 (0)