PageRenderTime 23ms CodeModel.GetById 2ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/main.lua

https://code.google.com/p/airmann-faderport-driver/
Lua | 239 lines | 116 code | 56 blank | 67 comment | 2 complexity | c52a48f1eaa140883288b0cb1b9240f2 MD5 | raw file
  1--[[------------------------------------------------------------------------------------
  2
  3  Airmann's FaderPort Renoise Driver
  4  
  5  A Renoise tool for integration of PreSonus FaderPort DAW Controller
  6
  7
  8  Copyright 2010 Matthias Ehrmann, 
  9  
 10  Licensed under the Apache License, Version 2.0 (the "License");
 11  you may not use this file except in compliance with the License. 
 12  You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
 13  
 14  Unless required by applicable law or agreed to in writing, software distributed 
 15  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 16  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
 17  language governing permissions and limitations under the License. 
 18  
 19-------------------------------------------------------------------------------------]]--
 20
 21require "FaderPort"
 22
 23--[[ locals ]] ---------------------------------------------------------------
 24
 25local fader_port = nil 
 26
 27--[[ globals ]] --------------------------------------------------------------
 28
 29-- preferences
 30prefs = renoise.Document.create("FaderPortPreferences") {  
 31    
 32    dump_midi = false, -- dump midi messages
 33    
 34    auto_connect = true, -- true: Renoise connects to FaderPort automatically during start up
 35    
 36    default_is_post_fx_mixer = true, -- true: FaderPort driver starts in post fx mixer mode, false: in pre fx mixer mode
 37    
 38    latch_is_default_write_mode = true, -- true: default fader write mode is "latch", 
 39                                        -- false: default fader write mode is "write"
 40    
 41    sticky_mode_support = true, -- sticky mode available (trns button)
 42    
 43    undo_workaround = false, -- use dirty undo workaround to avoid massive creation of undo data
 44                             -- IMPORTANT: doesn't work WITHOUT FaderPort additional power supply !
 45                            
 46    switch_off_when_app_resigned = false, -- reset FadePort state whenever Renoise is not the active Window
 47                                          -- and re-initialize state whenever Renoise get the active Window
 48                                          -- This is important if you want to use FaderPort for more than
 49                                          -- one Renoise instance simultaneously          
 50                          
 51    virtual_pan_resolution = 128, -- resolution of virtual pan control (0..127)    
 52    anti_suck_min_turns = 3, -- the minimum number of hardware pan encoder turns for a virtual pan value change
 53    
 54    footswitch_pressed_signal = 1, -- either 0 or 1: means: signals for footswitch pressed / released can be swapped. 
 55                                   -- This is helpfull for compensation of varying footswitch wiring   
 56     
 57    midi_in_name = "FaderPort", -- name of MIDI in device
 58    midi_out_name = "FaderPort", -- name of MIDI out device
 59    
 60    -- list of device specific fader/pan binding pairs
 61    dsp_binding_list = {
 62    
 63    
 64      -- IMPORTANT HINT
 65      -- the order/focus of the bindings was laid on (final) mixing and not creative sound design
 66      -- means: level and stereo parameters like wet/gain/pan/width are usually the first binding pairs.
 67      -- E.g. compressors first binding pair is makeup and not threshold and so on
 68    
 69      
 70      --------------------- NATIVE DEVICES --------------------------------    
 71       
 72      -- Delay
 73      -- hint: if line sync is active 1/2 can be modfified, but you will see nothing in Renoise.
 74      -- Moreover 7/8 are not accessible, instead 12/13 are accessible if line sync is active
 75      "Delay","5","5","9","10","1","2","3","4","-1", 
 76                                                        
 77      "Reverb","2","3","2","4","-1", -- room size, width, damp, we assume it's used in a sendtrack with 100% wet
 78      "mpReverb","1","6","2","7","-1", -- duration, width, predelay, pan, we assume it's used in a sendtrack with 100% wet
 79       
 80      -- Dynamics
 81      "Compressor","5","5","1","2","3","4","-1", -- makeup, makeup, threshold, ratio, attack, release
 82      "Bus Compressor","5","6","1","2","3","4","-1", -- makeup, knee, threshold, ratio, attack, release
 83      "Maximizer","1","5","3","4","-1", -- boost, ceiling, peak rel, slow rel 
 84      "Gate","1","5","2","3","4","3","-1", -- threshold, floor, attack, hold, release, hold
 85       
 86      -- Filter
 87      "EQ 5","1","1","2","2","3","3","4","4","5","5","-1", -- iterate over bands
 88      "EQ 10","1","1","2","2","3","3","4","4","5","5", -- iterate over bands
 89              "6","6","7","7","8","8","9","9","10","10","-1",
 90      "Mixer EQ","1","5","3","2","2","4","-1", -- Lo. Hi, Freq, Mid, Mid, Q
 91      "Filter","2","3","2","1","4","5","-1", -- cutoff, resonance, cutoff, type, gain, inertia
 92                                               -- hint: 4 is opt. Gain value (not always shown)
 93      "Comb Filter","1","2","3","4","5","5","-1", -- freq, feedback, inertia, wet mix, dry mix, dry mix
 94      
 95      -- Modulation
 96      "Chorus","5","2","3","1","4","6","-1", -- wet, depth, feedback, rate, delay, phase
 97      "Flanger","1","5","3","2","4","6","-1", -- amount, delay, amplitude, rate, feedback, phase
 98      "Phaser","4","5","1","2","3","7","-1", -- depth , feedback, floor, ceiling, lfo rate, stages
 99      "RingMod","3","3","2","1","4","5","-1",  -- amount, amount, freq, osc, phase, inertia
100      
101      -- Shape
102      "Cabinet Simulator","4","5","3","3","-1", -- wet, dry , gain, gain                          
103      "Distortion","4","5","3","2","1","1","-1", -- wet, dry, tone, drive, mode, mode 
104      "LofiMat","4","5","2","1","3","6","-1", -- wet, dry, rate, bit crunch, noise, smooth
105      "Scream Filter","3","4","2","1","3","5","-1", -- cutoff, resonance, distortion, cutoff, inertia
106       
107       -- Tools
108      "Gainer","1","2","-1", -- Gain, Pan
109      "DC Offset","1","2","-1", -- offset, auto dc on/off
110      "Stereo Expander","1","2","-1", -- expand, surround
111       
112      -- #Routing
113      "#Line Input","2","1","-1", -- volume, panning
114      "#ReWire Input","2","1","-1", -- volume, panning
115      "#Send","1","2","-1", -- amount, receiver
116      "#Multiband Send","1","7","3","8","5","8","2","2","4","4","6","6","-1", -- Amount1, Low, Amount2, High, Amount3, High, Receiver 1,2,3   
117       
118      -- *Meta Automation
119      "*Instr. Automation","1","2","3","4","5","6","7", 
120                           "8","9","10","11","12","13","14","-1", -- iterate over parameters
121      "*Instr. MIDI Control","1","2","3","4","5","6","7", 
122                           "8","9","10","11","12","13","14","-1", -- iterate over channels
123                           
124      -- *Mapping
125      "*Hydra","1","1","5","6","10","11","15","16",
126                                "20","21","25","26","30","31","35","36",
127                                "40","41","45","46","-1", -- input, input, iterate over parameters
128      "*XY Pad","2","1","6","7","11","12","-1",  -- x,y, x-min, x-max, y-min, y-max 
129                                                    -- Hint: auto reset not supported
130       
131      -- *Modulation 
132      "*Key Tracker","4","5","-1", -- min, max
133      "*LFO","4","5","6","7","-1", -- amplitude, offset, freq, type
134      "*Signal Follower","9","6","7","8","10","11","-1", -- sensitivity, dest off, attack, release, lp, hp
135      "*Velocity Tracker","4","5","-1", -- min, max 
136       
137      --------------------------- VST's --------------------------------------
138       
139      --Voxengo
140      "VST: Voxengo: Elephant","3","4","-1", -- in, out
141      "VST: Voxengo: Polysquasher", "5","1","3","4","2","2","-1" -- output,bypass, threshold, ratio, oversample, oversample      
142       
143    }
144  }  
145 
146prefs:load_from("config.xml")
147--prefs:save_as("config.xml")
148
149
150--[[ initialize ]] --------------------------------------------------------------
151
152-- instantiate driver
153if (not fader_port) then
154  fader_port = FaderPort()
155end
156
157if (fader_port) then
158  
159  --[[ DEBUG: all lights on test 
160  fader_port.all_lights_on()  
161  --]]
162 
163  --[[ DEBUG: funky lights test
164  fader_port.funky_lights()
165  --]]
166
167  -- add menu entries, keybindings 
168
169  -- reset
170  renoise.tool():add_menu_entry {
171    name = "Main Menu:Tools:FaderPort:Reset",
172    invoke = function() fader_port:reset() end
173  }
174
175  renoise.tool():add_keybinding {
176    name = "Global:Tools:Reset FaderPort",
177    invoke = function() fader_port:reset() end
178  }
179  
180  -- connect
181  renoise.tool():add_menu_entry {
182    name = "--- Main Menu:Tools:FaderPort:Connect",
183    invoke = function() fader_port:connect() end
184  }
185
186  renoise.tool():add_keybinding {
187    name = "Global:Tools:Connect to FaderPort",
188    invoke = function() fader_port:connect() end
189  }   
190
191  -- disconnect  
192  renoise.tool():add_menu_entry {
193    name = "Main Menu:Tools:FaderPort:Disconnect",
194    invoke = function() fader_port:disconnect() end
195  }
196
197  renoise.tool():add_keybinding {
198    name = "Global:Tools:Disconnect from FaderPort",
199    invoke = function() fader_port:disconnect() end
200  }  
201
202  -- auto connect
203  renoise.tool():add_menu_entry {
204    name = "--- Main Menu:Tools:FaderPort:Auto Connect",
205    invoke = function() fader_port:toggle_auto_connect() end,
206    selected = function() return prefs.auto_connect.value end
207  }
208
209  -- undo workaround  
210  renoise.tool():add_menu_entry {
211    name = "--- Main Menu:Tools:FaderPort:Undo Workaround",
212    invoke = function() fader_port:toggle_undo_workaround() end,
213    selected = function() return prefs.undo_workaround.value end
214  }
215
216  renoise.tool():add_keybinding {
217    name = "Global:Tools:Toggle FaderPort Undo Workaround",
218    invoke = function() fader_port:toggle_undo_workaround() end,
219    selected = function() return prefs.undo_workaround.value end
220  }  
221
222  -- device info dialog  
223  renoise.tool():add_menu_entry {
224    name = "Main Menu:View:FaderPort Device Infos",
225    invoke = function() fader_port:toggle_device_info_dialog() end,
226    selected = function() return fader_port:device_info_dialog_visible() end
227  }
228  
229  renoise.tool():add_keybinding {
230    name = "Global:View:FaderPort Device Infos",
231    invoke = function() fader_port:toggle_device_info_dialog() end,
232    selected = function() return fader_port:device_info_dialog_visible() end
233  }  
234 
235end  
236
237--[[ debug ]]--------------------------------------------------------------]]--
238
239_AUTO_RELOAD_DEBUG = true