|(require rs-l)||package: rs-l|
This package collects useful tools for creating loops and events for rs - the Racket Sequencer.
This section lists all the functions that are available.
proc : procedure? cond-proc : procedure? valid-offset? : 0
Returns an event that wraps the supplied procedure. The procedure is only called if cond-proc returns true. The procedure gets the step time as a parameter (so you can use the same procedure you would use in an rs-e event).
Here is an example of how you create an event that sets a MIDI cc value when (random 3) is greater than 1:
(define cc1 (rs-m-event-cc instr 12 25)) (define cc1-cond (rs-l-cond (rs-e-fn cc1) (lambda () (> (random 3) 1))))
(rs-l-process-seq seq proc #:offset valid-offset?) → rs-e seq : list? proc : procedure? valid-offset? : 0
Every iteration proc is applied to seq before playing it. The result of the application is stored and serves as input to proc for the next iteration. Use this to create functions that create continuously changing sequences, such as rotating sequences.
(rs-l-repeats event repeat-proc #:offset valid-offset?) → rs-e event : rs-e? repeat-proc : procedure? valid-offset? : 0
Return an event that creates a sub sequence in which the supplied event is repeated a number of times. How often the event is repeated is determined by the return value of repeat-proc. repeat-proc is called every time the event is called.
Here is an example where a note is repeated between 2 and 4 times. The number of times it is repeated is different every time the event is called:
(define note-rep (rs-l-repeats note-event (lambda() (+ 2 (random 3)))))
(rs-l-rotate-left seq #:num-steps natural? #:offset valid-offset?) → rs-e seq : list? natural? : 1 valid-offset? : 0
(rs-l-rotate-right seq #:num-steps natural? #:offset valid-offset?) → rs-e seq : list? natural? : 1 valid-offset? : 0
These functions rotate the given sequence left or right, respectively, every time they’re called.
(define seq (list note1 note2 note3)) (define seq-rotating (list (rs-l-rotate-left seq #:num-steps 2)))
This rotates seq two steps to the left at the start of every iteration of the loop of the track it is assigned to.
The reason this works is that in rs sequences can have an arbitrary number of steps AND sequences can be nested. What happens is every iteration of the track loop the sequence "seq-rotating" is started, which has only one event, namely the event created by rs-l-rotate-left. This event returns another sequence, namely the list (note1 note2 note3), which is rotated every time the event created by rs-l-rotate-left is called.
The result loooks like this:
(list note1 note2 note3) (list note3 note1 note2) (list note2 note3 note1) (list note1 note2 note3) ;; ... etc
(rs-l-stack events #:get-step-function procedure? #:offset valid-offset?) → rs-e? events : list? procedure? : "Function that gets the next event from the stack" valid-offset? : 0
Creates a "stack event". Every time the stack event is triggered, one of the events from the list of events (the "stack") is triggered. Which event is triggered is determined by #:get-step-function. This is a function that hets the events and the current position (a 0 based index) as arguments. If it is not supplied, it defaults to a function that retrieves the element at the current position, so given a sequence (list '() note1 (note2 note3)) it will first do nothing, the next time play note1 and the third time it will play a sequence consisting of note2 and note3 (the fourth time it will go back to the first event in the list).
Stack events are a powerful tool to help you create alternating sequences.
(rs-l-stack-random events #:offset valid-offset?) → rs-e? events : list? valid-offset? : 0
Creates a "stack event" where events are selected randomly from the stack. So, for example, if you supply it a stack consisting of (list note1 note2 '()) every time it is triggered it will either play note1, note2 or nothing.
2020-06-06 Created rs-l-stack
2020-05-23 Initial release.