Skip to content

Commit

Permalink
Can now change frequency while sample is playing without stutter
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonard Tirulnikov committed Jul 9, 2011
1 parent afa264b commit 1d6759b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dsp.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,10 @@ Sampler.prototype.generate = function() {
};

Sampler.prototype.setFreq = function(frequency) {
this.frequency = frequency;
this.step = this.frequency / this.rootFrequency;
var totalProcessed = this.samplesProcessed * this.step;
this.frequency = frequency;
this.step = this.frequency / this.rootFrequency;
this.samplesProcessed = Math.round(totalProcessed/this.step);
};

Sampler.prototype.reset = function() {
Expand Down

0 comments on commit 1d6759b

Please sign in to comment.