Forums > MaxMSP

random Play~

July 10, 2007 | 7:19 pm

Hi, this I assume is really simple, but is driving my poor inexperienced max brain out!

All i want to do is playback with play~ at random parts of the loaded sound without changing the pitch. Its simply done with sfplay~ but i want the real time flexibility of play~ as ill be recording live chunks into the buffer~.

The problem is the comma in the list for the line~ object to playback the play~ sound.
I hope this makes sense in the patch example below.

Any help would be greatly appreciated, I hate asking when I think I should already know how.

max v2;
#N vpatcher 19 44 554 591;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 40 237 29 196617 stop;
#P message 39 220 33 196617 start;
#P message 109 58 53 196617 size 5000;
#P toggle 49 402 15 0;
#P newex 48 419 27 196617 gate;
#P newex 49 508 28 196617 dac~;
#P newex 49 462 27 196617 line~;
#P message 49 441 86 196617 $1 , 2000 1000;
#P newex 49 485 39 196617 play~ a;
#P flonum 471 267 44 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 471 243 27 196617 !-;
#P toggle 394 149 15 0;
#P newex 394 169 64 196617 metro 500;
#P flonum 394 216 64 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 394 191 79 196617 random 4900.;
#P window linecount 9;
#P comment 293 149 100 196617 because the metro will hit sample quite regular I guess I could set the end of the ramp to always be 5000 , so the second value will be 5000 minus the random figure:;
#P button 316 46 15 0;
#P flonum 394 89 67 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 316 66 105 196617 info~ a;
#P message 82 58 26 196617 read;
#P newex 80 240 28 196617 dac~;
#P newex 81 172 27 196617 line~;
#P message 81 151 92 196617 1000 , 2000 1000;
#P newex 81 202 39 196617 play~ a;
#P toggle 221 92 15 0;
#P newex 183 90 28 196617 adc~;
#P newex 183 107 54 196617 record~ a;
#P newex 82 79 79 196617 buffer~ a 5000;
#P window linecount 3;
#P comment 113 166 100 196617 how to make this list not fixed with a comma?;
#P window linecount 10;
#P comment 48 266 114 196617 I may be being completely dumb , I suspect I could just set two or three line~ oblects without the need for a comma , but I cant seem to figure it out , at least not without changing the speed… a la:;
#P window linecount 2;
#P comment 81 456 100 196617 not sure even this is doing what I meant!;
#P connect 27 0 26 0;
#P connect 26 0 23 0;
#P connect 23 0 24 0;
#P connect 24 0 22 0;
#P connect 22 0 25 0;
#P fasten 17 0 26 1 399 415 70 415;
#P connect 22 0 25 1;
#P connect 30 0 10 0;
#P fasten 29 0 10 0 44 236 85 236;
#P connect 7 0 10 0;
#P connect 8 0 9 0;
#P connect 9 0 7 0;
#P connect 11 0 3 0;
#P connect 28 0 3 0;
#P connect 7 0 10 1;
#P connect 6 0 4 0;
#P connect 5 0 4 0;
#P connect 5 1 4 0;
#P fasten 3 1 14 0 156 140 292 140 292 41 321 41;
#P connect 14 0 12 0;
#P connect 12 6 13 0;
#P connect 19 0 18 0;
#P connect 18 0 16 0;
#P connect 16 0 17 0;
#P fasten 17 0 20 0 399 237 476 237;
#P connect 20 0 21 0;
#P fasten 13 0 20 1 399 109 493 109;
#P pop;


July 10, 2007 | 8:19 pm

You dont need the comma because you can make a list consisting of the start point and a 0. to tell line to go to that point immediately (in 0 milliseconds). Here is an example:

#P user ezdac~ 104 652 148 685 0;
#P user gain~ 104 508 24 100 158 0 1.071519 7.94321 10.;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 104 477 43 196617 play~ a;
#P newex 104 448 32 196617 line~;
#P newex 308 60 48 196617 loadbang;
#P newex 104 360 27 196617 t i i;
#P newex 206 383 29 196617 + 0.;
#P newex 104 422 164 196617 pack 0. 0. 0. 0.;
#P newex 290 296 30 196617 !- 0.;
#P newex 165 265 29 196617 t b f;
#P toggle 165 143 15 0;
#P message 165 216 29 196617 500;
#P newex 165 176 58 196617 metro 500;
#P newex 104 336 44 196617 random;
#P message 250 39 53 196617 size 5000;
#P button 292 111 15 0;
#P flonum 370 154 67 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 292 131 105 196617 info~ a;
#P message 223 39 26 196617 read;
#P newex 223 60 79 196617 buffer~ a 5000;
#P comment 324 298 350 196617 pick a random start point between 0. and (total time – duration of playback);
#P comment 174 198 128 196617 duration of playback in ms;
#P comment 238 384 209 196617 start time + duration of playback = end time;
#P comment 271 426 356 196617 list: go to start point in 0 ms. go to end point over the duration of playback;
#P newex 159 449 68 196617 print lineList;
#P connect 17 0 21 0;
#P fasten 17 0 0 0 109 445 164 445;
#P fasten 15 1 18 1 189 352 230 352;
#P lcolor 7;
#P fasten 15 1 17 3 189 352 262 352;
#P lcolor 7;
#P fasten 15 1 16 0 189 288 295 288;
#P lcolor 7;
#P connect 22 0 23 0;
#P connect 21 0 22 0;
#P connect 23 0 24 0;
#P fasten 23 0 24 1 109 641 143 641;
#P fasten 15 0 11 0 170 309 109 309;
#P fasten 13 0 15 0 170 248 170 248;
#P fasten 20 0 9 0 313 95 297 95;
#P connect 19 0 17 0;
#P fasten 19 1 18 0 126 380 211 380;
#P fasten 7 6 16 1 375 152 315 152;
#P connect 7 6 8 0;
#P connect 11 0 19 0;
#P fasten 18 0 17 2 211 407 211 407;
#P fasten 16 0 11 1 295 324 143 324;
#P connect 12 0 13 0;
#P connect 14 0 12 0;
#P connect 6 0 5 0;
#P connect 10 0 5 0;
#P fasten 5 1 9 0 297 107 297 107;
#P connect 9 0 7 0;
#P window clipboard copycount 25;


