Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #398 condition never met #446

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added examples/files/tick.mp3
Binary file not shown.
10 changes: 10 additions & 0 deletions examples/playScore/index.html
@@ -0,0 +1,10 @@
<head>
<script language="javascript" type="text/javascript" src="../../lib/p5.js"></script>

<script language="javascript" type="text/javascript" src="../../lib/addons/p5.dom.js"></script>

<script language="javascript" type="text/javascript" src="../../lib/p5.sound.js"></script>

<script language="javascript" type="text/javascript" src="sketch.js"></script>

</head>
51 changes: 51 additions & 0 deletions examples/playScore/sketch.js
@@ -0,0 +1,51 @@
/* eslint-disable strict */
let mypart, score, cnv, tick;

function preload() {
tick = loadSound('../files/tick.mp3');
}

function setup() {
cnv = createCanvas(400, 400);
textAlign(CENTER);
cnv.mousePressed(playOneTime);
cnv.doubleClicked(playMeTwice);

mypart = new p5.Part(4, 1/4);

tick.pattern = [1, 2, 3, 4];
tick.phrase = new p5.Phrase('metro', playTick, tick.pattern );
mypart.addPhrase(tick.phrase);
}

function playMeTwice() {
userStartAudio();
score = new p5.Score(mypart, mypart);
score.setBPM(55);
score.start();
}

function playOneTime() {
userStartAudio();
score = new p5.Score(mypart);
score.setBPM(55);
score.start();
}

function draw() {
background(33);
textSize(32);
fill(255);
text('click to play once', width/2, height/2-25);
text('double-click to play twice', width/2, height/2+25);
}

function playMyPart() {
userStartAudio();
score.start();
}

function playTick(time) {
tick.play(time);
}

1 change: 1 addition & 0 deletions index.html
Expand Up @@ -69,6 +69,7 @@ <h2>p5.sound
<div><a href="examples/play_soundfile">play_soundfile</a></div>
<div><a href="examples/playbackRate">playbackRate</a></div>
<div><a href="examples/playbackRatePart">playbackRatePart</a></div>
<div><a href="examples/playScore">playScore</a></div>
<div><a href="examples/polyphonicSynth-Keyboard">polyphonicSynth-Keyboard</a></div>
<div><a href="examples/pulseWaveform">pulseWaveform</a></div>
<div><a href="examples/record">record</a></div>
Expand Down
13 changes: 4 additions & 9 deletions lib/p5.sound.js
@@ -1,4 +1,4 @@
/** [p5.sound] Version: 0.3.12 - 2020-01-06 */
/** [p5.sound] Version: 0.3.13 - 2020-04-11 */
/**
* <p>p5.sound extends p5 with <a href="http://caniuse.com/audio-api"
* target="_blank">Web Audio</a> functionality including audio input,
Expand Down Expand Up @@ -5889,7 +5889,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;
*
* @method getCentroid
* @for p5.FFT
* @return {Number} Spectral Centroid Frequency Frequency of the spectral centroid in Hz.
* @return {Number} Spectral Centroid Frequency of the spectral centroid in Hz.
*
*
* @example
Expand Down Expand Up @@ -10303,7 +10303,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;
var thisScore = this;

for (var i in arguments) {
if (arguments[i] && this.parts[i]) {
if (arguments[i]) {
this.parts[i] = arguments[i];
this.parts[i].nextPart = this.parts[i + 1];

Expand All @@ -10320,11 +10320,6 @@ var __WEBPACK_AMD_DEFINE_RESULT__;
p5.Score.prototype.onended = function () {
if (this.looping) {
this.parts[0].start();
} else {
this.parts[this.parts.length - 1].onended = function () {
this.stop();
this.resetParts();
};
}

this.currentPart = 0;
Expand Down Expand Up @@ -10598,7 +10593,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;
}
};
/**
* Synchronize loops. Use this method to start two more more loops in synchronization
* Synchronize loops. Use this method to start two or more loops in synchronization
* or to start a loop in synchronization with a loop that is already playing
* This method will schedule the implicit loop in sync with the explicit master loop
* i.e. loopToStart.syncedStart(loopToSyncWith)
Expand Down
2 changes: 1 addition & 1 deletion lib/p5.sound.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/p5.sound.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/p5.sound.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -4,7 +4,7 @@
"type": "git",
"url": "https://github.com/processing/p5.js-sound.git"
},
"version": "0.3.12",
"version": "0.3.13",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.4.5",
Expand Down
7 changes: 1 addition & 6 deletions src/looper.js
Expand Up @@ -389,7 +389,7 @@ define(function(require) {

var thisScore = this;
for (var i in arguments) {
if (arguments[i] && this.parts[i]) {
if (arguments[i]) {
this.parts[i] = arguments[i];
this.parts[i].nextPart = this.parts[i + 1];
this.parts[i].onended = function() {
Expand All @@ -405,11 +405,6 @@ define(function(require) {
if (this.looping) {
// this.resetParts();
this.parts[0].start();
} else {
this.parts[this.parts.length - 1].onended = function() {
this.stop();
this.resetParts();
};
}
this.currentPart = 0;
};
Expand Down