bryangrim / darkice

Automatically exported from code.google.com/p/darkice
0 stars 0 forks source link

Split Stereo input to TWO SEPARATE feeds #31

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Enhancement request:

The ability to take a stereo input, Left and Right channels and encode them in 
MP3 and Ogg to SEPARATE FEEDS on the IceCast server.

the input section would have:

channel =2

The feeds sections would be like:

[icecast2-0]

various options
mountPoint = radio1
channel = 1, L

This would feed ONE channel, the LEFT channel to the defined mountpoint

[icecast2-1]
mountPoint = radio2
channel = 1, R

This would feed ONE channel, the RIGT channel to the defined mountpoint

I also might decide to feed a JOINT stereo feed

mountPoint = radio1andradio2
channel = 2

This would be a great help to those of us using DarkIce to encode live public 
safety radios. This allows each sound card to feed 2 SEPARATE feeds thus no 
need for the user to use the balance control to select sides.

Original issue reported on code.google.com by rec9...@gmail.com on 10 Aug 2010 at 2:16

GoogleCodeExporter commented 8 years ago
This would certainly be a nice feature. I am currently streaming 2 scanner 
radios with 2 soundcards, with this feature one soundcard can generate two 
separate mono streams.
I'm all for it :)

Original comment by j.m.boon...@gmail.com on 3 Nov 2010 at 1:15

GoogleCodeExporter commented 8 years ago
Actually you could do this with JACK. Launch two instances of darkice (both 
beeing mono) and connect the left channel of your soundcard to the input-port 
of one darkice-instance and the right port of your soundcard to the other one

Original comment by kri...@gmail.com on 4 Nov 2010 at 8:45

GoogleCodeExporter commented 8 years ago
Thanks, but to keep this on task and point.

I am looking for native support of this with a single instance of darkice.

jack is an issue to use for some users, from compatibility issues to downright 
crashing and/or not working especially with some of the newer "HD" type 
chipsets. 

Original comment by rec9...@gmail.com on 4 Nov 2010 at 11:12

GoogleCodeExporter commented 8 years ago
Still no native support?

A bit OT, but how would you do this using jackaudio?

Original comment by rickard....@gmail.com on 23 Mar 2011 at 5:49

GoogleCodeExporter commented 8 years ago
Not the answer to your question, not a native solution and OT but maybe it´s 
helping someone else...

I was able to split left/right channel with ALSA.

I used the /etc/asound.conf that is also attached.
Darkice is able to use the ALSA-plugs with "device=plug:*plugname*"

Most annoying thing I missed was the "ipc_key" that, of course, has to be the 
same for all dsnoop plugs with the same source...

Original comment by fabian.d...@gmail.com on 24 Mar 2011 at 9:49

Attachments:

GoogleCodeExporter commented 8 years ago
I very interested in this asound.conf and splitting this off.. what distro and 
version are you using? 

And some more info on the "ipc_key"

I would like to test this out for my setups, and if this can split left right 
off to separate feeds ... then I am all set... 

I have to use "default" for my device with KMint Julia aka Linux Mint KDE 10 
Julia to get darkice to encode... /dev/dsp/ didn't work any more... this is 
most likely phonon related.... 

More info on this would be greatly appreciated... THANKS!

Original comment by rec9...@gmail.com on 24 Mar 2011 at 3:41

GoogleCodeExporter commented 8 years ago
Can you post an result of aplay -L to list your hardware to compare with the 
asound.conf 

Also your darkice.cfg

I would like to put together a wiki or other article for others on how to do 
this... if we can ... as this is very useful in my particular field of 
streaming...

My aplay -L results in:
rec9140@cleo-rec9140-desktop ~ $ aplay -L
default
pulse
    Playback/recording through the PulseAudio sound server
front:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    Front speakers
surround40:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Digital
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    Direct sample mixing device
dmix:CARD=NVidia,DEV=1
    HDA NVidia, ALC889A Digital
    Direct sample mixing device
