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

@ -231,6 +231,16 @@ export class UserAPI {
this.MidiConnection.sendSysExMessage(data)
}
public program_change(program: number, channel: number): void {
/**
* Sends a MIDI program change to the current MIDI output.
*
* @param program - The MIDI program to send
* @param channel - The MIDI channel to send the program change on
*/
this.MidiConnection.sendProgramChange(program, channel)
}
public midi_clock(): void {
/**
* Sends a MIDI clock to the current MIDI output.

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 {
/**