home *** CD-ROM | disk | FTP | other *** search
- /* linear interpolation between selected events */
- /* written by Henry Lowengard, after much prodding by Ken Bookstein */
- /* modified by Joe Pearce (2-15-91) */
-
- /* The FIRST selected event of the indicated type (CTL, PBEN, etc.) */
- /* determines the channel (and control number if CTL or note number */
- /* if polyphonic AT) of events that will be "sloped". Here is what */
- /* is affected in each case: */
- /* Control Change (CTL): Controller Value */
- /* Pitch Bend (PBEN): Bend Value */
- /* Channel Aftertouch (CAT): Pressure */
- /* Polyphonic Aftertouch (PAT): Pressure */
-
- Options results
-
- /* hokey box creator */
-
- MXLABEL "Event Type:"
- MXRADIO "Control Change,Pitch Bend,Channel AT,Polyphonic AT"
- MXSLIDER " Step Width:,1,10,1"
- MXREQUEST "Interpolate Event Slope,SLOPE"
- if result == 0 then exit
-
- /* get the data */
-
- MXVALUE 2
- i = Result
- if i = 0 then Etype = 'CTL'
- if i = 1 then Etype = 'PBEN'
- if i = 2 then Etype = 'CAT'
- if i = 3 then Etype = 'PAT'
-
- MXVALUE 3
- Stepsize = Result
- if Etype = "PBEN" then StepSize = StepSize * 128
-
- GETBARDATA
-
- /* use brain, do work ! */
- evtIota = 1 /* array of selected goodies */
- MXPOINTER "sleepy"
-
- BEGINSCAN 'selected'
- /* trace r */
- if result ~=0 then do forever
- NEXTEVENT
- if result == 0 then break /* skoot when out of events */
-
- if EVENT.TYPE == ETYPE then do
- if ETYPE = "CTL" then do
- /* looking for first or last */
- if evtIota = 1 then do
- echannel = EVENT.CHANNEL
- enum = EVENT.NUM
- end
- else if echannel ~= EVENT.CHANNEL | enum ~= EVENT.NUM then break
- EvtV.EVTIOTA = EVENT.VALUE
- EvtT.evtIota = EVENT.START.ticks
- EvtB.evtIota = EVENT.START.bars
- EvtC.evtIota = EVENT.START.clocks
- EvtIota = EvtIota +1
- end /* control change stuff */
- if Etype = "PBEN" then do
- if evtIota = 1 then echannel = EVENT.CHANNEL
- else if echannel ~= EVENT.CHANNEL then break
-
- EVTV.EVTIOTA = EVENT.NUM
- EVTT.EVTIOTA = EVENT.START.ticks
- EvtB.evtIota = EVENT.START.bars
- EvtC.evtIota = EVENT.START.clocks
- EvtIota = EvtIota +1
- end /* pbend stuff */
- if Etype = "CAT" then do
- if evtIota = 1 then echannel = EVENT.CHANNEL
- else if echannel ~= EVENT.CHANNEL then break
-
- EVTV.EVTIOTA = EVENT.PRESSURE
- EVTT.EVTIOTA = EVENT.START.ticks
- EvtB.evtIota = EVENT.START.bars
- EvtC.evtIota = EVENT.START.clocks
- EvtIota = EvtIota +1
- end /* channel AT stuff */
- if ETYPE = "PAT" then do
- /* looking for first or last */
- if evtIota = 1 then do
- echannel = EVENT.CHANNEL
- enum = EVENT.NUM
- end
- else if echannel ~= EVENT.CHANNEL | enum ~= EVENT.NUM then break
- EvtV.EVTIOTA = EVENT.PRESSURE
- EvtT.evtIota = EVENT.START.ticks
- EvtB.evtIota = EVENT.START.bars
- EvtC.evtIota = EVENT.START.clocks
- EvtIota = EvtIota +1
- end /* polyphonic AT stuff */
- end /* types matched on first one... */
- /* re scan etc etc. */
- end /* forever 8^) if beg scan's result ~=0 */
-
- evtiota = evtiota -1
- say EVTiota "is number of matching selected events!"
-
- if evtiota <= 1 then do
- MXREPORT "Not enough "||Etype||"'s selected!"
- exit
- end
-
- /* debugging code */
- /*
- do i= 1 to evtiota
- say i EvtT.i ":" EvtV.i
- end
- */
-
- /* loop around like a dope stuffing in ye events */
- do Evti = 2 to EvtIota
- EvtF=Evti-1 /* from value */
- T0 = EvtT.EvtF /* first time in clox */
- T1 = EvtT.EvtI /* ditto for end time */
- C0 = EvtV.EvtF /* low end control */
- C1 = EvtV.EvtI /* end for values */
-
- /* debugging code */
- /* MXREPORT "FROM/TO:"||t0||":"||T1||" "||c0||":"||C1||", range "||C1-C0 */
-
- DT = T1-T0
- DC = C1-C0
- ByAmt = SIGN(DC)*StepSize
-
- if dC ~= 0 then do
- OldC=-1
- do InI = c0+Byamt to c1-Byamt by ByAMT
-
- delticks = (((ini-C0)/DC)*DT)%1 + EvtC.EvtF
- EVENT.START.CLOCKS = delticks // BARDATA.MEASURE
- EVENT.START.BARS = EvtB.EvtF + delticks % BARDATA.MEASURE
- EVENT.TYPE=ETYPE
- EVENT.CHANNEL=echannel
-
- IF ETYPE = "CTL" then do
- EVENT.NUM = ENUM
- EVENT.VALUE =INI
- if Event.Value ~= OldC then do
- oldc=Event.Value
- ADDEVENT
- end
- end
- if ETYPE = "PBEN" then do
- EVENT.NUM = INI
- if Event.NUM ~= OldC then do
- oldc=Event.Num
- ADDEVENT
- end
- end
- if ETYPE = "CAT" then do
- EVENT.PRESSURE = INI
- if Event.PRESSURE ~= OldC then do
- oldc=Event.Pressure
- ADDEVENT
- end
- end
- IF ETYPE = "PAT" then do
- EVENT.NUM = ENUM
- EVENT.PRESSURE =INI
- if Event.PRESSURE ~= OldC then do
- oldc=Event.PRESSURE
- ADDEVENT
- end
- end
- end
- end /* DT is valid */
- end
-
- /* MXREPORT "All Done!" */ /* it should be obvious... */
- MXPOINTER "normal"
- exit
-