From 44511732c0b224a806005c3d361ec8ac0d07b6ad Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Sun, 5 Aug 2018 22:53:20 -0400 Subject: [PATCH] Begin implementing performance layer --- src/performance.clj | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/performance.clj diff --git a/src/performance.clj b/src/performance.clj new file mode 100644 index 0000000..663c84d --- /dev/null +++ b/src/performance.clj @@ -0,0 +1,32 @@ +(ns performance) + +;; A performance is a data structure that describes the act +;; of performing a piece of music. It is a vector of events, +;; where each event describes the playing of a single note + +(def simple-performance + [{:time 0 ;; the start time in seconds from the beginning of the performance + :pitch 27 ;; the note's absolute pitch (see music/abs-pitch) + :duration 3/8 ;; duration of the note in seconds + :instrument "Cello" ;; instrument playing the note + :volume 50 ;; volume at which to play the note + :params []}]) ;; an array of doubles -- not clear what this is for yet + +;; A context represents the context in which a musical value is performed. +;; It is passed around during the interpretation of a musical value to represent +;; changing tempo, key signature, tempo, etc. +(def my-context + {:time 0 ;; time at which the performance starts in seconds + :player {:?? :??} ;; not sure what this is + :instrument "Cello" ;; instrument currently playing (?) + :duration-t 2 ;; the duration in seconds of a whole note + :pitch-offset 0 ;; a pitch offset -- number of semitones to transpose notes up or down + :volume 50 ;; volume of performance + :key [:C :major]}) ;; current key signature + +(defn metro + "Generates a duration-t value (the duration in seconds of a whole note) + from the number of beats per minute and the duration of a beat (1/4 for + quarter notes, 1/2 for half notes, etc.)" + [bpm beat-duration] + (/ 60 (* bpm beat-duration)))