question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

buggy behaviour in part.onStep()

See original GitHub issue

the pattern below has 8 beats, play() is called 8 times but part.onStep is called 7 times. When the part is looping, part.onStep is still only called 7 times.


let sound, m = 0, n = 0;

function setup () {
  masterVolume(0.4);

  const pat = [1,1,1,1,1,1,1,1];
  const phrase = new p5.Phrase('phrase', play, pat);

  const part = new p5.Part();
  part.onStep(() => {
    console.log(`step ${++n}`);
  });
  part.addPhrase(phrase);
  part.setBPM(60);
  part.start();
  // part.loop();
  
  sound = new p5.MonoSynth();

  userStartAudio().then(() => {
     console.log("user start audio");
   });
}

function draw () {
  background(0);
}

function play (time, notused) {
  console.log(`play ${++m}`);
  sound.play('D4');
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
crcdngcommented, Apr 29, 2020

I just checked with p5.js 1.0.0 and the problem still persists.

The expected behavior in the example above would be: part.onStep should be called 8 times.

Using part.loop() instead of part.start(), part.onStep should be called 8 times for each loop as long as it is looping.

1reaction
crcdngcommented, Apr 29, 2020

Hi, the above code was my program demonstrating the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rotation is buggy #2 - Saiyato/volumio-rotary-encoder-plugin
Hi, I managed to get the plugin working, but the behaviour is very erratic. Sometimes it raises the volume, sometimes it lowers it...
Read more >
Who's afraid of a big bad optimizing compiler? - LWN.net
These cannot possibly all be buggy, can they? Answer. However, the remainder of this article will assume properly aligned and machine-word-sized accesses, in ......
Read more >
Suspension Design and testing of an All-Terrain Vehicle using ...
The essential parameters were identified to model the suspension system, both front and rear of a Baja Buggy. The designing was performed ...
Read more >
THE JOEL TEST quick note: 12 STEPS TO BETTER CODE
complete steps to reproduce the bug; expected behaviour; observed (buggy) behaviour; who handle it; whether it has been fixed or not.
Read more >
I made a coding error which caused a big production issue ...
Every programmer writes buggy code at some point. ... I had a function called barx(), and I wasn't sure it was being called...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found