Adding MIDI Program Change

This commit is contained in:
2023-08-05 21:30:30 +02:00
parent dfca663517
commit a62f3006ef
2 changed files with 31 additions and 0 deletions

View File

@ -137,6 +137,27 @@ export class MidiConnection{
console.error('MIDI output not available.');
}
}
public sendProgramChange(programNumber: number, channel: number): void {
/**
* Sends a MIDI Program Change message to the currently selected MIDI output.
*
* @param programNumber MIDI program number (0-127)
* @param channel MIDI channel (0-15)
*
* @example
* // Send a Program Change message to select program 1 on channel 1
* sendProgramChange(0, 0);
*/
const output = this.midiOutputs[this.currentOutputIndex];
if (output) {
output.send([0xC0 + channel, programNumber]); // Program Change
} else {
console.error('MIDI output not available.');
}
}
public sendMidiControlChange(controlNumber: number, value: number): void {
/**