Skip to content

Commit c39bb24

Browse files
Added detune and playback rate to playback and sample. also added empty reverb class.
1 parent a5252a5 commit c39bb24

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/Playback.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class Playback extends AbstractAudioWrapper {
7575
this.delay = isNaN(Number(options.delay )) ? 0 : Number(options.delay); // 0 default
7676
this.offset = isNaN(Number(options.offset)) ? 0 : Number(options.offset); // 0 default
7777
this.playDuration = options.playDuration; // No default needed, undefined and null are both valid values
78+
this.playbackRate = isNaN(Number(options.playbackRate)) ? 1 : Number(options.playbackRate);
79+
this.detune = isNaN(Number(options.detune)) ? 0 : Number(options.detune);
7880

7981
this._play(this.delay, this.offset, this.playDuration);
8082
}
@@ -93,6 +95,8 @@ class Playback extends AbstractAudioWrapper {
9395

9496
this.fademaskerNode.gain.value = 0;
9597
this._sourceNode || this._createSourceNode();
98+
this._sourceNode.playbackRate.value = this.playbackRate;
99+
this._sourceNode.detune.value = this.detune;
96100
this._sourceNode.start(ctx.currentTime + delay, offset, duration);
97101
this.declicker.fadeIn();
98102

src/Sample.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ class Sample extends AbstractAudioWrapper {
6363
this.loops = isNaN(Number(options.loops )) ? 0 : Math.max(Number(options.loops) | 0, -1); // 0 default, >= -1, integers only
6464
this.delay = isNaN(Number(options.delay )) ? 0 : Number(options.delay); // 0 default
6565
this.pan = isNaN(Number(options.pan )) ? 0 : Number(options.pan); // 0 default
66-
this.offset = isNaN(Number(options.offset)) ? 0 : Number(options.offset); // 0 default
66+
this.offset = isNaN(Number(options.offset)) ? 0 : Number(options.offset); // 0 default
67+
this.playbackRate = isNaN(Number(options.playbackRate)) ? 1 : Number(options.playbackRate);
68+
this.detune = isNaN(Number(options.detune)) ? 0 : Number(options.detune);
6769

6870
this.playDuration = options.playDuration; // No default needed, undefined means "play until end"
6971

@@ -273,7 +275,9 @@ class Sample extends AbstractAudioWrapper {
273275
pan: this.pan,
274276
offset: this.offset,
275277
interrupt: this.interrupt,
276-
duration: this.playDuration
278+
duration: this.playDuration,
279+
playbackRate: this.playbackRate,
280+
detune: this.detune
277281
};
278282
}
279283

@@ -288,6 +292,9 @@ class Sample extends AbstractAudioWrapper {
288292

289293
this.interrupt = ( o.interrupt === undefined ? this.interrupt : o.interrupt);
290294
this.playDuration = o.hasOwnProperty('playDuration') ? o.playDuration : this.playDuration; // "undefined" is a valid value (means play to end). Null, in SJS2, also means play to end.
295+
296+
this.playbackRate = isNaN(Number(o.playbackRate)) ? this.playbackRate : Number(o.playbackRate);
297+
this.detune = isNaN(Number(o.detune)) ? this.detune : Number(o.detune);
291298
}
292299

293300
}

src/effects/Reverb.js

Whitespace-only changes.

0 commit comments

Comments
 (0)