The path to the alda
executable.
The default value is "alda", which will depend on your PATH.
The path to the `alda` executable. The default value is "alda", which will depend on your PATH.
(->lisp-form object)
Returns an S-expression representation of its argument, which must implement the LispForm protocol.
Objects that implement the LispForm protocol have corresponding Lisp representations in alda-lisp.
Returns an S-expression representation of its argument, which must implement the LispForm protocol. Objects that implement the LispForm protocol have corresponding Lisp representations in alda-lisp.
(->str x)
Converts a value into a string of Alda code.
This function is used under the hood by play!
to convert its arguments
into a string of code to send to the Alda CLI.
Converts a value into a string of Alda code. This function is used under the hood by [[play!]] to convert its arguments into a string of code to send to the Alda CLI.
(alda & args)
Invokes alda
at the command line, using args
as arguments.
The return value is the string of stdout, if the command was successful, i.e. if the exit code was 0.
If the exit code is non-zero, an ex-info is thrown, including context about the result and what command was run.
Stdout and stderr output are printed as they are produced.
Examples:
(alda "version")
;;=> "alda 2.0.0\n"
(alda "parse" "-c" "bassoon: o3 c")
;;=> "{\"aliases\":{},\"current-parts\":[\"0xc0002509c0\"],..."
(alda "\"make me a sandwich\"")
;;=> Usage:
;;=> alda [command]
;;=>
;;=> Available Commands:
;;=> doctor Run health checks to determine if Alda can run correctly
;;=> export Evaluate Alda source code and export to another format
;;=> help Help about any command
;;=> instruments Display the list of available instruments
;;=> parse Display the result of parsing Alda source code
;;=> play Evaluate and play Alda source code
;;=> ps List background processes
;;=> repl Start an Alda REPL client/server
;;=> shutdown Shut down background processes
;;=> stop Stop playback
;;=> telemetry Enable or disable telemetry
;;=> update Update to the latest version of Alda
;;=> version Print Alda version information
;;=>
;;=> Flags:
;;=> -v, --verbosity int verbosity level (0-3) (default 1)
;;=>
;;=> Use "alda [command] --help" for more information about a command.
;;=>
;;=> ---
;;=>
;;=> Usage error:
;;=>
;;=> unknown command "make me a sandwich" for "alda"
;;=> Execution error (ExceptionInfo) at alda.core/alda (core.clj:58).
;;=> Non-zero exit status.
Invokes `alda` at the command line, using `args` as arguments. The return value is the string of stdout, if the command was successful, i.e. if the exit code was 0. If the exit code is non-zero, an ex-info is thrown, including context about the result and what command was run. Stdout and stderr output are printed as they are produced. Examples: ```clojure (alda "version") ;;=> "alda 2.0.0\n" (alda "parse" "-c" "bassoon: o3 c") ;;=> "{\"aliases\":{},\"current-parts\":[\"0xc0002509c0\"],..." (alda "\"make me a sandwich\"") ;;=> Usage: ;;=> alda [command] ;;=> ;;=> Available Commands: ;;=> doctor Run health checks to determine if Alda can run correctly ;;=> export Evaluate Alda source code and export to another format ;;=> help Help about any command ;;=> instruments Display the list of available instruments ;;=> parse Display the result of parsing Alda source code ;;=> play Evaluate and play Alda source code ;;=> ps List background processes ;;=> repl Start an Alda REPL client/server ;;=> shutdown Shut down background processes ;;=> stop Stop playback ;;=> telemetry Enable or disable telemetry ;;=> update Update to the latest version of Alda ;;=> version Print Alda version information ;;=> ;;=> Flags: ;;=> -v, --verbosity int verbosity level (0-3) (default 1) ;;=> ;;=> Use "alda [command] --help" for more information about a command. ;;=> ;;=> --- ;;=> ;;=> Usage error: ;;=> ;;=> unknown command "make me a sandwich" for "alda" ;;=> Execution error (ExceptionInfo) at alda.core/alda (core.clj:58). ;;=> Non-zero exit status. ```
(at-marker name)
Sets the active instruments' current offset to the offset of the marker with the provided name.
Examples:
(at-marker "verse-1")
;;=> #alda.core.AtMarker{:name "verse-1"}
(->str (at-marker "verse-1"))
;;=> "@verse-1"
(println
(play!
(part "piano")
"o4 c8 d e f"
(marker "here")
"g2"
(part "electric-bass")
(at-marker "here")
"o2 g2"
(part "trombone")
(at-marker "here")
"o3 b2"))
;;=> piano:
;;=> o4 c8 d e f %here g2
;;=> electric-bass:
;;=> @here o2 g2
;;=> trombone:
;;=> @here o3 b2
Sets the active instruments' current offset to the offset of the marker with the provided name. Examples: ```clojure (at-marker "verse-1") ;;=> #alda.core.AtMarker{:name "verse-1"} (->str (at-marker "verse-1")) ;;=> "@verse-1" (println (play! (part "piano") "o4 c8 d e f" (marker "here") "g2" (part "electric-bass") (at-marker "here") "o2 g2" (part "trombone") (at-marker "here") "o3 b2")) ;;=> piano: ;;=> o4 c8 d e f %here g2 ;;=> electric-bass: ;;=> @here o2 g2 ;;=> trombone: ;;=> @here o3 b2 ```
(barline)
Barlines, at least currently, do nothing beyond visually separating other events.
Examples:
(barline)
;;=> #alda.core.Barline{}
(->str (barline))
;;=> "|"
(play!
(part "piano")
(note (pitch :c) (note-length 4))
(note (pitch :d) (note-length 8))
(note (pitch :e))
(note (pitch :f))
(note (pitch :g))
(note (pitch :a))
(note (pitch :b))
(octave :up)
(barline)
(note (pitch :c)))
;;=> "piano:\nc4 d8 e f g a b > | c"
Barlines, at least currently, do nothing beyond visually separating other events. Examples: ```clojure (barline) ;;=> #alda.core.Barline{} (->str (barline)) ;;=> "|" (play! (part "piano") (note (pitch :c) (note-length 4)) (note (pitch :d) (note-length 8)) (note (pitch :e)) (note (pitch :f)) (note (pitch :g)) (note (pitch :a)) (note (pitch :b)) (octave :up) (barline) (note (pitch :c))) ;;=> "piano:\nc4 d8 e f g a b > | c" ```
(chord & events)
Causes every active instrument to play each note in the chord simultaneously at the instrument's current offset.
Events may include notes, rests, and attribute change (e.g. octave change) events.
Examples:
(chord (note (pitch :c))
(note (pitch :e))
(note (pitch :g)))
;;=> #alda.core.Chord{
;;=> :events (#alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :c,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil}
;;=> #alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :e,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil}
;;=> #alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :g,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil})}
(->str (chord (note (pitch :c))
(note (pitch :e))
(note (pitch :g))))
;;=> "c / e / g"
(play!
(part "piano")
(chord (note (pitch :e))
(note (pitch :g))
(octave :up)
(note (pitch :c))))
;;=> "piano:\ne / g > / c"
Causes every active instrument to play each note in the chord simultaneously at the instrument's current offset. Events may include notes, rests, and attribute change (e.g. octave change) events. Examples: ```clojure (chord (note (pitch :c)) (note (pitch :e)) (note (pitch :g))) ;;=> #alda.core.Chord{ ;;=> :events (#alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :c, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil} ;;=> #alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :e, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil} ;;=> #alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :g, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil})} (->str (chord (note (pitch :c)) (note (pitch :e)) (note (pitch :g)))) ;;=> "c / e / g" (play! (part "piano") (chord (note (pitch :e)) (note (pitch :g)) (octave :up) (note (pitch :c)))) ;;=> "piano:\ne / g > / c" ```
(connect! & [{:keys [host port] :or {host "localhost"}}])
Sets the host and port number used internally by alda-clj to send messages to the Alda REPL server.
By default, alda-clj uses alda play
on every call to (play! ...)
to play
each score in an isolated context. This might be sufficient if you're just
experimenting or trying out the alda-clj library for the first time and you
don't feel like starting an Alda REPL server.
For a better experience when live-coding or composing interactively, start an
Alda REPL server by running alda repl --server
, and then use
(connect! ...)
to configure alda-clj to talk to the Alda REPL server.
When called without arguments, (connect!)
assumes that the REPL server is
running on localhost and attempts to read the port from the
.alda-nrepl-port
file that Alda created.
To specify a different host or port, you can include a map as an argument, e.g.:
(connect! {:port 12345}) ; localhost:12345
(connect! {:host "1.2.3.4" 12345}) ; 1.2.3.4:12345
To restore the default state where alda-clj uses alda play
instead of
talking to an Alda REPL server, use disconnect!
.
Sets the host and port number used internally by alda-clj to send messages to the Alda REPL server. By default, alda-clj uses `alda play` on every call to `(play! ...)` to play each score in an isolated context. This might be sufficient if you're just experimenting or trying out the alda-clj library for the first time and you don't feel like starting an Alda REPL server. For a better experience when live-coding or composing interactively, start an Alda REPL server by running `alda repl --server`, and then use (`connect! ...)` to configure alda-clj to talk to the Alda REPL server. When called without arguments, `(connect!)` assumes that the REPL server is running on localhost and attempts to read the port from the `.alda-nrepl-port` file that Alda created. To specify a different host or port, you can include a map as an argument, e.g.: ```clojure (connect! {:port 12345}) ; localhost:12345 (connect! {:host "1.2.3.4" 12345}) ; 1.2.3.4:12345 ``` To restore the default state where alda-clj uses `alda play` instead of talking to an Alda REPL server, use [[disconnect!]].
(cram duration & events)
A cram expression time-scales the events it contains based on the ratio of the "inner duration" of the events to the "outer duration" of each current instrument.
Examples:
(cram (note-length 2)
(note (pitch :e))
(note (pitch :f))
(note (pitch :e))
(note (pitch :f))
(note (pitch :e)))
;;=> #alda.core.Cram{
;;=> :duration #alda.core.NoteLength{:number 2, :dots 0},
;;=> :events (#alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :e,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil}
;;=> #alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :f,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil}
;;=> #alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :e,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil}
;;=> #alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :f,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil}
;;=> #alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :e,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil})}
(->str (cram (note-length 2)
(note (pitch :e))
(note (pitch :f))
(note (pitch :e))
(note (pitch :f))
(note (pitch :e))))
;;=> "{ e f e f e }2"
(play!
(part "piano")
(octave 4)
(cram (note-length 1)
(note (pitch :c))
(note (pitch :d))
(cram nil
(note (pitch :e))
(note (pitch :f))
(note (pitch :g)))
(note (pitch :a))
(note (pitch :b)))
(octave :up)
(note (pitch :c)))
;;=> "piano:\no4 { c d { e f g } a b }1 > c"
A cram expression time-scales the events it contains based on the ratio of the "inner duration" of the events to the "outer duration" of each current instrument. Examples: ```clojure (cram (note-length 2) (note (pitch :e)) (note (pitch :f)) (note (pitch :e)) (note (pitch :f)) (note (pitch :e))) ;;=> #alda.core.Cram{ ;;=> :duration #alda.core.NoteLength{:number 2, :dots 0}, ;;=> :events (#alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :e, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil} ;;=> #alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :f, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil} ;;=> #alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :e, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil} ;;=> #alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :f, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil} ;;=> #alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :e, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil})} (->str (cram (note-length 2) (note (pitch :e)) (note (pitch :f)) (note (pitch :e)) (note (pitch :f)) (note (pitch :e)))) ;;=> "{ e f e f e }2" (play! (part "piano") (octave 4) (cram (note-length 1) (note (pitch :c)) (note (pitch :d)) (cram nil (note (pitch :e)) (note (pitch :f)) (note (pitch :g))) (note (pitch :a)) (note (pitch :b))) (octave :up) (note (pitch :c))) ;;=> "piano:\no4 { c d { e f g } a b }1 > c" ```
(disconnect!)
Clears out the host and port number used internally by alda-clj to send messages to the Alda REPL server.
This puts alda-clj back into its default state, where it uses alda play
on
every call to (play! ...)
instead of sending messages to an Alda REPL
server.
See connect!
for more information.
Clears out the host and port number used internally by alda-clj to send messages to the Alda REPL server. This puts alda-clj back into its default state, where it uses `alda play` on every call to `(play! ...)` instead of sending messages to an Alda REPL server. See [[connect!]] for more information.
(duration & components)
Returns a duration component, which consists of multiple note length components "tied" together.
Examples:
(duration (note-length 8 {:dots 1})
(note-length 16)
(ms 250))
;;=> #alda.core.Duration{
;;=> :components (#alda.core.NoteLength{:number 8, :dots 1}
;;=> #alda.core.NoteLength{:number 16, :dots 0}
;;=> #alda.core.Milliseconds{:number 250})}
(->str (duration (note-length 8 {:dots 1})
(note-length 16)
(ms 250)))
;;=> "8.~16~250ms"
(play!
(part "piano")
(note (pitch :c)
(duration (note-length 1)
(note-length 1)
(note-length 2 {:dots 1}))))
;;=> "piano:\nc1~1~2."
Returns a duration component, which consists of multiple note length components "tied" together. Examples: ```clojure (duration (note-length 8 {:dots 1}) (note-length 16) (ms 250)) ;;=> #alda.core.Duration{ ;;=> :components (#alda.core.NoteLength{:number 8, :dots 1} ;;=> #alda.core.NoteLength{:number 16, :dots 0} ;;=> #alda.core.Milliseconds{:number 250})} (->str (duration (note-length 8 {:dots 1}) (note-length 16) (ms 250))) ;;=> "8.~16~250ms" (play! (part "piano") (note (pitch :c) (duration (note-length 1) (note-length 1) (note-length 2 {:dots 1})))) ;;=> "piano:\nc1~1~2." ```
(end-voices)
Ends the current voice group.
Examples:
(end-voices)
;;=> #alda.core.EndVoices{}
(->str (end-voices))
;;=> "V0:"
(play!
(part "piano")
(voice 1)
(octave 4)
(note (pitch :c) (note-length 8))
(note (pitch :d))
(note (pitch :e))
(note (pitch :f))
(note (pitch :g))
(note (pitch :a))
(voice 2)
(octave 3)
(note (pitch :g) (note-length 4 {:dots 1}))
(note (pitch :d) (note-length 4 {:dots 1}))
(end-voices)
(octave 3)
(chord
(note (pitch :f) (note-length 1))
(octave :up)
(note (pitch :c))
(note (pitch :a))))
;;=> "piano:\nV1: o4 c8 d e f g a V2: o3 g4. d4. V0: o3 f1 > / c / a"
Ends the current voice group. Examples: ```clojure (end-voices) ;;=> #alda.core.EndVoices{} (->str (end-voices)) ;;=> "V0:" (play! (part "piano") (voice 1) (octave 4) (note (pitch :c) (note-length 8)) (note (pitch :d)) (note (pitch :e)) (note (pitch :f)) (note (pitch :g)) (note (pitch :a)) (voice 2) (octave 3) (note (pitch :g) (note-length 4 {:dots 1})) (note (pitch :d) (note-length 4 {:dots 1})) (end-voices) (octave 3) (chord (note (pitch :f) (note-length 1)) (octave :up) (note (pitch :c)) (note (pitch :a)))) ;;=> "piano:\nV1: o4 c8 d e f g a V2: o3 g4. d4. V0: o3 f1 > / c / a" ```
(get-variable var-name)
Returns any number of events previously defined as a variable.
Examples:
(get-variable "riffA")
;;=> #alda.core.GetVariable{:name "riffA"}
(->str (get-variable "riffA"))
;;=> "riffA"
(play!
(set-variable "riffA"
(note (pitch :d))
(note (pitch :f))
(note (pitch :a)))
(part "piano")
(get-variable "riffA"))
;;=> "riffA = d f a\npiano:\nriffA"
Returns any number of events previously defined as a variable. Examples: ```clojure (get-variable "riffA") ;;=> #alda.core.GetVariable{:name "riffA"} (->str (get-variable "riffA")) ;;=> "riffA" (play! (set-variable "riffA" (note (pitch :d)) (note (pitch :f)) (note (pitch :a))) (part "piano") (get-variable "riffA")) ;;=> "riffA = d f a\npiano:\nriffA" ```
(key-sig x)
Emits inline Lisp code (key-sig ...)
You can specify the key signature in a few ways:
(key-sig "f+ c+ g+")
(key-sig '(a major))
(key-sig '(f (sharp) c (sharp) g (sharp)))
Emits inline Lisp code `(key-sig ...)` You can specify the key signature in a few ways: ```clojure (key-sig "f+ c+ g+") (key-sig '(a major)) (key-sig '(f (sharp) c (sharp) g (sharp))) ```
(key-sig! x)
Emits inline Lisp code (key-sig! ...)
You can specify the key sig!nature in a few ways:
(key-sig! "f+ c+ g+")
(key-sig! '(a major))
(key-sig! '(f (sharp) c (sharp) g (sharp)))
Emits inline Lisp code `(key-sig! ...)` You can specify the key sig!nature in a few ways: ```clojure (key-sig! "f+ c+ g+") (key-sig! '(a major)) (key-sig! '(f (sharp) c (sharp) g (sharp))) ```
(key-signature x)
Emits inline Lisp code (key-signature ...)
You can specify the key signature in a few ways:
(key-signature "f+ c+ g+")
(key-signature '(a major))
(key-signature '(f (sharp) c (sharp) g (sharp)))
Emits inline Lisp code `(key-signature ...)` You can specify the key signature in a few ways: ```clojure (key-signature "f+ c+ g+") (key-signature '(a major)) (key-signature '(f (sharp) c (sharp) g (sharp))) ```
(key-signature! x)
Emits inline Lisp code (key-signature! ...)
You can specify the key signature in a few ways:
(key-signature! "f+ c+ g+")
(key-signature! '(a major))
(key-signature! '(f (sharp) c (sharp) g (sharp)))
Emits inline Lisp code `(key-signature! ...)` You can specify the key signature in a few ways: ```clojure (key-signature! "f+ c+ g+") (key-signature! '(a major)) (key-signature! '(f (sharp) c (sharp) g (sharp))) ```
(marker name)
Places a marker at the current absolute offset.
Examples:
(marker "verse-1")
;;=> #alda.core.Marker{:name "verse-1"}
(->str (marker "verse-1"))
;;=> "%verse-1"
(println
(play!
(part "piano")
"o4 c8 d e f"
(marker "here")
"g2"
(part "electric-bass")
(at-marker "here")
"o2 g2"
(part "trombone")
(at-marker "here")
"o3 b2"))
;;=> piano:
;;=> o4 c8 d e f %here g2
;;=> electric-bass:
;;=> @here o2 g2
;;=> trombone:
;;=> @here o3 b2
Places a marker at the current absolute offset. Examples: ```clojure (marker "verse-1") ;;=> #alda.core.Marker{:name "verse-1"} (->str (marker "verse-1")) ;;=> "%verse-1" (println (play! (part "piano") "o4 c8 d e f" (marker "here") "g2" (part "electric-bass") (at-marker "here") "o2 g2" (part "trombone") (at-marker "here") "o3 b2")) ;;=> piano: ;;=> o4 c8 d e f %here g2 ;;=> electric-bass: ;;=> @here o2 g2 ;;=> trombone: ;;=> @here o3 b2 ```
(metric-modulation & args)
Emits inline Lisp code (metric-modulation ...)
Emits inline Lisp code `(metric-modulation ...)`
(metric-modulation! & args)
Emits inline Lisp code (metric-modulation! ...)
Emits inline Lisp code `(metric-modulation! ...)`
(midi-note note-number)
Returns the pitch component of a note, expressed as a MIDI note number.
See also pitch
, which expresses pitch as a letter and accidentals.
->str
cannot be used on a MIDI note number component directly because there is no native Alda syntax for a MIDI note number; this feature is only accessible via themidi-note
alda-lisp function.In alda-clj, just like in alda-lisp,
midi-note
can be used instead ofpitch
as the pitch component of a note. To stringify a note with amidi-note
pitch component, we fallback to emitting alda-lisp code.
Examples:
(midi-note 42)
;;=> #alda.core.MidiNoteNumber{:note-number 42}
(->lisp-form (midi-note 42))
;;=> (midi-note 42)
(->str (midi-note 42))
;;=> Execution error (IllegalArgumentException) at alda.core/eval160$fn$G (core.clj:71).
;;=> No implementation of method: :-str of protocol: #'alda.core/Stringify found for class: alda.core.MidiNoteNumber
(->str (note (midi-note 42) (note-length 8)))
;;=> "(note (midi-note 42) (note-length 8))"
(->str (note (pitch :c) (note-length 8)))
;;=> "c8"
Returns the pitch component of a note, expressed as a MIDI note number. See also [[pitch]], which expresses pitch as a letter and accidentals. > [[->str]] cannot be used on a MIDI note number component directly because > there is no native Alda syntax for a MIDI note number; this feature is only > accessible via the `midi-note` alda-lisp function. > > In alda-clj, just like in alda-lisp, `midi-note` can be used instead of > `pitch` as the pitch component of a note. To stringify a note with a > `midi-note` pitch component, we fallback to emitting alda-lisp code. Examples: ```clojure (midi-note 42) ;;=> #alda.core.MidiNoteNumber{:note-number 42} (->lisp-form (midi-note 42)) ;;=> (midi-note 42) (->str (midi-note 42)) ;;=> Execution error (IllegalArgumentException) at alda.core/eval160$fn$G (core.clj:71). ;;=> No implementation of method: :-str of protocol: #'alda.core/Stringify found for class: alda.core.MidiNoteNumber (->str (note (midi-note 42) (note-length 8))) ;;=> "(note (midi-note 42) (note-length 8))" (->str (note (pitch :c) (note-length 8))) ;;=> "c8" ```
(ms number)
Returns a millisecond note length component.
Examples:
(ms 456)
;;=> #alda.core.Milliseconds{:number 456}
(ms 456)
;;=> "456ms"
(play!
(part "piano")
(note (pitch :c) (ms 1005)))
;;=> "piano:\nc1005ms"
Returns a millisecond note length component. Examples: ```clojure (ms 456) ;;=> #alda.core.Milliseconds{:number 456} (ms 456) ;;=> "456ms" (play! (part "piano") (note (pitch :c) (ms 1005))) ;;=> "piano:\nc1005ms" ```
(new-score!)
Resets the Alda REPL server's state and initializes a new score.
Throws an exception if you haven't connected to an Alda REPL server yet.
(See connect!
for more information.)
Resets the Alda REPL server's state and initializes a new score. Throws an exception if you haven't connected to an Alda REPL server yet. (See [[connect!]] for more information.)
(note pitch & [duration slur?])
Causes every active instrument 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.
A third argument, slur?
may be optionally included. When truthy, this
includes a final slur (~
) to be appended to the code that is generated.
This means the note will be sustained for the absolute fullest value, with
minimal space between this note and the next. (By default, there is a small
amount of space between notes.)
Examples:
(note (pitch :d :flat))
;;=> #alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :d,
;;=> :accidentals (:flat)},
;;=> :duration nil,
;;=> :slurred? nil}
(->str (note (pitch :d :flat)))
;;=> "d-"
(->str (note (pitch :f) (note-length 8)))
;;=> "f8"
(->str (note (pitch :f)
(duration (note-length 1) (note-length 8))
:slur))
;;=> "f1~8~"
(play!
(part "piano")
(note (pitch :g)))
;;=> "piano:\ng"
Causes every active instrument 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. A third argument, `slur?` may be optionally included. When truthy, this includes a final slur (`~`) to be appended to the code that is generated. This means the note will be sustained for the absolute fullest value, with minimal space between this note and the next. (By default, there is a small amount of space between notes.) Examples: ```clojure (note (pitch :d :flat)) ;;=> #alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :d, ;;=> :accidentals (:flat)}, ;;=> :duration nil, ;;=> :slurred? nil} (->str (note (pitch :d :flat))) ;;=> "d-" (->str (note (pitch :f) (note-length 8))) ;;=> "f8" (->str (note (pitch :f) (duration (note-length 1) (note-length 8)) :slur)) ;;=> "f1~8~" (play! (part "piano") (note (pitch :g))) ;;=> "piano:\ng" ```
(note-length number & [{:keys [dots]}])
Returns a note length component, which is expressed as an integer (e.g. 4
is a quarter note) and, optionally, 1 or more dots (e.g. to make a dotted
quarter note, double dotted half note, etc.).
Examples:
(note-length 8)
;;=> #alda.core.NoteLength{:number 8, :dots 0}
(->str (note-length 4 {:dots 2}))
;;=> "4.."
(play!
(part "piano")
(note (pitch :c)
(note-length 1 {:dots 1})))
;;=> "piano:\nc1."
Returns a note length component, which is expressed as an integer (e.g. `4` is a quarter note) and, optionally, 1 or more dots (e.g. to make a dotted quarter note, double dotted half note, etc.). Examples: ```clojure (note-length 8) ;;=> #alda.core.NoteLength{:number 8, :dots 0} (->str (note-length 4 {:dots 2})) ;;=> "4.." (play! (part "piano") (note (pitch :c) (note-length 1 {:dots 1}))) ;;=> "piano:\nc1." ```
(octave value)
Sets the current octave, which is used to calculate the pitch of notes.
value
can be an octave number, :up
or :down
.
Examples:
(octave 3)
;;=> #alda.core.OctaveSet{:octave-number 3}
(->str (octave 3))
;;=> "o3"
(octave :down)
;;=> #alda.core.OctaveShift{:direction :down}
(->str (octave :down))
;;=> "<"
(play!
(part "piano")
(octave 0)
(note (pitch :c) (note-length 8))
(octave :up)
(note (pitch :c))
(octave :up)
(note (pitch :c))
(octave :up)
(note (pitch :c))
(octave :up)
(note (pitch :c))
(octave :up)
(note (pitch :c))
(octave :up)
(note (pitch :c))
(octave :up)
(note (pitch :c)))
;;=> "piano:\no0 c8 > c > c > c > c > c > c > c"
Sets the current octave, which is used to calculate the pitch of notes. `value` can be an octave number, `:up` or `:down`. Examples: ```clojure (octave 3) ;;=> #alda.core.OctaveSet{:octave-number 3} (->str (octave 3)) ;;=> "o3" (octave :down) ;;=> #alda.core.OctaveShift{:direction :down} (->str (octave :down)) ;;=> "<" (play! (part "piano") (octave 0) (note (pitch :c) (note-length 8)) (octave :up) (note (pitch :c)) (octave :up) (note (pitch :c)) (octave :up) (note (pitch :c)) (octave :up) (note (pitch :c)) (octave :up) (note (pitch :c)) (octave :up) (note (pitch :c)) (octave :up) (note (pitch :c))) ;;=> "piano:\no0 c8 > c > c > c > c > c > c > c" ```
(octave! x)
Emits inline Lisp code (octave! ...)
Example usage:
(octave! 5)
(octave! :up)
(octave! :down)
Emits inline Lisp code `(octave! ...)` Example usage: ```clojure (octave! 5) (octave! :up) (octave! :down) ```
(pan! & args)
Emits inline Lisp code (pan! ...)
Emits inline Lisp code `(pan! ...)`
(panning & args)
Emits inline Lisp code (panning ...)
Emits inline Lisp code `(panning ...)`
(panning! & args)
Emits inline Lisp code (panning! ...)
Emits inline Lisp code `(panning! ...)`
(parse-events & xs)
Converts its arguments into a string of Alda code (via ->str
) and sends
it to the Alda CLI to be parsed into events JSON.
Returns a seq of deserialized records.
Converts its arguments into a string of Alda code (via [[->str]]) and sends it to the Alda CLI to be parsed into events JSON. Returns a seq of deserialized records.
(part x)
Sets the current instrument instance(s) based on instrument-call
.
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'"
.
For convenience, single quotes can be used around the nickname instead of double quotes.
Examples:
(part "piano")
;;=> #alda.core.InstrumentCall{:names ["piano"],
;;=> :nickname nil}
(part "piano/trumpet")
;;=> #alda.core.InstrumentCall{:names ["piano" "trumpet"],
;;=> :nickname nil}
(part {:names ["piano" "trumpet"] :nickname "trumpiano"})
;;=> #alda.core.InstrumentCall{:names ["piano" "trumpet"],
;;=> :nickname "trumpiano"}
(->str (part {:names ["piano" "trumpet"] :nickname "trumpiano"}))
;;=> "piano/trumpet \"trumpiano\":"
(play!
(part "piano/trumpet 'trumpiano'")
(note (pitch :c)))
;;=> "piano/trumpet \"trumpiano\":\nc"
Sets the current instrument instance(s) based on `instrument-call`. `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'"`. For convenience, single quotes can be used around the nickname instead of double quotes. Examples: ```clojure (part "piano") ;;=> #alda.core.InstrumentCall{:names ["piano"], ;;=> :nickname nil} (part "piano/trumpet") ;;=> #alda.core.InstrumentCall{:names ["piano" "trumpet"], ;;=> :nickname nil} (part {:names ["piano" "trumpet"] :nickname "trumpiano"}) ;;=> #alda.core.InstrumentCall{:names ["piano" "trumpet"], ;;=> :nickname "trumpiano"} (->str (part {:names ["piano" "trumpet"] :nickname "trumpiano"})) ;;=> "piano/trumpet \"trumpiano\":" (play! (part "piano/trumpet 'trumpiano'") (note (pitch :c))) ;;=> "piano/trumpet \"trumpiano\":\nc" ```
(pause & [duration])
Causes every active instrument 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.
Examples:
(pause (note-length 2))
;;=> #alda.core.Rest{:duration #alda.core.NoteLength{:number 2, :dots 0}}
(->str (pause (note-length 2)))
;;=> "r2"
(play!
(part "piano")
(note (pitch :c) (note-length 8))
(pause (note-length 8))
(note (pitch :c) (note-length 8))
(pause (note-length 8))
(note (pitch :c) (note-length 8))
(pause (note-length 8)))
;;=> "piano:\nc8 r8 c8 r8 c8 r8"
Causes every active instrument 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. Examples: ```clojure (pause (note-length 2)) ;;=> #alda.core.Rest{:duration #alda.core.NoteLength{:number 2, :dots 0}} (->str (pause (note-length 2))) ;;=> "r2" (play! (part "piano") (note (pitch :c) (note-length 8)) (pause (note-length 8)) (note (pitch :c) (note-length 8)) (pause (note-length 8)) (note (pitch :c) (note-length 8)) (pause (note-length 8))) ;;=> "piano:\nc8 r8 c8 r8 c8 r8" ```
(pitch letter & accidentals)
Returns the pitch component of a note.
Examples:
(pitch :c :sharp)
;;=> #alda.core.LetterAndAccidentals{:letter :c, :accidentals (:sharp)}
(->str (pitch :c :sharp))
;;=> "c+"
(->str (pitch :g))
;;=> "g"
(play!
(part "piano")
(note (pitch :c)))
;;=> "piano:\nc"
Returns the pitch component of a note. Examples: ```clojure (pitch :c :sharp) ;;=> #alda.core.LetterAndAccidentals{:letter :c, :accidentals (:sharp)} (->str (pitch :c :sharp)) ;;=> "c+" (->str (pitch :g)) ;;=> "g" (play! (part "piano") (note (pitch :c))) ;;=> "piano:\nc" ```
(play! & xs)
Converts its arguments into a string of Alda code (via ->str
) and sends
it to the Alda CLI to be parsed and played.
Returns the string of code that was sent to alda play
.
Converts its arguments into a string of Alda code (via [[->str]]) and sends it to the Alda CLI to be parsed and played. Returns the string of code that was sent to `alda play`.
(quant & args)
Emits inline Lisp code (quant ...)
Emits inline Lisp code `(quant ...)`
(quant! & args)
Emits inline Lisp code (quant! ...)
Emits inline Lisp code `(quant! ...)`
(quantization & args)
Emits inline Lisp code (quantization ...)
Emits inline Lisp code `(quantization ...)`
(quantization! & args)
Emits inline Lisp code (quantization! ...)
Emits inline Lisp code `(quantization! ...)`
(quantize & args)
Emits inline Lisp code (quantize ...)
Emits inline Lisp code `(quantize ...)`
(quantize! & args)
Emits inline Lisp code (quantize! ...)
Emits inline Lisp code `(quantize! ...)`
(reference-pitch & args)
Emits inline Lisp code (reference-pitch ...)
Emits inline Lisp code `(reference-pitch ...)`
(reference-pitch! & args)
Emits inline Lisp code (reference-pitch! ...)
Emits inline Lisp code `(reference-pitch! ...)`
(score-text)
Returns the string of Alda code that is "loaded" into the Alda REPL session.
Throws an exception if you haven't connected to an Alda REPL server yet.
(See connect!
for more information.)
Returns the string of Alda code that is "loaded" into the Alda REPL session. Throws an exception if you haven't connected to an Alda REPL server yet. (See [[connect!]] for more information.)
(send-nrepl-message! msg)
Sends an nREPL message to the Alda REPL server defined in alda-nrepl-server-info.
(See connect!
and disconnect!
for information about configuring
alda-clj to talk to your Alda REPL server.
Sends an nREPL message to the Alda REPL server defined in *alda-nrepl-server-info*. (See [[connect!]] and [[disconnect!]] for information about configuring alda-clj to talk to your Alda REPL server.
(set-duration & args)
Emits inline Lisp code (set-duration ...)
Emits inline Lisp code `(set-duration ...)`
(set-note-length & args)
Emits inline Lisp code (set-note-length ...)
Emits inline Lisp code `(set-note-length ...)`
(set-variable var-name & events)
Defines any number of events as a variable so that they can be referenced by name.
Examples:
(set-variable "riffA"
(note (pitch :d))
(note (pitch :f))
(note (pitch :a)))
;;=> #alda.core.SetVariable{
;;=> :name "riffA",
;;=> :events (#alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :d,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil}
;;=> #alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :f,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil}
;;=> #alda.core.Note{
;;=> :pitch #alda.core.LetterAndAccidentals{
;;=> :letter :a,
;;=> :accidentals nil},
;;=> :duration nil,
;;=> :slurred? nil})}
(->str (set-variable "riffA"
(note (pitch :d))
(note (pitch :f))
(note (pitch :a))))
;;=> "riffA = d f a"
(play!
(set-variable "riffA"
(note (pitch :d))
(note (pitch :f))
(note (pitch :a)))
(part "piano")
(get-variable "riffA"))
;;=> "riffA = d f a\npiano:\nriffA"
Defines any number of events as a variable so that they can be referenced by name. Examples: ```clojure (set-variable "riffA" (note (pitch :d)) (note (pitch :f)) (note (pitch :a))) ;;=> #alda.core.SetVariable{ ;;=> :name "riffA", ;;=> :events (#alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :d, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil} ;;=> #alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :f, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil} ;;=> #alda.core.Note{ ;;=> :pitch #alda.core.LetterAndAccidentals{ ;;=> :letter :a, ;;=> :accidentals nil}, ;;=> :duration nil, ;;=> :slurred? nil})} (->str (set-variable "riffA" (note (pitch :d)) (note (pitch :f)) (note (pitch :a)))) ;;=> "riffA = d f a" (play! (set-variable "riffA" (note (pitch :d)) (note (pitch :f)) (note (pitch :a))) (part "piano") (get-variable "riffA")) ;;=> "riffA = d f a\npiano:\nriffA" ```
(stop!)
Stops playback.
When connected to an Alda REPL server, this is done by sending a "stop" message to the server.
Otherwise, we stop playback globally by running alda stop
.
Stops playback. When connected to an Alda REPL server, this is done by sending a "stop" message to the server. Otherwise, we stop playback globally by running `alda stop`.
(tempo & args)
Emits inline Lisp code (tempo ...)
Emits inline Lisp code `(tempo ...)`
(tempo! & args)
Emits inline Lisp code (tempo! ...)
Emits inline Lisp code `(tempo! ...)`
(track-vol & args)
Emits inline Lisp code (track-vol ...)
Emits inline Lisp code `(track-vol ...)`
(track-vol! & args)
Emits inline Lisp code (track-vol! ...)
Emits inline Lisp code `(track-vol! ...)`
(track-volume & args)
Emits inline Lisp code (track-volume ...)
Emits inline Lisp code `(track-volume ...)`
(track-volume! & args)
Emits inline Lisp code (track-volume! ...)
Emits inline Lisp code `(track-volume! ...)`
(transpose & args)
Emits inline Lisp code (transpose ...)
Emits inline Lisp code `(transpose ...)`
(transpose! & args)
Emits inline Lisp code (transpose! ...)
Emits inline Lisp code `(transpose! ...)`
(transposition & args)
Emits inline Lisp code (transposition ...)
Emits inline Lisp code `(transposition ...)`
(transposition! & args)
Emits inline Lisp code (transposition! ...)
Emits inline Lisp code `(transposition! ...)`
(tuning-constant & args)
Emits inline Lisp code (tuning-constant ...)
Emits inline Lisp code `(tuning-constant ...)`
(tuning-constant! & args)
Emits inline Lisp code (tuning-constant! ...)
Emits inline Lisp code `(tuning-constant! ...)`
(voice number)
Begins a voice identified by number
.
Until the voice group ends, all voices are played simultaneously.
Examples:
(voice 2)
;;=> #alda.core.Voice{:number 2}
(->str (voice 2))
;;=> "V2:"
(play!
(part "clarinet")
(voice 1)
(octave 4)
(note (pitch :c) (note-length 8))
(note (pitch :d))
(note (pitch :e))
(note (pitch :f) (note-length 2))
(voice 2)
(octave 4)
(note (pitch :e) (note-length 8))
(note (pitch :f))
(note (pitch :g))
(note (pitch :a) (note-length 2))
(voice 3)
(octave 4)
(note (pitch :g) (note-length 8))
(note (pitch :a))
(note (pitch :b))
(octave :up)
(note (pitch :c) (note-length 2))))
;;=> "clarinet:\nV1: o4 c8 d e f2 V2: o4 e8 f g a2 V3: o4 g8 a b > c2"
Begins a voice identified by `number`. Until the voice group ends, all voices are played simultaneously. Examples: ```clojure (voice 2) ;;=> #alda.core.Voice{:number 2} (->str (voice 2)) ;;=> "V2:" (play! (part "clarinet") (voice 1) (octave 4) (note (pitch :c) (note-length 8)) (note (pitch :d)) (note (pitch :e)) (note (pitch :f) (note-length 2)) (voice 2) (octave 4) (note (pitch :e) (note-length 8)) (note (pitch :f)) (note (pitch :g)) (note (pitch :a) (note-length 2)) (voice 3) (octave 4) (note (pitch :g) (note-length 8)) (note (pitch :a)) (note (pitch :b)) (octave :up) (note (pitch :c) (note-length 2)))) ;;=> "clarinet:\nV1: o4 c8 d e f2 V2: o4 e8 f g a2 V3: o4 g8 a b > c2" ```
(vol! & args)
Emits inline Lisp code (vol! ...)
Emits inline Lisp code `(vol! ...)`
(volume & args)
Emits inline Lisp code (volume ...)
Emits inline Lisp code `(volume ...)`
(volume! & args)
Emits inline Lisp code (volume! ...)
Emits inline Lisp code `(volume! ...)`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close