context = window ConfigureTracksStore = @ConfigureTracksStore @ConfigureLiveTracksDialog = React.createClass({ mixins: [Reflux.listenTo(@ConfigureTracksStore,"onConfigureTracksChanged"), Reflux.listenTo(@AppStore, "onAppInit")] onConfigureTracksChanged:(configureTracks) -> @setState({configureTracks: configureTracks}) onAppInit: (@app) -> getInitialState: () -> {configureTracks: null, midiInterface: null} renderAudio: () -> inputOneOptions = [] inputTwoOptions = [] defaultSelectionOne = `` defaultSelectionTwo = `` inputOneOptions.push(defaultSelectionOne) inputTwoOptions.push(defaultSelectionTwo) inputOneValue = '' inputTwoValue = '' selectedInstrument = '' selectedVst = 'NONE' instruments = [] instruments.push(``) for instrument in context.JK.server_to_client_instrument_alpha instruments.push(``) vsts = [] instrumentDisabled = true vstDisabled = true if @state.configureTracks? if @state.configureTracks.scanningVsts scan = `
Scanning your system
for VST & AU plug-ins...
` selectedInstrument = @state.configureTracks.editingTrack.instrument_id if @state.configureTracks.editingTrack.instrument_id? if @state.configureTracks.editingTrack.length == 1 input = @state.configureTracks.editingTrack[0] if input.number == 0 inputOneValue = input.id else inputTwoValue = input.id if @state.configureTracks.editingTrack.length > 1 inputOneValue = @state.configureTracks.editingTrack[0].id inputTwoValue = @state.configureTracks.editingTrack[1].id instrumentDisabled = @state.configureTracks.editingTrack.length == 0 vstDisabled = @state.configureTracks.editingTrack.length == 0 || @state.configureTracks.unscanned if @state.configureTracks.unscanned initialScan = `

“If you want to use an audio plugin, click the manage audio plugins link above, and then click the scan for new or updated plugins link in the menu.

` for input in @state.configureTracks.musicPorts.inputs include = false # we need to see that this input is unassigned, or one of the two selected for unassignedInputs in @state.configureTracks.trackAssignments.inputs.unassigned if unassignedInputs.id == input.id include = true break if !include # not see if it's the currently edited track for currentInput in @state.configureTracks.editingTrack if currentInput.id == input.id include = true if include item = `` inputOneOptions.push(item) inputTwoOptions.push(item) for plugin in @state.configureTracks.vstPluginList.vsts if plugin.category == 'NONE' vsts.push(``) else if plugin.isInstrument == false vsts.push(``) if @state.configureTracks.editingTrack.vst? vstAssignedThisTrack = true selectedVst = @state.configureTracks.editingTrack.vst.file vstSettingBtnClasses = classNames({'button-orange': vstAssignedThisTrack, 'button-grey': !vstAssignedThisTrack}) `

Audio Input Ports

Select one or two inputs ports to assign to this track. Note that if you assign a single input port, the app will automatically duplicate this port into a stereo track.

Instrument

Audio Effects (optional)

manage audio plugins
SETTINGS . . .
{initialScan} {scan}
` renderMidi: () -> midiInterfaces = [] midiInterfaces.push(``) midiInstruments = [] instruments = [] for instrument in context.JK.server_to_client_instrument_alpha instruments.push(``) selectedMidiInterface = '' selectedInstrument = context.JK.client_to_server_instrument_map[50].server_id # default to electric guitar selectedMidiInstrument = '' instrumentDisabled = true midiInstrumentDisabled = true vstAssignedThisTrack = false if @state.configureTracks? if @state.configureTracks.scanningVsts scan = `
Scanning your system
for VST & AU plug-ins...
` if @state.configureTracks.unscanned initialScan = `

“If you want to use a midi instrument, click the manage audio plugins link above, and then click the scan for new or updated plugins link in the menu.

` logger.debug("current midi device: " + @state.configureTracks.editingTrack.midiDeviceIndex) selectedMidiInterface = @state.midiInterface || @state.configureTracks.editingTrack.midiDeviceIndex selectedInstrument = @state.configureTracks.editingTrack.instrument_id if @state.configureTracks.editingTrack.instrument_id? instrumentDisabled = !@state.midiInterface? || !selectedMidiInterface? midiInstrumentDisabled = @state.configureTracks.unscanned instrumentDisabled = false if @state.configureTracks.editingTrack.vst? vstAssignedThisTrack = true selectedMidiInstrument = @state.configureTracks.editingTrack.vst.file vstSettingBtnClasses = classNames({'button-orange': vstAssignedThisTrack, 'button-grey': !vstAssignedThisTrack}) for midiDevice in @state.configureTracks.attachedMidiDevices.midiDevices midiInterfaces.push(``) for plugin in @state.configureTracks.vstPluginList.vsts if plugin.isInstrument == true midiInstruments.push(``) else if plugin.category == 'NONE' midiInstruments.push(``) `

MIDI Interface

scan for connected MIDI interfaces

Instrument Display Name

MIDI Instrument (VST or AU Plugin)

manage audio plugins
SETTING . . .
{initialScan} {scan}
Instructions:
  1. Select your MIDI interface.
  2. Select your MIDI instrument and set its settings as needed. The instrument is ready to play after you select it, and you can test it.
  3. Select the Instrument you want displayed in the Session window.
  4. Click Add Track, then Save Settings.
` render: () -> action = 'ADD TRACK' header = 'add track' isAudio = !@state.configureTracks? || @state.configureTracks.trackType == 'audio' isMidi = !isAudio if isAudio activeElement = @renderAudio() scanHelpRight = `Don't see your plug-in in the list above?` else activeElement = @renderMidi() scanHelpLeft = `Don't see your plug-in in the list above?` if !@state.configureTracks?.newTrack action = 'CLOSE' header = 'update track' else cancelBtn = `CANCEL` `

{header}

{activeElement}
{scanHelpLeft} {cancelBtn} {action} {scanHelpRight}
` inputChanged: (e) -> $root = $(@getDOMNode()) $select1 = $root.find('.input-one') $select2 = $root.find('.input-two') audioInput1 = $select1.val() audioInput2 = $select2.val() if audioInput1 == '' audioInput1 = null if audioInput2 == '' audioInput2 = null logger.debug("ConfigureLiveTracksDialog: ", audioInput1, audioInput2) if audioInput1? && audioInput1 == audioInput2 e.preventDefault() # TODO: tell user they can't do this return ConfigureTracksActions.associateInputsWithTrack(audioInput1, audioInput2) vstsChanged: (e) -> $root = $(@getDOMNode()) $select = $root.find('select.vsts') vstSelected = $select.val() #if vstSelected != 'NONE' vstSelected = {file: vstSelected} if @state.configureTracks?.trackType == 'midi' @updateMidiAssociations() else logger.debug("associating vst", vstSelected) ConfigureTracksActions.associateVSTWithTrack(vstSelected) @setState({midiInterface: null}) audioInstrumentSelected: (e) -> $root = $(@getDOMNode()) instrumentId = $root.find('.instrument-pick').val() ConfigureTracksActions.associateInstrumentWithTrack(instrumentId) midiInstrumentSelected: (e) -> $root = $(@getDOMNode()) midiInstrumentId = $root.find('.midi-instrument-pick').val() midiSelVal = $root.find('.midi-select').val() vstsSelVal = $root.find('.vsts').val() if midiSelVal == "" || vstsSelVal == "NONE" context.JK.Banner.showAlert("MIDI interface and MIDI plugin must be selected.") else ConfigureTracksActions.associateInstrumentWithTrack(midiInstrumentId) # instrumentSelected: `async function(e) { # const $root = $(this.getDOMNode()); # const $select = $root.find('.instrument-pick'); # const instrumentId = $select.val(); # await ConfigureTracksActions.associateInstrumentWithTrack(instrumentId); # }` doClose: (e) -> e.preventDefault() # check that instrument is selected $root = $(@getDOMNode()) $instrument = $root.find('.instrument-pick') instrumentId = $instrument.val() $select1 = $root.find('.input-one') $select2 = $root.find('.input-two') audioInput1 = $select1.val() audioInput2 = $select2.val() if audioInput1 == '' audioInput1 = null if audioInput2 == '' audioInput2 = null if audioInput1 == null && audioInput2 == null context.JK.Banner.showAlert("At least one input must be specified.") return if instrumentId == null || instrumentId == '' context.JK.Banner.showAlert("Please select an instrument.") return @app.layout.closeDialog('configure-live-tracks-dialog', false) onCancel: (e) -> ConfigureTracksActions.cancelEdit() @app.layout.closeDialog('configure-live-tracks-dialog', true) vstSettings: (e) -> e.preventDefault() ConfigureTracksActions.showVstSettings() componentDidMount: () -> $root = $(@getDOMNode()) componentWillUpdate: () -> $root = $(@getDOMNode()) # componentDidUpdate: () -> # $root = $(@getDOMNode()) # $manageAudioPlugins = $root.find('.manage-audio-plugins') # unless $manageAudioPlugins.data('initialized') # $manageAudioPlugins.manageVsts().on(context.JK.EVENTS.VST_OPERATION_SELECTED, @vstOperation).data('initialized', true) # if true # easyDropdown support # context.JK.dropdown($root.find('select')) # $root.find('select.input-selectors').unbind('change').change(@inputChanged) # $root.find('select.instrument-pick').unbind('change').change(@instrumentSelected) # $root.find('select.vsts').unbind('change').change(@vstsChanged) componentDidUpdate: `function() { const $root = $(this.getDOMNode()); const $manageAudioPlugins = $root.find('.manage-audio-plugins'); if (!$manageAudioPlugins.data('initialized')) { $manageAudioPlugins.manageVsts().on(context.JK.EVENTS.VST_OPERATION_SELECTED, this.vstOperation).data('initialized', true); } if (true) { // easyDropdown support context.JK.dropdown($root.find('select')); $root.find('select.input-selectors').unbind('change').change(this.inputChanged); $root.find('select.instrument-pick').unbind('change').change(this.audioInstrumentSelected); $root.find('select.midi-instrument-pick').unbind('change').change(this.midiInstrumentSelected); $root.find('select.vsts').unbind('change').change(this.vstsChanged); $root.find('select.midi-select').unbind('change').change(this.midiInterfaceChanged); } }` trackTypeChanged: (event) -> if @ignoreICheck logger.debug("ignoring track type changed") return $checkedType = $(event.target); value = $checkedType.val() logger.debug("trackTypeChanged: " + value, $checkedType) ConfigureTracksActions.desiredTrackType(value) #@setState({trackType: value}) initialScan: (e) -> e.preventDefault() ConfigureTracksActions.vstScan() dontSeePlugin: (e) -> e.preventDefault() context.JK.popExternalLink('https://jamkazam.desk.com/customer/portal/articles/2252557-adding-a-scan-folder-path-for-plugins') vstOperation: (e, data) -> if data.vstOperation == 'scan' ConfigureTracksActions.vstScan() else if data.vstOperation == 'clear' ConfigureTracksActions.clearVsts() else if data.vstOperation == 'manage' ConfigureTracksActions.manageVsts() manageAudioPlugins: (e) -> e.preventDefault() $root = $(@getDOMNode()) $manageAudioPlugins = $root.find('.manage-audio-plugins') $manageAudioPlugins.btOn() scanMidi: (e) -> e.preventDefault() ConfigureTracksActions.midiScan() midiInterfaceChanged: (e) -> @updateMidiAssociations() updateMidiAssociations: (e) -> $root = $(@getDOMNode()) $select = $root.find('select.midi-select') midiInterface = $select.val() $select = $root.find('select.vsts') vstSelected = $select.val() logger.debug("updateMidiAssocations", vstSelected, midiInterface) if vstSelected != 'NONE' vstSelected = {file: vstSelected} else vstSelected = null if midiInterface == '' midiInterface = null midi = @state.midiInterface || midiInterface if vstSelected? && midi? logger.debug("updating midi:#{midi} & vst: #{vstSelected.file}") ConfigureTracksActions.associateVSTWithTrack(vstSelected) setTimeout((() => ConfigureTracksActions.associateMIDIWithTrack(midi) ), 250) else if midi? logger.debug("updating midi:#{midiInterface}") ConfigureTracksActions.associateMIDIWithTrack(midiInterface) else logger.debug("unassociating midi:#{midiInterface}") ConfigureTracksActions.associateMIDIWithTrack(null) @setState({midiInterface: midiInterface}) })