tidalcycles / strudel

Web-based environment for live coding algorithmic patterns, incorporating a faithful port of TidalCycles to JavaScript
https://strudel.cc/
GNU Affero General Public License v3.0
579 stars 105 forks source link

Gain Modulation with calculated modulation per event #1095

Open daslyfe opened 1 month ago

daslyfe commented 1 month ago

This pattern could be used as the basis for all kinds of interesting modulations.

An example:

setCps(.5)
$: s("bd:4:4!4").gain(.4)
$: s("oh!16").gain(.1).am("4").amskew(1)

$: note("{f g c d}%16".add("{12 7 0}%16")).am("<4 16 6>").amskew("<1 0 .5>").s("sawtooth").release(.1)

The timing of the modulation for the non-synced clock is a little off, and I haven't been able to figure out why yet. Maybe @felixroos you might have an idea? The synced clock timing is accurate.

felixroos commented 1 month ago

just a quick idea: maybe tremolo should be an alias of am ? (Then also pm should be an alias of vibrato) need to dig into the rest of it soon..

daslyfe commented 1 month ago

just a quick idea: maybe tremolo should be an alias of am ? (Then also pm should be an alias of vibrato) need to dig into the rest of it soon..

Yeah that makes sense to me 👍

daslyfe commented 1 month ago

Okay this should be ready to go now. The cycle calculation jitters a bit on the non synced chromium clock but isn't very noticeableand can probably be improved with better math.

daslyfe commented 1 month ago

I updated the non synced clock to more closely match the synced clock in order to make the cps calculation more accurate on chrome. I also brought over the setCycle function that can be integrated in new features :)

felixroos commented 1 month ago

I've tested it and it works great! It would be good to find a syntax to allow switching between absolute phase (like am) and relative phase (like all others rn). I imagine being able to apply tremolo with a relative/resetting phase could also be something desirable. It probably makes sense to make relative phase the default and add some keyword for absolute phase. Maybe something like am.lfo(). It also depends on which other effects might be suitable for absolute phase. Could this also be used for non repeating effects like envelopes?

felixroos commented 1 month ago

I've tested it and it works great! It would be good to find a syntax to allow switching between absolute phase (like am) and relative phase (like all others rn). I imagine being able to apply tremolo with a relative/resetting phase could also be something desirable. It probably makes sense to make relative phase the default and add some keyword for absolute phase. Maybe something like am.lfo(). It also depends on which other effects might be suitable for absolute phase. Could this also be used for non repeating effects like envelopes?

the switching between relative and absolute is probably not needed yet in this PR, just an idea for the future (tho it implies a breaking change)

felixroos commented 1 month ago

just a quick idea: maybe tremolo should be an alias of am ? (Then also pm should be an alias of vibrato) need to dig into the rest of it soon..

Yeah that makes sense to me 👍

thinking again about this, I realized there is a distinction between fm and vib:

just from a naming perspective, it might make sense for am to be frequency relative as well? The frequency independent version would probably be tremolo then? Combining this with absolute / relative phase, we have 4 variants:

absolute frequency  relative frequency
relative phase vib / tremolo fm / am
absolute phase vib.sync ? / tremolo.sync ? fm.sync ? / am.sync ?

not sure if relative frequency + absolute phase is even needed..

daslyfe commented 1 month ago

just a quick idea: maybe tremolo should be an alias of am ? (Then also pm should be an alias of vibrato) need to dig into the rest of it soon..

Yeah that makes sense to me 👍

thinking again about this, I realized there is a distinction between fm and vib:

  • fm is relative to the hap frequency, which allows keeping the timbre of different notes the same (fmh controls the ratio of modulator and carrier frequency)
  • vib uses an absolute modulator frequency, independent of the carrier frequency (typically used for lower frequency modulation)

just from a naming perspective, it might make sense for am to be frequency relative as well? The frequency independent version would probably be tremolo then? Combining this with absolute / relative phase, we have 4 variants:

absolute frequency  relative frequency relative phase vib / tremolo fm / am absolute phase vib.sync ? / tremolo.sync ? fm.sync ? / am.sync ? not sure if relative frequency + absolute phase is even needed..

I think having different words for cycle based speed and frequency based might limit us when other modulations are added that don’t have similar word equivalents. I think it would be better to have something like amBasis(“<frequency cycle”) with cycle always being the default because it is much more rhythmically useful