dsnoop:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    Direct sample snooping device
dsnoop:CARD=NVidia,DEV=1
    HDA NVidia, ALC889A Digital
    Direct sample snooping device
hw:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    Direct hardware device without any conversions
hw:CARD=NVidia,DEV=1
    HDA NVidia, ALC889A Digital
    Direct hardware device without any conversions
plughw:CARD=NVidia,DEV=0
    HDA NVidia, ALC889A Analog
    Hardware device with all software conversions
plughw:CARD=NVidia,DEV=1
    HDA NVidia, ALC889A Digital
    Hardware device with all software conversions

I am using the line in of the built in card... ....

If you got a good tutorial on asound.conf so I can translate all this it would 
be a great help...

THANKS for the hint on this... I never knew ALSA itself might be able to do 
this!

Original comment by rec9...@gmail.com on 24 Mar 2011 at 3:57

GoogleCodeExporter commented 8 years ago
Based on this to send LEFT to feed x and RIGHT to feed y requires TWO instances 
of darkice

darkice1
[input]
device = plug:plug_onboard_left

And the second instance

[input]
device = plug:plug_onboard_right

correct? 

Hmmm... ok... not quite as elegant as once instance.. but ... no real deal...

I just need to understand this asound.conf vars

Original comment by rec9...@gmail.com on 24 Mar 2011 at 4:29

GoogleCodeExporter commented 8 years ago
Wondering if the rate in the this should match the darkice config so if I am 
using 22050 then this section should match????

