JamesHarrison / openob

The Open Outside Broadcast project for radio contribution links and studio-transmitter links.
158 stars 34 forks source link

TX forces stereo for all sources #22

Closed naxxfish closed 10 years ago

naxxfish commented 10 years ago

As of commit to add setting of sample rate, tx will now always be in stereo.

naxxfish commented 10 years ago

This is caused by some lines in https://github.com/JamesHarrison/openob/blob/master/openob/rtp/tx.py that sets the sample rate used in the capsfilter to request a specific sample rate if one is specified on the command line.

    # Decide which format to apply to the capsfilter (Jack uses float)
    if audio_input == 'jack':
      type = 'audio/x-raw-float'
    else:
      type = 'audio/x-raw-int'
    # if audio_rate has been specified, then add that to the capsfilter
    if audio_rate != 0:
      self.capsfilter.set_property("caps", gst.Caps('%s, channels=2, rate=%d' % (type, audio_rate) ) )
    else:
      self.capsfilter.set_property("caps", gst.Caps('%s, channels=2' % type ) )

A fix would probably be to simply not specify channels in the caps filter.

JamesHarrison commented 10 years ago

There's another question here about mono vs stereo - in my ideal setup I should be able to force the TX into mono even with a stereo input (to save bandwidth). One could argue that that's JACK's job or similar but I think being able to perform stereo -> mono and mono -> stereo conversion within OpenOB (in TX/RX) would be a useful feature and worth adding. What the best way to go about that in GStreamer is I don't know yet.

naxxfish commented 10 years ago

There are two ways you could go about it. Either you request a mono stream from your source (with a capsfilter directly after it), or you request stereo always and mono it only if requested.

Stereo to mono, the most obvious way of doing this would be a deinterleve element to split into two mono streams, then an adder element to add them together and then a volume element to take it down by -3dB to compensate.

Having said that, it might be useful to be able to request a specific input (e.g. left channel) to be used. That might be useful for having talkback sent to a different place to contribution audio, for example.

A sensible precedence might be:

JamesHarrison commented 10 years ago

Perhaps then it'd be best to ignore this until 3.x; one of the main things I'm thinking about at the moment is how we specify "ports" within an OpenOB network. We'll just have to think about routing to specific channels rather than just devices.

naxxfish commented 10 years ago

How about for the next milestone we just remove the extraneous caps specification (as per snippet above), and defer any cleverness regarding monoing streams and the like until 3.x. That way at least it won't break for mono only sources in 2.x, which I have had some issues with (e.g. USB headset mics that don't present audio as stereo from alsasrc)

JamesHarrison commented 10 years ago

That'd be my preference. Closing this for now.