Commit Graph

23 Commits

Author SHA1 Message Date
David Lu
d5a7aeb85f Removed something I accidentally left in 2021-06-13 19:22:04 -04:00
David Lu
02414e2089 Updated examples to showcase dynamics 2021-06-06 21:48:33 -04:00
David Lu
21834a4d07 Added Alda file for Rachmaninoff Piano Concerto no. 2 2021-04-24 17:41:32 -04:00
Dave Yarwood
40eb33ccd0 fix AWOBMOLG example score: d+/d+ should be d+/>d+ 2020-03-11 22:11:55 -04:00
Dave Yarwood
45a5f0d86c add an example score that uses vol and track-vol attributes 2020-01-23 16:47:58 -05:00
Dave Yarwood
6d1faceff4 comment lisp fn not supported in v2 2019-11-16 22:27:02 -05:00
Dave Yarwood
bd4605374c modes1.alda => modes.alda 2019-09-23 13:58:19 -04:00
Dave Yarwood
61e38b083d add examples from alda-core, modified for v2 2019-04-20 11:29:46 -04:00
Dave Yarwood
b9370b0a6b move client/server dependency out into a separate project 2016-11-15 19:47:07 -05:00
Dave Yarwood
502bf21c6e add clapping music example 2016-09-20 20:55:13 -04:00
Dave Yarwood
ac069b795b add some quantization for character 2016-09-05 17:11:33 -04:00
Dave Yarwood
8500631cd0 update debussy quartet example
Wow, I totally butchered the rhythms in the first line! I thought it sounded outlandish, even for Debussy... Sounds much better now.

I added the 2nd and 3rd stanzas, made a bunch of miscellaneous fixes, and added some dynamics.
2016-08-13 00:18:13 -04:00
Dave Yarwood
6ed37793eb change natural syntax: = -> _
= is being used now for variable definition, which makes '=' as a natural syntax a little confusing.

_ can also be used in variable names, but variable names must start with at least two letters, so there is no conflict, grammar-wise.
2016-07-18 14:24:15 -04:00
Dave Yarwood
f321902d5b variables! 2016-07-18 00:06:44 -04:00
Dave Yarwood
cd695f4aa0 1.0.0-rc17: fix MIDI issues with quant >= 100 2016-05-21 12:28:48 -04:00
Dave Yarwood
ed659d597b example score: overriding a global attribute 2016-05-15 14:00:57 -04:00
Dave Yarwood
5d812373e7 fix multi-poly example
`set-duration` sets the number of beats, not the standard note length (meaning quarter = 4, whole = 1 etc.)
2016-05-15 13:00:33 -04:00
Dave Yarwood
267526923f updated alda.now to use alda.lisp the new way
With the changes I just made to alda.lisp, score evaluation is now a self-contained process. This allows us to be flexible in the way we use alda.now.

I've adjusted things so that the `play!` function by default will start up a new score and evaluate the events in its body within that context. It actually uses *current-score* as the context, but when that's nil, it starts a new score and uses that.

Scores are represented as atoms referencing Alda score maps.

*current-score* can be manipulated via the `with-score` and `with-new-score` macros, which bind *current-score* to a particular score or a new score, respectively, and then both modify *current-score* and return the modified score.

There's also `play-score!`, which will play an entire score, given the score map or an atom referencing it.
2016-04-17 23:07:10 -04:00
Dave Yarwood
4715c73bbb functionally purify alda.lisp
Lots of changes and refactorings here. I think I might write a blog post about it.

