Some math, please ! (calculate sample length after variable playback speed)

    MaxMSPadvanced

    Mousin
    Sep 17 2018 | 2:06 pm
    Hi,
    I don't know if someone could help me. I would like to calculate the length of a sample playback after applying a speed ratio controlled by env. if needed, to keep eventual formula simple, let's say (with a simple linear attack/decay env): >>> env goes from a speed factor of MinSF to MaxSF in AttackT ms, and goes from a speed factor of MaxSF to MinSF in DecayT ms (Message to [line] >> "MinSF, MaxSF AttackT MinSF DecayT") SL - the length of sample played at original speed (speed factor 1.) MinSF - Start and End env speed factor MaxSF - the env maximum speed factor. (a speed factor of 2 play the sample in SL/2. ms, a speed factor of 0.5 play the sample in SL/0.5 ms) AttackT - Attack time in ms (range: any >= 0. float) DecayT - Decay time in ms (range: any >= 0. float) (The result should give the length when the sample is played until the end, witch can happen before or after the end of the env) Is that possible to calculate that with Max ? Many thanks by advance !

    • Floating Point's icon
      Floating Point
      Sep 19 2018 | 12:17 am
      I think this works:
      Max Patcher
      In Max, select New From Clipboard.
      Show Text
      but you'd need to test it.
      It's derived from the kinematics equation to calculate distance given starting velocity and constant acceleration: s=ut + 1/2 at^2 which simplifies to: attack_time*(SFmin+SFmax)/2 in your parlance and same for decay time (then just add them together)
      Share
    • MAXIME JERRY FRAISSE's icon
      MAXIME JERRY FRAISSE's icon
      MAXIME JERRY FRAISSE
      May 21 2023 | 6:05 pm
      hello 2018! Mousin, did you find a solution? it doesn't seem to work for me.
    • Roman Thilenius's icon
      Roman Thilenius's icon
      Roman Thilenius
      May 21 2023 | 7:59 pm
      if the segments are actually linear, you can safely assume the mid-point to be the average speed of that segment. if they are not linear you should ask albert einstein or try another hobby.
    • MAXIME JERRY FRAISSE's icon
      MAXIME JERRY FRAISSE's icon
      MAXIME JERRY FRAISSE
      May 21 2023 | 8:59 pm
      do you mean this should work ?
      Max Patcher
      In Max, select New From Clipboard.
      initial sample length = 1s start speedRatio = 2 end speedRatio = 0.5 new time = 1,25s ?