Skip to content

Commit

Permalink
Add LADSPA based transmitted audio shaping
Browse files Browse the repository at this point in the history
It's now possible to apply LADSPA plugin audio processing to the
transmitted audio. Plugins are set up using the LADSPA_PLUGINS
configuration variable.
  • Loading branch information
sm0svx committed Sep 7, 2024
1 parent 457b0a3 commit b66719b
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 4 deletions.
31 changes: 30 additions & 1 deletion src/doc/man/svxlink.conf.5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH SVXLINK.CONF 5 "AUGUST 2024" Linux "File Formats"
.TH SVXLINK.CONF 5 "SEPTEMBER 2024" Linux "File Formats"
.
.SH NAME
.
Expand Down Expand Up @@ -2502,6 +2502,35 @@ The TONE_SIGLEV_LEVEL configuration variable is used to set the tone level.
It is a value in the 1-100 range which indicate the output level in percent
of the maximum possible level. The default is 10.
.TP
.B LADSPA_PLUGINS
Used to set up one or more LADSPA plugins to process the transmitted audio.
The processing chain is applied right at the top of the transmitter audio
processing and will only affect how the audio sounds. Any digital signal
processing done on the audio after that, like DTMF, CTCSS etc, is unaffected.

LADSPA is a framework for sharing pluggable audio components and there are
numerous plugins to choose from. Each plugin has a name ("label") and zero or
more configuration parameters ("control input ports"). To find out which
plugins are installed on your system, use the "listplugins" command. If you
are missing some plugin it may be available to install using your package
system (rpm/yum/dnf, deb/apt etc). To find out more information about a
plugin, use the "analyseplugin" command (e.g. analyseplugin filter hpf). Learn
more about the LADSPA framework in their official documentation.

In SvxLink only plugins that have exactly one audio input and one audio
output can be used, so all stereo plugins are excluded for example. The same
thing is valid for input-only or output-only plugins.

The analyseplugin utility will, among other things, list the ports. All ports
that are typed as "input, control" can be used to configure the plugin. Valid
range and a default value may also be listed. The format for the
LADSPA_PLUGINS configuration variable in SvxLink is
"label1:port1:port2:...:portN,label2:port1:port2:...:portN,...". Note that
only control input ports are counted here so when applying the parameters any
intermingled ports of other types are skipped.

Example: LADSPA_PLUGINS=hpf:1000,tap_dynamics_m:4:500:15:15:13
.TP
.B MASTER_GAIN
This configuration variable can be used to fine tune or increase the audio
gain for all transmitted sound if it's not possible to do using the normal
Expand Down
3 changes: 3 additions & 0 deletions src/svxlink/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
ACCEPT_CALLSIGN and REJECT_CALLSIGN configuration variables. That is done
for both AUTH_KEY connections and certificate connections.

* It's now possible to apply LADSPA plugin audio processing to the transmitted
audio. Plugins are set up using the LADSPA_PLUGINS configuration variable.



1.8.0 -- 25 Feb 2024
Expand Down
1 change: 1 addition & 0 deletions src/svxlink/svxlink/svxlink.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ PREEMPHASIS=0
DTMF_TONE_LENGTH=100
DTMF_TONE_SPACING=50
DTMF_DIGIT_PWR=-15
#LADSPA_PLUGINS=hpf:1000
#MASTER_GAIN=0.0
#OB_AFSK_ENABLE=0
#OB_AFSK_VOICE_GAIN=-6
Expand Down
61 changes: 59 additions & 2 deletions src/svxlink/trx/LocalTx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This file contains a class that implements a local transmitter.
\verbatim
SvxLink - A Multi Purpose Voice Services System for Ham Radio Use
Copyright (C) 2003-2023 Tobias Blomberg / SM0SVX
Copyright (C) 2003-2024 Tobias Blomberg / SM0SVX
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -75,6 +75,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <HdlcFramer.h>
#include <AfskModulator.h>
#include <AsyncAudioFsf.h>
#ifdef LADSPA_VERSION
#include <AsyncAudioLADSPAPlugin.h>
#endif


/****************************************************************************
Expand Down Expand Up @@ -457,7 +460,61 @@ bool LocalTx::initialize(void)
prev_src->registerSink(comp, true);
prev_src = comp;
*/


#ifdef LADSPA_VERSION
std::vector<std::string> ladspa_plugin_cfg;
if (cfg.getValue(name(), "LADSPA_PLUGINS", ladspa_plugin_cfg))
{
for (const auto& pcfg : ladspa_plugin_cfg)
{
std::istringstream is(pcfg);
std::string label;
std::getline(is, label, ':');
//std::cout << "### pcfg=" << pcfg << " label=" << label << std::endl;
auto plug = new Async::AudioLADSPAPlugin(label);
if (!plug->initialize())
{
std::cerr << "*** ERROR: Could not instantiate LADSPA plugin "
"instance with label '" << label << "' "
<< "specified in configuration variable "
<< name() << "/LADSPA_PLUGINS." << std::endl;
return false;
}
unsigned long portno = 0;
LADSPA_Data val;
while (is >> val)
{
while ((portno < plug->portCount()) &&
!(plug->portIsControl(portno) && plug->portIsInput(portno)))
{
++portno;
}
if (portno >= plug->portCount())
{
std::cerr << "*** ERROR: Too many parameters specified for LADSPA "
"plugin \"" << plug->label()
<< "\" specified in configuration variable "
<< name() << "/LADSPA_PLUGINS." << std::endl;
return false;
}
plug->setControl(portno++, val);
char colon = 0;
if ((is >> colon) && (colon != ':'))
{
std::cerr << "*** ERROR: Illegal format for " << name()
<< "/LADSPA_PLUGINS configuration variable" << std::endl;
return false;
}
}

plug->print(name() + ": ");

prev_src->registerSink(plug, true);
prev_src = plug;
}
}
#endif

// If preemphasis is enabled, create the preemphasis filter
if (cfg.getValue(name(), "PREEMPHASIS", value) && (atoi(value.c_str()) != 0))
{
Expand Down
2 changes: 1 addition & 1 deletion src/versions
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LIBECHOLIB=1.3.4
LIBASYNC=1.7.99.4

# SvxLink versions
SVXLINK=1.8.99.4
SVXLINK=1.8.99.5
MODULE_HELP=1.0.0
MODULE_PARROT=1.1.1
MODULE_ECHO_LINK=1.6.0
Expand Down

0 comments on commit b66719b

Please sign in to comment.