home *** CD-ROM | disk | FTP | other *** search
- /* RexxEdit example ARexx macro program */
-
- /* Velocity scaler written entirely in ARexx */
-
- options results /* always include this command */
-
- MXSLIDER "Initial Level:,0,300" /* percentage level change */
-
- MXSLIDER "Final Level:,0,300" /* percentage level change */
-
- MXSLIDER "Random Factor:,0,100" /* random fluctuations */
-
- MXNOTESIZE "Duration:" /* duration selector */
-
- MXRADIO "Attack velocity,Release velocity" /* mutually exclusive */
-
- MXRADIO "Selected events,All events" /* mutually exclusive */
-
- MXREQUEST "AREXX VELOCITY SCALER,SCALE" /* bring up requester & wait */
- if result == 0 then exit /* 0 if user canceled */
-
- MXPOINTER "sleepy" /* tell user we're busy */
-
- MXVALUE 1 /* get initial level */
- initval = result
-
- MXVALUE 2 /* get final level */
- finalval = result
-
- MXVALUE 3 /* get random level */
- rndfactor = result
-
- MXVALUE 5 /* attack or release velocity */
- veltype = result
-
- notecount = 0 /* do scan to just find start and end times */
-
- MXVALUE 6 /* selected or all events */
- if result == 0 then BEGINSCAN 'selected'
- else BEGINSCAN 'all'
-
- if result ~= 0 then do forever /* if BEGINSCAN ok, scan events */
-
- NEXTEVENT /* get next event */
- if result == 0 then break /* 0 if no more events */
-
- if EVENT.TYPE == 'NOTE' then do /* if a note... */
- if notecount == 0 then do /* if no notes found yet... */
- if EVENT.CLOCKTYPE == 'ABS' then starttime = EVENT.START.QFRAMES
- else starttime = EVENT.START.TICKS
- end
- else do /* if have start value... */
- if EVENT.CLOCKTYPE == 'ABS' then stoptime = EVENT.START.QFRAMES
- else stoptime = EVENT.START.TICKS
- end
- notecount = notecount + 1 /* add one to note count */
- end
- end
- ENDSCAN /* terminate the first scan */
-
- /* if only one note or start & stop times the same, no scaling needed */
-
- if notecount < 2 | starttime == stoptime then do
- MXPOINTER "normal"
- exit
- end
-
- offtime = stoptime - starttime /* time diference */
- offval = finalval - initval /* velocity change over time */
- if rndfactor > 0 then random(1,1,time('S')) /* initialize random command */
-
- MXVALUE 4 /* begin the second scan */
- if result == 0 then BEGINSCAN 'selected'
- else BEGINSCAN 'all'
-
- if result ~= 0 then do forever
-
- NEXTEVENT /* get next event */
- if result == 0 then break /* 0 if no more events */
-
- if EVENT.TYPE == 'NOTE' then do /* if a note... */
- /* get the event's time */
- if EVENT.CLOCKTYPE == 'ABS' then thistime = EVENT.START.QFRAMES
- else thistime = EVENT.START.TICKS
-
- /* scale & randomize */
- percent = (offval * (thistime - starttime)) % offtime + initval
- if rndfactor > 0 then
- percent = percent + random(0,2 * rndfactor) - rndfactor
-
- /* adjust correct velocity */
- if veltype == 0 then do
- EVENT.ATTACK = (EVENT.ATTACK * percent) % 100
- if (EVENT.ATTACK < 0) then EVENT.ATTACK = 0
- if (EVENT.ATTACK > 127) then EVENT.ATTACK = 127
- end
- else do
- EVENT.RELEASE = (EVENT.RELEASE * percent) % 100
- if (EVENT.RELEASE < 0) then EVENT.RELEASE = 0
- if (EVENT.RELEASE > 127) then EVENT.RELEASE = 127
- end
-
- REPLEVENT /* replace the event */
-
- end
- end
- ENDSCAN /* end second scan */
-
- MXPOINTER "normal" /* done! */
-