Skip to content

Commit 44787eb

Browse files
authored
Add Config support for Soft Vocoder (#832)
* Add support for soft-vocoder * Update CONFIGURE.md * Update software_imbe_decoder.cc
1 parent 997ff24 commit 44787eb

File tree

16 files changed

+54
-37
lines changed

16 files changed

+54
-37
lines changed

docs/CONFIGURE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Here is a map of the different sections of the *config.json* file:
103103

104104
### Global Configs
105105

106+
106107
| Key | Required | Default Value | Type | Description |
107108
| ---------------------------- | :------: | ------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
108109
| ver || | number | The version of formatting for the config file. **This should be set to 2**. Trunk Recorder will not start without this set. |
@@ -131,6 +132,8 @@ Here is a map of the different sections of the *config.json* file:
131132
| debugRecorderAddress | | "127.0.0.1" | string | The network address of the computer that will be monitoring the Debug Recorders. UDP packets will be sent from Trunk Recorder to this computer. The default is *"127.0.0.1"* which is the address used for monitoring on the same computer as Trunk Recorder. |
132133
| audioStreaming | | false | **true** / **false** | Whether or not to enable the audio streaming callbacks for plugins. |
133134
| newCallFromUpdate | | true | **true** / **false** | Allow for UPDATE trunking messages to start a new Call, in addition to GRANT messages. This may result in more Calls with no transmisions, and use more Recorders. The flipside is that it may catch parts of a Call that would have otherwise been missed. Turn this off if you are running out of Recorders. |
135+
| softVocoder | | false | **true** / **false** | Use the Software Decode vocoder from OP25 for Phase 1 audio. Give it a try if you are hearing weird tones in your audio. Whether it makes your audio sound better or worse is a matter of preference. |
136+
134137

135138

136139
#### Source Object

lib/op25_repeater/include/op25_repeater/p25_frame_assembler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace gr {
5252
* class. op25_repeater::p25_frame_assembler::make is the public interface for
5353
* creating new instances.
5454
*/
55-
static sptr make(int silence_frames, const char* udp_host, int port, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, bool do_audio_output, bool do_phase2_tdma, bool do_nocrypt);
55+
static sptr make(int silence_frames, bool soft_vocoder, const char* udp_host, int port, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, bool do_audio_output, bool do_phase2_tdma, bool do_nocrypt);
5656
virtual void set_xormask(const char*p) {}
5757
virtual void set_nac(int nac) {}
5858
virtual void set_slotid(int slotid) {}

lib/op25_repeater/lib/p25_frame_assembler_impl.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ namespace gr {
7474
}
7575

7676
p25_frame_assembler::sptr
77-
p25_frame_assembler::make(int silence_frames, const char *udp_host, int port, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, bool do_audio_output, bool do_phase2_tdma, bool do_nocrypt) {
78-
return gnuradio::get_initial_sptr(new p25_frame_assembler_impl(silence_frames, udp_host, port, debug, do_imbe, do_output, do_msgq, queue, do_audio_output, do_phase2_tdma, do_nocrypt));
77+
p25_frame_assembler::make(int silence_frames, bool soft_vocoder, const char *udp_host, int port, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, bool do_audio_output, bool do_phase2_tdma, bool do_nocrypt) {
78+
return gnuradio::get_initial_sptr(new p25_frame_assembler_impl(silence_frames, soft_vocoder, udp_host, port, debug, do_imbe, do_output, do_msgq, queue, do_audio_output, do_phase2_tdma, do_nocrypt));
7979
}
8080

8181
/*
@@ -95,13 +95,13 @@ static const int MAX_IN = 1; // maximum number of input streams
9595
/*
9696
* The private constructor
9797
*/
98-
p25_frame_assembler_impl::p25_frame_assembler_impl(int silence_frames, const char *udp_host, int port, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, bool do_audio_output, bool do_phase2_tdma, bool do_nocrypt)
98+
p25_frame_assembler_impl::p25_frame_assembler_impl(int silence_frames, bool soft_vocoder, const char *udp_host, int port, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, bool do_audio_output, bool do_phase2_tdma, bool do_nocrypt)
9999
: gr::block("p25_frame_assembler",
100100
gr::io_signature::make (MIN_IN, MAX_IN, sizeof (char)),
101101
gr::io_signature::make ((do_output) ? 1 : 0, (do_output) ? 1 : 0, (do_audio_output && do_output) ? sizeof(int16_t) : ((do_output) ? sizeof(char) : 0 ))),
102102
d_do_imbe(do_imbe),
103103
d_do_output(do_output),
104-
p1fdma(op25audio, logts, debug, do_imbe, do_output, do_msgq, queue, output_queue, do_audio_output),
104+
p1fdma(op25audio, logts, debug, do_imbe, do_output, do_msgq, queue, output_queue, do_audio_output, soft_vocoder),
105105
d_do_audio_output(do_audio_output),
106106
d_do_phase2_tdma(do_phase2_tdma),
107107
p2tdma(op25audio, logts, 0, debug, do_msgq, queue, output_queue, do_audio_output),

lib/op25_repeater/lib/p25_frame_assembler_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace gr {
7676
void set_phase2_tdma(bool p);
7777

7878
public:
79-
p25_frame_assembler_impl(int silence_frames, const char* udp_host, int port, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, bool do_audio_output, bool do_phase2_tdma, bool do_nocrypt);
79+
p25_frame_assembler_impl(int silence_frames, bool soft_vocoder, const char* udp_host, int port, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, bool do_audio_output, bool do_phase2_tdma, bool do_nocrypt);
8080
~p25_frame_assembler_impl();
8181

8282
op25_audio op25audio;

lib/op25_repeater/lib/p25p1_fdma.cc

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ namespace gr {
198198
fprintf(stderr, "%s p25p1_fdma::set_nac: 0x%03x\n", logts.get(d_msgq_id), d_nac);
199199
}
200200

201-
p25p1_fdma::p25p1_fdma(const op25_audio& udp, log_ts& logger, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, std::deque<int16_t> &output_queue, bool do_audio_output, int msgq_id) :
201+
p25p1_fdma::p25p1_fdma(const op25_audio& udp, log_ts& logger, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, std::deque<int16_t> &output_queue, bool do_audio_output, bool soft_vocoder, int msgq_id) :
202202
write_bufp(0),
203203
d_debug(debug),
204204
d_do_imbe(do_imbe),
@@ -208,6 +208,7 @@ namespace gr {
208208
d_do_audio_output(do_audio_output),
209209
d_nac(0),
210210
d_msg_queue(queue),
211+
d_soft_vocoder(soft_vocoder),
211212
output_queue(output_queue),
212213
framer(new p25_framer(logger, debug, msgq_id)),
213214
qtimer(op25_timer(TIMEOUT_THRESHOLD)),
@@ -723,27 +724,31 @@ namespace gr {
723724
if (d_do_audio_output) {
724725
if ( !encrypted()) {
725726
// This is the Vocoder that OP25 currently uses.
726-
/*software_decoder.decode_fullrate(u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7], E0, ET);
727-
audio_samples *samples = software_decoder.audio();
728-
for (int i=0; i < SND_FRAME; i++) {
729-
if (samples->size() > 0) {
730-
snd[i] = (int16_t)(samples->front());
731-
samples->pop_front();
732-
} else {
733-
snd[i] = 0;
727+
728+
if (d_soft_vocoder) {
729+
// This is vocoder that is for half-rate
730+
software_decoder.decode_fullrate(u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7], E0, ET);
731+
audio_samples *samples = software_decoder.audio();
732+
for (int i=0; i < SND_FRAME; i++) {
733+
if (samples->size() > 0) {
734+
snd[i] = (int16_t)(samples->front());
735+
samples->pop_front();
736+
} else {
737+
snd[i] = 0;
738+
}
734739
}
735-
}*/
740+
} else {
736741

737-
// This is the older, fullrate vocoder
738-
// it was copied from p25p1_voice_decode.cc
739-
int16_t frame_vector[8];
742+
// This is the older, fullrate vocoder
743+
// it was copied from p25p1_voice_decode.cc
744+
int16_t frame_vector[8];
740745

741-
for (int i=0; i < 8; i++) { // Ugh. For compatibility convert imbe params from uint32_t to int16_t
742-
frame_vector[i] = u[i];
746+
for (int i=0; i < 8; i++) { // Ugh. For compatibility convert imbe params from uint32_t to int16_t
747+
frame_vector[i] = u[i];
748+
}
749+
frame_vector[7] >>= 1;
750+
vocoder.imbe_decode(frame_vector, snd);
743751
}
744-
frame_vector[7] >>= 1;
745-
vocoder.imbe_decode(frame_vector, snd);
746-
747752

748753
if (op25audio.enabled()) { // decoded audio goes out via UDP (normal code path)
749754
op25audio.send_audio(snd, SND_FRAME * sizeof(int16_t));

lib/op25_repeater/lib/p25p1_fdma.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ namespace gr {
8080
bool d_do_msgq;
8181
int d_msgq_id;
8282
bool d_do_audio_output;
83+
bool d_soft_vocoder;
8384
int d_nac;
8485
gr::msg_queue::sptr d_msg_queue;
8586
std::deque<int16_t> &output_queue;
@@ -118,7 +119,7 @@ namespace gr {
118119
void crypt_reset();
119120
void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key);
120121
void rx_sym (const uint8_t *syms, int nsyms);
121-
p25p1_fdma(const op25_audio& udp, log_ts& logger, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, std::deque<int16_t> &output_queue, bool do_audio_output, int msgq_id = 0);
122+
p25p1_fdma(const op25_audio& udp, log_ts& logger, int debug, bool do_imbe, bool do_output, bool do_msgq, gr::msg_queue::sptr queue, std::deque<int16_t> &output_queue, bool do_audio_output, bool soft_vocoder, int msgq_id = 0);
122123
~p25p1_fdma();
123124
uint32_t load_nid(const uint8_t *syms, int nsyms, const uint64_t fs);
124125
bool load_body(const uint8_t * syms, int nsyms);

lib/op25_repeater/lib/software_imbe_decoder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ software_imbe_decoder::synth_voiced()
15931593
}
15941594

15951595
psi1 = psi1 +(Oldw0 + w0) * 80;
1596-
psi1 = remainderf(psi1, 2 * M_PI); // ToDo: decide if its 2pi or pi^2
1596+
psi1 = remainderf(psi1, 2 * M_PI); // ToDo: decide if its 2pi or pi^2 // YEP it should be 2pi
15971597

15981598
for(ell = 1; ell <= L/4; ell++) {
15991599
phi[ell][ New] = psi1 * ell;

trunk-recorder/global_structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct Config {
3737
int control_retune_limit;
3838
bool broadcast_signals;
3939
bool enable_audio_streaming;
40+
bool soft_vocoder;
4041
bool record_uu_v_calls;
4142
int frequency_format;
4243
};

trunk-recorder/gr_blocks/decoders/tps_decoder_sink_impl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ void tps_decoder_sink_impl::initialize_p25() {
224224
bool do_audio_output = 0;
225225
bool do_tdma = 0;
226226
bool do_crypt = 0;
227-
op25_frame_assembler = gr::op25_repeater::p25_frame_assembler::make(silence_frames, wireshark_host, udp_port, verbosity, do_imbe, do_output, do_msgq, rx_queue, do_audio_output, do_tdma, do_crypt);
227+
bool soft_vocoder = false;
228+
op25_frame_assembler = gr::op25_repeater::p25_frame_assembler::make(silence_frames, soft_vocoder, wireshark_host, udp_port, verbosity, do_imbe, do_output, do_msgq, rx_queue, do_audio_output, do_tdma, do_crypt);
228229

229230
connect(self(), 0, valve, 0);
230231
connect(valve, 0, slicer, 0);

trunk-recorder/main.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ bool load_config(string config_file) {
232232
BOOST_LOG_TRIVIAL(info) << "Control channel warning rate: " << config.control_message_warn_rate;
233233
config.control_retune_limit = pt.get<int>("controlRetuneLimit", 0);
234234
BOOST_LOG_TRIVIAL(info) << "Control channel retune limit: " << config.control_retune_limit;
235+
config.soft_vocoder = pt.get<bool>("softVocoder", false);
236+
BOOST_LOG_TRIVIAL(info) << "Phase 1 Software Vocoder: " << config.soft_vocoder;
235237
config.enable_audio_streaming = pt.get<bool>("audioStreaming", false);
236238
BOOST_LOG_TRIVIAL(info) << "Enable Audio Streaming: " << config.enable_audio_streaming;
237239
config.record_uu_v_calls = pt.get<bool>("recordUUVCalls", true);

0 commit comments

Comments
 (0)