CrossClj

1.0.0-rc50 docs

SourceDocs



RECENT
    VARS
    *attribute-table*
    *initial-attr-vals*
    add-event
    add-events
    add-note-or-rest
    alda-code
    apply-attribute
    apply-global-attributes
    at-marker
    barline
    calculate-duration
    chord
    continue
    continue!
    cram
    defattribute
    duration
    end-voice-group
    end-voices
    get-attr
    get-kw-name
    get-val-fn
    get-variable
    global-attribute
    global-attributes
    import-all-vars
    instruments-all-at-same-offset
    key-sig
    key-sig!
    key-signature
    key-signature!
    log-attribute-change
    marker
    ms
    namespaces
    note
    note-length
    octave
    octave!
    Offset
    offset<=
    offset=
    pan
    pan!
    panning
    panning!
    part
    pause
    pitch
    quant
    quant!
    quantization
    quantization!
    quantize
    quantize!
    schedule
    score
    set-attribute
    set-attributes
    set-duration
    set-duration!
    set-variable
    tempo
    tempo!
    times
    track-vol
    track-vol!
    track-volume
    track-volume!
    update-score
    voice
    voices
    vol
    vol!
    volume
    volume!

    « Index of all namespaces of this project

    alda.parser transforms Alda code into Clojure code, which can then be
    evaluated with the help of this namespace.
    (add-event {:keys [instruments events markers], :as score} {:keys [instrument offset], :as event})
    (add-events score events)
    (add-note-or-rest {:keys [beats-tally beats-tally-default instruments voice-instruments current-voice], :as score} {:keys [beats], :as event})
    (alda-code code)
    Attempts to parse a string of text within the context of the current score;
    if the code parses successfully, the result is one or more events that are
    spliced into the score.
    (apply-attribute {:keys [beats-tally], :as score} inst attr val)
    Given an instrument map, a keyword representing an attribute, and a value,
    returns the updated instrument with that attribute update applied.
    (apply-global-attributes)
    For each instrument in :current-instruments, looks between the instrument's
    :last-offset and :current-offset and applies any attribute changes occurring
    within that window.
    
    Both global and per-instrument attributes are applied; in the case that a
    per-instrument attribute is applied at the exact same time as a global
    attribute, the per-instrument attribute takes precedence for that instrument.
    (at-marker name)
    Set the marker at which events will be added.
    
    (barline)
    Barlines, at least currently, do nothing when evaluated in alda.lisp.
    
    (calculate-duration beats tempo time-scaling & [ms])
    Given a number of beats, a tempo, and a time-scaling factor, calculates the
    duration in milliseconds.
    
    Takes as an optional final argument a number of milliseconds to add to the
    total.
    (chord & events)
    Causes every instrument in :current-instruments to play each note in the
    chord simultaneously at the instrument's :current-offset.
    (continue score & body)
    Continues the score represented by the score map score, evaluating the
    events in body and returning the completed score.
    (continue! score-atom & body)
    Convenience function for dealing with Alda scores stored in atoms.
    
    (continue! my-score
      (part 'bassoon'
        (note (pitch :c))))
    
    is short for:
    
    (apply swap! my-score continue
      (part 'bassoon'
        (note (pitch :c))))
    (cram & events)
    A cram expression evaluates the events it contains, time-scaled based on the
    inner tally of beats in the events and the outer durations of each current
    instrument.
    macro
    (defattribute attr-name & things)
    Convenience macro for setting up attributes.
    
    (duration & components)
    Combines a variable number of tied note-lengths into one.
    
    Note-lengths can be expressed in beats or milliseconds. This distinction is
    made via the :type key in the map. The number of beats/milliseconds is
    provided via the :value key in the map.
    
    e.g.
    (note-length 1) => {:type :beats, :value 4}
    (ms 4000)       => {:type :milliseconds, :value 4000}
    
    To preserve backwards compatibility, a note-length expressed as a simple
    number (not wrapped in a map) is interpreted as a number of beats.
    
    Barlines can be inserted inside of a duration -- these currently serve a
    purpose in the parse tree only, and evaluate to nil in alda.lisp. This
    function ignores barlines by removing the nils.
    
    Returns a map containing the total number of beats (counting only those
    note-lengths that are expressed in standard musical notation) and the total
    number of milliseconds (counting only those note-lengths expressed in
    milliseconds).
    
    This information is used by events (like notes and rests) to calculate the
    total duration in milliseconds (as this depends on the score's time-scaling
    factor and the tempo of the instrument the event belongs to).
    (end-voice-group score)
    (end-voices)
    By default, the score remains in 'voice mode' until it reaches an end-voices
    event. This is so that if an instrument part ends with a voice group, the
    same voices can be appended later if the part is resumed, e.g. when building
    a score gradually in the Alda REPL or in a Clojure process.
    
    The end-voices event is emitted by the parser when it parses 'V0:'.
    (get-attr kw)
    Given a keyword representing an attribute (which could be an alias, e.g.
    :quant for :quantization), returns the attribute map, which includes the
    attribute's keyword name (e.g. :quantization) and its transform function.
    
    The transform function is a higher-order function which takes a new,
    user-friendly value (e.g. 100 instead of 1.0) and returns the function to
    apply to an instrument's existing value to update it to the new value.
    (See alda.lisp.attributes for examples of transform functions.)
    
    Throws an exception if the argument supplied is not a valid keyword name
    or alias for an existing attribute.
    (get-kw-name attr)
    Given an attr (e.g. :tempo), which could be an alias (e.g. :quant for
    :quantization), returns the correct keyword name of the attribute to which
    it refers.
    
    Throws an exception if the argument supplied is not a valid keyword name or
    alias for an existing attribute.
    (get-val-fn attr val)
    Given an attr (e.g. :tempo) and a user-friendly val (e.g. 100), returns the
    function to apply to an instrument's existing value to update it to the new
    value.
    
    Throws an exception if the argument supplied is not a valid keyword name or
    alias for an existing attribute.
    (get-variable var-name)
    Returns any number of events previously defined as a variable.
    
    (global-attribute attr val)
    Public fn for setting global attributes in a score.
    e.g. (global-attribute :tempo 100)
    (global-attributes & attrs)
    Convenience fn for setting multiple global attributes at once.
    e.g. (global-attributes :tempo 100 :volume 50)
    Private
    (import-all-vars ns)
    Imports all public vars from a namespace into the alda.lisp namespace.
    
    (instruments-all-at-same-offset {:keys [current-instruments instruments], :as score})
    If all of the :current-instruments are at the same absolute offset, returns
    that offset. Returns nil otherwise.
    
    (Returns 0 if there are no instruments defined yet, e.g. when placing a
     marker or a global attribute at the beginning of a score.)
    (key-sig x__24319__auto__)
    (key-sig! x__24320__auto__)
    (key-signature x__24319__auto__)
    (key-signature! x__24320__auto__)
    (log-attribute-change {:keys [id], :as inst} attr old-val new-val)
    (marker name)
    Places a marker at the current absolute offset. Throws an exception if there
    are multiple instruments active at different offsets.
    (ms n)
    Represents a duration value specified in milliseconds.
    
    Wraps it in a map to give the duration function context that we're talking
    about milliseconds, not beats.
    (note pitch-fn)(note pitch-fn x)(note pitch-fn {:keys [beats ms slurred]} slur?)
    Causes every instrument in :current-instruments to play a note at its
    :current-offset for the specified duration.
    
    If no duration is specified, the note is played for the instrument's own
    internal duration, which will be the duration last specified on a note or
    rest in that instrument's part.
    (note-length number)(note-length number {:keys [dots]})
    Converts a number, representing a note type, e.g. 4 = quarter, 8 = eighth,
    into a number of beats. Handles dots if present.
    
    Wraps the result in a map to give the duration function context that we're
    talking about a number of beats.
    (octave x__24319__auto__)
    (octave! x__24320__auto__)
    (offset<= score & offsets)
    Convenience fn for determining if offsets are in order.
    
    (offset= score & offsets)
    Convenience fn for comparing absolute/relative offsets.
    
    (pan x__24319__auto__)
    (pan! x__24320__auto__)
    (panning x__24319__auto__)
    (panning! x__24320__auto__)
    (part instrument-call & events)
    Determines the current instrument instance(s) based on the instrument-call
    and evaluates the events within that context.
    
    instrument-call can either be a map containing :names and an optional
    :nickname (e.g. {:names ['piano' 'trumpet'] :nickname ['trumpiano']}) or a
    valid Alda instrument call string, e.g. 'piano/trumpet 'trumpiano''.
    (pause & [{:keys [beats ms], :as dur}])
    Causes every instrument in :current-instruments to rest (not play) for the
    specified duration.
    
    If no duration is specified, each instrument will rest for its own internal
    duration, which will be the duration last specified on a note or rest in
    that instrument's part.
    (pitch letter & accidentals)
    Returns a fn that will calculate the frequency in Hz, within the context
    of an instrument's octave and key signature.
    (quant x__24319__auto__)
    (quant! x__24320__auto__)
    (quantization x__24319__auto__)
    (quantization! x__24320__auto__)
    (quantize x__24319__auto__)
    (quantize! x__24320__auto__)
    (schedule f)
    Schedules an arbitrary function to be called at the current point in the
    score (determined by the current instrument's marker and offset).
    
    If there are multiple current instruments, the function will be executed
    once for each instrument, at the marker + offset of that instrument.
    (score & body)
    Initializes a new score, evaluates the events contained in body (updating
    the score accordingly) and returns the completed score.
    
    A score and its evaluation context are effectively the same thing. This
    means that an evaluated score can be used as an input to continue-score
    (set-attribute attr val)
    Public fn for setting attributes in a score.
    e.g. (set-attribute :tempo 100)
    (set-attributes & attrs)
    Convenience fn for setting multiple attributes at once.
    e.g. (set-attributes :tempo 100 :volume 50)
    (set-duration x__24319__auto__)
    (set-duration! x__24320__auto__)
    (set-variable var-name & events)
    Defines any number of events as a variable so that they can be referenced by
    name.
    (tempo x__24319__auto__)
    (tempo! x__24320__auto__)
    (times n event)
    Repeats an Alda event (or sequence of events) n times.
    
    (track-vol x__24319__auto__)
    (track-vol! x__24320__auto__)
    (track-volume x__24319__auto__)
    (track-volume! x__24320__auto__)
    multimethod
    Events in Alda are represented as maps containing, at the minimum, a value
    for :event-type to serve as a unique identifier (by convention, a keyword)
    to be used as a dispatch value.
    
    An Alda score S-expression simply reduces update-score over all of the
    score's events, with the initial score state as the initial value to be
    reduced.
    
    Lists/vectors are a special case -- they are reduced internally and treated
    as a single 'event sequence'.
    (voice voice-number & events)
    One voice in a voice group.
    
    (voices & voices)
    Voices are chronological sequences of events that each start at the same
    time. The resulting :current-offset is at the end of the voice that finishes
    last.
    (vol x__24319__auto__)
    (vol! x__24320__auto__)
    (volume x__24319__auto__)
    (volume! x__24320__auto__)