Forums > MaxMSP

buffer~ arguments from input

January 3, 2011 | 5:59 am

Hi I have some buffer objects that looks like this:
[buffer~ 01sound 01sound.aif]
[buffer~ 02sound 02sound.aif]
[buffer~ 03sound 03sound.aif]
I would like to modularize it a bit so that I can input an integer (01, 02, 03)
into buffer~ and have buffer~ interpret the integer like sprintf does. Is there a way to write something like this?
[buffer~ %ldsound %ldsound.aif]
and have buffer interpret it correctly? Is there maybe some other way to achieve what I am trying to do?

Thanks
Pete


January 3, 2011 | 8:34 am

First, it would be impossible to give 03 as an argument. Then, of course it is possible to make an abstraction with a buffer~ object, that gets named and which loads a sound file based on an argument. It could be done using sprintf.
[sprintf set %02dsound] and [sprintf replace %02dsound.aif] should do it.

_
johan


January 3, 2011 | 6:17 pm

Hi thanks for you reply. So how does [sprintf replace %02dsound.aif] get connected to [buffer~].
03 sounds like a sensible argument to me. Can you explain why it is impossible?

Thanks
Pete


January 3, 2011 | 7:06 pm

Numbers in Max can’t have leading zeros. The reason that the sprintf solution works is that it is no longer a number at the output of sprintf.


January 3, 2011 | 8:07 pm

Thanks that makes sense. I still am not sure how to pass srguments into a buffer object, though. How does [sprintf replace %02dsound.aif] get connected to [buffer~]?

Thanks
Pete


January 6, 2011 | 2:01 am

OK so I compressed a patch demonstrating what I am trying to do, if any one would care to have a look any advice would be greatly appreciated.

– Pasted Max Patch, click to expand. –

Thanks
Pete



MIB
January 6, 2011 | 2:39 am

one way:

– Pasted Max Patch, click to expand. –

January 6, 2011 | 2:45 am

"How does [sprintf replace %02dsound.aif] get connected to [buffer~]?"

with a connection?


January 6, 2011 | 10:17 am

combine also have a zero padding option.

– Pasted Max Patch, click to expand. –

January 7, 2011 | 5:24 am

Thanks to everyone for their suggestions. That works perfectly.

Cheers
Pete


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