July 10, 2007 | 8:41 pm

ahhhh! thanks so much. that was really irritating me. I’m still really struggling with lots of message based stuff, maybe there’s more message based tutorials i missed somewhere?

Thanks again.


July 11, 2007 | 10:39 am

it seems you may have found an answer, but for future reference commas in messages must be preceded by a backslash.

for more info on punctuation in max check the max46topics.pdf (p.116).

j


July 11, 2007 | 5:06 pm

thanks justin, time for a long recap I feel!


July 11, 2007 | 6:08 pm

"
it seems you may have found an answer, but for future reference commas in messages must be preceded by a backslash."

this is false. When putting a comma into an object such as expr, you need to put a backslash.

Commas are used all the time in messages. In a message, a comma denotes a separate event. No backslash needed.

In the above problem using line, the comma was not the real problem with getting the concept to work. The messages being sent to line~ in the original patch worked, they just weren’t doing what Seruka wanted.

Check the max topic on punctuation, its near the end of the pdf

Also, here is an example:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 30 269 224 196617 expr 8.175798 * pow(1.0594633\,$i1);
#B color 5;
#P flonum 30 289 49 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 30 251 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 131 170 98 196617 (as opposed to this);
#P message 50 169 78 196617 start stop bang;
#P newex 30 203 32 196617 print;
#P message 30 129 86 196617 start , stop , bang;
#P newex 30 83 32 196617 print;
#P message 30 57 60 196617 $1 , $2 , $3;
#P message 30 29 34 196617 5 6 7;
#P comment 122 130 224 196617 or to send messages in a specific order;
#P comment 257 273 367 196617 Here is an example of when you need a comma in an object (from the help file!);
#P connect 9 0 11 0;
#P connect 11 0 10 0;
#P fasten 7 0 6 0 55 193 35 193;
#P connect 5 0 6 0;
#P connect 3 0 4 0;
#P connect 2 0 3 0;
#P window clipboard copycount 12;


July 12, 2007 | 8:00 am

Robbie Lockwood schrieb:
> All i want to do is playback with play~ at random parts of the loaded
> sound without changing the pitch. Its simply done with sfplay~ but i
> want the real time flexibility of play~ as ill be recording live
> chunks into the buffer~.
>
> The problem is the comma in the list for the line~ object to playback
> the play~ sound. I hope this makes sense in the patch example below.

As had been pointed out already the comma isn’t your problem.
For your specific task, you might want to look into groove~, because its
easier to navigate and navigation is independant of the playback speed.
With play~ you would have to calculate the duration as well to keep the
pitch constant…

There are three objects for the same purpose: to play back a buffer~’s
content: groove~, play~, wave~. They differ in the way they are
controlled. You should really learn all three, it will save you some
trouble, as each of the three is suited for different playback tasks,
though in theory you could use any of them for any playback task…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


July 12, 2007 | 8:31 am

Hi,

consider also that with play~ you are forced to use small buffers by
the 32 bits addressing mode of Max/Msp (otherways you get strange
artifacts).

There are a bunch of hi-res objects which resolve this issue.

All the best


Alessandro Fogar

http://www.fogar.it

2007/7/12, Stefan Tiedje :
> Robbie Lockwood schrieb:
> > All i want to do is playback with play~ at random parts of the loaded
> > sound without changing the pitch. Its simply done with sfplay~ but i
> > want the real time flexibility of play~ as ill be recording live
> > chunks into the buffer~.
> >
> > The problem is the comma in the list for the line~ object to playback
> > the play~ sound. I hope this makes sense in the patch example below.
>
> As had been pointed out already the comma isn’t your problem.
> For your specific task, you might want to look into groove~, because its
> easier to navigate and navigation is independant of the playback speed.
> With play~ you would have to calculate the duration as well to keep the
> pitch constant…
>
> There are three objects for the same purpose: to play back a buffer~’s
> content: groove~, play~, wave~. They differ in the way they are
> controlled. You should really learn all three, it will save you some
> trouble, as each of the three is suited for different playback tasks,
> though in theory you could use any of them for any playback task…
>
> Stefan
>
> –
> Stefan Tiedje————x——-
> –_____———–|————–
> –(_|_ —-|—–|—–()——-
> — _|_)—-|—–()————–
> ———-()——–www.ccmix.com
>
>
>


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