roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.06k stars 213 forks source link

Configurable channel set #86

Closed gavv closed 3 weeks ago

gavv commented 7 years ago

What we need:

Features:

Internals:

API:

CLI:

kaosbeat commented 3 years ago

is it, at the moment, possible to have a multi-channel setup?

for example jack-router allows to specify virtual outputs. They show up in my qjack-ctl Screen Shot 2021-03-04 at 14 34 58

How would I connect each one of them to a single roc-send? So my roc-recv on the other side just has to deal with 1 channel.

When doing roc-send -L I get

supported device drivers:
  core

on OSX

How would I connect to the right device? And pass the right channel to each roc-send instance?

gavv commented 3 years ago

Hi!

is it, at the moment, possible to have a multi-channel setup?

Currently, roc always uses exactly two channels. I'm planning to fix this in 0.2 (upcoming major release).

How would I connect each one of them to a single roc-send? So my roc-recv on the other side just has to deal with 1 channel.

Currently roc doesn't support JACK. But if you map each output port to a separate ALSA device, you can run an instance of roc-send for each device.

If somebody will add support for JACK in future, it could be possible to connect roc-send directly to a JACK port.

How would I connect to the right device? And pass the right channel to each roc-send instance?

You can use --input option of roc-send to specify device ID. IIRC, you can get the list of devices available using system_profiler SPAudioDataType.

We use sox for recording and playback on macOS, and its latency is not ideal. I plan to add native coreaudio backend in 0.3.

kaosbeat commented 3 years ago

I'm planning to fix this in 0.2 (upcoming major release).

We'll see multichannel when it arrives :)

if you map each output port to a separate ALSA device, you can run an instance of roc-send for each device.

I guess on a mac you cannot make separate ALSA devices?

The system profiler spits out quite a list. It however has no effect I tried the --input option with no success. It defaults to the the default input device, which is on my mac a single channel microphone. I'm using the "name" because that is the closest I can find to ID

I tried changing the inputs like this: roc-send --input "Audiohub 2x4" --packet-length=5ms -vv -s rtp+rs8m:192.168.1.152:10001 -r rs8m:192.168.1.152:10002

the output of system_profiler SPAudioDataType is

$ system_profiler SPAudioDataType
dlopen error : dlopen(libjack.0.dylib, 0x0001): file not found 'libjack.0.dylib'
dlopen error : dlopen(libjack.0.dylib, 0x0001): file not found 'libjack.0.dylib'
Audio:

    Devices:

        DisplayPort:

          Manufacturer: Apple Inc.
          Output Channels: 2
          Current SampleRate: 48000
          Transport: DisplayPort
          Output Source: HP LP2475w

        Audiohub 2x4:

          Input Channels: 2
          Manufacturer: Novation
          Output Channels: 4
          Current SampleRate: 48000
          Transport: USB
          Input Source: Default
          Output Source: Default

        External Headphones:

          Default System Output Device: Yes
          Manufacturer: Apple Inc.
          Output Channels: 2
          Current SampleRate: 44100
          Transport: Built-in
          Output Source: External Headphones

        MacBook Pro Microphone:

          Input Channels: 1
          Manufacturer: Apple Inc.
          Current SampleRate: 48000
          Transport: Built-in
          Input Source: MacBook Pro Microphone

        MacBook Pro Speakers:

          Default Input Device: Yes
          Default Output Device: Yes
          Manufacturer: Apple Inc.
          Output Channels: 2
          Current SampleRate: 44100
          Transport: Built-in
          Output Source: MacBook Pro Speakers

        JackRouter:

          Input Channels: 8
          Manufacturer: Grame
          Output Channels: 20
          Current SampleRate: 0
          Transport: Unknown
          Input Source: Default
          Output Source: Default

but even running without the input option roc-send won't start

$ roc-send --packet-length=5ms -vv -s rtp+rs8m:192.168.1.152:10001 -r rs8m:192.168.1.152:10002
13:16:16.349 [dbg] roc_sndio: initializing sox backend
13:16:16.349 [dbg] roc_send: pool: initializing: object_size=2064 poison=0
13:16:16.349 [dbg] roc_send: pool: initializing: object_size=2576 poison=0
13:16:16.349 [dbg] roc_send: pool: initializing: object_size=632 poison=0
13:16:16.352 [inf] roc_sndio: sox source: opening: driver=coreaudio input=default
13:16:16.433 [inf] roc_sndio: sox source: in_bits=32 out_bits=32 in_rate=48000 out_rate=0 in_ch=1 out_ch=0 is_file=0
13:16:16.433 [err] roc_sndio: sox source: can't open: unsupported # of channels: expected=2 actual=1
13:16:16.433 [inf] roc_sndio: sox source: closing input
13:16:16.434 [err] roc_send: can't open input file or device: driver=(null) input=(null)

I just have to go to audio setting and set a different default audio device that has 2 channel input. Tried doing this for "jackrouter" (as that would solve part of my other problem) but I cannot choose this device as a default input/output

We use sox for recording and playback on macOS, and its latency is not ideal. I plan to add native coreaudio backend in 0.3.

I was surprised how well it works out-of-the-box with default settings, I did not expect < 10ms latency...

gavv commented 3 years ago

I guess on a mac you cannot make separate ALSA devices?

Oh, yes, this is only about Linux.

I tried changing the inputs like this:

Looks legit. Last time I tested it with soundflower device: https://gavv.github.io/articles/roc-tutorial/#run-roc-send-1

So when you use --input "Audiohub 2x4", roc-send ignores it and just uses default input device?

but even running without the input option roc-send won't start

Yes, until this issue is resolved, roc-send wont work unless audio backend allows to open device in two-channel mode. PulseAudio will always allow it and perform channel mapping if necessary. IIRC coreaudio just doesn't have this feature, so for now you can use only two-channel devices.

BTW until there is multichannel support, you can try to hack the source code and just change the number of channels, which is hard-coded to 2, to another number. You'll need to change DefaultChannelMask in roc_pipeline and maybe a few other constants (not sure).

gavv commented 12 months ago
gavv commented 3 weeks ago

All patches merged. Surround support will be completed and merged separately.