Transpose contents of buffer~ as a process

    Oct 15 2013 | 8:44 am
    Not sure if this is possible or not. I want to transpose the contents of a buffer~ ie change the length and alter the pitch, so if I have a note in the buffer~ which is 2000ms long and a C4 I want to change it to 1000ms long at C5, 4000ms at C4 etc. I'm thinking I might be able to do this in real-time by using two buffer~s, and playing the sample into the currently unused buffer before switching to it but this is rather clunky. Is there a way of doing this offline? ie faster than real-time?
    If you're wondering why the convoluted route, it's because I'm loading them as impulse responses not using them for playback.

    • Oct 15 2013 | 4:42 pm
      To do that task in better-than-real time, you could write the operation in Java.file://localhost/Applications/Max%206.1/java-doc/api/com/cycling74/msp/MSPBuffer.html All the work for programming rate-change, interpolation, etc. has already been done in the play~ and groove~ objects, though, so I'd advise trying to leverage that work rather than starting from scratch.
    • Oct 15 2013 | 5:25 pm
      So presumably I can't achieve this using standard Max objects. Is this in any way a beginner project? I don't know Java, but am not averse to learning some. Any pointers appreciated.
    • Oct 15 2013 | 5:38 pm
      You could do something comparable using gen~. The same caveats apply about duplicating work that's already been done for realtime rate-change with play~ and groove~. Changing the increment rate to achieve the desired transposition, and interpolating between samples so as not to introduce unwanted distortion are both common computer music programming operations, but are not, imho, a "beginner project".
    • Oct 15 2013 | 6:17 pm
      Fair enough, I'll continue with my convoluted solution unless anyone has already done this, and I'll try to put some effort in learning java later... it's on the to-do list but I never quite get there!
    • Oct 15 2013 | 6:17 pm
      You could also do this faster than real time inside an upsampled poly~, if you want to do it in straight max.
      I'd prefer java myself, but this should work. How much of a speed up do you need?
    • Oct 15 2013 | 6:33 pm
      Well.. as fast as possible really. Ideally the user could just click to transpose the buffer~, but the samples are usually only 3 seconds max. So if I put my buffer and a playback object inside poly| and upsample the lot it will speed up the process by whatever the sample rate increase is, so if Max is at 48khz and i up it to 192 it will run 4x faster? I also take it I would need 2 buffer objects, one to play from and another to copy into?
    • Oct 15 2013 | 6:59 pm
      Yup, that's pretty much it. Also, you can use the mute 1/mute 0 message with thispoly~ so you don't have to run it when you're not resampling.
      If you do it in gen~ inside of poly~, you can also use fancier interpolation modes.
    • Oct 15 2013 | 7:25 pm
      Thanks Peter, will give it a go.
    • Oct 15 2013 | 8:01 pm
      if you want to switch as fast as possible and you are fine with per-key resolution for 2 or 3 octaves, why not use 30 buffers with 30 samples?
    • Oct 15 2013 | 9:12 pm
      It's a good idea, but there are no samples to start with - the user copies them to the buffer from an existing sample of their choice. It's like an IR instrument where you can quickly design new IRs using existing samples - not for the purpose of reverb but more for general sound design. Will post it up when it's finished.
    • Oct 16 2013 | 10:42 am
      So I've got the patch working outside of poly~. It's not my most elegant creation, but it works. I'm just unsure of how to put it inside a poly~, ie what needs to go in. I've used line~ and wave~, but don't understand how the timing will work when upsampled in poly - do I need divide my playback times?