mdedwards / slippery-chicken

slippery chicken: algorithmic composition software in common lisp and clos
http://michael-edwards.org/sc
72 stars 3 forks source link

added csound-play method and csound helper functions #62

Closed rubenphilipp closed 1 year ago

rubenphilipp commented 1 year ago

Hello Michael,

I finally found some time to implement a csound-play method. As depicted in the code documentation, it is aimed at creating Csound-scores from sc-objects for one or more players and writing it to a .sco-file. All p-fields other than p1-p3 (i.e. the Csound-instrument name, the onset and the duration) will be generated either by a list of lists (for static values) or a user defined function. The latter is the reason why I created a csound.lsp-file and included a simple helper function for creating p-fields for the frequency and amplitude values derived from the events processed by csound-play. Some work might be necessary in order to implement sndfile-palette compatibility. Albeit there is already a draft of this feature on my hard drive, I decided to keep things straightforward and just push this first working version.

Here is an example call of the method:

(in-package :sc)

(let ((mini
        (make-slippery-chicken
         '+mini+
         :ensemble '(((pno (piano :midi-channel 1))
                      (vln (violin :midi-channel 2))))
         :set-palette '((1 ((f3 g3 as3 a3 bf3 b3 c4 d4 e4 f4 g4 a4 bf4 cs5))))
         :set-map '((1 (1 1 1 1 1 1 1))
                    (2 (1 1 1 1 1 1 1))
                    (3 (1 1 1 1 1 1 1)))
         :tempo-map '((1 (q 60)))
         :rthm-seq-palette '((1 ((((4 4) h (q) e (s) s))
                                 :pitch-seq-palette ((1 (2) 3))))
                             (2 ((((4 4) (q) e (s) s h))
                                 :pitch-seq-palette ((1 2 3))))
                             (3 ((((4 4) e (s) s h (q)))
                                 :pitch-seq-palette ((2 3 3))))
                             (4 ((((4 4) (s) s h (q) e))
                                 :pitch-seq-palette ((3 1 (2))))))
         :rthm-seq-map '((1 ((pno (1 2 1 2 1 2 1))
                             (vln (1 2 1 2 1 2 1))))
                         (2 ((pno (3 4 3 4 3 4 3))
                             (vln (3 4 3 4 3 4 3))))
                         (3 ((pno (1 2 1 2 1 2 1))
                             (vln (1 2 1 2 1 2 1))))))))
  (csound-play mini
               '(pno vln)
               '(1 "fmsynth")
               :csound-file "/tmp/weird-piece.sco"
               :chords 1
               :delimiter #\tab
               :comments t))

I tested it with a set of my own compositions and with some of the tutorial compositions in your manual and, so far, did not encounter any inconvenience.

Hope you like it…

Greetings Ruben

rubenphilipp commented 1 year ago

Closed this pull request for further revision.

Ruben