tidalcycles / strudel

Web-based environment for live coding algorithmic patterns, incorporating a faithful port of TidalCycles to JavaScript
https://strudel.cc/
GNU Affero General Public License v3.0
636 stars 109 forks source link

Flesh out midi() #192

Open yaxu opened 2 years ago

yaxu commented 2 years ago

Relates to #60

Wish list:

ccn(a).ccv(b).midi() // Sends cc a with value b
nrpnn(a).nrpv(b).midi() // Sends nrprn a with value b
midinote("40 20").midi() // sends midi notes
n(a).midi() // send midi note a.add(60) 
n(5).ccn(20).ccv(40).midi() // send a note and a cc in one pattern

The above send to first midi channel, send to both second and sixth like:

midinote("40 20").channel("[1,5]").midi()

Also midinote, polytouch, midibend, etc..

edit:

felixroos commented 2 years ago

nice wish list! would also love to find a way to support mpe for microtonal stuff

yaxu commented 2 years ago

I think these mostly would work already via superdirt e.g. ccn(30).ccv(70).superdirt()

Tidal also has grouped parameters for cc and nrpn so this is possible cc("30:70"), it'd be nice to support that here too!

felixroos commented 2 years ago

started implementing this in https://github.com/tidalcycles/strudel/compare/objectify-midi there is this list of controls: https://webmidijs.org/api/classes/OutputChannel#sendControlChange

clickglue commented 2 years ago

Hi, thank you so much for all the work you put in Strudel, I really love playing it with digitakt/tone! Is there already a way to sync the midi clock?

felixroos commented 2 years ago

Strudel currently does not support clock syncing, but I think the library it uses supports clocks: https://webmidijs.org/api/classes/Input#event:clock / https://webmidijs.org/api/classes/Output#sendClock I think using strudel as the clock source would be simpler to implement, because the scheduler would not need syncing

yaxu commented 2 years ago

Yes it would be a matter of calling .sendClock 48 times per cycle (assuming one 'note' per cycle), and .sendClockonce every 4 cycles or so. In tidal this looks like midicmd "[midiClock*48, start/4]" # s "midi". It could be nice to abstract this a bit to make it friendlier but it's quite nice to be able to tweak the numbers directly.

Here's superdirt's logic for turning messages into midi: https://github.com/musikinformatik/SuperDirt/blob/develop/classes/DirtEventTypes.sc#L40

There's some nuances e.g. if a control change arrives in the same message as a note you want to send the control change first. (This can delay notes a bit though.. midi gets fiddly)

felixroos commented 12 months ago

idea: use registerSound for midi output, which allows doing things like note("c a f e").s("midi") (like tidal)

felixroos commented 11 months ago

Hi, thank you so much for all the work you put in Strudel, I really love playing it with digitakt/tone! Is there already a way to sync the midi clock?

clock is now implemented in https://github.com/tidalcycles/strudel/pull/710

clickglue commented 11 months ago

Thanks! Thats great!

Van: "Felix Roos" @.> Aan: "tidalcycles/strudel" @.> Cc: "clickglue" @.>, "Comment" @.> Verzonden: Woensdag 27 september 2023 22:55:41 Onderwerp: Re: [tidalcycles/strudel] Flesh out midi() (Issue #192)

Hi, thank you so much for all the work you put in Strudel, I really love playing it with digitakt/tone! Is there already a way to sync the midi clock?

clock is now implemented in [ https://github.com/tidalcycles/strudel/pull/710 | #710 ]

— Reply to this email directly, [ https://github.com/tidalcycles/strudel/issues/192#issuecomment-1738065543 | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/AELXOAKV5UTFSNR72A33J7DX4SHE3ANCNFSM56W7NHAQ | unsubscribe ] . You are receiving this because you commented. Message ID: @.***>

totalgee commented 9 months ago

It would be great if a midiprogram() (or midiprog or whatever you want to call it) function could be added, to send MIDI program change messages. I'm using a Dirtywave M8 tracker with Strudel (USB MIDI), and there it is possible to switch instruments (i.e. program) even with each note, for a given channel. For example, instrument/program 1 might be bass drum, 2 might be snare, and I might want to use both of those on a single MIDI channel, switching back and forth.

Also, if there is a note and program change message at the same time, the program change should be sent first, so the correct instrument is selected before playing the note. This works fine for me in SuperCollider, so I know it can work.

Regardless of my M8 needs, it would be useful to be able to switch presets on any external synth (even if on many of them there is a slight delay before the new sound can be used -- you might send the program change at the start of a cycle or new section of the piece).