Trimming/cropping buffer~


    Oct 11 2007 | 6:15 pm
    I am using mxj buf.OP with very good results but I have run into a problem. I am recording quad files into buffer~s. I set the buffers to an initial size that is larger than the length I'll be intending to record. This results in a period of silence at the end of the buffer and possibly anoth at the beginning if I delay the start of sound for a time after turning record~ on. I think searching the buffer for zero value samples at the begin and end and then copying to another buffer would crop it. Has anyone done this or made a utility to do this?
    Cheers Gary Lee Nelson Oberlin College www.timara.oberlin.edu/GaryLeeNelson

    • Oct 11 2007 | 7:15 pm
      I've done this in the past using the bufcpy~ external (http://www.publicbeta.cx/maxx/). It can copy any part of a buffer given 2 arguments for start and end time.
      Hope that helps Dan
      Quote: Gary Lee Nelson wrote on Thu, 11 October 2007 12:15 ---------------------------------------------------- > I am using mxj buf.OP with very good results but I have run into a problem. > I am recording quad files into buffer~s. I set the buffers to an initial > size that is larger than the length I'll be intending to record. This > results in a period of silence at the end of the buffer and possibly anoth > at the beginning if I delay the start of sound for a time after turning > record~ on. I think searching the buffer for zero value samples at the > begin and end and then copying to another buffer would crop it. Has anyone > done this or made a utility to do this? > > Cheers > Gary Lee Nelson > Oberlin College > www.timara.oberlin.edu/GaryLeeNelson > > > ----------------------------------------------------
    • Oct 11 2007 | 8:55 pm
      bufcpy~ is not yet UB. Besides, the biggest part of this job is getting the 2 arguments. After that, buf.OP can do the copy.
      - search from the beginning of the buffer until a non-zero sample is found in any channel. Set argument 1 - search from the end of the buffer until a non-zero sample is found in any channel. Set argument 1
      On 10/11/07 3:15 PM, "Dan" wrote:
      > > I've done this in the past using the bufcpy~ external > (http://www.publicbeta.cx/maxx/). It can copy any part of a buffer given 2 > arguments for start and end time. > > Hope that helps > Dan > > Quote: Gary Lee Nelson wrote on Thu, 11 October 2007 12:15 > ---------------------------------------------------- >> I am using mxj buf.OP with very good results but I have run into a problem. >> I am recording quad files into buffer~s. I set the buffers to an initial >> size that is larger than the length I'll be intending to record. This >> results in a period of silence at the end of the buffer and possibly anoth >> at the beginning if I delay the start of sound for a time after turning >> record~ on. I think searching the buffer for zero value samples at the >> begin and end and then copying to another buffer would crop it. Has anyone >> done this or made a utility to do this? >> >> Cheers >> Gary Lee Nelson >> Oberlin College >> www.timara.oberlin.edu/GaryLeeNelson >> >> >> > ---------------------------------------------------- > >
      Cheers Gary Lee Nelson Oberlin College www.timara.oberlin.edu/GaryLeeNelson
    • Oct 12 2007 | 1:10 am
      On 12 oct. 07, at 05:55, Gary Lee Nelson wrote:
      > bufcpy~ is not yet UB. Besides, the biggest part of this job is > getting the > 2 arguments. After that, buf.OP can do the copy. > > - search from the beginning of the buffer until a non-zero sample > is found > in any channel. Set argument 1 > - search from the end of the buffer until a non-zero sample is > found in any > channel. Set argument 1
      This deosn't seem very difficult to achieve in Java with something like that (not tested):
      public void inteligentCrop(int channel) { float[] samps = MSPBuffer.peek(bufname, channel); int start, end = 0;
      for (int i = 0; i < samps.length; i++) { if (Math.abs(samps[i]) > 0) { start = i; break; } }
      for (int i = (samps.length - 1); i >= 0; i--) { if (Math.abs(samps[i]) > 0) { end = i; break; } }
      // doCopy(channel, start, end); }
      ej
    • Oct 12 2007 | 12:51 pm
      Thanks ej,
      Yes, that looks like exactly the thing. I guess I can't put off learning java anymore. I'll have a look through the buf.OP to see if I can add a crop message.
      Cheers Gary Lee Nelson Oberlin College www.timara.oberlin.edu/GaryLeeNelson
      On 10/11/07 9:10 PM, "Emmanuel Jourdan" wrote:
      > On 12 oct. 07, at 05:55, Gary Lee Nelson wrote: > >> bufcpy~ is not yet UB. Besides, the biggest part of this job is >> getting the >> 2 arguments. After that, buf.OP can do the copy. >> >> - search from the beginning of the buffer until a non-zero sample >> is found >> in any channel. Set argument 1 >> - search from the end of the buffer until a non-zero sample is >> found in any >> channel. Set argument 1 > > This deosn't seem very difficult to achieve in Java with something > like that (not tested): > > public void inteligentCrop(int channel) > { > float[] samps = MSPBuffer.peek(bufname, channel); > int start, end = 0; > > for (int i = 0; i < samps.length; i++) { > if (Math.abs(samps[i]) > 0) { > start = i; > break; > } > } > > for (int i = (samps.length - 1); i >= 0; i--) { > if (Math.abs(samps[i]) > 0) { > end = i; > break; > } > } > > // > doCopy(channel, start, end); > } > > > ej > >