home *** CD-ROM | disk | FTP | other *** search
/ Hope PC Multimedia SuperPack 2 / HOMEPC.iso / CAKEWALK / SPLITNOT.CA_ / SPLITNOT.bin
Text File  |  1996-02-22  |  4KB  |  123 lines

  1. ;
  2. ; SPLITNOT.CAL
  3. ;
  4. ; This routine modifies a source track, splitting it by note# into 
  5. ; separate destination tracks. Only notes are split ... all other 
  6. ; track parameters (Controllers, Tempos, Meters and Markers), 
  7. ; if any, remain in the source track.
  8. ;
  9. ; Use this routine for splitting up a drum machine or other type 
  10. ; of instrument track where voices are assigned by note number.
  11. ;
  12. ; = Courtesy Red Nile Productions 1993 (714)498-7515 CIS:70044,2733
  13. ;
  14. ; = Modified 12/10/93 by Greg Hendershott at user's request to
  15. ;   have this display notes as names (like C#5) rather than numbers
  16. ;   in the track names.  Caveat: The note names always use sharps
  17. ;   and assume BaseOctave=0.
  18.  
  19. (do
  20.     (if (< VERSION 20)
  21.         (do
  22.             (pause "This CAL program requires CAL version 2.0 or higher")
  23.             (exit)
  24.         )
  25.     )
  26.     (include "need20.cal")    ; Require version 2.0 or higher of CAL
  27.  
  28.     (int nOctave)
  29.     (int nSrcTrk 1)
  30.     (int nDestTrk (+ nSrcTrk 1))
  31.     (int nDestChan 0)
  32.     (int nDestPort 1)
  33.     (int nNote 0)
  34.     (int bEvent FALSE)
  35.  
  36.     (getInt nSrcTrk "Source Track?" 1 256)
  37.     (-- nSrcTrk)    ; CAL uses 0..255
  38.  
  39.     (getInt nDestTrk "First Destination Track?" 1 256)
  40.     (-- nDestTrk)    ; CAL uses 0..255
  41.  
  42.     (getInt nDestChan "Destination Channel?" 0 16)
  43.     (-- nDestChan)    ; CAL uses -1..15
  44.  
  45.     (getInt nDestPort "Destination Port?" 1 16)
  46.     (-- nDestPort)    ; 0 .. 15
  47.  
  48.     ; If markers not set, select entire range
  49.     (if (== From Thru) 
  50.         (do
  51.             (= From 0)
  52.             (= Thru End)
  53.         )
  54.     )
  55.  
  56.     ; Select only source track
  57.     (TrackSelect 0 -1)
  58.     (TrackSelect 1 nSrcTrk)
  59.  
  60.     ; Set filter params. Split notes only .. 
  61.     ; Controllers stay in source track.
  62.     (ResetFilter 0 TRUE)
  63.     (SetFilterKind 0 NOTE TRUE)
  64.     (SetFilterKind 0 KEYAFT FALSE)
  65.     (SetFilterKind 0 CONTROL FALSE)
  66.     (SetFilterKind 0 PATCH FALSE)
  67.     (SetFilterKind 0 CHANAFT FALSE)
  68.     (SetFilterKind 0 WHEEL FALSE)
  69.     
  70.     (while (< nNote 127)
  71.         (do
  72.             ; Check for note events at current note # ...
  73.             (forEachEvent
  74.                 (if (&& (== Event.Kind NOTE) (== Note.Key nNote))
  75.                     (= bEvent TRUE)
  76.                 )
  77.             )
  78.  
  79.             ; If there are note events, paste them to the destination track
  80.             (if (== bEvent TRUE)
  81.                 (do
  82.                     ; Status message
  83.                     (message "Note # " nNote " --> Track " (+ 1 nDestTrk))
  84.  
  85.                     ; Set up filter .. item 0, NOTE, in the range nNote..nNote
  86.                     (SetFilterRange 0 0 TRUE nNote nNote)
  87.                     
  88.                     ; Cut/Paste the filtered events to the destintation track
  89.                     (EditCut From Thru TRUE TRUE FALSE FALSE FALSE FALSE)
  90.                     (EditPasteToTrack From 1 1 TRUE FALSE FALSE FALSE nDestTrk)
  91.  
  92.                     ; Name dest track
  93.                     (= nOctave (/ nNote 12))
  94.                     (switch (% nNote 12)
  95.                         0 (TrackName (format "Split Note C" nOctave) nDestTrk)
  96.                         1 (TrackName (format "Split Note C#" nOctave) nDestTrk)
  97.                         2 (TrackName (format "Split Note D" nOctave) nDestTrk)
  98.                         3 (TrackName (format "Split Note D#" nOctave) nDestTrk)
  99.                         4 (TrackName (format "Split Note E" nOctave) nDestTrk)
  100.                         5 (TrackName (format "Split Note F" nOctave) nDestTrk)
  101.                         6 (TrackName (format "Split Note F#" nOctave) nDestTrk)
  102.                         7 (TrackName (format "Split Note G" nOctave) nDestTrk)
  103.                         8 (TrackName (format "Split Note G#" nOctave) nDestTrk)
  104.                         9 (TrackName (format "Split Note A" nOctave) nDestTrk)
  105.                         10 (TrackName (format "Split Note A#" nOctave) nDestTrk)
  106.                         11 (TrackName (format "Split Note B" nOctave) nDestTrk)
  107.                     )
  108.                     
  109.                     ; Set forced channel & port, and unmute it
  110.                     (TrackChannel nDestChan nDestTrk)
  111.                     (TrackPort nDestPort nDestTrk)
  112.                     (TrackActive TRUE nDestTrk)
  113.                     
  114.                     (++ nDestTrk)
  115.                     (= bEvent FALSE)
  116.                 )
  117.             )
  118.             ; Else
  119.             (++ nNote)
  120.         )
  121.     )
  122. )
  123.