tmhglnd / mercury

A minimal and human-readable language and environment for the live coding of algorithmic electronic music.
http://www.timohoogland.com/mercury-livecoding
GNU General Public License v3.0
291 stars 13 forks source link

Perform small math operations in Mercury? #93

Open tmhglnd opened 8 months ago

tmhglnd commented 8 months ago

When creating lists it could be useful to just use some simple math to calculate the length that needs to be used instead of having to calculate this on your own. For example when using functions like every or cosine

current situation

list rtm rotate(every(euclid(11 5) 4 12) 36)
list len cosine(96 1 50 500)

new synth sine note(0 2) shape(1 len) play(rtm) time(1/12)

new situation could look something like:

list rtm rotate(every(euclid(11 5) 4*12) 3*12)
list len cosine(8*12 1 50 500)

new synth sine note(0 2) shape(1 len) play(rtm) time(1/12)

Or maybe possible to create a short alias with the already present list functions

list rtm rotate(every(euclid(11 5) *(4 12)) *(3 12))
list len cosine(*(8 12) 1 50 500)

new synth sine note(0 2) shape(1 len) play(rtm) time(1/12)