Trigger Bang Bang etc. Alternative

Jan 17, 2009 at 4:53am

Trigger Bang Bang etc. Alternative

Hi,

I’ve got a patch for randomly playing a folder of AIFF files. It works but I’ve got the whole thing on an endless Trigger Bang Bang set of instructions. Is this a dodgy way to do this? Are their more elegant techniques, solutions and/or objects to accomplish the same goal? Any suggestions and/or help finding this information in a tutorial or help file will be greatly appreciated.

Thanks,
S.

max v2;
#N vpatcher 499 44 1102 692;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 260 99 55 196617 delay 110;
#P button 192 187 15 0;
#P newex 187 98 55 196617 delay 100;
#P user ezdac~ 44 583 88 616 0;
#P button 156 407 15 0;
#P newex 156 439 30 196617 t b b;
#P toggle 156 479 15 0;
#P flonum 318 450 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 318 472 48 196617 speed $1;
#P button 273 407 15 0;
#P toggle 273 441 15 0;
#P message 233 474 43 196617 loop $1;
#N sfplay~ 1 120960 0 ;
#P newobj 42 543 44 196617 sfplay~;
#P newex 42 436 68 196617 prepend open;
#P newex 42 408 49 196617 tosymbol;
#P newex 42 380 100 196617 sprintf %s%s;
#P number 228 238 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 42 353 273 196617 “MacBookPro:/Users/silver/Desktop/Yeti/Yeti Sounds/”;
#P button 115 315 15 0;
#P number 42 315 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 190 210 43 196617 random;
#P user umenu 42 290 100 196647 1 64 306 1;
#X add AlgoDemonStar.aif;
#X add BrightGalaxy.aif;
#X add DeepNebula.aif;
#X add Underwater01.aif;
#X add WaterBubbles02.aif;
#P number 69 213 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 42 189 37 196617 folder;
#P message 111 134 58 196617 types AIFF;
#P message 42 163 273 196617 “MacBookPro:/Users/silver/Desktop/Yeti/Yeti Sounds/”;
#P message 312 132 33 196617 clear;
#P newex 36 92 66 196617 t b b b b b;
#P newex 36 58 48 196617 loadbang;
#P connect 0 0 1 0;
#P fasten 1 2 3 0 69 139 47 139;
#P fasten 4 0 5 0 116 182 47 182;
#P connect 3 0 5 0;
#P fasten 8 0 7 0 195 334 15 334 15 279 47 279;
#P connect 26 0 7 0;
#P fasten 2 0 7 0 317 279 47 279;
#P connect 5 0 7 0;
#P connect 7 0 9 0;
#P fasten 10 0 11 0 120 342 47 342;
#P connect 11 0 13 0;
#P connect 13 0 14 0;
#P connect 14 0 15 0;
#P fasten 22 0 16 0 161 505 47 505;
#P fasten 17 0 16 0 238 505 47 505;
#P connect 15 0 16 0;
#P connect 16 0 25 0;
#P connect 5 1 6 0;
#P fasten 20 0 16 1 323 505 81 505;
#P connect 16 0 25 1;
#P fasten 1 3 4 0 83 128 116 128;
#P fasten 7 1 10 0 137 310 120 310;
#P connect 7 1 13 1;
#P connect 27 0 24 0;
#P connect 24 0 23 0;
#P fasten 23 1 22 0 181 470 161 470;
#P connect 23 0 22 0;
#P connect 28 0 22 0;
#P connect 1 1 26 0;
#P connect 27 0 8 0;
#P fasten 6 0 8 1 74 235 169 235 169 185 228 185;
#P fasten 8 0 12 0 195 232 233 232;
#P fasten 18 0 17 0 278 463 238 463;
#P fasten 1 1 28 0 217 79;
#P fasten 1 0 18 0 41 113 28 113 28 470 228 470 228 436 278 436;
#P connect 19 0 18 0;
#P fasten 1 4 2 0 97 121 317 121;
#P connect 21 0 20 0;
#P pop;

#41725
Jan 17, 2009 at 9:13am

Hi Suzie

This business of the trigger bang bang …. etc is meant to help get the order of execution correct. the object connected to the right most bang will receive a bang before the objects connected to the left of it. (the right to left principle). Therefore in your patch, the delays are defeating the point of setting up the triggers in a particular order.

Here is an example of using some bangs which might help to clarify the ordering and emphasise just how important both the bang message is and the order in which bangs are carried out.

pelado

– Pasted Max Patch, click to expand. –
#148873
Jan 17, 2009 at 9:17am

In case you use max 4 here is a screenshot of the patch I attached to the last post

[img]index.php?t=getfile&id=2364&private=0[/img]

pelado

#148874
Jan 17, 2009 at 8:22pm

Hey Pelado,

Thanks so much. I was able to open your patch in the Max 5 demo but for some reason I keep getting errors. No sound plays when I load a folder of AIFFs. If I bang the urn to select a new sound file I get the errors: sfplay~ can’t find file and sfplay~ no open file. Maybe I’m missing something and don’t completely understand what is supposed to happen.

Thanks,
S.

#148875
Jan 17, 2009 at 8:34pm

That’s because you are sending [sfplay~] just a file name. If this file isn’t in your max search path then it won’t work. You can either make sure the folder you select is in the search path or make sure you are sending full file paths to [sfplay~].

You could do this by taking the path from your [opendialog] and [combine]-ing or [sprintf]-ing it together with the file name from your [umenu].

I hope this puts you back on track.

lh

#148876
Jan 18, 2009 at 3:30pm

Thanks lh, using sprintf made a working patch for me.
best, s.

#148877
Jan 19, 2009 at 2:24pm

