Browse Source

Fix stupid bug

master
Konrad Beckmann 1 year ago
parent
commit
2aa61c3474
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      ham.js

+ 3
- 3
ham.js View File

@ -76,10 +76,10 @@ CWModulator.prototype.connect = function(audioContext) {
CWModulator.prototype.insertTone = function(audioBuffer, offset, frequency, length, attack, decay) {
var i;
attack *= this.sampleRate;
decay *= this.sampleRate;
length *= this.sampleRate;
var i;
for (i = 0; i < length; i++) {
var ramp = this.gain;
if (i < attack) {
@ -88,7 +88,7 @@ CWModulator.prototype.insertTone = function(audioBuffer, offset, frequency, leng
else if (i > length - decay) {
ramp = Utils.cosLerp(0.0, this.gain, (length - i) / decay);
}
audioBuffer[i + offset] = Math.sin(this.frequency * i * Math.PI * 2 / this.sampleRate) * ramp;
audioBuffer[i + Math.round(offset)] = Math.sin(frequency * i * Math.PI * 2 / this.sampleRate) * ramp;
}
return i;
};
@ -183,7 +183,7 @@ HamJS.prototype.transmit = function(data, stopCurrent) {
var encoded = this.modem.encode(data);
console.log('encoded = ' + encoded);
var buffer = this.modem.modulate(encoded);
console.log('buffer = ' + buffer);
console.log('buffer:', buffer);
if (stopCurrent) {


Loading…
Cancel
Save