KN4GRO
Member
- Joined
- Sep 15, 2010
- Messages
- 41
Sorry but there should be a revision here...Hello all, just for reference, when wanting to point to a specific sink within the pulse server, it is a matter of simply using:
Thanks for the hint kevind963!Code:pulse:sinkname
I have put together a system that has 4 SDR's controlled by OP25. Each SDR is tuned to a specific talk group on a trunked system in my area (we'll call these north, central, west and south.) and FD Tone Notify is "listening" for tones in each area independently. More on this later...
Allow me to provide an example as it pertains to FD Tone Notify and Linux... Maybe this will help some other noob, just like me, in the future...
When you run OP25, if you choose to output the audio to the sound card, it creates a "playback" named: 'ALSA plug-in [python3.8]' (sometimes also called OP25: ALSA Playback depending on how you run OP25)
When you run an instance of FD Tone Notify, it does something similar but instead it creates a "record" (think "virtual" microphone) named: 'ALSA plug-in [aplay]'
So how do you make a "record" listen to the audio coming from a "playback?"
The simple answer is: If you're using pulseaudio, you first need to create a "null-sink" (think "virtual" cable that isn't plugged in anywhere...yet)
To create a null sink AND give it a name (name is important) you head out to a terminal window and type the following:
Code:pactl load-module module-null-sink sink_name=north sink_properties=device.description="north"
Why north? Well, you can make it whatever you want... I chose north because in my area, the four channels I'm monitoring are referred to as North District, Central District, and so on...
Now that you have a null sink (virtual cable that isn't plugged into anything) you can head over to pavucontrol and you will see both an output device called "north" and an input device called "Monitor of north" Think of these as two ends of our virtual cable...
<<<north output--------- lonely virtual cable with nothing to do yet (also called a null-sink) ---------input Monitor of north>>>
Since there is nothing being fed through this virtual cable yet, we need to do that next.
In pavucontrol, in the Playback tab, find your OP25 Playback and over on the right hand side you'll see a button that allows you to choose which "output" you want to playback on. Go ahead a choose "north" here.. Now we've plugged in the output side of our virtual cable. The other end, "input," still isn't plugged into anything. So head on over to the "Recording" tab and find your [aplay] plug-in and over on the right hand side you'll see a button that allows you to choose which "input" you want your record device to listen to.. Go ahead and choose "Monitor of north" here. Now that you've virtually plugged in both ends of your cable, you end up with something like this:
OP25: Playback <<<north output--------- happy cable with audio flowing through it ---------input Monitor of north>>> FD Tone Notify Record
So now we've got what we need, everything should be fine, right? Well, not exactly... You see, everything we've done here will not survive a machine reboot or restarting of either FD Tone Notify or OP25.... Further, OP25 and in fact anything that you point at pulseaudio tends to "fallback" on either the last output used by pavucontrol or simply point to the default output as defined system wide or user specific conf files.. Multiply this problem by 4 channels and you can very quickly start to see the problem here... So what's the answer?
Well for starters we have to make our "virtual cables (null-sinks)" permanent, so that they survive a system reboot. To do this, you will need to make a simple change to your /etc/pulse/default.pa
The easiest way to do this is to use the following command from terminal:Code:sudo nano /etc/pulse/default.pa
You're going to want create the null sink much like we did above but, drop the pactl from the beginning of the line. Do this for each permanent virtual cable you want to load with your system. in my case I added four lines. Like this:
Code:load-module module-null-sink sink_name=north sink_properties=device.description="north" load-module module-null-sink sink_name=central sink_properties=device.description="central" load-module module-null-sink sink_name=west sink_properties=device.description="west" load-module module-null-sink sink_name=south sink_properties=device.description="south"
Now, when I boot my system, all four of my virtual cables are just sitting there, ready for me to use
From here on out, everything gets much easier! All you need to remember is the following: the output side of your cable is called "north" and input side of your cable is called "north.monitor" To connect to either side directly, all you have to do is modify the config file for OP25 and FD Tone Detect to force each instance to connect to a specified end of the specific cable every time it starts an instance...
For example, in the configuration JSON file for FD Tone Notify "/config/default.json" You can specify a device an "inputDevice" in the "audio" section...
In our case, this inputDevice would look like this:Code:"inputDevice": "pulse:north.monitor"
Do this in the associated config file of each instance you are running, i.e. central, west, south
Doing this will automatically plug the FD Tone Notify [aplay] device into the "Monitor of north" on the right side of your virtual cable!!! No need to point, click and choose anymore! This is very convenient as you can imagine... Every time the instance starts it will automatically plug itself in to the correct monitor! BEAUTIFUL!!
Now, on the left of our virtual cable (sink), your playback/output side, you want to use pulse:north without ".monitor" This allows us to plug OP25 into the correct output automatically, every time it starts!
If you're using multi_rx.py then you would put the "pulse.north" parameter in "device_name" under the "audio" section like this:
JSON:"audio": { "module": [ { "instance_name": "audio1", "device_name": "pulse.north", "udp_port": "23456", "audio_gain": 0.5, "number_channels": 1 } ] }
or if you are using rx.py then simply use "pulse.north" after the -O argument, like this:Code:./rx.py --nocrypt --args "rtl=0" --gains 'lna:36' -X -q -0 -v 1 -2 -V -O pulse.north -U -w -W 127.0.0.1 -u 23456 -T trunk.tsv -l http://0.0.0.0:8080 2> stderr.2
That's all folks! Do this for every instance and you'll be good to go.. Now, no matter what happens; a system reboot for whatever reason, a need to restart an instance, FD Tone Notify restarting a mic instance because it detected no data after 30 seconds, it should all reconnect itself to your proper audio structure without any interaction at all from you!
It took me quite a bit of digging and reading and sheer frustration to figure this out.. I want to thank everyone on RadioReference who helped me along the way! My only hope is that my writeup here is clear enough to help someone in the future!
If you all want to hear and see the live results of what I, with the help of the wonderful people at RadioReference Forums have accomplished, PM me and I will give you a link to the YouTube channel where all four streams are live. (I'm not sure what the rules are regarding self promotion on RadioReference but I'm pretty sure it's frowned upon so I won't post the link here unless someone says it's ok..)
In addition to four live streams on YouTube, I am using FD Tone Notify to listen for tones and then run an external command. That command is written in python and reaches out to the YouTube API, grabs the appropriate stream, calculates a time stamp, parses together a link and then compiles an alert that gets sent out to both Twitter and a Telegram Channel. When the alert link is clicked, it takes you right to the point in the stream where the alert happened and since the YouTube stream is preserved in perpetuity after a stream ends, the link is clickable whenever you want it!
Thank you again to everyone who helped in any way!
it is pulse:north not pulse.north as I stated earlier. Use a colon not a dot... To address the monitor side (downstream) it would be pulse:north.monitor
So the above JSON config for multi_rx.py should look like this:
JSON:
"audio": {
"module": [
{
"instance_name": "audio1",
"device_name": "pulse:north",
"udp_port": "23456",
"audio_gain": 0.5,
"number_channels": 1
}
]
}