fix for midi instrument selection

This commit is contained in:
Nuwan 2023-08-02 08:32:11 +05:30
parent 6d4b775321
commit 5e7d512a5e
3 changed files with 203 additions and 92 deletions

View File

@ -201,6 +201,7 @@
.one(EVENTS.DIALOG_CLOSED, async function(){
await populateAccountAudio()
})
}
async function handleActivateAudioProfile(audioProfileId) {
@ -296,13 +297,13 @@
return false;
});
$root.on('click', 'a[data-purpose=configure-audio-profile]', function (evt) {
$root.on('click', 'a[data-purpose=configure-audio-profile]', async function (evt) {
evt.stopPropagation();
var $btn = $(this);
var status = $btn.closest('tr').attr('data-status');
if(status == "good") {
cancelRescan();
handleConfigureAudioProfile($btn.attr('data-id'));
await handleConfigureAudioProfile($btn.attr('data-id'));
}
else {
context.JK.Banner.showAlert("Unable to configure this profile. Please verify that the devices associated are connected.");

View File

@ -293,13 +293,13 @@ ConfigureTracksStore = @ConfigureTracksStore
instrumentId = $select.val()
ConfigureTracksActions.associateInstrumentWithTrack(instrumentId)
# instrumentSelected: `function(e) {
# const $root = $(this.getDOMNode());
# const $select = $root.find('.instrument-pick');
# instrumentSelected: `async function(e) {
# const $root = $(this.getDOMNode());
# const $select = $root.find('.instrument-pick');
# const instrumentId = $select.val();
# ConfigureTracksActions.associateInstrumentWithTrack.trigger(instrumentId);
# }`
# const instrumentId = $select.val();
# await ConfigureTracksActions.associateInstrumentWithTrack(instrumentId);
# }`
doClose: (e) ->

View File

@ -59,7 +59,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
onMixersChanged: `async function(mixers) {
await this.loadChannels();
await this.loadTrackInstruments();
this.changed();
await this.changed();
}`
onPlatformChanged: (platform) ->
@ -105,7 +105,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
await this.listVsts();
await this.performMidiScan();
await this.listPaths();
this.changed();
await this.changed();
}`
# onEnableVst: () ->
@ -125,7 +125,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
setTimeout((async () => {
await this.listVsts();
this.changed();
await this.changed();
}
), 250);
}`
@ -136,10 +136,16 @@ void removeSearchPath(int typeId, QString pathToRemove);
trySave: () ->
onVstScan: () ->
@performVstScan(true)
# onVstScan: () ->
# @performVstScan(true)
@changed()
# @changed()
onVstScan: `async function() {
this.performVstScan(true);
await this.changed();
}`
# performVstScan: (sendChanged) ->
# #@hasVst = gon.global.vst_enabled & context.jamClient.hasVstHost()
@ -177,7 +183,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
return setTimeout((async () => {
await this.listVsts();
return this.changed();
await this.changed();
}
), 250);
}`
@ -201,7 +207,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
this.scanningVsts = false;
setTimeout((async () => {
await this.listVsts();
this.changed();
await this.changed();
}
), 100 );
}`
@ -221,7 +227,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
setTimeout((async () => {
await this.listVsts();
this.changed();
await this.changed();
}
), 0);
}`
@ -252,7 +258,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
logger.debug("VSTAddSearchPath: " + path);
await context.jamClient.VSTAddSearchPath(this.vstTypeId(), path);
await this.listPaths();
this.changed();
await this.changed();
}`
# onRemoveSearchPath: (path) ->
@ -265,7 +271,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
logger.debug("VSTRemoveSearchPath: " + path);
await context.jamClient.VSTRemoveSearchPath(this.vstTypeId(), path);
await this.listPaths();
this.changed();
await this.changed();
}`
# onSelectVSTDirectory:() ->
@ -301,7 +307,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
onMidiScan: `async function() {
await this.performMidiScan();
this.changed();
await this.changed();
}`
# performMidiScan: () ->
@ -386,80 +392,175 @@ void removeSearchPath(int typeId, QString pathToRemove);
clientInstrument = 50;
}
context.JK.client_to_server_instrument_map[clientInstrument];
return context.JK.client_to_server_instrument_map[clientInstrument];
}`
# the backend does not have a consistent way of tracking assigned inputs for midi.
# let's make it seem consistent
injectMidiToTrackAssignments: () ->
if @vstTrackAssignments?
for vst in @vstTrackAssignments.vsts
if vst.track == MIDI_TRACK - 1
if vst.midiDeviceIndex > -1
# injectMidiToTrackAssignments: () ->
# if @vstTrackAssignments?
# for vst in @vstTrackAssignments.vsts
# if vst.track == MIDI_TRACK - 1
# if vst.midiDeviceIndex > -1
# first see if midi is already there
midi = @findMidiTrack()
# # first see if midi is already there
# midi = @findMidiTrack()
if !midi?
instrument = @defaultTrackInstrument(MIDI_TRACK)
# if !midi?
# instrument = @defaultTrackInstrument(MIDI_TRACK)
midi = [{assignment: MIDI_TRACK}]
midi.instrument_id = instrument?.server_id
midi.assignment = MIDI_TRACK
@trackAssignments.inputs.assigned.push(midi)
else
@removeMidiTrack()
# midi = [{assignment: MIDI_TRACK}]
# midi.instrument_id = instrument?.server_id
# midi.assignment = MIDI_TRACK
# @trackAssignments.inputs.assigned.push(midi)
# else
# @removeMidiTrack()
changed: () ->
injectMidiToTrackAssignments: `async function() {
console.log('_DEBUG_ injectMidiToTrackAssignments vstTrackAssignments', this.vstTrackAssignments)
if (this.vstTrackAssignments != null) {
//(async () => {
for (let vst of Array.from(this.vstTrackAssignments.vsts)) {
if (vst.track === (MIDI_TRACK - 1)) {
if (vst.midiDeviceIndex > -1) {
@injectMidiToTrackAssignments()
let midi = this.findMidiTrack();
@editingTrack = []
@editingTrack.assignment = @trackNumber
if @trackNumber?
for inputsForTrack in @trackAssignments.inputs.assigned
if inputsForTrack.assignment == @trackNumber
@editingTrack = inputsForTrack
break
# slap on vst, if any, from list of vst assignments
for vst in @vstTrackAssignments.vsts
if vst.track == @editingTrack.assignment - 1
@editingTrack.vst = vst
@editingTrack.midiDeviceIndex = vst.midiDeviceIndex
break
for inputsForTrack in @trackAssignments.inputs.assigned
if vst.track == inputsForTrack.assignment - 1
inputsForTrack.vst = vst
if @editingTrack.vst?
logger.debug("current track has a VST assigned:" + @editingTrack.vst.file)
unscanned = !@scannedBefore && @vstPluginList.vsts.length <= 1
@item = {
unscanned: unscanned,
musicPorts: @musicPorts,
trackAssignments: @trackAssignments,
trackNumber: @trackNumber,
editingTrack: @editingTrack,
vstPluginList: @vstPluginList,
vstTrackAssignments: @vstTrackAssignments,
attachedMidiDevices: @attachedMidiDevices,
nextTrackNumber: @nextTrackNumber,
newTrack: @newTrack,
midiTrackAssignments: @midiTrackAssignments,
scanningVsts: @scanningVsts,
trackType: @trackType,
scanPaths: @scanPaths
if ((midi == null)) {
const instrument = await this.defaultTrackInstrument(MIDI_TRACK);
const instrument_id = instrument != null ? instrument.server_id : undefined;
if(!this.trackAssignments.inputs.assigned.find(i => i.instrument_id === instrument_id && i.assignment === MIDI_TRACK)){
midi = [{assignment: MIDI_TRACK}];
midi.instrument_id = instrument_id;
midi.assignment = MIDI_TRACK;
console.log('_DEBUG_ injectMidiToTrackAssignments midi', midi)
this.trackAssignments.inputs.assigned.push(midi);
}
}
} else {
this.removeMidiTrack();
}
}
}
//})();
}
}`
@trigger(@item)
#TODO: make asyncronus
# changed: () ->
# console.log('_DEBUG_ before injectMidiToTrackAssignments')
# @injectMidiToTrackAssignments()
# console.log('_DEBUG_ after injectMidiToTrackAssignments')
# @editingTrack = []
# @editingTrack.assignment = @trackNumber
# if @trackNumber?
# for inputsForTrack in @trackAssignments.inputs.assigned
# if inputsForTrack.assignment == @trackNumber
# @editingTrack = inputsForTrack
# break
# # slap on vst, if any, from list of vst assignments
# for vst in @vstTrackAssignments.vsts
# if vst.track == @editingTrack.assignment - 1
# @editingTrack.vst = vst
# @editingTrack.midiDeviceIndex = vst.midiDeviceIndex
# break
# for inputsForTrack in @trackAssignments.inputs.assigned
# if vst.track == inputsForTrack.assignment - 1
# inputsForTrack.vst = vst
# if @editingTrack.vst?
# logger.debug("current track has a VST assigned:" + @editingTrack.vst.file)
# unscanned = !@scannedBefore && @vstPluginList.vsts.length <= 1
# @item = {
# unscanned: unscanned,
# musicPorts: @musicPorts,
# trackAssignments: @trackAssignments,
# trackNumber: @trackNumber,
# editingTrack: @editingTrack,
# vstPluginList: @vstPluginList,
# vstTrackAssignments: @vstTrackAssignments,
# attachedMidiDevices: @attachedMidiDevices,
# nextTrackNumber: @nextTrackNumber,
# newTrack: @newTrack,
# midiTrackAssignments: @midiTrackAssignments,
# scanningVsts: @scanningVsts,
# trackType: @trackType,
# scanPaths: @scanPaths
# }
# console.log('_DEBUG_ changed @item', @item)
# @trigger(@item)
changed: `async function() {
let inputsForTrack, vst;
console.log('_DEBUG_ before injectMidiToTrackAssignments');
console.trace()
await this.injectMidiToTrackAssignments();
console.log('_DEBUG_ after injectMidiToTrackAssignments');
this.editingTrack = [];
this.editingTrack.assignment = this.trackNumber;
if (this.trackNumber != null) {
for (inputsForTrack of Array.from(this.trackAssignments.inputs.assigned)) {
if (inputsForTrack.assignment === this.trackNumber) {
this.editingTrack = inputsForTrack;
break;
}
}
}
// slap on vst, if any, from list of vst assignments
for (vst of Array.from(this.vstTrackAssignments.vsts)) {
if (vst.track === (this.editingTrack.assignment - 1)) {
this.editingTrack.vst = vst;
this.editingTrack.midiDeviceIndex = vst.midiDeviceIndex;
break;
}
for (inputsForTrack of Array.from(this.trackAssignments.inputs.assigned)) {
if (vst.track === (inputsForTrack.assignment - 1)) {
inputsForTrack.vst = vst;
}
}
}
if (this.editingTrack.vst != null) {
logger.debug("current track has a VST assigned:" + this.editingTrack.vst.file);
}
const unscanned = !this.scannedBefore && (this.vstPluginList.vsts.length <= 1);
this.item = {
unscanned,
musicPorts: this.musicPorts,
trackAssignments: this.trackAssignments,
trackNumber: this.trackNumber,
editingTrack: this.editingTrack,
vstPluginList: this.vstPluginList,
vstTrackAssignments: this.vstTrackAssignments,
attachedMidiDevices: this.attachedMidiDevices,
nextTrackNumber: this.nextTrackNumber,
newTrack: this.newTrack,
midiTrackAssignments: this.midiTrackAssignments,
scanningVsts: this.scanningVsts,
trackType: this.trackType,
scanPaths: this.scanPaths
};
console.log('_DEBUG_ changed @item', this.item);
this.trigger(this.item);
}`
# loadChannels: (forceInputsToUnassign, inputChannelFilter) ->
# # inputChannelFilter is an optional argument that is used by the Gear Wizard.
@ -753,7 +854,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
return setTimeout((async () => (
await this.listVsts(),
this.changed()
await this.changed()
)), 250);
}`
@ -843,9 +944,9 @@ void removeSearchPath(int typeId, QString pathToRemove);
}
} else {
logger.debug("deleting midi track");
this.onAssociateMIDIWithTrack(null);
await this.onAssociateMIDIWithTrack(null);
this.removeMidiTrack();
return this.changed();
await this.changed();
}
}`
@ -930,17 +1031,26 @@ void removeSearchPath(int typeId, QString pathToRemove);
//@performVstScan()
await this.performMidiScan();
this.changed();
await this.changed();
this.app.layout.showDialog('configure-live-tracks-dialog');
}`
onDesiredTrackType: (trackType) ->
@trackType = trackType
# onDesiredTrackType: (trackType) ->
# @trackType = trackType
if @trackType == 'midi'
@trackNumber = MIDI_TRACK
@changed()
# if @trackType == 'midi'
# @trackNumber = MIDI_TRACK
# @changed()
onDesiredTrackType: `async function(trackType) {
this.trackType = trackType;
if (this.trackType === 'midi') {
this.trackNumber = MIDI_TRACK;
}
await this.changed();
}`
# onUpdateOutputs: (outputId1, outputId2) ->
@ -1004,7 +1114,7 @@ void removeSearchPath(int typeId, QString pathToRemove);
setTimeout((async () => (
await this.listVsts(),
this.changed()
await this.changed()
)), 250);
}`