reaper/reaper-layer-sounds [ Functions ]

[ Top ] [ Functions ]

DATE

 October 1st 2022

DESCRIPTION

 Given a list of paths to sound files, create a reaper file that layers/mixes
 these together. We create as many mixes as possible given the number of
 tracks required, e.g. if there are 20 sound files and <num-tracks> is 4,
 then five mixes will be created, one after the other, with a gap of 10
 seconds by default. So the files are mixed together in the order of the
 first argument, with the longest file in the mix determining the overall
 duration and the shorter files beginning after a wait of <indent> multiplied
 by the difference between the longest and shorter files'
 durations. E.g. with a longest file duration of 60 seconds and a shorter
 file of 30 seconds, given :indent 0.5 the shorter file's start time would be
 15 seconds; if its duration was 20 seconds, the start time would be 20.

 In case sound files are passed in alphabetical order, e.g. by
 (get-sndfiles...), and assuming that it is undesireable that similarly-named
 sound files are placed one after the other, by default the function will
 shuffle the order of the mixes (i.e. the groups of 4 or whatever sound files
 per mix). NB the 4-groups are shuffled, not the files in the groups.

ARGUMENTS

 - a list of sound file paths (strings)
 - the number of tracks that should be layered/mixed

OPTIONAL ARGUMENTS

 keyword arguments:
 :tempo. The BPM value that should be written to the reaper project, if
 desired. Default = 60.
 :max-fade. The maximum length in seconds of a fade-in or fade-out. If this
 is too long for any given sound file, the :mid-fade multiplied by the sound
 file duration will be used. Default = 15 seconds.
 :min-fade. The proportion of a sound file's duration that should be used if
 :max-fade can't be used for both fade-in and fade-out. This should generally
 be < 0.5 but is not enforced. Default = 0.5.
 :reaper-file. The path of the reaper-file to be written. If this is NIL then
 no file is written and the reaper-file object is returned instead, with all
 mixes present. This could be used to add more tracks before writing the
 reaper file (see example below). Default = "/tmp/reaper-layer-sounds.rpp"
 :min-channels. The minimum number of a channels a reaper track should
 have. Usually this will be set to be the maximum number of channels any of
 the files on a single track have. But if you have a bunch of stereo files
 you want to place on, say, a track which should become 5th order ambisonics,
 you can set this to 36. Note that all reaper tracks should have an even
 number of channels so however the channel number is achieved it will be
 rouned up to the nearest even number if necessary. Default = 2.
 :max-channels. This can be set to override the number of channels of any
 given sound file, should it have more channels than you want, for some
 reason. Default = 4.
 :gap. The gap in seconds between the end of the previous mix and the start
 of the next. Default = 10 seconds.
 :shuffle. Whether to shuffle the mixes before writing. See above for
 details. Default = T.
 :indent. How far in to start the shorter sounds, as a function of their
 duration difference to the longest file (see above). 0.5 would have them
 centered bang in the middle. By default the golden mean, 0.618034 (what
 else?) i.e. (/ (- (sqrt 5) 1) 2).

RETURN VALUE

 If :reaper-file is given, then the path will be returned after writing,
 otherwise a reaper-file object is returned.

EXAMPLE

(let ((overlaps (reaper-overlap-sounds
                 (get-sndfiles "/Volumes/slim500/snd/samples/ambience/rain") 
                 :reaper-file nil))
      (layers (reaper-layer-sounds (get-sndfiles "~/ic/projects/mete/clm") 4
                                   :reaper-file nil)))
  (add (get-first (tracks overlaps)) (tracks layers))
  (write-reaper-file layers :min-channels 36
                     :file "~/ic/projects/mete/reaper/mete-clm-with-rain.rpp"))

SYNOPSIS

