GithubHelp home page GithubHelp logo

Comments (5)

telephon avatar telephon commented on May 24, 2024

The formula can be compiled as:

// for synths
~unitDuration = ~delta;

// for samples
~unitDuration = buffer.duration;

// then some conversions of unitDuration (covered below)

// then, finally
sustain = ~sustain ?? { if(~legato.notNil) { ~delta * ~legato } { unitDuration } };

// let samples end if needed
~buffer !? { sustain = min(unitDuration, sustain) };

samples synths
nothing specified plays the full sample plays to fill one delta
# sustain (secs) fills the sustain time with the sample. If looping, loop until time has passed plays the full sustain time
# speed speeds up the sample playback, shortening the total duration scale the synth sustain (parameter can be used in the synth)
# accelerate incrementally speeds up the sample playback scale the synth sustain (parameter can be used in the synth)
# begin shortens the sample playback and starts later in the sample shortens the synth sustain (parameter can be used in the synth)
# end shortens the sample playback and ends earlier in the sample shortens the synth sustain (parameter can be used in the synth)
# loop   loops n times between begin and end, extending the duration if legato/sustain don't set the limit   extends the synth sustain (parameter can be used in the synth)
# legato  calculates sustain from delta * legato, then, see sustain (same as sample)

… more to come …

The calculation of unitDuration

if (~unit == \c) { speed = speed * ~unitDuration * ~cps };

endSpeed = speed * (1.0 + accelerate);
avgSpeed = speed.abs + endSpeed.abs * 0.5;

if(~unit == \rate) { ~unit = \r }; // API adaption to tidal output

// sustain is the duration of the sample
switch(~unit,
    \r, {
        unitDuration = ~unitDuration * ~length / avgSpeed;
    },
    \c, {
        unitDuration = ~unitDuration * ~length / avgSpeed;
    },
    \s, {
        unitDuration = ~length;
    },
    { Error("this unit ('%') is not defined".format(~unit)).throw };
);
~loop !? { unitDuration = unitDuration * ~loop.abs };

Questions

  1. Should these unitDuration calculations affect also synths?
  2. Should legato override unitDuration calculations completely?

This concerns the meaning of the parameters:

  • speed
  • acceleration
  • begin & end

and:

  • unit

E.g. if we set begin and end of a synth, should it get shorter? If we set begin and end of a sample, and loop it many times, and specify legato, should the legato space be filled by the sample looping between begin and end?

from superdirt.

bgold-cosmos avatar bgold-cosmos commented on May 24, 2024

Just a few thoughts:

legato for samples: It currently can cut off sample playback early, but won't make it longer. This is still true when you use begin, end, loop, etc. I like this behavior, it basically means that for samples if I want direct control over how much "space" a sample uses, I use legato. I don't generally want samples to loop unless I explicitly say so. I could understand wanting to have an easy syntax for "loop the sample until the legato is filled"; right now that would be # loop "largenumber" # legato "whatever" which can be a little risky. I could imagine using # loop "-1" to mean this, but maybe that's too obscure.

telephon: yes, I'd also say that it is correct like this. A specific unit could be used to stretch the sample to fit sustain/legato. I don't think that loop -1 is too obscure really.

speed for synths: Actually, at the moment speed isn't completely unspecified as it still enters into the unitDuration calculation, regardless of whether the synth also uses it internally. This can get a bit weird. loop, begin, end, and accelerate also do this, although I rarely use most of those with synths. I think this is mostly OK - it just means that at least duration-wise synths mostly behave like samples, and that might be easiest for users to understand. Then it's up to the synth author if they want to do further interesting things with those parameters. But right now it can be rather idiosyncratic - a bunch of my synths overload speed and accelerate and I'm still not sure if it was the right thing to do. It'd be great to get a lot of feedback on this.

it is certainly good that the synths can use these parameters, so that many of the interesting functions that tidal defines have a meaning also for synths. But of course it should be left to the synth-author whether she wants to use it. The main question seems to be whether it is too obscure if you don't implement them in the SynthDef and they still affect the sustain of the synth. To me it seems that begin and end should definitely affect sustain (unless explicitly specified or legato is set). I'm less sure about speed. Even less about loop and accelerate.

from superdirt.

telephon avatar telephon commented on May 24, 2024

btw. there is also the option of deriving the default synth sustain from the SynthDef default argument. But that is an overhead for little gain, as it seemed.

I'd prefer to make a dictionary of events that you register with dirt, which allows you to specify default parameters for each kind of synth, or even do other things, like play sclang patterns (like grain clouds).

from superdirt.

telephon avatar telephon commented on May 24, 2024

solved now.

from superdirt.

telephon avatar telephon commented on May 24, 2024

… well, the overview would still be useful.

from superdirt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.