home *** CD-ROM | disk | FTP | other *** search
/ PC Musician 2000 / PC_Musician_2000.iso / PCMUSIC / SEQUENCE / CAL_CONT / C-NTROLR.CAL < prev    next >
Encoding:
Text File  |  1991-08-26  |  5.6 KB  |  222 lines

  1. ;;; Robert C. Prince, III  Cakewalk Pro SN: 406176-CP-4.0A
  2. ;;; P. O. Box 8043
  3. ;;; Athens, GA 30603-8043
  4. ;;; (404) 725-1014
  5. ;;;
  6. ;;; CONTROLR.CAL
  7. ;;;
  8. ;;; This is a CAL program that allows the user to change data for any
  9. ;;;  controller using addition or subtaction of a fixed amount, a high
  10. ;;;  and low boundary, or a percentage.
  11. ;;;
  12. ;;;  NOTE: This program automatically deletes any consecutive duplicate
  13. ;;;        controller values that are on the same MIDI channel.
  14. ;;;
  15. ;;; *********************************************************************
  16. ;;; Prolog
  17. (do
  18.    ; set variables
  19.    (int wtd 1)       ; what user wants to do, fixed change default
  20.    (int ctrlr 7)     ; which controller to affect, volume (7) is default
  21.    (int Fixed 1)     ; if wtd=1 user wants fixed add/subtract
  22.    (int HiLo 2)      ; if wtd=2 user wants hi low boundaries
  23.    (int Pct 3)       ; if wtd=3 user wants percentage
  24.    (int c 0)         ; counter to let user know something's happening
  25.    (int TEP 0)       ; total events processed
  26.    (int TCVS 0)      ; Temporary Controller Value Saver
  27.    (int TCCS 18)     ; Temporary Controller Channel Saver
  28.    (int d 0)         ; # dupes eliminated
  29.  
  30.    ; get which controller user wants to affect
  31.    (getInt ctrlr "Controller Number: " 1 127)
  32.  
  33.    ; get what user wants to do with the controller data
  34.    (getInt wtd "Fixed=1 Hi/Low=2 Percentage=3:" 1 3)
  35.  
  36.    ; now set the variables according to the task to complete
  37.    (switch wtd
  38.       
  39.       ;if user chose Fixed, do the following
  40.       Fixed     (do
  41.                    (int amt 10)
  42.                    (getInt amt "Amount to add?" -127 127)
  43.                 )
  44.  
  45.       ; if user chose Hi/Low, do the following
  46.       HiLo      (do
  47.                    (int H 127)   ; the highest data allowed
  48.                    (int L 0)     ; the lowest data allowed
  49.                    (getInt H "Highest amount:" 0 127 ) ; get Hi
  50.                    (getInt L "Lowest amount:" 0 127 )  ; get the Low
  51.                 )
  52.  
  53.       ; if user chose Percentage, do the following
  54.       Pct       (do
  55.                    (int percent 100)
  56.                    (getInt percent "Percentage?" 1 1000)
  57.                 )
  58.  
  59.    ;close off the switch parens
  60.    )
  61.  
  62. ;close off the do parens
  63. )
  64.  
  65. ;;; *********************************************************************
  66. ;;; Body
  67. ;;;
  68.  
  69. (do
  70.  
  71.    ; let user know something's being done
  72.    (message "Controller " ctrlr
  73.             "Events: " c
  74.             " Total Events: " TEP
  75.             "  Duplicates Deleted: " d
  76.    )
  77.  
  78.    ; bump up total events processed
  79.    (++ TEP)
  80.  
  81.    ; if the kind of event is a controller do something
  82.    (if (== Event.Kind CONTROL)
  83.  
  84.       ; yes it is a controller event, so see if it matches user's choice
  85.          (if (== Control.Num ctrlr)
  86.  
  87.             ; yes it matches user's choice
  88.             (do
  89.  
  90.                (switch wtd
  91.  
  92.                   ; if user chose Fixed, do the following
  93.                   Fixed     (+= Control.Val amt)
  94.  
  95.                   ; if user chose Hi/Low, do the following
  96.                   HiLo      (do
  97.                                ; is the data less than L?
  98.                                (if (< Control.Val L)
  99.  
  100.                                   ; YES, so make it equal L
  101.                                   (= Control.Val L)
  102.  
  103.                                   ; NO -- move on to next question
  104.                                   NIL
  105.  
  106.                                ; close off the if paren
  107.                                )
  108.  
  109.                                ; is the data greater than H?
  110.                                (if (> Control.Val H)
  111.  
  112.                                   ; YES, so make it equal H
  113.                                   (= Control.Val H)
  114.  
  115.                                   ; NO -- move on to next event
  116.                                   NIL
  117.  
  118.                                ; close off the if paren
  119.                                )
  120.  
  121.                             ;close off the do paren
  122.                             )
  123.  
  124.                   ; if user chose Percentage, do the following
  125.                   Pct
  126.                             (do
  127.                                 ; multiply data by percent
  128.                                 (*= Control.Val percent)
  129.  
  130.                                 ; divide result by 100
  131.                                 (/= Control.Val 100)
  132.  
  133.                              ;close off do paren
  134.                              )
  135.  
  136.                ;close off switch paren
  137.                )
  138.  
  139.                ; bump counter up
  140.                (++ c)
  141.  
  142.                ; delete any duplicates
  143.                (if (&& (== Control.Val TCVS) (== Event.Chan TCCS))
  144.                  ; yes it is a duplicate on the same MIDI channel
  145.                  (do
  146.                    (delete)
  147.                    (++ d)   ;; bump the # deletes counter up
  148.                  )
  149.                  ; no it is not a dupe, so store it's value and Chan #
  150.                  (do
  151.                    (= TCVS Control.Val)
  152.                    (= TCCS Event.Chan)
  153.                  )
  154.                )
  155.  
  156.             ; close the yes event matches user's choice do paren
  157.             )
  158.  
  159.             ; no, it does not match user's choice, so do nothing
  160.             NIL
  161.  
  162.          ; close of if controller number matches user's choice paren
  163.          )
  164.  
  165.       ; no it is not a controller event, so do nothing
  166.          NIL
  167.  
  168.    ; close off if event is controller paren
  169.    )
  170.  
  171. ; close off body/do paren
  172. )
  173.  
  174. ;;; *********************************************************************
  175. ;;; Epilog
  176. ;;;
  177.  
  178. NIL
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.