pcm.dsnoop_onboard {
      type dsnoop
      ipc_key 32
      slave {
          pcm "onboard"
          channels 2
          period_size 320
          rate 48000
          buffer_size 8192
          format S32_LE
      }
      bindings {
          0 0
          1 1
      }

Original comment by rec9...@gmail.com on 24 Mar 2011 at 5:57

GoogleCodeExporter commented 8 years ago
This is a good reference, but unfortunately its not as clear... unless you 
probably wrote ALSA... :( 

http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html#pcm_plugins

I put this to the test over the weekend with a test setup...

I can see what to do with the setup to specify the card, since first card is 0, 
and I need only have one v. 
so

pcm.onboard{
      type hw
      card 1
  }
  ctl.onboard {
      type hw
      card 1
  }

BECOMES:
pcm.onboard{
      type hw
      card 0
  }
  ctl.onboard {
      type hw
      card 0
  }

I guess what I am not sure of is specify dsnoop to snoop on the line in I get 
what its doing, but I want it snoop on the line in, not the mic, or does dsnoop 
auto select the current capture? ? ? ? 

Original comment by rec9...@gmail.com on 24 Mar 2011 at 6:55

GoogleCodeExporter commented 8 years ago
I am using card "1" but if you only have one card modify it to "0"
Yes, your are right it´s using the selected Alsa capture device of the 
specified card.

Change it with:
alsamixer -c *cardnumber*

It would also work without a dsnoop plug-in, but you could only use the capture 
device once then. In my case I have two applications, one using the stereo 
dsnoop and the second one is darkice.
You could also attach more if necessary Maybe this is what was confusing for 
you...

Original comment by fabian.d...@gmail.com on 24 Mar 2011 at 7:15

GoogleCodeExporter commented 8 years ago
First, again, THANKS ! ! !  ! !

This just goes with my other thought... if I had known ALSA could have done 
this I would've been doing this for over a year now!

After deciphering to a point, the alsa link, I've figured out whats going on 
but the lack of clear cut defined docs on what dsnoop does, just figuring out 
that its going to use the selected capture device alone is enough, or even what 
all the options in this asound.conf or .asoundrc do slows this down...

Thankfully I keep vm's around to test the living crap out of stuff so as not to 
borq up my main and production use stuff...

AGAIN THANKS FOR THE INFO! ! ! Its going to be a tremendous help!

Original comment by rec9...@gmail.com on 24 Mar 2011 at 8:41

GoogleCodeExporter commented 8 years ago
How does your asound.conf look in the end?

I have it working but find the audio is all garble unless darkice is configured 
to use 48000 as the sample rate but I would prefer to use 22050. I tried 
changing the asound.conf to be 22050 but doesnt seem to make any difference.

Any ideas?

Original comment by andrew.j...@gmail.com on 3 Aug 2011 at 11:58

GoogleCodeExporter commented 8 years ago
I am using this asound.conf splitting with:

rec9140@cleo-rec9140-desktop /etc $ cat asound.conf
pcm.onboard{
    type hw
    card 0
}
ctl.onboard {
    type hw
    card 0
}
### Dsnoop both channels
pcm.dsnoop_onboard {
    type dsnoop
    ipc_key 32
    slave {
        pcm "onboard"
        channels 2
        period_size 320
        rate 48000
        buffer_size 8192
        format S32_LE
    }
    bindings {
        0 0
        1 1
    }
}
### Dsnoop splited channels
pcm.onboard_left {
     type dsnoop
     ipc_key 32
     slave {
         pcm "onboard"
         channels 2
     }
     bindings.0  0
}

pcm.onboard_right {
     type dsnoop
     ipc_key 32
     slave {
         pcm "onboard"
         channels 2
     }
     bindings.0  1
}

### PLUGS ##
### used with darkice
### device = plug:plug_onboard_left
pcm.plug_onboard_left{
        type route
        slave.pcm "onboard_left"
        slave.channels 1
        ttable.0.0 1
}
pcm.plug_onboard_right{
        type route
        slave.pcm "onboard_right"
        slave.channels 1
        ttable.0.0 1
}

And here is a partial sample of one of my darkice cfg

rec9140@cleo-rec9140-desktop ~/darkice $ cat darkice_r2.cfg
# sample DarkIce configuration file, edit for your needs before using
# see the darkice.cfg man page for details

# this section describes general aspects of the live streaming session
[general]
duration        = 0        # duration of encoding, in seconds. 0 means forever
bufferSecs      = 1         # size of internal slip buffer, in seconds
reconnect       = yes       # reconnect to the server(s) if disconnected

# this section describes the audio input that will be streamed
[input]
device = plug:plug_onboard_right  # OSS DSP soundcard device for the audio input
sampleRate      = 22050     # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample   = 16        # bits per sample. try 16
channel         = 2         # channels. 1 = mono, 2 = stereo

# this section describes a streaming connection to an IceCast server
# there may be up to 8 of these sections, named [icecast-0] ... [icecast-7]
# these can be mixed with [icecast2-x] and [shoutcast-x] sections

# Don't forget, the name [icecast2-0] needs to change to [icecast2-1]
# and 2 and 3 as you add more feed destinations.

[icecast2-0]
# The audio format to encode to, we're using mp3 here
format          = mp3

# The bit rate mode to use, the commented out lines are for a fixed bit
# rate "constant bit rate" at 16 bits.  I prefer the variable bit rate
# for the sound quality it has and the throughput is very similar on avg

bitrateMode    = cbr
bitrate        = 32

# bitrateMode     = vbr

# Quality at .1, max is 1.0, but as you increase, so does the bandwidth
# used.  For mono scanner audio .1 is totally fine.
quality         = 0.8

# Takes the input and mixes it down to a mono output for the feed.
channel         = 1

You can listen to the feeds here:

http://audio.scancaster.net:8000/PolkCoFL

http://audio.scancaster.net:8000/LakelandPD

I don't hear any garble... there is a faint  garble to the Polk Co once since 
its a P25 input and there is a slight warble to the digital audio  which takes 
getting used to even on a real radio... but after EDACS ProVoice for numerous 
years I've become accustomed to the digital muffled audio.

I use KMint Linux Julia 64B which is a cleaned and polished kubunutu 
deriviative and I have disabled Pulseaudio server completely so its not used on 
my system for any purpose. Also note that the OSS stuff that is present in some 
kernels is MISSING ON *buntu's and most of its derivatives unless you 
recompiled the kernel to include it again.. but if your getting audio, thats 
probably not an issue.. just FYI.

Original comment by rec9...@gmail.com on 3 Aug 2011 at 1:29

GoogleCodeExporter commented 8 years ago
Tried using your asound config & darkice config.

Obviously I have added server information for darkice but I keep getting Buffer 
Overrun! messages every second and because of that audio is barely getting 
through.

[general]
duration        = 0        # duration of encoding, in seconds. 0 means forever
bufferSecs      = 1        # size of internal slip buffer, in seconds
reconnect       = yes      # reconnect to the server(s) if disconnected

[input]
device = plug:plug_onboard_left  # OSS DSP soundcard device for the audio input
sampleRate      = 22050     # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample   = 16        # bits per sample. try 16
channel         = 2         # channels. 1 = mono, 2 = stereo

[icecast2-0]
bitrateMode = cbr
format = mp3
bitrate = 32
quality = 0.8
channel = 1
server = XXX
port = 80
password = XXX
mountPoint = XXX
name = XXX

This drops back to once every couple seconds if I use a bitrate of 16 instead 
of 32 and audio comes through but has a skip every now and again due to the 
Buffer Overrun!

Buffer Overrun! and all its funny issues stops completely if I use a sampleRate 
of 48000 but then I cant use the highpass feature to stop audio from 300hz and 
below as its minimum is about 600hz at 48000

Any ideas?
Thanks!

Original comment by andrew.j...@gmail.com on 5 Aug 2011 at 5:29

GoogleCodeExporter commented 8 years ago
I've seen that sporadically, but never noticed any audio issues... but it looks 
like this will have to be a change in darkice to increase the buffer size to in 
the alsa code....

If your getting it constantly then I am thinking the machine its running on may 
be underpowered to do this... especially at 48K...

but the buffer is set by DarkIce and doesn't appear that you can change it in 
asound or some place...

Original comment by rec9...@gmail.com on 5 Aug 2011 at 12:56

GoogleCodeExporter commented 8 years ago
Uneless maybe you increase the bufferSecs of darkice.cfg to say something like 
60 seconds... but that means the stream on the server would be dealyed this 
long too...

Maybe try that and see what happens....

Original comment by rec9...@gmail.com on 5 Aug 2011 at 1:14

GoogleCodeExporter commented 8 years ago
Got it working without Buffer issues... here is what my config looks like.
It seems the highpass is casues the garble business, must be a full drop from 
that freq onwards instead of a drop over time hence why it sounds funny.

# this section describes general aspects of the live streaming session
[general]
duration        = 0        # duration of encoding, in seconds. 0 means forever
bufferSecs      = 5        # size of internal slip buffer, in seconds
reconnect       = yes      # reconnect to the server(s) if disconnected

# this section describes the audio input that will be streamed
[input]
device = plug:plug_onboard_left  # OSS DSP soundcard device for the audio input
sampleRate      = 48000     # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample   = 16        # bits per sample. try 16
channel         = 2         # channels. 1 = mono, 2 = stereo

# this section describes a streaming connection to an IceCast server
[icecast2-0]
# The audio format to encode to, we're using mp3 here
bitrateMode = cbr
format = mp3
bitrate = 32
quality = 0.8
sampleRate = 22050 
channel = 1
highpass = 250
server = XX
port = 80
password = XX
mountPoint = XX
name = XX

Original comment by andrew.j...@gmail.com on 6 Aug 2011 at 3:09

GoogleCodeExporter commented 8 years ago
I found that using

 bufferSecs      = 10

Eliminated the sporadic buffer overuns I was seeing, have not seen any in a 
week. So possibly this will resolve it for you...

Original comment by rec9...@gmail.com on 10 Aug 2011 at 11:38