Adding an audible output for Radio Listeners is the goal here, to provide added interest.

You should have at least installed SVXLink in the fashion described in the linked page here. Read and follow the directions explicitly. Do not use Bookworm yet as some of the repositories are not yet compatible.

DO NOT UNDER ANY CIRCUMSTANCES USE sudo apt install svxlink-server THE VERSION IS OUTDATED and will not contain SVXReflector.

You should have a USB Sound Card preferably the CM108 already described in these pages.

Time Allotment: Allow at least 60 Minutes at the very least.

Implementation for the DarkIce and Icecast2

Hopefully you shall have first tested and run your svxlink node.

If you want to stream the output for public consumption then this is what we shall do.

Installation of the Dummy Soundcard

In the terminal screen type the following command at the prompt.

sudo nano /etc/modules

Type the single line as follow

snd-aloop

Now type cntrl-o to save the new file and cntrl-x to exit the editor.

You can now load the module in your running system by typing sudo modprobe snd-aloop followed by enter.

Dummy Sound Card Configuration

At the other end of the Loopback, we will connect darkice as a streaming device. Type the following
sudo nano /etc/asound.conf

Then type the following lines exactly as they are written.

pcm_slave.hw_Loopback_1_2 {
               pcm “hw:Loopback,1,2”
               format S16_LE
               channels 2
               rate 48000
               }

pcm.plug_Loopback_1_2 {
               type plug
               slave hw_Loopback_1_2
               ttable {
                            0.0 = 1
                            0.1 = 1
                           }
                }

Ensure you have the correct syntax, and the correct number of curly braces.
Save the file by typing cntrl-o and cntrl-x as before.

Create a new file by sudo nano /etc/modprobe.d/asound.conf

Type this one line.

options snd-aloop index=1 pcm_substreams=8

Save and close the file as before.
Reboot the raspberry at this stage.

To verify the installation type sudo aplay -l

you should see the following:

**** List of PLAYBACK Hardware Devices ****
card 0: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7

If you do not see this but some errors, then go back up to Dummy Sound Configuration, and remove the configuration, save the file, reboot and repeat the configuration once more.

Now, when you open the device ‘plug_Loopback_1_2’ in an application, the above will force the ‘Loopback,1,2’ to be configured with parameters that SvxLink likes, and the explicit wiring of only the left channel. The darkice config will then be like this:

[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
realtime = no # run the encoder with POSIX realtime priority
rtprio = 3 # scheduling priority for the realtime threads

# this section describes the audio input that will be streamed

[input]
device = plug_Loopback_1_2 # ALSA 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 = 1 # channels. 1 = mono, 2 = stereo

Installing the apps Darkice and Icecast2

sudo apt install darkice icecast2

As you install icecast2, you will be presented with request for passwords and other parameters. Make notes as you proceed. You will need to configure darkice after reboot.

Directions are includes with both packages.

Darkice requires you to do the following before you can operate on it.
sudo gunzip /usr/share/doc/darkice/examples/darkice.cfg.gz
then
sudo cp /usr/share/doc/darkice/examples/darkice.cfg /etc
then
sudo nano /etc/darkice.cfg
to final configure the dummy sound card you have previously made above.

[general]
duration = 0
bufferSecs = 5
reconnect = yes

[input]
device = plug_Loopback_1_2                                 # You may need to change the numbers here for your setup
sampleRate = 44100
bitsPerSample = 16
channel = 2

[icecast2-0]
bitrateMode = cbr
bitrate = 320                                               # Max bitrate for MP3 is 320 and best for binaural audio
format = mp3
quality = 1.0                                               # Sets the quality of the stream 1.0 being highest
server = your ip address                            # This is a free server or you can pay for one
port = 8000                                                    # Your port number from your icecast2 settings
mountPoint = url:8000           # Omit the ‘/’ before ‘stream’ in Darkice “stream.mp3” for example
password = source password here                   # Source password from icecast or private paid for server password
name = your stream name                                              # Name of account
description = Live binaural stream for headphones              # Stream description
genre = Binaural 3D for headphones
public = yes

Save the file.

sudo nano /etc/default/darkice and change “no” to “yes” and save and exit.

sudo nano /etc/default/icecast2 and add a new line ENABLE=true, save and exit.

Once you have configured IceCast – (sudo nano /etc/icecast2/icecast.xml), we can now…

sudo mkdir /etc/scripts

cd /etc/scripts

sudo nano darkice.sh, and type the following text exactly into it.

#!bin/sh

sudo /usr/bin/darkice -c /etc/darkice.cfg

save and close the file.

sudo chmod +x darkice.sh

now

sudo nano /etc/rc.local

and insert the following line before the final line exit 0.

sleep 20

sudo sh /etc/scripts/darkice.sh

save the file.

Now we enable Icecast2 as follows.

sudo systemctl enable icecast2 && sudo systemctl start icecast2

Now we must reconfigure svxlink.conf to channel out to the Dummy Sound Card.

sudo nano /etc/svxlink/svxlink.conf

First of all we need to configure a transmitter channel.

[TxStream]

TYPE=Local
AUDIO_DEV=alsa:hw:Loopback,0,2
AUDIO_CHANNEL=0
PTT_TYPE=NONE
TIMEOUT=7200
TX_DELAY=0
PREEMPHASIS=0

Now to add it to a MultiTx

[MultiTx]

TYPE=Multi
TRANSMITTERS=Tx1,TxStream

Now we change the Transmitter itself to reflect these changes.

[SimplexLogic]

Change TX=Tx1 to TX=MultiTx

And save the file.

Now finally we can reboot.

The stream will start after a short delay on boot up. In a browser type the ip address of the raspberry e.g. 192.168.1.195:8000

and click on the link presented.

http://svxportal-uk.ddns.net:8000

Leave a Reply

Your email address will not be published. Required fields are marked *