alda-lang / alda-core

The core machinery of Alda
80 stars 26 forks source link

`note` function ignores the duration argument #82

Closed UlyssesZh closed 4 years ago

UlyssesZh commented 4 years ago
(note (pitch :c) (note-length 1))
(note (pitch :c) (ms 400))

etc.

The argument (pitch :c) works, but the argument (note-length 1) or (ms 400) does not and is ignored.

daveyarwood commented 4 years ago

This isn't well-documented, but you have to wrap note-length and ms in a call to duration, which concatenates together 1 or more "duration components" (e.g. note-length, ms):

(note (pitch :c) (duration (note-length 1)))
(note (pitch :c) (duration (ms 400)))

;; adding duration components together
(note
  (pitch :c)
  (duration
    (note-length 1)
    (ms 2345)
    (note-length 8 {:dots 2})))

I'll point out that the "inline Clojure code" feature is going away in Alda v2. Going forward, the best way to write scores by writing Clojure code is to write a Clojure program that uses my alda-clj library. When you use alda-clj, you can actually leave out the duration wrapper and just do something like (note (pitch :c) (note-length 16))

daveyarwood commented 4 years ago

Closing this, as it's been a while. Let me know if you have any questions or want to continue the conversation!