User Tools

Site Tools


midi_scripting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
midi_scripting [2018/11/25 15:36]
be.ing [Soft-takeover] clarify when softTakeoverIgnoreNextValue should be called
midi_scripting [2019/07/08 09:20] (current)
swiftb0y fixed slight formatting issues
Line 1: Line 1:
-====== Controller Scripting ======+ ====== Controller Scripting ======
  
 In order to support the features of many MIDI controllers,​ Mixxx offers what we call MIDI Scripting (introduced in Mixxx v1.7.0). It enables MIDI controls to be mapped to [[http://​doc.trolltech.com/​4.5/​qtscript.html|QtScript]] (also known as [[http://​en.wikipedia.org/​wiki/​JavaScript_syntax|Javascript]]/​[[http://​www.ecma-international.org/​publications/​standards/​Ecma-262.htm|EMCAScript]]) functions, allowing mappings to manage complex behaviors. These user-created functions can then do anything desired with the MIDI event info such as affect different controls depending on whether another button is pressed, adjust incoming control values to work better with Mixxx (i.e. for [[#​scratching]]),​ send messages to LED displays on the controller, or even [[#turning a 2 deck controller into a 4 deck controller|turn a 2 deck controller into a 4 deck controller]]. In order to support the features of many MIDI controllers,​ Mixxx offers what we call MIDI Scripting (introduced in Mixxx v1.7.0). It enables MIDI controls to be mapped to [[http://​doc.trolltech.com/​4.5/​qtscript.html|QtScript]] (also known as [[http://​en.wikipedia.org/​wiki/​JavaScript_syntax|Javascript]]/​[[http://​www.ecma-international.org/​publications/​standards/​Ecma-262.htm|EMCAScript]]) functions, allowing mappings to manage complex behaviors. These user-created functions can then do anything desired with the MIDI event info such as affect different controls depending on whether another button is pressed, adjust incoming control values to work better with Mixxx (i.e. for [[#​scratching]]),​ send messages to LED displays on the controller, or even [[#turning a 2 deck controller into a 4 deck controller|turn a 2 deck controller into a 4 deck controller]].
Line 201: Line 201:
 syncConnection = engine.makeConnection('​[Channel3]',​ '​sync_enabled',​ syncButtonOutputCallback);​ syncConnection = engine.makeConnection('​[Channel3]',​ '​sync_enabled',​ syncButtonOutputCallback);​
 syncConnection.trigger();​ syncConnection.trigger();​
 +</​code>​
 +
 +//New in Mixxx 2.3:// You can check if a connection is disconnected by checking ''​isConnected''​ or by comparing the return value of ''​disconnect()'':​
 +
 +<code javascript>​
 +var syncConnection = engine.makeConnection('​[Channel1]',​ '​sync_enabled',​ function () {});
 +
 +print(syncConnection.isConnected);​ // prints true
 +var successful_disconnect = syncConnection.disconnect();​
 +if (successful_disconnect) {
 +    print("​syncConnection has been successfully disconnected"​);​
 +} else {
 +    print("​There was an error disconnecting SyncConnection"​);​
 +    // can happen when the connection has already been disconnected
 +}
 +print(syncConnection.isConnected);​ // prints false in most cases
 +
 </​code>​ </​code>​
  
Line 426: Line 443:
 </​code>​ </​code>​
  
 +===== Color API =====
 +
 +As most DJing applications,​ mixxx is capable of colored hotcues. There are several ways of accessing and processing color information in scripts. To keep compability with color limited hardware, we provide a [[hotcue_colors|8 color colorpalette]].
 +Each of those colors has a unique ID. This ID can be retrieved via the ''​engine.getValue('​[ChannelN]',​ '​hotcue_X_color_id'​)''​ (where N and X are the respective Deck and hotcue whose information is being accessed).
 +The color API features two methods:
 +
 +  * **color.predefinedColorFromID**(//​id//​) - returns a single color object by the provided ID.
 +  * **color.predefinedColorsList**() - returns the whole color palette in the form of a color object array. Since controllers handle colors differently from model to model, it is up to you to interpret the color and send it to the controller.
 +
 +To prevent some code duplication and to provide a more robust API, a new color object was created. It can be retrieved by using ''​color.predefinedColorFromID(id)''​ and it returns a struct/​hashmap/​dictionary which contain the properties of the colors in the Color palette. It contains the following properties:
 +
 +  * **red** - red color channel (//8-bit precision//​).
 +  * **green** - (green color channel (//8-bit precision//​).
 +  * **blue** - (blue color channel (//8-bit precision//​).
 +  * **alpha** - alpha color channel (//8-bit precision//​);​ currently unused.
 +  * **id** - internal ID of the color.
 +
 +Since these Methods might seem a bit confusing, we provide hotcuebutton class via [[components_js|Components JS]], which is able to take care of the color feature automatically (see [[components_js#​hotcuebutton|Components JS Hotcue]]).
 ===== Helper functions ===== ===== Helper functions =====
  
midi_scripting.1543178206.txt.gz ยท Last modified: 2018/11/25 15:36 by be.ing