jam-cloud/web/app/assets/javascripts/react-components/stores/MixerStore.js.coffee

111 lines
3.6 KiB
CoffeeScript

context = window
logger = context.JK.logger
MIX_MODES = context.JK.MIX_MODES;
@MixerStore = Reflux.createStore(
{
init: ->
# Register with the app store to get @app
this.listenTo(context.AppStore, this.onAppInit);
this.listenTo(context.SessionStore, this.onSessionChange)
this.listenTo(context.MixerActions.mute, this.onMute)
this.listenTo(context.MixerActions.faderChanged, this.onFaderChanged)
this.listenTo(context.MixerActions.initGain, this.onInitGain)
this.listenTo(context.MixerActions.initPan, this.onInitPan)
this.listenTo(context.MixerActions.panChanged, this.onPanChanged)
context.JK.HandleVolumeChangeCallback2 = @handleVolumeChangeCallback
context.JK.HandleMetronomeCallback2 = @handleMetronomeCallback
context.JK.HandleBridgeCallback2 = @handleBridgeCallback
context.JK.HandleBackingTrackSelectedCallback2 = @handleBackingTrackSelectedCallback
handleVolumeChangeCallback: () ->
logger.debug("volume change")
handleMetronomeCallback: () ->
logger.debug("metronome callback")
handleBridgeCallback: (vuData) ->
eventName = null
mixerId = null
value = null
vuInfo = null
for vuInfo in vuData
eventName = vuInfo[0];
vuVal = 0.0;
if eventName == "vu"
mixerId = vuInfo[1];
leftValue = vuInfo[2];
leftClipping = vuInfo[3];
rightValue = vuInfo[4];
rightClipping = vuInfo[5];
# 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
@mixers.updateVU(mixerId + "_vul", (leftValue + 80) / 80, leftClipping)
@mixers.updateVU(mixerId + "_vur", (rightValue + 80) / 80, rightClipping)
handleBackingTrackSelectedCallback: () ->
logger.debug("backing track selected")
onAppInit: (@app) ->
@gearUtils = context.JK.GearUtilsInstance
@sessionUtils = context.JK.SessionUtils
onSessionChange: (session) ->
@session = session
masterMixers = context.jamClient.SessionGetAllControlState(true);
personalMixers = context.jamClient.SessionGetAllControlState(false);
# TODO: grab correct mix mode , line 870 sessionModel.js
@mixers = new context.MixerHelper(session, masterMixers, personalMixers, MIX_MODES.PERSONAL)
this.trigger({session: @session, mixers: @mixers})
onMute: (mixers, muting) ->
for mixer in mixers
@mixers.mute(mixer.id, mixer.mode, muting);
# simulate a state change to cause a UI redraw
this.trigger({session: @session, mixers: @mixers})
onFaderChanged: (data, mixerIds, groupId) ->
@mixers.faderChanged(data, mixerIds, groupId)
this.trigger({session: @session, mixers: @mixers})
onPanChanged: (data, mixerIds, groupId) ->
@mixers.panChanged(data, mixerIds, groupId)
this.trigger({session: @session, mixers: @mixers})
onInitGain: (mixer) ->
@mixers.initGain(mixer)
onInitPan: (mixer) ->
@mixers.initPan(mixer)
onMixersChanged: (type, text) ->
if @mixers
masterMixers = context.jamClient.SessionGetAllControlState(true);
personalMixers = context.jamClient.SessionGetAllControlState(false);
# TODO: grab correct mix mode , line 870 sessionModel.js
@mixers.updateMixers(type, text, masterMixers, personalMixers)
SessionActions.mixersChanged.trigger(type, text, @mixers.getTrackInfo())
this.trigger({session: @session, mixers: @mixers})
}
)