To briefly summarize this commit:

  - BEFORE:
    - There were a bunch of top-level dynamic vars like *current-instruments* and *events* and a bunch of others.
    - We were alter-var-root'ing and binding'ing things all over the place.
    - Because of this, only one score evaluation context could exist at a time; loading a new score into a server, for example, would necessarily have to interact with or overrwrite any existing score evaluation context. One-off evaluation of a score (without affecting the current score in progress) was not possible.
    - Score evaluation relied on mutable state over time as the score got evaluated. For example, evaluating (note (pitch :c)) would alter-var-root on *events* and *instruments* to update the state of those things.

  - AFTER:
    - No more top-level vars.
    - A score is a map containing a bunch of data about the current state of the evaluation context. Because immutable data is awesome, the current state of a score can easily be stored in a symbol or an atom or be let-bound or whatever.
    - This makes it easy to evaluate multiple scores (with different evaluation contexts) at the same time, and each score evaluation context is a totally isolated environment.
    - This will make it possible for the server to parse, evaluate and play Alda scores in isolation from one another, solving many bugs and generally making life easier.
    - Incidentally, fixed issue #199. Local attributes occurring at the same time as global attributes will now override the global attributes.
    - alda.lisp event functions like `note` and `chord` no longer work via side effects. Instead, each event function returns a map containing all the necessary information about that event.
    - The score function basically reduces through the events of the score, starting with a fresh score context map and updating it for each event in the score.
    - There is a function called `continue` which will take a score context map and continue evaluating further events. This is what we're going to use to "update" a score a little at a time via the Alda REPL, server and command-line client.
    - Because event functions no longer work via side effects, inline Clojure code will work a little differently. Basically, you'll just write code that returns one or more Alda events, instead of code that produces side effects and returns nil.
2016-04-17 23:07:10 -04:00
Dave Yarwood
f0479ccb78 fix bug re: starting an event sequence with an event sequence (same for crams within crams)
I had negative lookaheads like `!("[" | "]") events` in the rules for event sequences and cram expressions, but they weren't really doing anything (apart from disallowing event sequences/crams in the initial position) because the rule wasn't being used recursively.

I tried simply removing the negative lookaheads and it seems to work fine! ¯\_(ツ)_/¯
2016-02-21 18:40:33 -05:00
Dave Yarwood
03ccd0f705 add MIDI percussion instrument
In the future, we will hopefully have a plug-in that will make writing percussion parts much nicer. Perhaps the plug-in could map ASCII characters to different percussion sounds, and then you could write your percussion parts using a drum tab-like syntax.

For now, we can at least make percussion available, and it can be used just like any other MIDI instrument.
2016-01-24 17:26:11 -05:00
Dave Yarwood
789ca3e6b4 Extract parser into separate tasks ✂️
This commit changes Alda's parsing process from using a single, monolithic grammar to parse an entire score in one pass, to parsing a score in several discrete steps, using a separate grammar/parser for each phase.

The perks of doing it this way:

- It will give us greater flexibility with syntax features. For example, this will make it a lot easier (maybe even possible to begin with) to implement inline variable definitions which terminate in a newline -- we can just parse them after comments and Clojure expressions, but before everything else.
- We can leverage more of Instaparse's built-in optimizations for parallelizing work. Each instrument part will be parsed concurrently, for example.
- Because we'll be feeding each parser smaller bodies of text, performance will improve significantly. I tested at least one score that took ~6 seconds to parse before, but now takes ~600-700 ms.

The downsides:

- There is no longer a single parse tree for an entire score.
- Parsing errors will be harder to understand from the stacktrace alone. Line/column numbers will no longer refer to the entire score file, but rather the small section of the score that is being parsed.
- We'll need to rewrite/rethink `parse-with-context`, which the Alda REPL uses to determine the context of a snippet of Alda code. Currently this works by doing a series of partial parses using the single alda.bnf grammar.

I think these are hardships worth enduring for the benefits we'll gain, especially in light of the poor performance we're dealing with with the current single-grammar system, and the need to pave the way forward for advanced syntactical features as the language's grammar grows in complexity.
2015-11-12 01:10:05 -05:00
Dave Yarwood
2033702b48 add parser benchmarks/smoke tests 2015-11-12 00:50:33 -05:00