Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules / multiple-file scores #133

Closed
daveyarwood opened this issue Oct 15, 2015 · 1 comment
Closed

Modules / multiple-file scores #133

daveyarwood opened this issue Oct 15, 2015 · 1 comment
Labels

Comments

@daveyarwood
Copy link
Member

daveyarwood commented Oct 15, 2015

The original idea which I proposed in #7:

Modules

Take the variable concept and apply it to entire files.

For example, each instrument's part could be written in a separate file in the same directory as a main file, then in the main file (say, "score.alda"), you could write something like:

&clarinet.alda
&trombone.alda
&tuba.alda
&banjo.alda
&piano.alda
&drums.alda

and each of these statements would be replaced by the contents of each file at compile time.

This would be especially cool in that you could define custom instruments (e.g. custom synth instruments) as standalone files and then load them in as modules in any piece of music in which you'd like to use them.

NOTE: Modules might be a little tricky to implement and preserve line numbers for error reporting. Ideally we'd be able to report the line/column number and name of the file where the error occurred.

A more recent insight:

For modules, I never really liked the &filename.alda syntax I came up with. Now that we can leverage inline Clojure code, maybe it should just be (load-module "/path/to/file.alda") and/or (load-score "/path/to/file.alda")

Interestingly, since inline Clojure code evaluation was added, it has been possible to load Clojure code from other files (via clojure.core/load-file), which is great in itself and gets us halfway there. load-module could read Alda (and by extension, Clojure) code from a file and parse and evaluate it within the context of the current score. Instrument parts and even rudimentary plugins could thus be written and distributed as .alda files.

An open question I have is how load-file and load-module will handle relative paths. Ideally, it will be possible to distribute Alda scores as folders containing multiple .alda files, as git repos, etc. So, relative paths should ideally be interpreted relative to the score they're written in, not the user's current working directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant