{"action":"closed","issue":{"url":"https://api.github.com/repos/alda-lang/alda/issues/104","labels_url":"https://api.github.com/repos/alda-lang/alda/issues/104/labels{/name}","comments_url":"https://api.github.com/repos/alda-lang/alda/issues/104/comments","events_url":"https://api.github.com/repos/alda-lang/alda/issues/104/events","html_url":"https://github.com/alda-lang/alda/issues/104","id":108410465,"number":104,"title":"Provide superpowers for inline Clojure code","user":{"login":"daveyarwood","id":4909079,"avatar_url":"https://avatars.githubusercontent.com/u/4909079?v=3","gravatar_id":"","url":"https://api.github.com/users/daveyarwood","html_url":"https://github.com/daveyarwood","followers_url":"https://api.github.com/users/daveyarwood/followers","following_url":"https://api.github.com/users/daveyarwood/following{/other_user}","gists_url":"https://api.github.com/users/daveyarwood/gists{/gist_id}","starred_url":"https://api.github.com/users/daveyarwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daveyarwood/subscriptions","organizations_url":"https://api.github.com/users/daveyarwood/orgs","repos_url":"https://api.github.com/users/daveyarwood/repos","events_url":"https://api.github.com/users/daveyarwood/events{/privacy}","received_events_url":"https://api.github.com/users/daveyarwood/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/alda-lang/alda/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-25T21:24:06Z","updated_at":"2015-10-20T14:29:04Z","closed_at":"2015-10-20T14:29:04Z","body":"Now that inline Clojure code is implemented, it would be useful to have a couple of new things defined in `alda.lisp`, ready for use in inline Clojure code:\r\n\r\n* An `alda-code` function or macro that takes a string as an argument and parses it at eval-time. This would be super sweet because it would allow users to generate strings of Alda code using inline Clojure code, and then have them be evaluated as if they were part of the score.\r\n    * I'm not sure this would work 100% of the time (since `clj-expr` nodes can only be placed in certain positions according to the Alda grammar), but maybe we don't necessarily need it to.\r\n    * simple example: `c d e (alda-code \"f\") g` would evaluate to:\r\n\r\n            (alda.lisp/note (alda.lisp/pitch :c))\r\n            (alda.lisp/note (alda.lisp/pitch :d))\r\n            (alda.lisp/note (alda.lisp/pitch :e))\r\n            (alda.lisp/alda-code \"f\")\r\n            (alda.lisp/note (alda.lisp/pitch :g))\r\n\r\n        and then `(alda.lisp/alda-code \"f\")`, when evaluated, would parse `f` into `(alda.lisp/note (alda.lisp/pitch :f))` and evaluate it, effectively doing the same thing as just writing `f` in your score instead of `(alda-code \"f\")`. This is a dumb example because why wouldn't you just write `f`? But the power lies in being able to use Clojure to dynamically generate strings of Alda code, *at runtime, inside your Alda score*.\r\n\r\n* A way to schedule function call events the way that note events are scheduled. Right now, if you insert `(println \"hey there!\")` in the middle of an Alda score, the printing will happen right away when the score is evaluated. But wouldn't it be cool if we could add some sort of event-scheduling function to `alda.lisp`? I'm envisioning being able to print out things at certain points in the score, or basically do *anything* at any point during the playback of the score, by simply adding something like `(schedule #(println \"drop the bass\"))` right where you want it to happen in the score. The `schedule` function would only need to add the function to the score's `:events` as a sort of \"function event\" that includes an offset, which would be determined in the same way as the offset of note events. Then we could teach `play-event!` how to handle these function events. Easy peasy."}}