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

TGrains2/3 do not respond to 'amp' argument #286

Open
Prosperoh opened this issue Apr 16, 2020 · 3 comments
Open

TGrains2/3 do not respond to 'amp' argument #286

Prosperoh opened this issue Apr 16, 2020 · 3 comments

Comments

@Prosperoh
Copy link

Prosperoh commented Apr 16, 2020

The 'amp' argument given to TGrains2/3 does not seem to have any effect, all grains having maximum amplitude (though changing the window does have an effect).

Taking the same example as a similar issue that was found in TGrains (supercollider/supercollider#2807):

b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
{ // This should fade in... but starts at full volume
	TGrains2.ar(2, Impulse.ar(15), b, centerPos: Line.ar(0, 5, 10, doneAction: 2), amp: Line.ar(0, 1, 10));
}.play;

What seems to be going wrong: in BhobGrains.cpp, a 'const float amp' is declared in both UGens and takes the value of the parameter, but this value is never actually used. It is later shadowed by the 'amp' variable declared in the GRAIN_AMP_2/3 macros, which is computed from the window and then used by GRAIN2_LOOP_BODY_1/2/4 in defining 'outval', such that 'outval' is never scaled to the 'amp' argument.

I have a local solution that stores the 'amp' argument in the Grain2 struct and uses it in the GRAIN_AMP_2/3 macros, but I am not aware of any code guidelines for this specific structure, also since a similar issue has been fixed in the past for TGrains.

@telephon
Copy link
Member

The best way is on each trigger to call a DEMANDINPUT(<input index>). This will work with normal ugens, but also with demand ugens like Dbrown for instance.

@scztt
Copy link
Contributor

scztt commented Apr 16, 2020

This should fix, I just noticed this the other day: #287
Did you solve this roughly the same way?

@Prosperoh
Copy link
Author

Yes, I solved it exactly like that!

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