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

Effects don't stop when removed #1

Closed
JohnPaulHarold opened this issue May 29, 2016 · 13 comments
Closed

Effects don't stop when removed #1

JohnPaulHarold opened this issue May 29, 2016 · 13 comments
Assignees

Comments

@JohnPaulHarold
Copy link
Contributor

JohnPaulHarold commented May 29, 2016

When removing an effect from a sound, I'd have expected the effect to stop, but instead the effect carries on modifying the source. You can see that the EffectsNode has been removed, it's not that removeEffect is doing nothing, just that it's not cancelling the effect that's been added.

I'd offer up sample code, but following the first example in the Effects section highlights the issue.

Is the above expected behaviour?

@alemangui
Copy link
Owner

It's indeed an error. The effect should stop modifying the source. Nice catch!

@JohnPaulHarold
Copy link
Contributor Author

OK, glad it's been captured then. I was wondering if I was overlooking something and should have been setting the wetMix down to zero before removing the effect.

@alemangui
Copy link
Owner

Should be fixed now. Thanks for the heads up :)

@JohnPaulHarold
Copy link
Contributor Author

The current fix kills the sound also, I'm not sure if that's intended or not. After I've removed an effect and hear nothing, I can pause() the Sound object created and then play it again, and it resumes on from it's last known position.

@alemangui alemangui reopened this Jun 1, 2016
@alemangui
Copy link
Owner

alemangui commented Jun 1, 2016

You're right. This commit should take care of this. Let me know if you have further issues.

d516f6c

@JohnPaulHarold
Copy link
Contributor Author

Yeah, this is still with issues. I'm using stems, and so my Sound buffers are 4+ minutes long. Well, they're longer than simple soundfx samples at any rate. Adding effects seems fine, removing seems OK some of the time, but it will often lose sync and never recover that or worst case just stop making any sound from which it will also not recover.

@alemangui alemangui reopened this Jun 3, 2016
@alemangui
Copy link
Owner

Interesting, could you maybe send me a URL or jsfiddle, jsbin or something similar?

@JohnPaulHarold
Copy link
Contributor Author

JohnPaulHarold commented Jun 6, 2016

I'll try and make a simple demo to highlight this. Later this week probably.

@JohnPaulHarold
Copy link
Contributor Author

small example. http://webui.lt/pz_fx_test/examples/effects_on_off.html

In this test, you can fairly easily get the streams out of sync, but I couldn't replicate the sound completely dying and never returning. Where I was seeing that, I also had an analyser node wired in on each Sound. I could update the test later so each loop has a simple VU meter and see if that's an issue also.

I can also upload the test to the repo, that way it can be tested locally.

@alemangui alemangui mentioned this issue Jun 19, 2016
@alemangui
Copy link
Owner

Indeed. This is a separate bug which is also evidenced in other areas of the library. Thanks for the catch. I have filed #9 to tackle it.

@shinedark
Copy link

hey im still having trouble removing effects they stay loaded to the audio file. i got the latest version still doesn't work. here is a link to the code https://github.com/shinedark/samplerdj

@alemangui
Copy link
Owner

alemangui commented Sep 14, 2016

Hey @shinedark,

Took a look at your repo, looks pretty cool :)

I think the issue in your case might be the usage of jQuery's .keydown method, which is fired multiple times when the key is down, not just once. I believe this is what happens:

  1. the user holds down one of the effect keys (let's say x for the delay),
  2. jQuery's .keydown fires multiple times (let's say 10 times for this example), each time adding an effect via the code:
sampler._aud.addEffect(dubDelay);
  1. the pizzicato Sound now has the same effect instance added 10 times. This can be checked by using an undocumented property effects. In your case, sampler._aud.effects would be an array of 10 elements.
  2. now you release the x key. jQuery's .keyup is only fired once, as opposed to .keydown.
  3. Pizzicato's removeEffect is only called once, and 9 other instances of the effect are still in the sound.

A workaround for your project is to make sure that you only add the effect once.

A future discussion topic might be:

  • Should Pizzicato allow adding multiple times the same effect? I tend to think so, it would make little sense to duplicate effects just to use them more than once.
  • Should Pizzicato remove all instances of a particular effect when it's added more than once? Perhaps... currently it only removes the first it finds.

I hope this makes sense.

@shinedark
Copy link

thank you that fixed my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants