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 / Numark-NS7-scripts.js < prev    next >
Text File  |  2011-02-04  |  3KB  |  112 lines

  1. /**
  2.  * Numark NS7 controller script v1.9.0
  3.  * Copyright (C) 2010  Anders Gunnarsson
  4.  *
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License
  7.  * as published by the Free Software Foundation; either version 2
  8.  * of the License, or (at your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  18.  **/
  19. NumarkNS7 = new Controller();
  20. NumarkNS7.RateRanges = [0.08, 0.10, 0.30, 1.00];
  21.  
  22.  
  23.  
  24. NumarkNS7.Deck = Deck;
  25. NumarkNS7.Deck.scratchMode = false;
  26. NumarkNS7.Deck.rateRange = NumarkNS7.RateRanges[1];
  27.  
  28. NumarkNS7.Deck.prototype.rateRangeHandler = function(value) {
  29.    if(value == ButtonState.pressed) {
  30.       var i;
  31.       for(i=0; i < NumarkNS7.RateRanges.length; i++) {
  32.          if(NumarkNS7.RateRanges[i] == this.rateRange) {
  33.             break;
  34.          }
  35.       }
  36.       
  37.       //Found correct value increment by one
  38.       i++;
  39.       
  40.       //Wrap if needed
  41.       if(i == NumarkNS7.RateRanges.length) {
  42.          i = 0;
  43.       }
  44.       
  45.       this.rateRange = NumarkNS7.RateRanges[i];
  46.    }
  47. }
  48.  
  49. NumarkNS7.Deck.prototype.scratchHandler = function(value) {
  50.    if(value == ButtonState.pressed) {
  51.       if(this.scratchMode) {
  52.          this.scratchMode = false;
  53.          this.Buttons.Scratch.setLed(LedState.on);
  54.       } else {
  55.          this.scratchMode = true;
  56.          this.Buttons.Scratch.setLed(LedState.on);
  57.       }
  58.    }
  59. }
  60.  
  61. NumarkNS7.Deck.prototype.jogMove = function(value) {
  62.    if(!isNaN(this.previousJogValue)) {
  63.       var offset = value - this.previousJogValue;
  64.  
  65.       if(offset > 63) {
  66.          offset = offset - 128;
  67.       } else if(offset < -63) {
  68.          offset = offset + 128;
  69.       }
  70.  
  71.       if(this.scratchMode) {
  72.          engine.scratchTick(this.deckNumber, offset);
  73.       } else {
  74.          engine.setValue(this.group,"jog", offset);
  75.       }
  76.    }
  77.    this.previousJogValue = value;
  78. }
  79.  
  80. NumarkNS7.Decks = {"Left":new NumarkNS7.Deck(1,"[Channel1]"), "Right":new NumarkNS7.Deck(2,"[Channel2]")};
  81. NumarkNS7.GroupToDeck = {"[Channel1]":"Left", "[Channel2]":"Right"};
  82.  
  83. NumarkNS7.GetDeck = function(group) {
  84.    try {
  85.       return NumarkNS7.Decks[NumarkNS7.GroupToDeck[group]];
  86.    } catch(ex) {
  87.       return null;
  88.    }
  89. }
  90.  
  91. NumarkNS7.Decks.Left.addButton("RateRange", new Button(), "rateRangeHandler");
  92. NumarkNS7.Decks.Left.addButton("Scratch", new Button(), "scratchHandler");
  93.  
  94. NumarkNS7.Decks.Right.addButton("RateRange", new Button(), "rateRangeHandler");
  95. NumarkNS7.Decks.Right.addButton("Scratch", new Button(), "scratchHandler");
  96.  
  97.  
  98. NumarkNS7.rate_range = function(channel, control, value, status, group) {
  99.    var deck = NumarkNS7.GetDeck(group);
  100.    deck.Buttons.RateRange.handleEvent(value);
  101. }
  102.  
  103. NumarkNS7.scratch = function(channel, control, value, status, group) {
  104.    var deck = NumarkNS7.GetDeck(group);
  105.    deck.Buttons.Scratch.handleEvent(value);
  106. }
  107.  
  108. NumarkNS7.jog_move = function(channel, control, value, status, group) {
  109.    var deck = NumarkNS7.GetDeck(group);
  110.    deck.jogMove(value);
  111. }
  112.