Skip to content

Commit

Permalink
fixed instrument reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
Modrigue committed Jan 8, 2024
1 parent 8cdf3dd commit c9a9b7c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions js/scale_keyboard/instruments.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/scale_keyboard/instruments.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions ts/scale_keyboard/instruments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,21 @@ function onInstrumentSelected(selectorId: string)
if (!instrLoaded)
loadSelectedInstrument(selectorId);
else
updateSelectedInstrument(instrumentLoadingId, selectorId);
updateSelectedInstrument(instrId, selectorId);
}

function updateSelectedInstrument(instrumentId: number, selectorId: string)
{
// update current instrument and volume
const channelId = getChannelIdFromSelector(selectorId);
//console.log(channelId, instrumentId);
MIDI.channels[channelId].program = instrumentId - 1;
volumePlay = <number>instrumentsVolumesDict.get(instrumentId);

// update generated song track instrument if existing
for (let i = 1; i <= 2; i++)
if (generatedMidi!= null && instrumentLoadingSelectorId == `song_generator_instrument_track${i}`)
generatedMidi.UpdateInstrument(i, instrumentLoadingId);
generatedMidi.UpdateInstrument(i, instrumentId);
}

function getChannelIdFromSelector(selectorId: string) : number
Expand Down

0 comments on commit c9a9b7c

Please sign in to comment.