diff --git a/src/looper.js b/src/looper.js index 2dfaf9e5..c02e1f36 100644 --- a/src/looper.js +++ b/src/looper.js @@ -387,7 +387,7 @@ class Score { constructor() { // for all of the arguments this.parts = []; - this.currentPart = new Array(arguments.length);; + this.currentPart = new Array(arguments.length); var thisScore = this; for (var i in arguments) { @@ -396,7 +396,7 @@ class Score { this.parts[i].onended = function () { thisScore.resetPart(i); playNextPart(thisScore); - }; + }; } this.looping = false; } diff --git a/test/tests/p5.FFT.js b/test/tests/p5.FFT.js index fd83baaa..578f963c 100644 --- a/test/tests/p5.FFT.js +++ b/test/tests/p5.FFT.js @@ -55,4 +55,61 @@ describe('p5.FFT', function () { expect(fft.smoothing).to.equal(0.8); expect(fft.smooth()).to.equal(0.8); }); + + let soundFile, oscillator; + it('can set Oscillator as input', function (done) { + oscillator = new p5.Oscillator(); + try { + fft.setInput(oscillator); + } catch (err) { + return expect.fail(); + } + oscillator.start(); + + setTimeout(() => { + let spectrum = fft.analyze(); + const someFrequencyIsNotZero = spectrum.some( + (frequency) => frequency !== 0 + ); + expect(someFrequencyIsNotZero).to.equal(true); + oscillator.dispose(); + done(); + }, 500); + }); + it('can set soundFile as input', function (done) { + soundFile = p5.prototype.loadSound('./testAudio/drum.mp3', () => { + soundFile.disconnect(); + try { + fft.setInput(soundFile); + } catch (err) { + return done(err); + } + soundFile.play(); + setTimeout(() => { + let spectrum = fft.analyze(); + const someFrequencyIsNotZero = spectrum.some( + (frequency) => frequency !== 0 + ); + expect(someFrequencyIsNotZero).to.equal(true); + soundFile.dispose(); + done(); + }, 500); + }); + }); + it('can handle any Unknown sources', function (done) { + let UnknownSource = { UnknownSource: 'this is a unknown object' }; + try { + fft.setInput(UnknownSource); + } catch (err) { + return done(err); + } + setTimeout(() => { + let spectrum = fft.analyze(); + const someFrequencyIsNotZero = spectrum.some( + (frequency) => frequency !== 0 + ); + expect(someFrequencyIsNotZero).to.equal(false); + done(); + }, 500); + }); });