Play~ Individual Control of Sample Length & Pitch


    Jan 16 2006 | 9:44 pm
    I have been trying to use play~ to control samples used in a drum machine
    patch. The advantage I have with play is the ability to change the start,
    length and read speed of the sample in the buffer. The problem I have is
    that I need control of the length of sample at every pitch range. The way
    play alters the pitch is by shortening or lengthening the the read in which
    the buffer is read. Thus if I have set the pitch and then shorten the length
    of the sample it changes its pitch again.
    Is there away to make them mutally exclusive ? Or would using another file
    playing object (groove~,sfplay~) be a better option?
    Will

    • Jan 31 2006 | 5:07 pm
      Can anyone help me with this? I really dont see how I get the two parameters to operate individually.
    • Jan 31 2006 | 5:07 pm
    • Jan 31 2006 | 6:08 pm
      You can try a granular solution. I have the [gran.play.file~]
      abstraction as part of my granular toolkit. URL below.
      -----
      Nathan Wolek
      nw@nathanwolek.com
    • Feb 01 2006 | 5:09 pm
      Thanks for the suggestion but I am trying to build this without using externals.
      When I am trying to do is be able to control the pitch of the sample and length, regardless of one another which to me seems nearly impossible with play~ unless theres a formula which maintains the pitch when the length is changed.
      I am starting to edge towards using a different sound object. I tried it with groove and a waveform viewer, but in order to change the length the sample has to be looped and thats no good for a drum machine.
      Are there any other sound playing objects which would enable me to manipulate the buffer in this way?
    • Feb 01 2006 | 11:19 pm
      Here's one way to do it. I wouldn't recommend this setup for
      controlling a drum machine, since it's relying on the scheduler/queue
      to do triggering, but hopefully it'll give a point for jumping off...
      Also - You should check out [wave~] and all of the MSP tutorials as
      well. I think the sampling sections could be particularly helpful to
      you.
      max v2;
    • Feb 02 2006 | 9:25 pm
      On Feb 1, 2006, at 9:09 AM, Will Pickersgill wrote:
      >
      > Thanks for the suggestion but I am trying to build this without
      > using externals.
      > When I am trying to do is be able to control the pitch of the sample
      > and length, regardless of one another which to me seems nearly
      > impossible with play~ unless theres a formula which maintains the
      > pitch when the length is changed.
      Dude. That's what we call a non-trivial problem. There is no formula
      for this. This is one of the classic signal theory problems.
      The main crux of the problem is that you have to either lose or
      fabricate information to change pitch without changing speed. This is
      because you're trying to affect the frequency domain in the time
      domain, these two domains are not orthogonal... frequency depends on
      time. The solution to the problem will most likely also be non-
      trivial (especially to solve the problem with a minimum of audible/
      unwanted artifacts) and it definitely can't be perfect because of the
      change in information. That's why people here use externals to do it.
      Sorry, I don't mean to rant but I'm sure that you could have gleaned
      the difficulty of your task from the previous replies and from your
      experiments. You're smart: if it's not simple to you then it's
      probably not simple.
      I think other people have mentioned using gizmo~. I believe that's
      not a bad way to change the pitch without changing the speed, so just
      take into account the pitch change you induced with play~ and you're
      golden.
      I think gizmo~ uses FFT. I have written a few patches that use
      granular techniques towards the same end. The real tough part is to
      get rid of the artifacts, and at some point your input to output
      information ratio will just be too skewed to effectively do so.
      > I am starting to edge towards using a different sound object. I
      > tried it with groove and a waveform viewer, but in order to change
      > the length the sample has to be looped and thats no good for a drum
      > machine.
      >
      > Are there any other sound playing objects which would enable me to
      > manipulate the buffer in this way?
      Programming is a compromise, just like Art.
      _Mark
    • Feb 03 2006 | 7:55 pm
      Thanks for your help. I have managed to rig something up with everyones advice.
      I am now trying to get a jsui dial to update itself with the length of the sample loaded into the buffer. I want to take the sample length time from info~ and feed into the jsui dial so that its max range is that of the sample length.
      The only way I can see to do it is by passing it a message which would update the java script of the dial, namely the variable "val".
      Any suggestions?
      Will
    • Feb 03 2006 | 9:54 pm
      I'd be curious to see what you came up with, if you're willing to
      share. - David
    • Feb 06 2006 | 12:15 pm
      Well to be honest its not all that different from the help thats been given. I havent implemented gizmo~ or anything like that. Davids method of transposing as been used and I have added a velocity dial.
      It works quite efficiently in my drum machine. For the velocity I am using a matrixctrl in dial mode with 3 different settings (hard, medium, soft velocity). When hard is selected 1's appear in the pattrstorage, when medium 2's etc. I want to be able to extract from the pattrstorage the cells value and correspond it to a velocity value. Would the best way to do this be to filter the output of the pattrstorage and use if statements to trigger a set velocity value?
      I hope that is clear?
      Will
      max v2;
    • Feb 16 2006 | 3:58 pm
      Hi there
      I'm creating a drum machine too, I can't figure out why the info~ object doesn't seem to return any info of any of my samples. I only want the buffer size (in ms) returned so I can have variable decay lengths for each step, without using a fixed maximum.
      Can you help?
    • Feb 16 2006 | 4:42 pm
      I also found that info wasnt giving me the right info for the sample loaded in the buffer so I used sfinfo~ immediately from the open file dialog to get the total length of the sample.
      Hope that helps.
    • Feb 16 2006 | 4:52 pm
      Sweet! Cheers for that it works perfectly.
      Another couple of questions if you have a mo, since you're working on a drum machine too.
      Having trouble getting sample-accurate timing - I know there's a way using the phasor object. Any experience with that?
      Also, how to prevent midi feedback loops - I want to have control information coming into and going out of my control surface (Behringer motorized faders) but obviously there needs to be some sort of barrier to stop the midi signal from looping. Just in case you know of anything off the top of your head, no problem if not.
      Cheers!
    • Feb 16 2006 | 10:16 pm
      No problem.
      I havent used phasor~ either to trigger my samples. The drum machine I am making is part of a bigger project which has a dj player with 2 decks, drum machine and hopefully a granular synth with step sequencer.
      I hope to get them all synchronised together and am attempting to do this using Tristan Jehan's beat~ object.
      The bpm info from beat~ is sent to the tempo object which defines the drum machine tempo. This sends out triggers to a matrixcrtl and the corresponding drum play~ object.
      The timing of the matrixctrl and the actual playback seems to be a bit off even though there are both trigger by the tempo~ object which is odd and I am still trying to figure out why.
      About midi feedback loops, I havent really looked into making my drum machine midi controllable as other parts of my project use it so cant really help you on that one, sorry.
      Hope some of the info was useful.
    • Feb 16 2006 | 10:32 pm
      For sample-accuracy you really want peek~ and poke~. Those will let
      you get at the individual samples.
      _Mark