Forums > MaxMSP

deducing the length of a sample in bars

June 11, 2010 | 11:01 am

Hi guys,

I’m wondering if someone could point me in the right direction. I need a sampler I’ve built to be able to automaticaly set the length of the sample in bars. I’m not sure what the best way to go about it is. I’ve been thinking about 2 possibilities.

1. Is there an object that will search a message for a number, and if it is there then it will send a bang out of a specified outlet. Basically I’m thinking if I put the length at the end of the samples name. For example the file is named "IntroGuitar4.wav", so the object sees a 4 in the message and sends a bang, which sets the length.

2. Can this be acheived with a mathematical equation, by looking at the number of samples etc?

Thanks in advance for any help.



MIB
June 11, 2010 | 11:24 am

maybe use info~ or sfinfo~ to get the length of your sample and then use the [translate] object to convert to bar:beats:units


June 11, 2010 | 11:27 am

A little more info. I’m using part of the modsquad patch, which is in the examples folder. It’s excellent at working out the tempo as long as the number of beats is set correctly first, but for instance if a sample is twice as long as the number of beats set, the bpm will be set at half the speed it should be. Because I’m using multiple loops of differing lengths I need to be able to set the length of each sample individually, and preferably without having to do it manually for each sample initiated.


June 11, 2010 | 11:28 am

Ah. Thanks. Just having a look now.


June 11, 2010 | 2:57 pm

Right…

I’ve decided that it would be better for me to follow idea number 1, as I won’t always want to play the samples back at their original speed.

I just came across the zl object, which would do the job perfectly accept for the fact that I have to label the files in a particular way to get it to see the numbers. So if the file is named introguitar 4 .wav it works fine, it sees the four and sends a bang out of the left outlet. The problem is that when using umenu, if there are spaces in the file name, for some reason it puts brackets around the text, which again means that zl doesn’t see the number for some reason.


June 11, 2010 | 3:56 pm

I’d bassically like if there is a work around for this, or if anyone knows of another way I could accomplish it.


Viewing 6 posts - 1 through 6 (of 6 total)