(defun reaper-layer-sounds (sndfiles num-tracks
                            &key (tempo 60)
                              (max-fade 15) ; seconds
                              (min-fade .4) ; proportion of duration
                              (reaper-file "/tmp/reaper-layer-sounds.rpp")
                              ;; e.g. if you want all tracks to be 26 channels
                              ;; despite the number of channels in the sound
                              ;; files set this here
                              (min-channels 2)
                              (max-channels 4)
                              ;; gap in seconds between groups
                              (gap 10)
                              ;; shuffle (fixed-seed) the subgroups so that the
                              ;; sound files are not simply processed by
                              ;; directory order?
                              (shuffle t)
                              (indent 0.618034))

reaper/reaper-overlap-sounds [ Functions ]

[ Top ] [ Functions ]

DATE

 October 1st 2022.

DESCRIPTION

 Create a reaper file with one track that overlaps/cross-fades all the given
 sound files.

ARGUMENTS

 - a list of sound files paths (strings) to overlap

OPTIONAL ARGUMENTS

 keyword arguments:
 
 :overlap. The proportion by which to overlap the sound files. Given that
 sound files can have any duration and be overlapped in any order, this
 proportion is applied to the shortest of any two sound files to be
 cross-faded. default = 0.5.
 :reaper-file. The path of the reaper-file to be written. If this is NIL then
 no file is written and the reaper-file object is returned instead, with all
 mixes present. This could be used to add more tracks before writing the
 reaper file (see example in reaper-layer-sounds). Default =
 "/tmp/reaper-layer-sounds.rpp"
 :min-channels. See reaper-layer-sounds. Default = 2.
 :max-channels. See reaper-layer-sounds. Default = 4.
 :track-name. The string used to name the track in reaper. Default =
 "overlaps"
 :tempo. The BPM value that should be written to the reaper project, if
 desired. Default = 60.

RETURN VALUE

 If :reaper-file is given, then the path will be returned after writing,
 otherwise a reaper-file object is returned. See reaper-layer-sounds for an
 example.

SYNOPSIS

(defun reaper-overlap-sounds (sndfiles &key (tempo 60) (min-channels 2)
                                         (max-channels 4) (overlap .5)
                                         (track-name "overlaps")
                                         (reaper-file
                                          "/tmp/reaper-layer-sounds.rpp"))

reaper/write-reaper-file [ Methods ]

[ Top ] [ Methods ]

DESCRIPTION

 Write a reaper file from the reaper-items in the data slot.

ARGUMENTS

 - a reaper-file object

OPTIONAL ARGUMENTS

 keyword arguments: 
 - :file. The path of the reaper file to write. Default will be the id slot
   of the reaper-file object + .rpp, placed in the default-directory of
   slippery-chicken (itself /tmp by default).
 - :markers. These are either a simple list of times (in seconds) or a
   mixture containing sublists such as (marker-number time-in-secs
   label-string colour), or just the first two or three of those. See the
   write-reaper-marker method for details. Default = NIL.
 - :min-channels (default 2) and :max-channels (default 4). These are the
   minimum and maximum channel counts of the reaper-tracks which are usually
   dependent upon or influence the number of channels reflected in the sound
   files' playback. A sound file could have any number of channels of course
   and usually we'd use the maximum number of channels a track's sound files
   have to set the channels slot, but here we can limit these to something
   reasonable (or e.g. force 4-channel tracks even though all sound files are
   stereo).

RETURN VALUE

 The patch to the generated reaper file.

EXAMPLE

;;; one simple way of algorithmically generating a reaper file:
(let* ((tempo 240)
       (items
         (make-reaper-items1
          (get-sndfiles
           (concatenate 'string
                        cl-user::+slippery-chicken-home-dir+
                        "tests/test-sndfiles-dir-2"))
          '(e (w) (q) q (h) (e) e. (q.) q (w) e (w) e.)
           tempo
          :input-start '(0 .1 .2)
          :play-rate '(1 1.02 1 .98 1.01 1 1.02)
          :preserve-pitch t))
       ;; NB the tempo of the reaper file is independent of the items
       (rf (make-reaper-file 'reaper-test items :tempo tempo)))
  (write-reaper-file rf))

;;; or to write a reaper file with markers only, at times given in seconds
(write-reaper-file (make-reaper-file 'test nil) :markers '(1 2 3.5 7))

;;; mixed marker data starting with simple times
(write-reaper-file (make-reaper-file 'test nil)
  :markers '(1 2 3.5 7 (49 8.021 "nice label") ; number 49, time 8.021, named 
             (562 9.1 "better label" blue))) ; sim. but with a recognised colour

SYNOPSIS

(defmethod write-reaper-file ((rf reaper-file)
                              &key file markers
                                   (min-channels 2) (max-channels 4))

sclist/reaper-file [ Classes ]

[ Top ] [ sclist ] [ Classes ]

sclist/reaper-track [ Classes ]

[ Top ] [ sclist ] [ Classes ]

sndfile/reaper-item [ Classes ]

[ Top ] [ sndfile ] [ Classes ]

NAME

 reaper

 File:             reaper.lsp            

 Class Hierarchy:  named-object -> linked-named-object -> sndfile ->
                   reaper-item
 Class Hierarchy:  named-object -> linked-named-object -> sclist ->
                   reaper-track
 Class Hierarchy:  named-object -> linked-named-object -> sclist ->
                   reaper-file

 Version:          1.0.12

 Project:          slippery chicken (algorithmic composition)

 Purpose:          Class and routine definition for the generation of partial
                   and/or complete reaper files from rhythms, soundfiles.

 Author:           Michael Edwards: m@michael-edwards.org

 Creation date:    January 21st 2021

 $$ Last modified:  17:02:25 Thu Oct 19 2023 CEST

 SVN ID: $Id: sclist.lsp 963 2010-04-08 20:58:32Z medward2 $

utilities/pdivide-reaper-markers [ Functions ]

[ Top ] [ utilities ] [ Functions ]

DESCRIPTION

 Write to standard out (terminal/interpreter) marker data for a reaper file
 generated from calls to the pdivide function.

ARGUMENTS

 Takes the same arguments as the pdivide function

RETURN VALUE

 T

SYNOPSIS

(defun pdivide-reaper-markers (&rest args)

utilities/pexpand-reaper-markers [ Functions ]

[ Top ] [ utilities ] [ Functions ]

DATE

 September 4th 2015, Edinburgh

DESCRIPTION

 Using the pexpand function, we write marker information in a format which
 can be read by the Reaper (version 4/5+) DAW software. Though we can think
 of the outputs of pexpand to be in beats, seconds, bars, or any arbitrary
 scale, the timings of Reaper markers are in seconds, hence the need here
 for an initial tempo. In other words, we treat the output of pexpand to be
 beat counts; if you would prefer to interpret these as bars, simply divide
 the tempo by the number of beats per bar. If there are to be tempo changes
 in the mix/piece Reaper itself will update the markers' positions when the
 new tempo is inserted in the project window--this is fine when you are
 thinking in beats/bars but beware of changing tempo in Reaper if you are
 thinking of markers with fixed timings (seconds).

 Copy the output of this into the Reaper file verbatim (no enclosing < >
 marks) before the <PROJBAY tag.

ARGUMENTS

 - the tempo in BPM
 - the number of generations: see the pexpand function
 - (&rest) the proportions: see the pexpand function

RETURN VALUE

 Always T

EXAMPLE

(pexpand-reaper-markers 144 2 6 3 5 4)
->
  MARKER 1 7.5 "level 4" 0 0 1
  MARKER 2 15.0 "level 4" 0 0 1
  MARKER 3 22.5 "level 4" 0 0 1
  MARKER 4 30.0 "level 4" 0 0 1
  MARKER 5 37.5 "level 4" 0 0 1
...
  MARKER 108 810.0 "level 1" 0 0 1
  MARKER 109 817.5 "level 4" 0 0 1
  MARKER 110 825.0 "level 4" 0 0 1
  MARKER 111 832.5 "level 4" 0 0 1
  MARKER 112 840.0 "level 4" 0 0 1
  MARKER 113 847.5 "level 4" 0 0 1
  MARKER 114 855.0 "level 3" 0 0 1
...
  MARKER 319 2392.5 "level 4" 0 0 1
  MARKER 320 2400.0 "level 3" 0 0 1
  MARKER 321 2407.5 "level 4" 0 0 1
  MARKER 322 2415.0 "level 4" 0 0 1
  MARKER 323 2422.5 "level 4" 0 0 1


Here's where I pasted the data into the .RPP Reaper file:

  <TEMPOENVEX
    ACT 0
    VIS 1 0 1
    LANEHEIGHT 0 0
    ARM 0
    DEFSHAPE 1 -1 -1
  >
  MARKER 1 7.5 "level 4" 0 0 1
  MARKER 2 15 "level 4" 0 0 1
  MARKER 3 22.5 "level 4" 0 0 1
  MARKER 4 30 "level 4" 0 0 1
...
  MARKER 320 2400 "level 3" 0 0 1
  MARKER 321 2407.5 "level 4" 0 0 1
  MARKER 322 2415 "level 4" 0 0 1
  MARKER 323 2422.5 "level 4" 0 0 1
  <PROJBAY
  >
  <TRACK {EBF9837F-BE25-9542-B720-A1862C0DF380}

SYNOPSIS

(defun pexpand-reaper-markers (tempo generations &rest proportions)