Begin implementing performance layer
This commit is contained in:
parent
f5853bf37d
commit
44511732c0
32
src/performance.clj
Normal file
32
src/performance.clj
Normal file
@ -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)))
|
Loading…
Reference in New Issue
Block a user