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

Maybe add audio/control rate boiler code? #27

Open
madskjeldgaard opened this issue Nov 13, 2020 · 3 comments
Open

Maybe add audio/control rate boiler code? #27

madskjeldgaard opened this issue Nov 13, 2020 · 3 comments

Comments

@madskjeldgaard
Copy link
Contributor

madskjeldgaard commented Nov 13, 2020

Hi again.

Just a heads up / FYI. I am using this to write my first ugens (hurraaay!!) and it's going fairly well, but as a newbie to this I just wanted to let you know that I found the lack of audio/control rate distinction a bit confusing.

If you build and run the example plugin that this template generates, it emits horrible noise if you just set the gain to a fixed value like 0.5 but fine if modulating by audiorate SinOsc.ar(0.1) for example. This to me (as a newbie) was a bit confusing.

I know this would be at the cost of making the default example here more complicated but I would personally have preferred if the audio/control rate stuff was a bit more verbose in the built example :)

// 1. set the calculation function.
  if (isAudioRateIn(1)) {
    // if the gain argument is audio rate
    set_calc_function<SimpleGain, &SimpleGain::next_a>();
  } else {
    // if thene gain argument is control rate (or a scalar).
    set_calc_function<SimpleGain, &SimpleGain::next_k>();
  };

  // Check if "gain" is control rate or audio rate
  if (isAudioRateIn(1)) {
    next_a(1);
  } else {
    next_k(1);
  }

etc

And thanks again for this awesome tool !

best!

@madskjeldgaard
Copy link
Contributor Author

ah no sorry, maybe it's better to just update the next function to use in0 instead for the gain arg?

void SimpleGain::next(int nSamples) {
  const float *input = in(0);
  const float gain = in0(1);
  float *outbuf = out(0);

  // simple gain function
  for (int i = 0; i < nSamples; ++i) {
    outbuf[i] = input[i] * gain;
  }
}

@mossheim
Copy link

i'd be happy to accept a pull request, but i currently have no time to spend on this repo, sorry. i agree this would be a good addition

@madskjeldgaard
Copy link
Contributor Author

madskjeldgaard commented Nov 13, 2020 via email

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

2 participants