Skip to content

Commit 46f87e4

Browse files
Merge pull request #639 from satyasaibhushan/bug-fixing
Bug fixing
2 parents 37a7644 + c2a3c71 commit 46f87e4

File tree

7 files changed

+23
-37
lines changed

7 files changed

+23
-37
lines changed

examples/spatial_panning_listener/sketch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ function draw() {
8484

8585

8686
//Position the sound in 3 dimensions
87-
panner3d.position( flock.boids[0].position.x,
87+
panner3d.set( flock.boids[0].position.x,
8888
flock.boids[0].position.y,
8989
flock.boids[0].position.z);
9090

91-
listener3d.spatializer.setPosition(0,0,cam_z_pos)
91+
listener3d.position(0,0,cam_z_pos)
9292
//listener3d.orientX(cam_y_rot)
9393
//listener3d.spatializer.orientY(cam_x_rot)
9494
// listener3d.spatializer.setOrientation(cam_x_rot,cam_y_rot,0)

src/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ p5.BandPass = BandPass;
8888
import EQ from './eq';
8989
p5.EQ = EQ;
9090

91-
import listener3D from './listener3d';
92-
p5.listener3D = listener3D;
91+
import Listener3D from './listener3d';
92+
p5.Listener3D = Listener3D;
9393

9494
import Panner3D from './panner3d';
9595
p5.Panner3D = Panner3D;

src/looper.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,14 @@ class Score {
387387
constructor() {
388388
// for all of the arguments
389389
this.parts = [];
390-
this.currentPart = new Array(arguments.length);
390+
this.currentPart = 0;
391391

392392
var thisScore = this;
393393
for (var i in arguments) {
394394
this.parts[i] = arguments[i];
395-
this.parts[i].nextPart = this.parts[i + 1];
395+
if (i > 0) {
396+
this.parts[i - 1].nextPart = this.parts[i];
397+
}
396398
this.parts[i].onended = function () {
397399
thisScore.resetPart(i);
398400
playNextPart(thisScore);

src/polysynth.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import p5sound from './main';
22
import TimelineSignal from 'Tone/signal/TimelineSignal.js';
3-
import { noteToFreq, freqToMidi } from './helpers';
3+
import { noteToFreq } from './helpers';
44

55
/**
66
* An AudioVoice is used as a single voice for sound synthesis.
@@ -274,9 +274,7 @@ class PolySynth {
274274
else {
275275
currentVoice = this._oldest;
276276

277-
oldestNote = freqToMidi(
278-
this.audiovoices[this._oldest].oscillator.freq().value
279-
);
277+
let oldestNote = this.audiovoices[this._oldest].oscillator.freq().value;
280278
this.noteRelease(oldestNote);
281279
this._oldest = (this._oldest + 1) % (this.maxVoices - 1);
282280
}
@@ -389,6 +387,8 @@ class PolySynth {
389387
this.notes[n].dispose();
390388
delete this.notes[n];
391389
}
390+
this._newest = 0;
391+
this._oldest = 0;
392392
return;
393393
}
394394

@@ -400,10 +400,7 @@ class PolySynth {
400400
} else {
401401
//Find the scheduled change in this._voicesInUse that will be previous to this new note
402402
//subtract 1 and schedule this value at time 't', when this note will stop playing
403-
var previousVal = Math.max(
404-
~~this._voicesInUse.getValueAtTime(t).value,
405-
1
406-
);
403+
var previousVal = Math.max(~~this._voicesInUse.getValueAtTime(t), 1);
407404
this._voicesInUse.setValueAtTime(previousVal - 1, t);
408405
//Then update all scheduled values that follow to decrease by 1 but never go below 0
409406
if (previousVal > 0) {

src/reverb.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,7 @@ class Reverb extends Effect {
103103
*/
104104
process(src, seconds, decayRate, reverse) {
105105
src.connect(this.input);
106-
var rebuild = false;
107-
if (seconds) {
108-
this._seconds = seconds;
109-
rebuild = true;
110-
}
111-
if (decayRate) {
112-
this._decay = decayRate;
113-
}
114-
if (reverse) {
115-
this._reverse = reverse;
116-
}
117-
if (rebuild) {
118-
this._buildImpulse();
119-
}
106+
this.set(seconds, decayRate, reverse);
120107
}
121108

122109
/**

src/soundfile.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,11 @@ class SoundFile {
515515
* </code></div>
516516
*/
517517
playMode(str) {
518-
var s = str.toLowerCase();
518+
var s = str.toLowerCase().trim();
519519

520520
// if restart, stop all other sounds from playing
521521
if (s === 'restart' && this.buffer && this.bufferSourceNode) {
522-
for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) {
522+
for (var i = 0; i < this.bufferSourceNodes.length; i++) {
523523
var now = p5sound.audiocontext.currentTime;
524524
this.bufferSourceNodes[i].stop(now);
525525
}
@@ -715,10 +715,9 @@ class SoundFile {
715715
this._paused = false;
716716
} else if (this.buffer && this.bufferSourceNode) {
717717
var now = p5sound.audiocontext.currentTime;
718-
var t = time || 0;
719718
this.pauseTime = 0;
720-
this.bufferSourceNode.stop(now + t);
721-
this._counterNode.stop(now + t);
719+
this.bufferSourceNode.stop(now + time);
720+
this._counterNode.stop(now + time);
722721
this._playing = false;
723722
this._paused = false;
724723
}
@@ -999,7 +998,7 @@ class SoundFile {
999998
* @return {Number} [channels]
1000999
*/
10011000
channels() {
1002-
return this.buffer.numberOfChannels;
1001+
if (this.buffer) return this.buffer.numberOfChannels;
10031002
}
10041003

10051004
/**
@@ -1010,7 +1009,7 @@ class SoundFile {
10101009
* @return {Number} [sampleRate]
10111010
*/
10121011
sampleRate() {
1013-
return this.buffer.sampleRate;
1012+
if (this.buffer) return this.buffer.sampleRate;
10141013
}
10151014

10161015
/**
@@ -1022,7 +1021,7 @@ class SoundFile {
10221021
* @return {Number} [sampleCount]
10231022
*/
10241023
frames() {
1025-
return this.buffer.length;
1024+
if (this.buffer) return this.buffer.length;
10261025
}
10271026

10281027
/**
@@ -1045,7 +1044,7 @@ class SoundFile {
10451044
if (this.buffer) {
10461045
// set length to window's width if no length is provided
10471046
if (!length) {
1048-
length = window.width * 5;
1047+
length = window.innerWidth * 5;
10491048
}
10501049
if (this.buffer) {
10511050
var buffer = this.buffer;

test/tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ import('./tests/p5.SoundRecorder.js');
1414
import('./tests/p5.SoundFile.js');
1515
import('./tests/p5.Amplitude.js');
1616
import('./tests/p5.Oscillator.js');
17+
import('./tests/p5.Reverb.js');

0 commit comments

Comments
 (0)