ctford / leipzig

A music composition library for Clojure and Clojurescript.
Other
454 stars 26 forks source link

Full stop #3

Closed matschaffer closed 11 years ago

matschaffer commented 11 years ago

Was playing around with leipzig again this evening and found myself wanting a "full stop" helper.

I noticed I can capture the play future and stop it like this:

(def player (->> drums (times 4) play))
(future-cancel player)

But I get the feeling something like

(leipzig.live/stop)

that canceled all play futures could be handy if you happen to kick off a somewhat long sequence.

ctford commented 11 years ago

Very good point. It's something that I've noticed in my own music. e.g. when I accidentally played a piano piece with the pitches and durations reversed.

On 4 July 2013 09:41, Mat Schaffer notifications@github.com wrote:

Was playing around with leipzig again this evening and found myself wanting a "full stop" helper.

I noticed I can capture the play future and stop it like this:

(def player (->> drums (times 4) play))(future-cancel player)

But I get the feeling something like

(leipzig.live/stop)

that canceled all play futures could be handy if you happen to kick off a somewhat long sequence.

— Reply to this email directly or view it on GitHubhttps://github.com/ctford/leipzig/issues/3 .

matschaffer commented 11 years ago

It occurred to me last night that this might also be nice for stopping jams.

I tend to keep my riff definitions at the top of the file and the "control" commands (e.g., (jam drums), (->> drums play),etc) toward the bottom. Every couple of iterations I find myself head-scratching when (jam drums) doesn't work since I forgot that I'd nil'd it.

ctford commented 11 years ago

What do you think the best way to do it is?

The simplest thing I can think of is to register each future in an atom as they're created in play, and then cancel 'n clear with the hypothetical leipzig.live/stop.

Normally I'd consider this approach horrible global state, but actually we want global state here because we want to kill sounds even if the user doesn't have a reference to the future.

I'll implement the naive approach above and see how it goes.

Thanks for the feedback.

ctford commented 11 years ago

I've implemented a simple stop in 376e8bc309496fb87ac5308b61beacb56349df27.

Does it solve your problem? Is there a better way?

ctford commented 11 years ago

This enhancement was released in 0.7.0.