1.
242.axial

2.
110.folderfiles

3.
writing all samples in a large buffer and then work with dynamic play positions instead of triggering files.

-110

#148878
Jan 19, 2009 at 11:06pm

Only slightly off topic,

Is there an object out there that will randomly select/open a file from a specified folder or path without having to specify a file name.

Personally I’m using windows and I assume Max would have to query the folder to determine the number of files in it – I’m not sure if this is possible.

I’ve got this working, but only by appending a list with a random number and having to change the file name’s of all my files to integers = very tedious.

#148879
Jan 20, 2009 at 12:48am

Have a look at the “prefix_settings” subpatch in the [umenu] helpfile, you could use this in conjunction with [opendialog] and [random] to load all the files into a umenu and then it random index numbers. If you need more pointers just ask!

lh

#148880
Jan 20, 2009 at 2:10am

On Jan 19, 2009, at 3:06 PM, pechnatunk wrote:

> Personally I’m using windows and I assume Max would have to query
> the folder to determine the number of files in it – I’m not sure if
> this is possible.

The folder object will report all the files in a given directory.
Here’s an example I posted in another thread:

– Pasted Max Patch, click to expand. –

- C

Chris Muir
cbm@well.com

http://www.xfade.com

#148881
Jan 21, 2009 at 10:38pm

#148882
Jan 22, 2009 at 1:54am

Thanks Stefan,

The reason the I with sfplay~ on during load is just temporary to test the patch. This is part of the sound part of an audio visual patch that will be controlled by a sculpture via bluetooth arduino.

I am interested in the idea of making a bunch of cues for one long sound file but I am not sure how to do that. How would I randomly select the cues with a bang from the controller? I’ve looked around the tutorials but maybe I am missing something. Also, I want the sounds to loop until there is another bang to randomly select the next sound file. I do not know how to do this with cues. And haven’t found an answer yet in the tutorials or forums. I’ll keep looking and play around but the set up I have now works, it just is not very elegant and has a little latency.

Thanks again.

Best,
Suzie

#148883
Jan 22, 2009 at 5:18am

Here’s a small example patch, all the functions of both [sfplay~] and [sflist~] are explained in their helpfiles, there are a lot more features mentioned in there as well. I hope it makes things a bit clearer for you.

lh

#P window setfont “Sans Serif” 18.;
#P window linecount 1;
#P comment 506 46 130 196626 trigger cues;
#P window setfont “Sans Serif” 9.;
#P hidden newex 580 97 27 196617 – 1;
#P number 547 175 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 247 184 62 196617 prepend set;
#P window linecount 5;
#P message 247 204 129 196617 preload 5 “Macintosh HD:/Users/lukehall/Music/Ideas/Guardians/voxverse1.aif” 45000 53000;
#P window linecount 1;
#P newex 55 161 76 196617 prepend embed;
#P toggle 55 143 15 0;
#P newex 460 193 66 196617 prepend loop;
#P toggle 460 175 15 0;
#P number 580 117 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 547 117 15 12;
#P newex 547 135 43 196617 random;
#P newex 547 155 27 196617 + 2;
#P newex 547 193 94 196617 prepend somename;
#P user ezdac~ 547 239 591 272 0;
#N sfplay~ 1 120960 0 ;
#P newobj 547 216 44 196617 sfplay~;
#P number 330 143 53 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 271 143 53 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 212 123 15 0;
#P newex 212 141 56 196617 opendialog;
#P number 170 123 35 9 2 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 153 123 15 12;
#P newex 153 141 27 196617 i;
#P newex 153 161 188 196617 sprintf preload %ld “%s” %ld %ld;
#N sflist~ somename 0;
#P newobj 153 184 89 196617 sflist~ somename;
#P window linecount 2;
#P comment 157 88 214 196617 set a cue number , an audio file and the start and end points then press the leftmost button;
#P comment 55 115 78 196617 save cues with the patch?;
#P window linecount 1;
#P comment 460 159 68 196617 loop the cue?;
#P comment 647 194 108 196617 refer to the [sflist~];
#P comment 581 156 126 196617 2 is the lowest cue number;
#P comment 619 118 144 196617 set this to the number of cues;
#P window setfont “Sans Serif” 18.;
#P comment 119 45 100 196626 set cues;
#P connect 25 0 26 0;
#P connect 10 0 9 0;
#P connect 9 0 8 0;
#P connect 8 0 7 0;
#P fasten 26 0 7 0 60 181 158 181;
#P connect 11 0 9 1;
#P connect 13 0 12 0;
#P connect 12 0 8 1;
#P fasten 8 0 28 0 158 181 252 181;
#P connect 28 0 27 0;
#P connect 14 0 8 2;
#P connect 15 0 8 3;
#P connect 23 0 24 0;
#P connect 21 0 20 0;
#P connect 20 0 19 0;
#P connect 19 0 29 0;
#P connect 29 0 18 0;
#P fasten 24 0 16 0 465 213 552 213;
#P connect 18 0 16 0;
#P connect 16 0 17 0;
#P hidden connect 11 0 30 0;
#P hidden connect 30 0 22 0;
#P connect 22 0 20 1;
#P fasten 16 0 17 1 552 235 586 235;
#P window clipboard copycount 32;

#148884
Jan 22, 2009 at 6:14am

hey lh,

thanks so much for the patch. it provided one of those “a-ha” moments. i had looked at the help files for sflist and sfplay before but the true meaning (and power) just didn’t sink in. prepend is my new friend. your generosity is very sincerely appreciated.

best,
s.

#148885
Jan 22, 2009 at 9:11pm

#148886

You must be logged in to reply to this topic.