From 7a7986e30a63d94ad730655c505eeeea171bcd03 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Fri, 2 Sep 2022 11:10:51 +0530 Subject: [PATCH] fixing audio config and session related issues --- web/app/assets/javascripts/asyncJamClient.js | 4 +- .../SessionMediaTracks.js.jsx.coffee | 3 +- .../SessionMyTrack.js.jsx.coffee | 3 +- .../SessionStatsHover.js.jsx.coffee | 5 + .../helpers/MixerHelper.js.coffee | 31 +++- .../stores/ConfigureTracksStore.js.coffee | 142 ++++++++++++------ .../stores/MixerStore.js.coffee | 27 +++- 7 files changed, 147 insertions(+), 68 deletions(-) diff --git a/web/app/assets/javascripts/asyncJamClient.js b/web/app/assets/javascripts/asyncJamClient.js index 671a757ba..4f7cf5382 100644 --- a/web/app/assets/javascripts/asyncJamClient.js +++ b/web/app/assets/javascripts/asyncJamClient.js @@ -488,11 +488,11 @@ (d) => d.request_id !== deferred.request_id ); } else if (evt_id) { - //logger.log("EVENT RESPONSE FROM CLIENT APP", evt_id, Object.keys(response)[0]) + logger.log("EVENT RESPONSE FROM CLIENT APP", evt_id, Object.keys(response)[0]) let method = Object.keys(response)[0] switch (method) { case 'execute_script': - logger.log(`execute_script: ${response['execute_script']}`); + //logger.log(`execute_script: ${response['execute_script']}`); eval(response['execute_script']); break; diff --git a/web/app/assets/javascripts/react-components/SessionMediaTracks.js.jsx.coffee b/web/app/assets/javascripts/react-components/SessionMediaTracks.js.jsx.coffee index cfda3029e..ca7b1b58d 100644 --- a/web/app/assets/javascripts/react-components/SessionMediaTracks.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/SessionMediaTracks.js.jsx.coffee @@ -298,7 +298,7 @@ ChannelGroupIds = context.JK.ChannelGroupIds JamTrack
  • - Audio File + Audio File
  • @@ -430,7 +430,6 @@ ChannelGroupIds = context.JK.ChannelGroupIds @closeWindow() handleBackingTrackSelectedCallback: (result) -> - @setState({backingTrackDialogOpen: false}) SessionActions.openBackingTrack(result) diff --git a/web/app/assets/javascripts/react-components/SessionMyTrack.js.jsx.coffee b/web/app/assets/javascripts/react-components/SessionMyTrack.js.jsx.coffee index 19e888e3e..b81fd2a76 100644 --- a/web/app/assets/javascripts/react-components/SessionMyTrack.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/SessionMyTrack.js.jsx.coffee @@ -8,6 +8,7 @@ ConfigureTracksActions = @ConfigureTracksActions mixins: [Reflux.listenTo(@SessionStatsStore,"onStatsChanged")] onStatsChanged: (stats) -> + console.log('STATS', stats) @setState({stats: stats[@props.clientId]}) getInitialState: () -> @@ -190,7 +191,7 @@ ConfigureTracksActions = @ConfigureTracksActions context.JK.helpBubble($root.find('.disabled-track-overlay'), 'missing-my-tracks', {}, {positions:['top'], offsetParent: $root.closest('.top-parent')}); - return this.initializeVstEffects(); + this.initializeVstEffects(); }` componentWillUpdate: (nextProps, nextState) -> diff --git a/web/app/assets/javascripts/react-components/SessionStatsHover.js.jsx.coffee b/web/app/assets/javascripts/react-components/SessionStatsHover.js.jsx.coffee index 9e97c6e0f..3cac9b247 100644 --- a/web/app/assets/javascripts/react-components/SessionStatsHover.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/SessionStatsHover.js.jsx.coffee @@ -247,14 +247,19 @@ StatsInfo = { onStatsChanged: (stats) -> stats = window.SessionStatsStore.stats + console.log('=stats', stats) if stats? if stats.parent? # if we have a parent, then use stats from the JamBlaster (parent), not ourselves. Otherwise we'll get bad stats (no Audio etc) + console.log('=stats.parent', stats.parent) + console.log('=@props.participant.client_id', @props.participant.client_id) + console.log('=stats.parent[@props.participant.client_id]', stats.parent[@props.participant.client_id]) clientStats = stats.parent[@props.participant.client_id] else clientStats = stats[@props.participant.client_id] else clientStats = null + console.log('=clientStats', clientStats) @setState({stats: clientStats}) getInitialState: () -> diff --git a/web/app/assets/javascripts/react-components/helpers/MixerHelper.js.coffee b/web/app/assets/javascripts/react-components/helpers/MixerHelper.js.coffee index e51698158..610694875 100644 --- a/web/app/assets/javascripts/react-components/helpers/MixerHelper.js.coffee +++ b/web/app/assets/javascripts/react-components/helpers/MixerHelper.js.coffee @@ -703,19 +703,34 @@ MIX_MODES = context.JK.MIX_MODES; muteMixer: muteMixer } - mute: (mixerId, mode, muting) -> + # mute: (mixerId, mode, muting) -> + # mode = @mixMode unless mode? - mode = @mixMode unless mode? + # @fillTrackVolumeObject(mixerId, mode) - @fillTrackVolumeObject(mixerId, mode) + # context.trackVolumeObject.mute = muting - context.trackVolumeObject.mute = muting + # context.jamClient.SessionSetControlState(mixerId, mode) - context.jamClient.SessionSetControlState(mixerId, mode) + # # keep state of mixer in sync with backend + # mixer = @getMixer(mixerId, mode) + # mixer.mute = muting - # keep state of mixer in sync with backend - mixer = @getMixer(mixerId, mode) - mixer.mute = muting + mute: `async function(mixerId, mode, muting) { + if (mode == null) { mode = this.mixMode; } + + this.fillTrackVolumeObject(mixerId, mode); + + context.trackVolumeObject.mute = muting; + + console.log('before SessionSetControlState', mixerId, mode) + await context.jamClient.SessionSetControlState(mixerId, mode); + console.log('after SessionSetControlState', mixerId, mode) + + // keep state of mixer in sync with backend + const mixer = this.getMixer(mixerId, mode); + mixer.mute = muting; + }` getOriginalVolume: (mixers, gainType) -> originalVolume = null diff --git a/web/app/assets/javascripts/react-components/stores/ConfigureTracksStore.js.coffee b/web/app/assets/javascripts/react-components/stores/ConfigureTracksStore.js.coffee index abc340774..9a2e89413 100644 --- a/web/app/assets/javascripts/react-components/stores/ConfigureTracksStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/ConfigureTracksStore.js.coffee @@ -65,27 +65,48 @@ void removeSearchPath(int typeId, QString pathToRemove); onPlatformChanged: (platform) -> @platform = platform - onReset: (loadProfile) -> - logger.debug("ConfigureTracksStore:reset", this) - @trackNumber = null - @editingTrack = null + # onReset: (loadProfile) -> + # logger.debug("ConfigureTracksStore:reset", this) + # @trackNumber = null + # @editingTrack = null - # you have to load the current profile in order to see track info, which we need - #if loadProfile - #currentProfile = context.jamClient.LastUsedProfileName(); - #result = context.jamClient.FTUELoadAudioConfiguration(currentProfile); + # # you have to load the current profile in order to see track info, which we need + # #if loadProfile + # #currentProfile = context.jamClient.LastUsedProfileName(); + # #result = context.jamClient.FTUELoadAudioConfiguration(currentProfile); - @loadChannels() - @loadTrackInstruments() + # @loadChannels() + # @loadTrackInstruments() - #if force || context.jamClient.hasVstAssignment() - # @performVstScan() + # #if force || context.jamClient.hasVstAssignment() + # # @performVstScan() - @listVsts() - @performMidiScan() - @listPaths() - @changed() + # @listVsts() + # @performMidiScan() + # @listPaths() + # @changed() + onReset: `async function(loadProfile) { + logger.debug("ConfigureTracksStore:reset", this); + this.trackNumber = null; + this.editingTrack = null; + + // you have to load the current profile in order to see track info, which we need + //if loadProfile + //currentProfile = context.jamClient.LastUsedProfileName(); + //result = context.jamClient.FTUELoadAudioConfiguration(currentProfile); + + await this.loadChannels(); + await this.loadTrackInstruments(); + + //if force || context.jamClient.hasVstAssignment() + // @performVstScan() + + await this.listVsts(); + await this.performMidiScan(); + await this.listPaths(); + this.changed(); + }` # onEnableVst: () -> # logger.debug("enabling VSTs") @@ -101,10 +122,10 @@ void removeSearchPath(int typeId, QString pathToRemove); logger.debug("enabling VSTs"); await context.jamClient.VSTLoad(); - return setTimeout((() => { - this.listVsts(); + setTimeout((async () => { + await this.listVsts(); - return this.changed(); + this.changed(); } ), 250); }` @@ -153,8 +174,8 @@ void removeSearchPath(int typeId, QString pathToRemove); onClearVsts: `async function() { await context.jamClient.VSTClearAll(); - return setTimeout((() => { - this.listVsts(); + return setTimeout((async () => { + await this.listVsts(); return this.changed(); } @@ -165,23 +186,45 @@ void removeSearchPath(int typeId, QString pathToRemove); logger.debug("manage vst selected") @app.layout.showDialog('manage-vsts-dialog') - onVstScanComplete: () -> - # XXX must wait a long time to get track assignments after scan/ - logger.debug("vst scan complete") - @scanningVsts = false - setTimeout((() => - @listVsts() - @changed() - ), 100 ) + # onVstScanComplete: () -> + # # XXX must wait a long time to get track assignments after scan/ + # logger.debug("vst scan complete") + # @scanningVsts = false + # setTimeout((() => + # @listVsts() + # @changed() + # ), 100 ) + + onVstScanComplete: `function() { + // XXX must wait a long time to get track assignments after scan/ + logger.debug("vst scan complete"); + this.scanningVsts = false; + setTimeout((async () => { + await this.listVsts(); + this.changed(); + } + ), 100 ); + }` - onVstChanged: () -> - setTimeout() - logger.debug("vst changed") + # onVstChanged: () -> + # setTimeout() + # logger.debug("vst changed") - setTimeout((() => - @listVsts() - @changed() - ), 0) + # setTimeout((() => + # @listVsts() + # @changed() + # ), 0) + + onVstChanged: `function() { + setTimeout(); + logger.debug("vst changed"); + + setTimeout((async () => { + await this.listVsts(); + this.changed(); + } + ), 0); + }` # listPaths: () -> # @scanPaths = context.jamClient.VSTListSearchPaths() @@ -208,8 +251,8 @@ void removeSearchPath(int typeId, QString pathToRemove); onAddSearchPath: `async function(path) { logger.debug("VSTAddSearchPath: " + path); await context.jamClient.VSTAddSearchPath(this.vstTypeId(), path); - this.listPaths(); - return this.changed(); + await this.listPaths(); + this.changed(); }` # onRemoveSearchPath: (path) -> @@ -221,7 +264,7 @@ void removeSearchPath(int typeId, QString pathToRemove); onRemoveSearchPath: `async function(path) { logger.debug("VSTRemoveSearchPath: " + path); await context.jamClient.VSTRemoveSearchPath(this.vstTypeId(), path); - this.listPaths(); + await this.listPaths(); this.changed(); }` @@ -252,9 +295,14 @@ void removeSearchPath(int typeId, QString pathToRemove); this.vstTrackAssignments = await context.jamClient.VSTListTrackAssignments(); }` - onMidiScan: () -> - @performMidiScan() - @changed() + # onMidiScan: () -> + # @performMidiScan() + # @changed() + + onMidiScan: `async function() { + await this.performMidiScan(); + this.changed(); + }` # performMidiScan: () -> @@ -709,8 +757,8 @@ void removeSearchPath(int typeId, QString pathToRemove); } // no way to unset VST assignment yet - return setTimeout((() => ( - this.listVsts(), + return setTimeout((async () => ( + await this.listVsts(), this.changed() )), 250); @@ -887,7 +935,7 @@ void removeSearchPath(int typeId, QString pathToRemove); } //@performVstScan() - this.performMidiScan(); + await this.performMidiScan(); this.changed(); @@ -959,8 +1007,8 @@ void removeSearchPath(int typeId, QString pathToRemove); await context.jamClient.VST_EnableMidiForTrack(this.trackNumber - 1, true, midiInterface); } - return setTimeout((() => ( - this.listVsts(), + setTimeout((async () => ( + await this.listVsts(), this.changed() )), 250); diff --git a/web/app/assets/javascripts/react-components/stores/MixerStore.js.coffee b/web/app/assets/javascripts/react-components/stores/MixerStore.js.coffee index 95773c89b..0273aa3a0 100644 --- a/web/app/assets/javascripts/react-components/stores/MixerStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/MixerStore.js.coffee @@ -105,7 +105,7 @@ rest = context.JK.Rest() # TODO - no guarantee range will be -80 to 20. Get from the # GetControlState for this mixer which returns min/max # value is a DB value from -80 to 20. Convert to float from 0.0-1.0 - console.log('handleBridgeCallback@mixers',@mixers) + #console.log('handleBridgeCallback@mixers',@mixers) @mixers.updateVU(mixerId, mode, (leftValue + 80) / 80, leftClipping, (rightValue + 80) / 80, rightClipping) #@mixers.updateVU(mixerId + "_vur", (rightValue + 80) / 80, rightClipping) @@ -153,7 +153,6 @@ rest = context.JK.Rest() # @issueChange() onSessionChange: `async function(session) { - console.log('onSessionChange', session) if(!session){ return } if (!session.inSession()) { this.sessionEnded(); } @@ -167,15 +166,27 @@ rest = context.JK.Rest() return this.issueChange(); }` - onMute: (mixers, muting) -> + # onMute: (mixers, muting) -> - mixers = [mixers] unless $.isArray(mixers) + # mixers = [mixers] unless $.isArray(mixers) - for mixer in mixers - @mixers.mute(mixer.id, mixer.mode, muting); + # for mixer in mixers + # @mixers.mute(mixer.id, mixer.mode, muting); - # simulate a state change to cause a UI redraw - @issueChange() + # # simulate a state change to cause a UI redraw + # @issueChange() + + onMute: `async function(mixers, muting) { + + if (!$.isArray(mixers)) { mixers = [mixers]; } + + for (let mixer of Array.from(mixers)) { + await this.mixers.mute(mixer.id, mixer.mode, muting); + } + + // simulate a state change to cause a UI redraw + this.issueChange(); + }` onFaderChanged: (data, mixers, gainType, controlGroup) ->