home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Aplikacje_64-bitowe / Mixxx / mixxx-1.9.0-win64.exe / midi / Vestax-VCI-100-scripts.js < prev   
Text File  |  2010-12-04  |  6KB  |  208 lines

  1. VestaxVCI100 = new function() {
  2.    this.group = "[Master]";
  3.    this.loopHotcueDeck = null;
  4.    this.shiftMode = false;
  5.    this.jogPlaylistScrollMode = false;
  6.    this.Controls = [];
  7.    this.Buttons = [];
  8. }
  9.  
  10. VestaxVCI100.ButtonState = {"released":0x00, "pressed":0x7F};
  11. VestaxVCI100.Button = function (controlId) {
  12.    this.controlId = controlId;
  13.    this.state = VestaxVCI100.ButtonState.released;
  14. };
  15. VestaxVCI100.Button.prototype.handleEvent = function(value) {
  16.    this.handler(value);
  17. };
  18.  
  19. VestaxVCI100.addButton = function(buttonName, button, eventHandler) {
  20.    if(eventHandler) {
  21.       var executionEnvironment = this;
  22.       function handler(value) {
  23.          button.state = value;
  24.          executionEnvironment[eventHandler](value);
  25.       }
  26.       button.handler = handler;
  27.    }
  28.    this.Buttons[buttonName] = button; 
  29. };
  30.  
  31. VestaxVCI100.key1Handler = function(value) {
  32.    var deck = this.loopHotcueDeck;
  33.    if(value && deck != null) {
  34.       if(deck.loop) {
  35.          engine.setValue(deck.group,"loop_in",1);
  36.       } else if(deck.hotcue) {
  37.          if(deck.Buttons.Hotcue.state == VestaxVCI100.ButtonState.pressed) {
  38.             engine.setValue(deck.group,"hotcue_1_set", 1);
  39.          } else {
  40.             engine.setValue(deck.group,"hotcue_1_goto", 1);
  41.          }
  42.       }
  43.    }
  44. };
  45.  
  46. VestaxVCI100.key2Handler = function(value) {
  47.    var deck = this.loopHotcueDeck;
  48.    if(value && deck != null) {
  49.       if(deck.loop) {
  50.          engine.setValue(deck.group,"loop_out",1);
  51.       } else if(deck.hotcue) {
  52.          if(deck.Buttons.Hotcue.state == VestaxVCI100.ButtonState.pressed) {
  53.             engine.setValue(deck.group,"hotcue_2_set", 1);
  54.          } else {
  55.             engine.setValue(deck.group,"hotcue_2_goto", 1);
  56.          }
  57.       }
  58.    }
  59. };
  60.  
  61. VestaxVCI100.key3Handler = function(value) {
  62.    var deck = this.loopHotcueDeck;
  63.    if(value && deck != null) {
  64.       if(deck.loop) {
  65.          engine.setValue(deck.group,"reloop_exit",1);
  66.       } else if(deck.hotcue) {
  67.          if(deck.Buttons.Hotcue.state == VestaxVCI100.ButtonState.pressed) {
  68.             engine.setValue(deck.group,"hotcue_3_set", 1);
  69.          } else {
  70.             engine.setValue(deck.group,"hotcue_3_goto", 1);
  71.          }
  72.       }
  73.    }
  74. };
  75.  
  76. VestaxVCI100.addButton("Key1", new VestaxVCI100.Button(0x62), "key1Handler");
  77. VestaxVCI100.addButton("Key2", new VestaxVCI100.Button(0x63), "key2Handler");
  78. VestaxVCI100.addButton("Key3", new VestaxVCI100.Button(0x64), "key3Handler");
  79.  
  80.  
  81. VestaxVCI100.Deck = function (deckNumber, group) {
  82.    this.deckNumber = deckNumber;
  83.    this.group = group;
  84.    this.vinylMode = true;
  85.    this.scratching = false;
  86.    this.loop = false;
  87.    this.hotcue = false;
  88.    this.Buttons = [];
  89. }
  90.  
  91. VestaxVCI100.Deck.prototype.addButton = VestaxVCI100.addButton;
  92.  
  93. VestaxVCI100.Deck.prototype.jogMove = function(jogValue) {
  94.    jogValue = jogValue * 3;
  95.    engine.setValue(this.group,"jog", jogValue);
  96. }
  97.  
  98. VestaxVCI100.Deck.prototype.scratchMove = function(jogValue) {
  99.     engine.scratchTick(this.deckNumber, jogValue);
  100. }
  101.  
  102. VestaxVCI100.Deck.prototype.loopHandler = function(value) {
  103.    if(value) {
  104.       VestaxVCI100.loopHotcueDeck = this;
  105.       this.loop = true;
  106.       this.hotcue = false;
  107.    }
  108. };
  109.  
  110. VestaxVCI100.Deck.prototype.hotcueHandler = function(value) {
  111.    if(value) {
  112.       VestaxVCI100.loopHotcueDeck = this;
  113.       this.hotcue = true;
  114.       this.loop = false;
  115.    }
  116. };
  117.  
  118. VestaxVCI100.Decks = {"Left":new VestaxVCI100.Deck(1,"[Channel1]"), "Right":new VestaxVCI100.Deck(2,"[Channel2]")};
  119. VestaxVCI100.GroupToDeck = {"[Channel1]":"Left", "[Channel2]":"Right"};
  120.  
  121. VestaxVCI100.GetDeck = function(group) {
  122.    try {
  123.       return VestaxVCI100.Decks[VestaxVCI100.GroupToDeck[group]];
  124.    } catch(ex) {
  125.       return null;
  126.    }
  127. }
  128.  
  129. VestaxVCI100.Decks.Left.addButton("Loop", new VestaxVCI100.Button(0x65), "loopHandler");
  130. VestaxVCI100.Decks.Left.addButton("Hotcue", new VestaxVCI100.Button(0x66), "hotcueHandler");
  131. VestaxVCI100.Decks.Right.addButton("Loop", new VestaxVCI100.Button(0x67), "loopHandler");
  132. VestaxVCI100.Decks.Right.addButton("Hotcue", new VestaxVCI100.Button(0x68), "hotcueHandler");
  133.  
  134. VestaxVCI100.init = function (id) {
  135.    midi.sendShortMsg(0xB0,0x62,0x7F);
  136.    midi.sendShortMsg(0xB0,0x63,0x7F);
  137.    midi.sendShortMsg(0xB0,0x64,0x7F);
  138.    
  139.    midi.sendShortMsg(0x90,0x65,0x7F);
  140.    midi.sendShortMsg(0x90,0x66,0x7F);
  141.    midi.sendShortMsg(0x90,0x67,0x7F);
  142.    midi.sendShortMsg(0x90,0x68,0x7F);
  143.    
  144.    midi.sendShortMsg(0xB0,0x64,0x00);
  145.    midi.sendShortMsg(0x90,0x67,0x00);
  146.    midi.sendShortMsg(0x80,0x68,0x00);
  147. }
  148.  
  149.  
  150. //Mapping functions
  151. VestaxVCI100.vinyl_mode = function (channel, control, value, status, group) {
  152. //   var deck = VestaxVCI100.GetDeck(group);
  153. //   if(value) {
  154. //      if(deck.vinylMode) {
  155. //         deck.vinylMode = false;
  156. //         midi.sendShortMsg(0xB0, control, 0x00);
  157. //      } else {
  158. //         deck.vinylMode = true;
  159. //         midi.sendShortMsg(0xB0, control, 0x7F);
  160. //      }
  161. //   }
  162. }
  163.  
  164. VestaxVCI100.jog_touch = function (channel, control, value, status, group) {
  165.    var deck = VestaxVCI100.GetDeck(group);
  166.    if(value) {
  167.       engine.scratchEnable(deck.deckNumber, 128*3, 45, 1.0/8, (1.0/8)/32);
  168.    } else {
  169.       engine.scratchDisable(deck.deckNumber);
  170.    }
  171. }
  172.  
  173. VestaxVCI100.jog_wheel = function (channel, control, value, status, group) {
  174.    // 41 > 7F: CW Slow > Fast ??? 
  175.    // 3F > 0 : CCW Slow > Fast ???
  176.    var jogValue = value - 0x40; // -64 to +63, - = CCW, + = CW
  177.    VestaxVCI100.GetDeck(group).jogMove(jogValue);
  178. }
  179.  
  180. VestaxVCI100.jog_wheel_scratch = function (channel, control, value, status, group) {
  181.    // 41 > 7F: CW Slow > Fast ??? 
  182.    // 3F > 0 : CCW Slow > Fast ???
  183.    var jogValue = value - 0x40; // -64 to +63, - = CCW, + = CW
  184.    VestaxVCI100.GetDeck(group).scratchMove(jogValue);
  185. }
  186.  
  187. VestaxVCI100.loopMode = function (channel, control, value, status, group) {
  188.    var deck = VestaxVCI100.GetDeck(group);
  189.    deck.Buttons.Loop.handleEvent(value);
  190. }
  191.  
  192. VestaxVCI100.hotcueMode = function (channel, control, value, status, group) {
  193.    var deck = VestaxVCI100.GetDeck(group);
  194.    deck.Buttons.Hotcue.handleEvent(value);
  195. }
  196.  
  197. VestaxVCI100.key1 = function (channel, control, value, status, group) {
  198.    VestaxVCI100.Buttons.Key1.handleEvent(value);
  199. }
  200.  
  201. VestaxVCI100.key2 = function (channel, control, value, status, group) {
  202.    VestaxVCI100.Buttons.Key2.handleEvent(value);
  203. }
  204.  
  205. VestaxVCI100.key3 = function (channel, control, value, status, group) {
  206.    VestaxVCI100.Buttons.Key3.handleEvent(value);
  207. }
  208.