alda-lang / alda-core

The core machinery of Alda
80 stars 26 forks source link

(volume 0) optimization #22

Closed daveyarwood closed 7 years ago

daveyarwood commented 7 years ago

Moved from https://github.com/alda-lang/alda/issues/267.

@elyisgreat had the idea that we could optimize performance by not adding silent notes to the :events of a score. In other words, they should behave exactly like a rest of the same duration.

Quoting myself:

If we were to optimize this, this line would probably be the place to do it. On this line, we're constructing a vector of notes to be added to the score. We already have a check to see if the duration of the note is 0 -- if so, no note should be added because a note with a duration of 0 is theoretically just silence. We could also add a check that volume is not 0.

I think this is a premature optimization though, and I don't want to inadvertently break something so I'm in no rush to try it. If someone else can try this change and verify it won't break anything (and maybe add unit tests / benchmarks), I'd happily review a PR.

daveyarwood commented 7 years ago

I don't think this is worth pursuing. Especially with the recent improvements I've been making to the parser (see #37), I don't think this will help performance much, and it seems like it might be useful for us to differentiate between a rest (i.e. no note) and a silent note.