SamiPerttu / fundsp

Library for audio processing and synthesis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tags and Tagged example request

RobDavenport opened this issue · comments

Hi congrats on the crate release!

Would it be possible to have an example made of how to use Tagged constants? I have read the readme.md but can't seem to figure out what its used for or how its used. Would this allow the changing of, say, a frequency for a pulse() at runtime?

Thanks!

Looks like I've figured it out:

const FREQUENCY_TAG: i64 = 0;
const DUTY_TAG: i64 = 1;
const VOLUME_TAG: i64 = 2;

let func =
    (tag(FREQUENCY_TAG, 0.0) | tag(DUTY_TAG, 0.0)) >> (tag(VOLUME_TAG, 0.0)) * pulse();
            
// And setting the values later with...
  func.set(FREQUENCY_TAG, new_frequency);
  func.set(VOLUME_TAG, 0.0);

Yes, that's how it works! Tags are constants that allow you to set and query their values, recursively.