Guest User

Untitled

a guest
Jan 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. (defn is-note-off
  2. "Adds note if was turned off to accumulator"
  3. [acc [note command]]
  4. (if (= :note-off command)
  5. (conj acc note)
  6. acc))
  7.  
  8. (defn is-note-on
  9. "Adds note if was turned on to accumulator"
  10. [acc [note command]]
  11. (if (= :note-on command)
  12. (conj acc note)
  13. acc))
  14.  
  15. (defn note-offs
  16. "Associates a tick with notes turned off at it"
  17. [acc tick note-events]
  18. (assoc acc tick (reduce is-note-off [] note-events)))
  19.  
  20. (defn note-ons
  21. "Associates a tick with notes turned on at it"
  22. [acc tick note-events]
  23. (assoc acc tick (reduce is-note-on [] note-events)))
  24.  
  25. (defn get-notes-by-type
  26. "Returns a map: key is tick, value is notes that match the command arg"
  27. [notes-by-ticks-map command-type]
  28. (if (= :note-on command-type)
  29. (reduce-kv note-ons {} notes-by-ticks-map)
  30. (reduce-kv note-offs {} notes-by-ticks-map)))
Add Comment
Please, Sign In to add comment