timestretch in gen~ ?


    Sep 21 2023 | 5:26 am
    Does anyone know of a way to do timestretch in gen~?
    MSP has [stretch~] based on Ztx, and timestretch options in [groove~].
    It would be useful to do these or something similar in gen~.

    • Graham Wakefield's icon
      Graham Wakefield
      Sep 21 2023 | 11:21 pm
      The timestretching algorithms in stretch~ (and groove~ -- it's the same underlying code) using the ztx library from Zynaptic (http://www.zynaptiq.com/ztx/). Because this is licensed technology, it can't be simply embedded in a code export capable context like gen~.
      Working within gen~ you would be wanting to 'roll your own' timestretch algorithms. Some of the simpler approaches include pitch-synchronous overlap add (PSOLA), which is pretty straightforward granular processing (and there's a basic example of this in the gen~ examples folder), or phase vocoder based stretching (which can be patched in a gen~ embedded within a pfft~).
      Better timestretching will take into account properties of the audio being stretched, responding separately to transients, working with fundamental & harmonics, and so on. That would be a fun project to work on, and it certainly would be useful!
      (FWIW ZTX appears to use a wavelet based approach according to their website. It would be an interesting project to try and develop wavelet methods in gen~ but it probably isn't easy to do.)
    • HighHarmonics's icon
      HighHarmonics's icon
      Sep 22 2023 | 3:13 am
      Thanks for the response Graham!
      The license restriction with Ztx makes sense, I didn't think about that.
      In the Examples, I see gen~.pitchshift and gen~.slicer that both use overlap-add. I'll dig into these.
      I would love to work on something like this, but it is probably beyond my level right now.
      Maybe it could be a topic in GSOT bk2...
    • Graham Wakefield's icon
      Graham Wakefield's icon
      Graham Wakefield
      Sep 22 2023 | 4:03 pm
      Yes, maybe!