/****MIXDOWN PLAYER ****/ ;joachim heintz june 2010 ;Mixes N mono soundfiles ;to M channels, with panning. ;If N=M, it's a 1:1 player. sr = 44100 ksmps = 64 nchnls = 2; change here if your device has more channels 0dbfs = 1 chn_S "_MBrowse", 1 opcode StrayGetEl, ii, Sijj ;returns the startindex and the endindex (= the first space after the element) for ielindex in String. if startindex returns -1, the element has not been found Stray, ielindx, isepA, isepB xin ;;DEFINE THE SEPARATORS isep1 = (isepA== -1? 32 : isepA) isep2 = (isepA== -1&& isepB== -1? 9 : (isepB == -1 ? isep1 : isepB)) Sep1 sprintf "%c",isep1 Sep2 sprintf "%c",isep2 ;;INITIALIZE SOME PARAMETERS ilen strlen Stray istartsel = -1;startindex for searched element iendsel = -1;endindex for searched element iel = 0;actual number of element while searching iwarleer = 1 indx = 0 if ilen == 0 igoto end ;don't go into the loop if Stray is empty loop: Snext strsub Stray,indx, indx+1; next sign isep1p strcmp Snext,Sep1; returns 0 if Snext is sep1 isep2p strcmp Snext,Sep2; 0 if Snext is sep2 ;;NEXT SIGN IS NOT SEP1 NOR SEP2 if isep1p != 0 && isep2p != 0 then if iwarleer == 1 then; first character after a separator if iel == ielindx then; if searched element index istartsel = indx;set it iwarleer = 0 else ;ifnot searched element index iel = iel+1;increase it iwarleer = 0;log thatit's not a separator endif endif ;;NEXT SIGN IS SEP1 OR SEP2 else if istartsel > -1 then; if this is first selector after searched element iendsel = indx;set iendsel igoto end;break else iwarleer = 1 endif endif loop_lt indx,1, ilen, loop end: xout istartsel,iendsel endop opcode StrayLen, i, Sjj ;returns the number of elements in Stray. elements are defined by two separators as ASCII coded characters: isep1 defaults to 32 (= space), isep2 defaults to 9 (= tab). if just one separator is used, isep2 equals isep1 Stray, isepA, isepB xin ;;DEFINE THE SEPARATORS isep1 = (isepA== -1? 32 : isepA) isep2 = (isepA== -1&& isepB== -1? 9 : (isepB == -1 ? isep1 : isepB)) Sep1 sprintf "%c",isep1 Sep2 sprintf "%c",isep2 ;;INITIALIZE SOME PARAMETERS ilen strlen Stray icount = 0;number of elements iwarsep = 1 indx = 0 if ilen == 0 igoto end ;don't go into the loop if String is empty loop: Snext strsub Stray,indx, indx+1; next sign isep1p strcmp Snext,Sep1; returns 0 if Snext is sep1 isep2p strcmp Snext,Sep2; 0 if Snext is sep2 if isep1p == 0 || isep2p == 0 then; if sep1 or sep2 iwarsep = 1;tell the log so else ;if not if iwarsep == 1 then ; and has been sep1 or sep2 before icount = icount+ 1; increase counter iwarsep = 0;and tell you are ot sep1 nor sep2 endif endif loop_lt indx,1, ilen, loop end: xout icount endop opcode MxdwnPlay, 0, Siiiiki Stray, ilen, ichnls, ifirstchn, iel, kvol, iskip xin ipan = iel* ((ichnls-1)/(ilen-1)) ioutch1 = int(ipan)+ifirstchn ioutch2 = ioutch1+1 Soutch1 sprintf "outchn%d",ioutch1 Soutch2 sprintf "outchn%d",ioutch2 ipan2 = frac(ipan) ist, ien StrayGetEl Stray,iel, 124 Sel strsub Stray,ist, ien asig soundin Sel,iskip iscale = ichnls/ ilen a1, a2 pan2 asig*iscale*kvol,ipan2 chnmix a1,Soutch1 if ipan != 0 then chnmix a2,Soutch2 endif if iel < ilen-1 then MxdwnPlay Stray,ilen, ichnls, ifirstchn, iel+1, kvol, iskip endif endop opcode ShowLED_a, 0, Sakkk ;Shows an audio signal in an outvalue channel. You can choose to show the value in dB or in raw amplitudes. ;;Input: ;Soutchan: string with the name of the outvalue channel ;asig: audio signal which is to displayed ;kdispfreq: refresh frequency (Hz) ;kdb: 1 = show in dB, 0 = show in raw amplitudes (both in the range 0-1) ;kdbrange: if idb=1: how many db-steps are shown (e.g. if 36 you will not see anything from a signal below -36 dB) Soutchan, asig, kdispfreq, kdb, kdbrange xin kdispval max_k asig,kdispfreq, 1 if kdb != 0 then kdb = dbfsamp(kdispval) kval = (kdbrange+ kdb) / kdbrange else kval = kdispval endif outvalue Soutchan,kval endop opcode ShowOver_a, 0, Sakk ;Shows if the incoming audio signal was more than 1 and stays there for some time ;;Input: ;Soutchan: string with the name of the outvalue channel ;asig: audio signal which is to displayed ;kdispfreq: refresh frequency (Hz) ;khold: time in seconds to "hold the red light" Soutchan, asig, kdispfreq, khold xin kon init 0 ktim times kstart init 0 kend init 0 khold = (khold< .01? .01 : khold); avoiding too short hold times kmax max_k asig,kdispfreq, 1 if kon == 0 && kmax > 1 then kstart = ktim kend = kstart+ khold outvalue Soutchan,kmax kon = 1 endif if kon == 1 && ktim > kend then outvalue Soutchan,0 kon = 0 endif endop opcode CollectShowClear, 0, iiikiii ;collect the audio channels, sends them to the display, and clears the global audio channel ichnls, ifirstout, icount, ktrigdisp, idboramp, idbrange, icliphold xin Soutchn sprintf "outchn%d",icount+ifirstout Sdisp sprintf "out%d",icount+1 Sover sprintf "over%d",icount+1 Schn sprintf "chn%d",icount+1 Schnval sprintf "%d",ifirstout+icount acollect chnget Soutchn outch ifirstout+icount,acollect ShowLED_a Sdisp,acollect, ktrigdisp, idboramp, idbrange ShowOver_a Sover,acollect, ktrigdisp, icliphold outvalue Schn,Schnval chnclear Soutchn if icount+1 < ichnls then CollectShowClear ichnls, ifirstout, icount+1, ktrigdisp, idboramp, idbrange, icliphold endif endop instr 1 ;input values Stray chnget "_MBrowse" ist, ien StrayGetEl Stray,0, 124; get duration from the first element Sfirst strsub Stray,ist, ien idur filelen Sfirst ilen StrayLen Stray,124 kchnls invalue "numoutch" kfirstout invalue "firstout" kskip invalue "skip" kdb invalue "db" kvol = ampdb(kdb) ichnls = i(kchnls) ifirstout = i(kfirstout) iskip = i(kskip) p3 = idur- iskip ;play as many channels as there are monofiles given, and pan to the output channels MxdwnPlay Stray,ilen, ichnls, ifirstout, 0, kvol, iskip ;;display time ktim timeinsts kplaypos = iskip+ ktim kposmin = floor(kplaypos/60) kpossec = floor(kplaypos%60) Smin sprintfk "%02d",kposmin Ssec sprintfk "%02d",kpossec outvalue "min",Smin outvalue "sec",Ssec ;;collect and display mixdown audio signals idboramp = 1;0=raw amps, 1=db idbrange = 48 icliphold = 2 ktrigdisp metro 10 CollectShowClear ichnls, ifirstout, 0, ktrigdisp, idboramp, idbrange, icliphold endin i 1 0 1 e 0 0 473 587 true 170 170 127 30 56 399 124 {e7d12ace-4150-46b5-929b-12b1cb9665aa} true 0 -3 324 316 96 76 {1bfffffe-61dc-4355-8d70-96591bf074a2} true 0 -3 375 362 37 28 {d7ca2aae-1384-4486-9c52-8c527b828211} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 333 362 37 28 {52f700e3-1b22-4bc9-b53f-f1125ea6f976} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 364 339 17 27 {a9d9274f-379f-4db8-86a2-1d04781b8628} true 0 -3 center Arial 14 3 0 0 0 255 255 255 noborder 1 1 sec 379 339 33 26 {a3a1342d-dd5b-419c-8b75-982f9d4c9592} true 0 -3 left Arial 14 3 0 0 0 255 255 255 noborder 1 1 min 333 339 33 26 {0e9ebddd-002b-4d81-9f3e-31d8174a9824} true 0 -3 right Arial 14 3 0 0 0 255 255 255 noborder 1 1 324 316 94 26 {a82a80c2-a91d-4602-b7b9-f7a43bf27c9f} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 numoutch 230 319 43 28 {fa061585-35fe-4b3e-8430-ab36d8832901} true 0 -3 left Arial 12 0 0 0 255 255 255 1.00000000 0 1e+12 false 2 29 319 203 27 {26b0c8cc-b398-4ff3-9808-b0d8ba7287ba} true 0 -3 left Arial 12 3 0 0 0 255 255 255 noborder 1 1 firstout 184 350 44 27 {b2a47df0-7f7f-4758-b32d-6e630f52968d} true 0 -3 left Arial 12 0 0 0 255 255 255 1.00000000 0 1e+12 false 1 29 350 156 27 {6b0b43c9-be40-4456-9e0f-292305d8c4e0} true 0 -3 left Arial 12 3 0 0 0 255 255 255 noborder 1 1 352 118 33 29 {e5582d70-8ce5-4c13-b3cf-1881b90a64ac} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 316 119 33 29 {b53ba656-e24c-4e19-b691-046114065a73} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 278 119 33 29 {94b9f142-532b-4c7d-ab6b-59b855371762} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 241 119 33 29 {56576ebf-1348-4ed8-bbf8-98040716404f} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 205 119 33 29 {b1dda0f4-3208-42cf-8dce-9fa4c5b84291} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 168 119 33 29 {cc6164c0-5283-4586-b272-0965f8af304c} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 131 119 33 29 {c12d11bc-4e9f-4cca-a214-87fe8decef1f} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 94 119 33 29 {f07326a2-2d40-4520-a3c4-cb13f0e6a4aa} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 352 148 33 29 {04836764-ae09-40d9-a9e1-3f83dce56fa5} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 94 147 33 29 {82a72ce3-b186-482b-976d-944b8f7d785c} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 29 146 52 29 {c24d1300-e14b-40de-b04a-b811acd9fefe} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 29 118 52 29 {7cc2eebb-6511-40e4-9da1-af23fe354c21} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 30 59 397 59 {eac54750-f5e9-4b16-a34e-a692ad43125f} true 0 -3 center Arial 12 3 0 0 0 255 255 255 noborder 1 1 73 11 308 42 {e23734f1-521f-4e65-9d55-58f2751ebc8b} true 0 -3 center Arial 22 3 0 0 0 255 255 255 noborder 1 1 42 277 67 27 {06c607cd-5822-47bb-9ecf-977bebb09709} true 0 -3 right Arial 12 3 0 0 0 255 255 255 noborder 1 1 370 278 47 27 {940a92e4-9d25-4003-9578-7ca125f0b716} true 0 -3 left Arial 12 3 0 0 0 255 255 255 noborder 1 1 db 320 277 52 28 {b91f69a5-a47c-4ea1-9d0f-046e44defbd8} true 0 -3 left Arial 12 3 0 0 0 255 255 255 noborder 1 1 253 188 80 25 {6d596540-3556-428d-bf81-e3302d85780c} true 0 -3 right Arial 10 3 0 0 0 255 255 255 noborder 1 1 db 109 277 212 28 {25d39018-0dcb-4f63-a4b6-519ef8219aa7} true 0 -3 -12.00000000 12.00000000 0.00000000 lin continuous -1.00000000 false skip 336 187 65 27 {1eeb0757-ffae-471e-a3fa-4210eaa86a53} true 0 -3 left Arial 12 0 0 0 255 255 255 0.00100000 0 1e+12 false 0 _MBrowse 19 228 417 27 {ea4bc9f6-b558-4a2a-9410-25edec264224} true 0 -3 _MBrowse 71 186 100 30 {368327a9-899a-403b-a55b-95357c3dbafe} true 0 -3 value 1.00000000 Select Files / false false out1 32 419 25 100 {496461c8-c3d7-47f7-8492-0468174480e7} true 0 -3 out1 0.00000000 1.00000000 0.00000000 1.00000000 -0.75150371 -0.75150371 fill 1 0.00000000 jump 0 234 0 false 0 0 0 over1 32 395 25 25 {37e14c1d-f864-4d2d-a955-3ef825e77185} true 0 -3 over1 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 155 3 0 false 0 0 0 out2 64 419 25 100 {b8737139-8ae2-4743-98db-a80e11912ca3} true 0 -3 out2 0.00000000 1.00000000 0.00000000 1.00000000 -0.80731731 -0.80731731 fill 1 0.00000000 jump 0 234 0 false 0 0 0 over2 64 395 25 25 {a8e39457-553c-41c5-bf44-ccf3379bc584} true 0 -3 over2 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 155 3 0 false 0 0 0 out3 97 419 25 100 {605082ea-44b3-4aed-9dad-b54709f3b8f9} true 0 -3 out3 0.00000000 1.00000000 0.00000000 1.00000000 -inf -inf fill 1 0.00000000 jump 0 234 0 false 0 0 0 over3 97 395 25 25 {48db23f6-2e0d-4d1e-974e-c9487c4c3138} true 0 -3 over3 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 155 3 0 false 0 0 0 out4 129 419 25 100 {9e16567b-0059-4f86-9b4d-300aa5bf2afe} true 0 -3 out4 0.00000000 1.00000000 0.00000000 1.00000000 -inf -inf fill 1 0.00000000 jump 0 234 0 false 0 0 0 over4 129 395 25 25 {26355726-dad2-44a1-8043-e4620741fd15} true 0 -3 over4 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 155 3 0 false 0 0 0 out5 163 419 25 100 {81470802-54bd-4a6c-be49-daa9a478552d} true 0 -3 out5 0.00000000 1.00000000 0.00000000 1.00000000 -inf -inf fill 1 0.00000000 jump 0 234 0 false 0 0 0 over5 163 395 25 25 {8db2e10f-1624-4d72-b4fe-1778191df70e} true 0 -3 over5 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 155 3 0 false 0 0 0 out6 195 419 25 100 {e83b3c5d-c1bc-4d3f-85c5-856165c8bb9d} true 0 -3 out6 0.00000000 1.00000000 0.00000000 1.00000000 -inf -inf fill 1 0.00000000 jump 0 234 0 false 0 0 0 over6 195 395 25 25 {8714d646-5805-4fc5-848c-00eb7e3dc30e} true 0 -3 over6 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 155 3 0 false 0 0 0 out7 228 419 25 100 {dc9eba00-b83d-4179-802b-b91532fd134a} true 0 -3 out7 0.00000000 1.00000000 0.00000000 1.00000000 -inf -inf fill 1 0.00000000 jump 0 234 0 false 0 0 0 over7 228 395 25 25 {6d0b2991-eed8-4871-947f-67bc67313855} true 0 -3 over7 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 155 3 0 false 0 0 0 out8 260 419 25 100 {99e658f1-d30b-415a-8a60-528f39dfd1e6} true 0 -3 out8 0.00000000 1.00000000 0.00000000 1.00000000 -inf -inf fill 1 0.00000000 jump 0 234 0 false 0 0 0 over8 260 395 25 25 {85b38a7f-e962-4601-bced-83da2ddb45fd} true 0 -3 over8 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 155 3 0 false 0 0 0 chn1 32 527 26 28 {93704853-a825-47eb-8ebe-f98787fc5f93} true 0 -3 center Arial 14 3 0 0 0 255 255 255 noborder 1 1 chn2 65 527 26 28 {7eac2f72-d419-4170-aae4-ae86c93a883d} true 0 -3 center Arial 14 3 0 0 0 255 255 255 noborder 1 1 chn3 96 527 26 28 {e65ccd55-3ea5-4533-98a9-2cbb7522c808} true 0 -3 chn4 129 527 26 28 {b623e5e3-f099-48fa-bf4d-47d1ce8740aa} true 0 -3 chn5 162 527 26 28 {56cd1e29-4de0-4afd-b397-dfdfd0706ad5} true 0 -3 chn6 195 527 26 28 {342db427-ee50-4a2d-89a2-1e4019a29082} true 0 -3 chn7 226 527 26 28 {de3febd8-3541-47b8-b52a-64f587255123} true 0 -3 chn8 259 527 26 28 {754a616e-23e5-4592-ac5e-14644c8261af} true 0 -3 324 531 80 25 {197181c4-cd2d-4977-bf2e-f6570b96c4a3} true 0 -3 left Arial 12 3 0 0 0 255 255 255 noborder 1 1 319 396 116 123 {5fc86a90-3ef0-4d41-a138-8342b66ec8b9} true 0 -3 left Arial 10 3 0 0 0 255 255 255 noborder 1 1