callback in addCue is called multiple times per cue time
See original GitHub issuep5 version: 1.0.0 p5.sound version: 0.3.12 Firefox 74.0.1, Ubuntu 19.10
The callback
in addCue(time, callback, [value])
is being called multiple times per cue time. The value
remains the same until the next cue time.
Is this the desired behaviour?
I would have expected the callback
to be called only once per cue time.
To see this, go to to the online example for addCue
and modify it slightly as follows:
let mySound;
let numCalls;
function preload() {
mySound = loadSound('assets/Damscray_DancingTiger.mp3');
}
function setup() {
let cnv = createCanvas(100, 100);
cnv.mousePressed(canvasPressed);
background(220);
text('tap to play', 10, 20);
// schedule calls to changeText
mySound.addCue(0, changeText, "hello" );
mySound.addCue(0.5, changeText, "hello," );
mySound.addCue(1, changeText, "hello, p5!");
mySound.addCue(1.5, changeText, "hello, p5!!");
mySound.addCue(2, changeText, "hello, p5!!!!!");
mySound.onended(() => console.log(numCalls));
}
function changeText(val) {
background(220);
text(val, 10, 20);
++numCalls;
}
function canvasPressed() {
numCalls = 0;
mySound.play();
}
I get numCalls to be 44 or 45 and not 5. In Google Chrome it is 600 or so.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11
Top Results From Across the Web
P5 soundfile addCue is called multiple times - Libraries - Processing ...
I am using the addCue method on a p5.soundFile. I invoke this method in the setup function. The callback function i provide is...
Read more >p5.js MediaElement addCue() Method - GeeksforGeeks
time : It is a number that specifies the time in seconds relative to the media element after which the given callback function...
Read more >reference | addCue() - P5.js
Schedule events to trigger every time a MediaElement (audio/video) reaches a playback cue point. Accepts a callback function, a time (in seconds) at...
Read more >Callback function called multiple times - javascript
I am trying to make calendar for my application, when i click on date for first time, callback method is getting called 1...
Read more >Implementing Cue Points Programmatically
Without this condition you would see that each cue point would be acted upon twice, the second time with no defined elements in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ok, thanks.
First install all depencies 1.npm install Then build the library 2.grunt
And thats all, you ll fins the library in Lib/ folder 🙃 @rjpgt