# Baked in support for midi-in, audio-in and audio devices/channels?

**URL:** https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098
**Category:** Strudel
**Tags:** questions
**Created:** [4 March 2024 09:53 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098 "2024-03-04T09:53:10Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![karollibardi](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/k/c77e96/32.png) [@karollibardi](https://uzu.lurk.org/u/karollibardi)
#### Post date: [4 March 2024 09:53 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098/1 "2024-03-04T09:53:10Z")

</div>

Hello. Firstly I would like to congratulate all the devs on Strudel for creating such an amazing piece of software. I've been using Sonic Pi for some time now and while I find it great, recently I've been playing with Strudel a lot because of its great amount of built in synths and samples and the ease of using 3rd party ones.

_As a sequencer strudel feels perfect to me already_ 🙂

There are three things that I am missing from Sonic Pi:

1. Ability to easily use midi inputs to play live music:

I want to use Strudel and patterns for drums but I want to be also able to be able to use a midi keyboard to trigger/control synths/samples "live". This is actually easy enough to accomplish already, here's an example of metronome done with Strudel's `sound` running next to a midi-controlled piano that uses synths/samples from Strudel (supports velocity and press duration):

```haskell
await WebMidi.enable()
const myInput = WebMidi.inputs[0];
const noteControls = Array.from(Array(128)).map(x => null)
myInput.removeListener('noteon');
myInput.removeListener('noteoff');
myInput.addListener('noteon', e => {
  const [n, vel] = e.dataBytes;
  superdough({ note: n, s: 'piano', postgain: vel / 127 }, 0.05, 10).then(function (x) {
    noteControls[n] = x;
  });
});
myInput.addListener('noteoff', e => {
  const [note] = e.dataBytes;
  const { mute } = noteControls[note]
  mute(0.1);
  noteControls[note] = null
})

sound("metal casio casio casio")

```

This won't work in latest Strudel, but it required only one line of code to be changed to make it happen:

> <https://github.com/tidalcycles/strudel/pull/975>
>
> I would like to introduce an ability to control synth or sample after it was tri…ggered. For now I just need the ability to mute, but I am open to implementing control over other aspects of sound too.
> 
> Here is an example of what I'm using this for:
> 
> \`\`\`
> await WebMidi.enable()
> const myInput = WebMidi.inputs\[0\];
> const noteControls = Array.from(Array(128)).map(x =\> null)
> myInput.removeListener('noteon');
> myInput.removeListener('noteoff');
> myInput.addListener('noteon', e =\> {
> const \[n, vel\] = e.dataBytes;
> superdough({ note: n, s: 'piano', postgain: vel / 127 }, 0.05, 10).then(function (x) {
> noteControls\[n\] = x;
> });
> });
> myInput.addListener('noteoff', e =\> {
> const \[note\] = e.dataBytes;
> const { mute } = noteControls\[note\]
> mute(0.1);
> noteControls\[note\] = null
> })
> 
> sound("metal casio casio casio")
> \`\`\`

Midi-in could also be useful for control over some things like swing etc, so maybe it deserves a wrapper that makes the code above easier to use and reduces boilerplate (and possibly preserves midi state across live code reloads)?

1. Ability to explicitly control audio channels (and possibly devices):

_I've already figured out that this is possible with_ `channels` (`ch`).

I want to be able to redirect some synths to audio channels different than default. Exact use case is - direct some output generated by `notes` or `sound` to headphones device instead of default speakers device so I can try out some melodies before I switch the mix to "default" and play so that everyone can hear it. What I described would require support for managing media devices, but to simplify things for start, I could just use a 4-in-channel, 4-out-channel sound card and have the ability to use channels 0,1 for "default" and channels 2,3 for things I'd like to try out. Then I could just revert everything to go to channels 0,1. There is already support for panning in stereo, so I guess this can't be too difficult to implement.

3\*. Support for live audio in.

This is a little cherry on top and I don't need it very badly, but I would love to have support for live audio in. In the simplest form I just want to mix music from other sources with Strudel output, which can be accomplished just with using an external mixer, but... If the audio could be handled inside the editor I could use the mixing facilities from point 2 to do the mix and also it would open up the possibility to use the already-present effects like reverb or delay.

Some feedback I'd love to have back:

- Does the Strudel/Tidal community even want/need that stuff? Maybe Strudel/Tidal should just be used for its awesome patterns as a sequencer, not as a general music live coding tool?
- How to approach coding this? Should I push for merging it into Strudel core? Should I build it as an esm "plugin", so that you import it and do something like "initMidiIn" or "initAudioIn" (similar to `initHydra`).

All feedback appreciated.

---

<div class="post-metadata">

### Author: ![ilesinge](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ilesinge/32/785_2.png) [@ilesinge](https://uzu.lurk.org/u/ilesinge)
#### Post date: [6 March 2024 21:22 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098/2 "2024-03-06T21:22:42Z")

</div>

I would definitely love to have live audio input to Strudel. My personal use case is to chop up live input and use it as samples to do (weird things). I finally used Tidal Cycles with [Tidal Looper](https://github.com/thgrund/tidal-looper) to achieve the same, but having such support in Strudel would be awesome. I checked a bit how to implement it but I didn't find a solution at the time.

Your other two suggestions seem totally reasonable, and even though I don't need it personally yet, I might in the future. I would be in favor of having it in the core even though I have no call in the decision 🙂  
You might find people to discuss this in more details on the Tidal/Strudel Discord in the Strudel channels: [Meet the community | Tidal Cycles](https://tidalcycles.org/docs/community/#discussion-and-sharing)

---

<div class="post-metadata">

### Author: ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)
#### Post date: [7 March 2024 19:27 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098/3 "2024-03-07T19:27:16Z")

</div>

You could use tidal looper with strudel, via [the superdirt bridge([MIDI & OSC 🌀 Strudel](https://strudel.cc/learn/input-output/)).

---

<div class="post-metadata">

### Author: ![froos](https://uzu.lurk.org/user_avatar/uzu.lurk.org/froos/32/3517_2.png) [@froos](https://uzu.lurk.org/u/froos)
#### Post date: [7 March 2024 20:00 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098/4 "2024-03-07T20:00:00Z")

</div>

> [@karollibardi](#):
>
> Ability to easily use midi inputs to play live music

> [@karollibardi](#):
>
> How to approach coding this? Should I push for merging it into Strudel core? Should I build it as an esm "plugin", so that you import it and do something like "initMidiIn" or "initAudioIn" (similar to `initHydra`).

for midi, there is already the [midi package](https://github.com/tidalcycles/strudel/tree/main/packages/midi) which also already has a [midin function](https://github.com/tidalcycles/strudel/blob/main/packages/midi/midi.mjs#L169) that currently only supports cc in. It is not yet documented, but you can find out more in [the PR](https://github.com/tidalcycles/strudel/pull/699). Note in would be a good addition to it. There is also [this issue for midi input](https://github.com/tidalcycles/strudel/issues/533), maybe we can talk about the details there (or preferably on the discord?).

Audio input is also very desirable for me, for which there is is [this issue](https://github.com/tidalcycles/strudel/pull/699https://github.com/tidalcycles/strudel/issues/610). I think there are 2 stages for audio input: 1. record samples into the sounds tab 2. record samples from code and loop them instantly (like tidal-looper).

---

<div class="post-metadata">

### Author: ![ilesinge](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ilesinge/32/785_2.png) [@ilesinge](https://uzu.lurk.org/u/ilesinge)
#### Post date: [1 April 2024 21:28 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098/5 "2024-04-01T21:28:41Z")

</div>

Hello ! I've implemented a live audio in looper which you can try and re-use:

> **[Strudel REPL](https://strudel.cc/?uxBZTiojsEW8)**
>
> Strudel is a music live coding environment for the browser, porting the TidalCycles pattern language to JavaScript.

---

<div class="post-metadata">

### Author: ![lwlsn](https://uzu.lurk.org/user_avatar/uzu.lurk.org/lwlsn/32/1306_2.png) [@lwlsn](https://uzu.lurk.org/u/lwlsn)
#### Post date: [29 July 2024 20:28 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098/6 "2024-07-29T20:28:24Z")

</div>

this is v cool!

---

<div class="post-metadata">

### Author: ![mojozart](https://uzu.lurk.org/user_avatar/uzu.lurk.org/mojozart/32/3043_2.png) [@mojozart](https://uzu.lurk.org/u/mojozart)
#### Post date: [7 December 2024 23:13 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098/7 "2024-12-07T23:13:01Z")

</div>

I like this request. Has progress been made? That is, is this possible now?

FWIW, in my case I would like to be able to point someone to a strudel.cc link, and tell them to open it in a MIDI-capable browser on Android and plug in their MIDI controller - such as keyboard, BopPad (drum) or WARBL (wind).

Where should I follow up? Did you find help on Discord?

---

<div class="post-metadata">

### Author: ![Virginie\_Alison](https://uzu.lurk.org/user_avatar/uzu.lurk.org/virginie_alison/32/3471_2.png) [@Virginie\_Alison](https://uzu.lurk.org/u/Virginie_Alison)
#### Post date: [19 December 2025 14:37 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098/8 "2025-12-19T14:37:34Z")

</div>

Salut ilesinge, de Bordeaux tu dois pouvoir parler français, sinon je te relancerai en anglais. Je n’arrive pas à faire marcher ton looper dans Strudel, il me répond “[getTrigger] error: sound loop not found! Is it loaded?” alors que ma carte son est bien connectée… dans ton script il y a une todo que je n’arrive pas à comprendre et probablement il y a qq chose que je dois faire ici… Merci d’avance pour ton aide ! Virginie de Lyon

---

<div class="post-metadata">

### Author: ![Virginie\_Alison](https://uzu.lurk.org/user_avatar/uzu.lurk.org/virginie_alison/32/3471_2.png) [@Virginie\_Alison](https://uzu.lurk.org/u/Virginie_Alison)
#### Post date: [21 December 2025 08:24 UTC](https://uzu.lurk.org/t/baked-in-support-for-midi-in-audio-in-and-audio-devices-channels/5098/9 "2025-12-21T08:24:02Z")

</div>

Hi yaxu again and all the contributers!

Could you please express here the “state of the art” concerning these two capabilities? :

- A way to play midi notes in Strudel from a midi keyboard?, or eventualy a way to transform cc controls (if it is for now the only “midi in” way) in midi notes?

- A Strudel live looper, accepting midi notes and/or audio inputs? (I’ve seen the @ilesinge looper, but as I already asked above to him (in French) I don’t success to make it working… and it seems to only accept audio sources (that is already fine, but with midi notes it would be perfect!)

Thank you very much in advance for your kind contributions 🙂
