Skip to content

Commit

Permalink
Partial solution to #148
Browse files Browse the repository at this point in the history
  • Loading branch information
jmiller656 committed Sep 3, 2015
1 parent c4bc767 commit 59e55df
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
44 changes: 44 additions & 0 deletions javascript/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,47 @@ instruments = {"1": "Acoustic Grand Piano",
"125":"Telephone Ring",
"126":"Helicopter",
"127":"Applause"};

ranges = {"41":[55,103],
"42":[48,91],
"43":[36,76],
"44":[28,67],
"33":[28,67],
"34":[28,67],
"35":[28,67],
"36":[28,67],
"37":[28,67],
"38":[28,67],
"39":[28,67],
"40":[28,67],
"25":[40,88],
"26":[40,88],
"27":[40,88],
"28":[40,88],
"29":[40,88],
"30":[40,88],
"31":[40,88],
"32":[40,88],
"59":[28,58],
"61":[34,77],
"58":[40,72],
"57":[55,82],
"60":[55,82],
"73":[74,102],
"74":[60,96],
"69":[58,91],
"72":[50,94],
"71":[34,75],
"68":[36,69],
"67":[44,76],
"66":[49,81],
"10":[79,108],
"14":[65,108],
"12":[53,89],
"13":[45,96],
"9":[60,108],
"15":[60,77],
"48":[40,55],
"7":[29,89],
"47":[24,103]
};
14 changes: 11 additions & 3 deletions libs/timbrejs/Instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ Instrument.prototype.setBpm = function(bpm){
}
//Preload all notes in the collection
Instrument.prototype.buildNotes= function(){
var range = this.getMaxMin();
var newNotes = {};
for(var i = 0; i < this.infoCollection.collection.length; i++){
for(var j = 0; j < this.infoCollection.collection[i].array.length; j++){
var key =(parseInt(this.infoCollection.collection[i].array[j]));
newNotes[key] = key+30;
newNotes[key] = key+range[0];
}
}
var toSort = [];
Expand All @@ -243,8 +244,8 @@ Instrument.prototype.buildNotes= function(){
else
return 0;
});
if(toSort[toSort.length-1]>100){
var mult = 100/toSort[toSort.length-1];
if(toSort[toSort.length-1]>range[1]){
var mult = range[1]/toSort[toSort.length-1];
for(var i = 0; i<toSort.length; i++){
toSort[i] = parseInt(mult*toSort[i]);
}
Expand Down Expand Up @@ -275,4 +276,11 @@ Instrument.prototype.stop = function(){
this.t.stop();
this.playing = false;
this.paused = false;
}

Instrument.prototype.getMaxMin = function(){
if(ranges[this.number])
return ranges[this.number];
else
return [30,100];
}

0 comments on commit 59e55df

Please sign in to comment.