Skip to content

Commit

Permalink
Added new variable to booper/sampler for easy identification. Also fi…
Browse files Browse the repository at this point in the history
…xed stepDuration calculation.

As requested in #130 's comments, a new string was added to CreateBooper and CreateSampler's functions named "instrumentName" which returns "booper" or "sampler" depending on the function.

Thanks to this change, hourly bell chimes and the town tune editor's "booper" now play at different speeds, thus allowing the hourly bell chime to sound nearly accurate to New Horizons!
  • Loading branch information
Xane123 committed May 4, 2020
1 parent fcf5b04 commit 53761bf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/global/tune_player.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
var createBooper = function(audioContext) {

var instrumentName = "booper";
var attack = 0.05; //in seconds
var decay = 0.1; //in seconds
var release = 0.15; //in seconds
Expand Down Expand Up @@ -88,6 +89,7 @@
* @returns {method} playNote
*/
var createSampler = function(audioContext) {
var instrumentName = "sampler";
var bellBuffer;
var startPoints = [null, null];
var chimeLength = 3.8;
Expand Down Expand Up @@ -169,9 +171,7 @@ var createTunePlayer = function(audioContext, bpm) {

var getStepDuration = function(instrument, bpm) {
if(stepDuration) return stepDuration;
stepDuration = (instrument == 'sampler') ? 1 / (bpm / 90) : 1 / (bpm / 60);
//alert(instrument.toString());
//stepDuration = 1 / (bpm / 90); //This affects the tune's speed in both the editor and hourly chime. Find a better way to slow down the bells.
stepDuration = (instrument.instrumentName == 'sampler') ? 1 / (bpm / 90) : 1 / (bpm / 60);
return stepDuration;
};

Expand Down

0 comments on commit 53761bf

Please sign in to comment.