Separate output channels for live_loops (or buffers)?

I sometimes think it would be a great feature, if you could direct one (or more) live_loops (or buffers) to separate outputs - as if a live_loop or a buffer was something like a track or channel.

I have no idea if that is even technically possible and also how I would use such a feature running on my Linux system (allthough I think it should be perfectly possible via Jack).

Right now I am thinking this would make it possible to

  • prelisten to a running live_loop and further more
  • you could do some post-mixing

Does anyone share this interest? And is it a feasable feature at all?

2 Likes

Hi Martin
Maybe this is what you’re thinking about?

live_loop :bd do
  with_fx :sound_out, output: 1 do #Ch1 -> left
      sample :bd_haus
      sleep 1
  end
end
2 Likes

Hi Christian,

wow, I must have repeatedly overlooked this in the documentation. Thanks for the enlightenment! Now I have only to find out how to use that …

Martin

Hi,

I did manage to figure it out using Jack-Mixer to route 2 live_loops to different output channels (the wording is somehow confusing: output, channel, client, port; I did encounter all these terms while doing some research); might be of interest for someone, who wants to achieve something similar:

Strangly if I set output: 1 for the first live_loop I would expect to hear just this one (out_1 and out_2) but I don’t; I hear both loops. If I use e. g. output: 3 for one and output: 5 (as in the screenshot) for the other loop, I am able to rout its sounds to different mixer channels. But… this is a first try and I am definitely not sure if I missed something…

Hmm I wondered something similar. I think it would be an incredibly useful feature to be able to record each buffer as a separate track simultaneously. I imagine this would be hard to do. However it would mean that I could perform an improvisation, pull out each instrument separately and post process them individually (trim out any mistake) and have an amazing sounding song.

Well, it seems perfectly possible to do that, see my first attempt (and by no means final result). Though - besides other things - it does involve a setup, which depends on the OS you are using.

By default FX always pass audio to the outer context. The sound_out* FX are no exception. What they actually do is both route the audio to the specified sound card output and route the audio to be outer lexical context. In your case these end up in the same audio card output audio channels hence the confusion.

If you were to output to audio card channel 10, the audio will be heard both on 10 and on 1,2 as expected as it’s the outer FX.

To only route the audio to channel 10, you would need to supply an amp: 0 as an opt to the :sound_out FX to suppress the standard lexical output behaviour but only after the FX has routed to channel 10.

Hope this makes sense :slight_smile:

Ok, thanks! And yes, makes sense so far. I will look into it more deeply next week. (By the way: A great feature!)

1 Like

For those, who are interested: Another proof of concept: A running configuration with Sonic Pi, Nonmixer and Carla with Calf Reverb Plugin applied to one of the live_loops:

Now obviously this quickly becomes a performance issue. I do need same faster hardware …

1 Like

Hey, I am working on a 4-channel- soundinstallation with sonic pi. I followed your describtion. Nevertheless, as soon as I use the soundout-fx to route my liveloop to channel 3 resp. channel 4 and “mute” channel 1 and 2, the audio is routed back to channel 1 and 2. Did i write it correctly?

with_fx :sound_out, output: 3, amp: 3 do
  with_fx :sound_out, output: 1, amp: 0 do
    with_fx :sound_out, output: 2, amp: 0 do
      with_fx :sound_out, output: 4, amp: 0 do
        live_loop :plant3a do
         ....
        end
      end
    end
  end
end

thanks for any further and detailed answer…in 3 days their is a public presentation :wink:

1 Like

Hi @KAtA,

If you take a look at the docstring of :sound_out you can see:

"Outputs a mono signal to a soundcard output of your choice. By default will mix the incoming stereo signal (generated within the FX block) into a single mono channel. However, with the mode: opt, it is possible to alternatively send either the incoming left or right channel out directly. "

In other words, what’s happening is:


----  left channel ---\ ---------------------------------------- left chan out
                       +---- mixed mono channel to output n
---- right channel ---/ ---------------------------------------- right chan out

We’re therefore effectively doing nothing to the input and output channels and are creating an additional channel which is piped to a specific sound card output.

So let’s take a look at this in code:

with_fx :sound_out, output: 4 do
# stereo sound source 
end

This will take #stereo sound source and output it to its external context and mix the source to mono and output to sound card output 4. If we only want to output to the sound card and not to the external context, we can supply an amp: 0:

with_fx :sound_out, output: 4, amp: 0 do
# stereo sound source 
end

This will only output the mixed mono signal to the sound card output 0 and not to the outer context, which means it won’t get automatically sent to channels 1 and 2 (which are the default channels of the outer context).

Now, this means that in your original code, when you nest two sets of with_fx in this manner you’re effectively not passing any audio from the inner fx to the outer as you’re “muting” it with amp: 0

with_fx :sound_out, output: 3, amp: 0 do
  # no sound here now as it has been muted
  with_fx :sound_out, output: 4, amp: 0 do
    # stereo sound source 
  end
end

This is probably a large part of the issue that you’re having.

Out of interest, what are you actually attempting to achieve? For example:

  • Are you wanting to send the same mono-mixed stream to your sound card outputs 3 and 4?
  • Were you trying to map channel 1 to 3 and 2 to 4 unchanged?
  • Did you still want the signal to come out of outputs 1 and 2 or want that muted?

Hopefully we can get you sorted soon :slight_smile:

1 Like

Thank you @samaaron so much for your quick reply.

To get the context: I built a device to measure the electrical conductivity of four plants, which is converted into MIDI notes by an Arduino patch. I have built live-loops for sound design of each plant and its conductance and would like to send one liveloop per plant to a single loudspeaker. Means, one liveloop per loudspeaker: live_loop :plant1 only to output 1, live_loop :plant2 only to output 2, live_loop :plant3 only to output3 and so on…

Well, this is actually the weird part, which seems not quite logical to me :wink:

Hi @KAtA,

well, it might help to realize the following: As Sam said, regarding a nested with_fx ... do code structure the sound (coming from inner live_loop :plant3a) travels from the inside to each with_fx :sound_out - but only if you let it and don’t mute the signal via amp: 0.

Can’t you do something like:

 live_loop :plant1 do
    with_fx :sound_out, output: 3 do # could also be outside live_loop
        # sound source
    end
 end
 live_loop :plant2 do
    with_fx :sound_out, output: 4 do
        # sound source
    end
 end

 live_loop :plant3 do
    with_fx :sound_out, output: 5 do
        # sound source
    end
 end

 live_loop :plant4 do
    with_fx :sound_out, output: 6 do
        # sound source
    end
 end

Or am I totally on the wrong track?

Okay, so it would be best if I don’t address channels 1 and 2 at all with_fx :sound_out, but distribute the live_loops to channels 3 to 6, which means that I have to define channels 3 to 6 with my sound card.

Maybe my iritations comes from this:

I didn’t understand, if I have to set “amp: 0” as an opt to output channel 10 OR set “amp:0” in a second line “:sound_out, output: 2, amp: 0”…

I try that tomorrow and let you know. I am confident now that I will be able to manage my output-problem :slight_smile:

Hi @KAtA,

this is actually quite simple - at least if you can use Jack for routing. I’ll explain in my own words, which might not be technically correct but work in practice. The default configuration for Sonic Pi and Supercollider is, that there will be 16 in- and output channel (8 stereo). Sonic Pi uses 1 + 2 as default to send audio to the system output (speakers). If I e. g. want to route output channels from Sonic Pi through external effects I could use channel 3 and 4 for Sonic Pi, route this into a reverb and then to the system output. I then would have to remove (or mute) the default output channel 1 + 2 because one the one hand I will get distortion because the output would be to high and on the other hand 1 + 2 would provide dry output (without reverb) besides the wet output from channel 3 and 4:

So if I want to explicitely route sound from Sonic Pi I do the following:

  • remove the default channel 1 and 2 connection to system output in Jack (resp. Carla or some other tool like Patchbay)
  • set up the effects and connections in Jack (resp. Carla …)
  • use with_fx :sound_out_stereo (if I don’t reconfigure SP resp. Supercollider I will have 7 track: 3 (+4), 5 (+6) etc.)
  • ah, I almost forgot: make sure that I explicitly route all live_loops to one of the channels 3 to 16 (except 1/2) because if I don’t this loop will be muted because I killed the default output 1 + 2 …
  • and, last but not least, on the picture I have one clean (stereo) channel which is 3/4 (this is the dry channel without effect and sort of replaces the default 1/2 connection); 5/6, 7/8 and 9/10 are being routed through effects and then to system output.

Unfortunately I have no idea how to achieve such a setup on MacOSX or Windows unless you install Jack (which is mandatory on Linux/Raspi if you work with Sonic Pi). Hope that helps.

Anyone, please feel free to correct me if I fail to be correct concerning the technical side …

1 Like

Hi @Martin,

thank you very much for your example and explanation. As you said, I removed channel 1 and 2 and configured channel 3, 4, 5, 6 in the soundcard-interface and it works very very well :smiley:

Now, I also get the idea on what sonicpi did, when I chained so many “with_fx :sound_out” and what happend with the signal…why it can’t work the way I thought it should.

THANK U @samaaron & @Martin - you made my day and soundinstallation!

4 Likes

Glad to hear that. I wish you luck for the Vernissage if there is one!

Thanks @Martin - well, for the exhibition everything technically worked just the way I intended. But in the botanical garden different plants were available than in my homegarden. The difference in the conductance had a huge impact on my prescripted soundscape, so that I had to rewrite a big part of my sonicpi script. :upside_down_face:

1 Like

Hi @KAtA,

glad to hear that! And I guess it is a good think that nature is somehow unpredictable, right?!

:wink:

hi KAtA, nice topic to read, can you share any videos of your performance ?

we have similar project with the kids here and i am wondering how to connect arduino boards to sonic pi data… maybe we have passed by this process.
Anyway, thank you very much
bye