'Lite' Optimizations and Tweaks for Win32CYG Build

This commit is contained in:
lwvmobile 2023-01-05 18:38:12 -05:00
parent bb2199ee84
commit 2ba9953d33
25 changed files with 359 additions and 264 deletions

View File

@ -1,4 +1,4 @@
project(dsd-fme)
project(dsd-fme-lite)
cmake_minimum_required(VERSION 2.8.11)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
@ -38,24 +38,24 @@ list(APPEND SRCS "${CMAKE_CURRENT_BINARY_DIR}/git_ver.c")
include_directories("${PROJECT_SOURCE_DIR}/include")
ADD_EXECUTABLE(dsd-fme ${SRCS} ${HEADERS})
TARGET_LINK_LIBRARIES(dsd-fme ${LIBS})
ADD_EXECUTABLE(dsd-fme-lite ${SRCS} ${HEADERS})
TARGET_LINK_LIBRARIES(dsd-fme-lite ${LIBS})
include(GNUInstallDirs)
install(TARGETS dsd-fme DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS dsd-fme-lite DESTINATION ${CMAKE_INSTALL_BINDIR})
# man page
find_program(HELP2MAN_FOUND help2man)
if (HELP2MAN_FOUND)
add_custom_command(TARGET dsd-fme POST_BUILD
add_custom_command(TARGET dsd-fme-lite POST_BUILD
COMMAND help2man
ARGS -n "Digital Speech Decoder"
--version-string=${GIT_TAG}
-o ${CMAKE_CURRENT_BINARY_DIR}/dsd-fme.1
-o ${CMAKE_CURRENT_BINARY_DIR}/dsd-fme-lite.1
--no-info
$<TARGET_FILE:dsd-fme>
$<TARGET_FILE:dsd-fme-lite>
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dsd-fme.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dsd-fme-lite.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
endif()
# uninstall target

View File

@ -1,3 +1,6 @@
## Notice
This branch is for modifications to make a Windows 32-bit binary to be precompiled, please DO NOT use this branch if you are a Linux User, or copy any contents out of here to modify your existing setup!
# Digital Speech Decoder - Florida Man Edition

View File

@ -1,23 +0,0 @@
#! /bin/bash
clear
echo DSD-FME Digital Speech Decoder - Florida Man Edition Auto Installer
echo This will clone, build, and install DSD-FME only.
echo If you need dependencies installed, please run download-and-install.sh instead.
echo
read -p "Press enter to continue"
git clone https://github.com/lwvmobile/dsd-fme
cd dsd-fme
sudo cp tone8.wav /usr/share/
sudo cp tone24.wav /usr/share/
sudo cp tone48.wav /usr/share/
sudo chmod 777 /usr/share/tone8.wav
sudo chmod 777 /usr/share/tone24.wav
sudo chmod 777 /usr/share/tone48.wav
mkdir build
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig

View File

@ -1,67 +0,0 @@
#! /bin/bash
clear
echo DSD-FME Digital Speech Decoder - Florida Man Edition Auto Installer
echo MBELib is considered a requirement on this build.
echo You must view this notice prior to continuing.
echo The Patent Notice can be found at the site below.
echo https://github.com/lwvmobile/mbelib#readme
echo Please confirm that you have viewed the patent notice by entering y below.
echo
echo y/N
read ANSWER
Y='y'
if [[ $Y == $ANSWER ]]; then
sudo apt update
sudo apt install libpulse-dev pavucontrol libsndfile1-dev libfftw3-dev liblapack-dev socat libusb-1.0-0-dev libncurses5 libncurses5-dev rtl-sdr librtlsdr-dev libusb-1.0-0-dev cmake git wget make build-essential libitpp-dev libncursesw5-dev
echo ITPP Manual Build and Install has been temporarily removed from this script due to issues with older versions of Ubuntu.
echo Please check to see that libitpp-dev has successfully been downloaded and installed from the repo.
read -p "Press enter to continue"
#wget -O itpp-latest.tar.bz2 http://sourceforge.net/projects/itpp/files/latest/download?source=files
#tar xjf itpp*
#if you can't cd into this folder, double check folder name first
#cd itpp-4.3.1
#mkdir build
#cd build
#cmake ..
#make -j `nproc`
#sudo make install
#sudo ldconfig
#cd ..
#cd ..
git clone https://github.com/lwvmobile/mbelib
cd mbelib
mkdir build
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
cd ..
cd ..
git clone https://github.com/lwvmobile/dsd-fme
cd dsd-fme
sudo cp tone8.wav /usr/share/
sudo cp tone24.wav /usr/share/
sudo cp tone48.wav /usr/share/
sudo chmod 777 /usr/share/tone8.wav
sudo chmod 777 /usr/share/tone24.wav
sudo chmod 777 /usr/share/tone48.wav
mkdir build
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
else
echo
echo Sorry, you cannot build DSD-FME without acknowledging the Patent Notice.
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 706 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 KiB

View File

@ -1,3 +1,7 @@
## Notice
These examples will need to be modified to run on the 'lite' branch, or any precompiled Windows binaries released. (i.e. dsd-fme to dsd-fme-lite.exe, -i pulse -o pulse, etc)
### Example Usage and Notes!
`dsd-fme` is all you need to run for pulse input, pulse output, and auto detect for DMR BS/MS, and P25 (1 and 2) . To use other decoding methods which cannot be auto detected, please use the following command line switches. Make sure to route audio into and out of DSD-FME using pavucontrol and virtual sinks as needed.

View File

@ -1,3 +1,7 @@
## Notice
These should not be followed for the 'lite' branch
## How to clone and build this branch
### Ubuntu 22.04/20.04/LM20/Debian Bullseye or Newer:

View File

@ -47,11 +47,14 @@
#include "p25p1_heuristics.h"
//OSS support
#include <sys/soundcard.h>
#include <pulse/simple.h> //PULSE AUDIO
#include <pulse/error.h> //PULSE AUDIO
#define SAMPLE_RATE_IN 48000 //48000
#define SAMPLE_RATE_OUT 8000 //8000,
#define SAMPLE_RATE_OUT 48000 //8000,
#ifdef USE_RTLSDR
#include <rtl-sdr.h>
@ -190,6 +193,7 @@ typedef struct
int audio_in_type;
char audio_out_dev[1024];
int audio_out_fd;
int audio_out_fdR; //right channel audio for OSS hack
SNDFILE *audio_out_file;
SF_INFO *audio_out_file_info;
@ -348,6 +352,9 @@ typedef struct
//Trunking - Tune Data Calls
uint8_t trunk_tune_data_calls;
//OSS audio - slot preference
uint8_t slot_preference;
} dsd_opts;
typedef struct

View File

@ -1,16 +0,0 @@
#! /bin/bash
clear
echo DSD-FME Digital Speech Decoder - Florida Man Edition
echo Automatic Git Pull and Rebuild
echo
sleep 1
##Open your clone folder##
git pull
sleep 2
##cd into your build folder##
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig

View File

@ -81,7 +81,7 @@ void dmr_dheader (dsd_opts * opts, dsd_state * state, uint8_t dheader[], uint32_
fprintf (stderr, "%s ", KNRM);
//end collecting data header info
fprintf (stderr, "%s ", KMAG);
fprintf (stderr, "%s ", KYEL);
if (state->data_header_sap[slot] == 0x4 && state->data_p_head[slot] == 0)
{

View File

@ -347,9 +347,22 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
memcpy (m2, ambe_fr2, sizeof(m2));
memcpy (m3, ambe_fr3, sizeof(m3));
// if ( opts->audio_in_type == 5 && internalslot == 0 && state->dmrburstR != 16 ) //(OSS shim)
// {
// processMbeFrame (opts, state, NULL, ambe_fr, NULL);
// processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
// processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
// }
// if ( opts->audio_in_type == 5 && internalslot == 1 && state->dmrburstL != 16 ) //(OSS shim)
// {
// processMbeFrame (opts, state, NULL, ambe_fr, NULL);
// processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
// processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
// }
processMbeFrame (opts, state, NULL, ambe_fr, NULL);
processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
cach_err = dmr_cach (opts, state, cachdata);
fprintf (stderr, "\n");

View File

@ -444,17 +444,18 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state)
if (state->audio_out_idx > opts->delay)
{
// output synthesized speech to sound card
if(opts->audio_out_type == 2)
{
//go F yourself PA
}
else
if (opts->audio_out_type == 5) //OSS
{
//Test just sending it straight on since I think I've figured out the STDIN and RTL for Stereo
pa_simple_write(opts->pulse_digi_dev_out, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2), NULL); //Yay! It works.
//OSS
result = write (opts->audio_out_fd, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2));
state->audio_out_idx = 0;
}
else if (opts->audio_out_type == 0)
{
pa_simple_write(opts->pulse_digi_dev_out, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2), NULL);
state->audio_out_idx = 0;
}
else state->audio_out_idx = 0; //failsafe for audio_out == 0
}
@ -478,15 +479,18 @@ playSynthesizedVoiceR (dsd_opts * opts, dsd_state * state)
if (state->audio_out_idxR > opts->delay)
{
// output synthesized speech to sound card
if(opts->audio_out_type == 2)
{
//go F yourself PA
}
else
if (opts->audio_out_type == 5) //OSS
{
pa_simple_write(opts->pulse_digi_dev_outR, (state->audio_out_buf_pR - state->audio_out_idxR), (state->audio_out_idxR * 2), NULL); //Yay! It works.
//OSS
result = write (opts->audio_out_fdR, (state->audio_out_buf_pR - state->audio_out_idxR), (state->audio_out_idxR * 2));
state->audio_out_idxR = 0;
}
else if (opts->audio_out_type == 0)
{
pa_simple_write(opts->pulse_digi_dev_outR, (state->audio_out_buf_pR - state->audio_out_idxR), (state->audio_out_idxR * 2), NULL);
state->audio_out_idxR = 0;
}
else state->audio_out_idxR = 0; //failsafe for audio_out == 0
}
@ -558,6 +562,7 @@ openAudioInDevice (dsd_opts * opts)
exit(1);
}
}
else if (strncmp(opts->audio_in_dev, "tcp", 3) == 0)
{
opts->audio_in_type = 8;
@ -567,13 +572,13 @@ openAudioInDevice (dsd_opts * opts)
opts->audio_in_file_info->seekable=0;
opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
opts->tcp_file_in = sf_open_fd(opts->tcp_sockfd, SFM_READ, opts->audio_in_file_info, 0);
if(opts->tcp_file_in == NULL)
{
fprintf(stderr, "Error, couldn't open TCP with libsndfile: %s\n", sf_strerror(NULL));
exit(1);
}
}
else if (strncmp(opts->audio_in_dev, "udp", 3) == 0)
{
opts->audio_in_type = 6;
@ -598,6 +603,10 @@ openAudioInDevice (dsd_opts * opts)
{
opts->audio_in_type = 0;
}
else if((strncmp(opts->audio_in_dev, "/dev/dsp", 8) == 0))
{
opts->audio_in_type = 5;
}
else if (strncmp(extension, ".bin", 3) == 0)
{
struct stat stat_buf;
@ -645,9 +654,11 @@ openAudioInDevice (dsd_opts * opts)
}
//open pulse audio if no bin or wav
else
else //seems this condition is never met
{
opts->audio_in_type = 0; //not sure if this works or needs to openPulse here
//opts->audio_in_type = 5; //not sure if this works or needs to openPulse here
fprintf(stderr, "Error, couldn't open input file.\n");
exit(1);
}
}
if (opts->split == 1)

View File

@ -52,7 +52,7 @@ char * FM_banner[9] = {
" ██║ ██║ ╚═══██╗██║ ██║   ██╔══╝ ██║╚██╔╝██║██╔══╝ ",
" ██████╔╝██████╔╝██████╔╝   ██║ ██║ ╚═╝ ██║███████╗",
" ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝",
" "
" Lite Edition v2.0.0-6-gc44e039 Windows 32-bit RC1 "
};
int
@ -352,11 +352,12 @@ initOpts (dsd_opts * opts)
opts->p25status = 0;
opts->p25tg = 0;
opts->scoperate = 15;
sprintf (opts->audio_in_dev, "pulse");
sprintf (opts->audio_in_dev, "/dev/dsp");
opts->audio_in_fd = -1;
sprintf (opts->audio_out_dev, "pulse");
sprintf (opts->audio_out_dev, "/dev/dsp");
opts->audio_out_fd = -1;
opts->audio_out_fdR = -1;
opts->split = 0;
opts->playoffset = 0;
@ -444,10 +445,10 @@ initOpts (dsd_opts * opts)
opts->inverted_dpmr = 0;
opts->dmr_mono = 0;
opts->dmr_stereo = 1;
opts->aggressive_framesync = 1; //more aggressive to combat wonk wonk voice decoding
//see if initializing these values causes issues elsewhere, if so, then disable.
opts->audio_in_type = 0; //this was never initialized, causes issues on rPI 64 (bullseye) if not initialized
opts->audio_out_type = 0; //this was never initialized, causes issues on rPI 64 (bullseye) if not initialized
opts->aggressive_framesync = 1;
opts->audio_in_type = 5;
opts->audio_out_type = 5;
opts->lrrp_file_output = 0;
@ -503,6 +504,12 @@ initOpts (dsd_opts * opts)
//Trunking - Tune Data Calls
opts->trunk_tune_data_calls = 0; //disabled by default
//OSS audio - Slot Preference
//slot preference is used during OSS audio playback to
//prefer one tdma voice slot over another when both are playing back
//this is a fix to cygwin stuttering when both slots have voice
opts->slot_preference = 0; //default prefer slot 1 -- state->currentslot = 0;
} //initopts
void
@ -728,7 +735,7 @@ initState (dsd_state * state)
state->p25_cc_is_tdma = 2; //init on 2, TSBK NET_STS will set 0, TDMA NET_STS will set 1. //used to determine if we need to change symbol rate when cc hunting
//experimental symbol file capture read throttle
state->symbol_throttle = 0; //throttle speed
state->symbol_throttle = 100; //throttle speed
state->use_throttle = 0; //only use throttle if set to 1
state->p2_scramble_offset = 0;
@ -834,18 +841,18 @@ usage ()
{
printf ("\n");
printf ("Usage: dsd-fme [options] Decoder/Trunking Mode\n");
printf (" or: dsd-fme [options] -r <files> Read/Play saved mbe data from file(s)\n");
printf (" or: dsd-fme -h Show help\n");
printf ("Usage: dsd-fme-lite [options] Decoder/Trunking Mode\n");
printf (" or: dsd-fme-lite [options] -r <files> Read/Play saved mbe data from file(s)\n");
printf (" or: dsd-fme-lite -h Show help\n");
printf ("\n");
printf ("Display Options:\n");
printf (" -N Use NCurses Terminal\n");
printf (" dsd-fme -N 2> log.ans \n");
printf (" dsd-fme-lite -N 2> log.ans \n");
printf (" -Z Log MBE/PDU Payloads to console\n");
printf ("\n");
printf ("Input/Output options:\n");
printf (" -i <device> Audio input device (default is pulse audio)\n");
printf (" - for piped stdin\n");
printf (" -i <device> Audio input device (default is /dev/dsp)\n");
printf (" pulse for pulse audio \n");
printf (" rtl:dev:freq:gain:ppm:bw:sq:udp for rtl dongle (see below)\n");
printf (" tcp for tcp client SDR++/GNURadio Companion/Other (Port 7355)\n");
printf (" tcp:192.168.7.5:7355 for custom address and port \n");
@ -853,8 +860,11 @@ usage ()
printf (" filename.wav for 48K/1 wav files (SDR++, GQRX)\n");
printf (" filename.wav -s 96000 for 96K/1 wav files (DSDPlus)\n");
printf (" (Use single quotes '/directory/audio file.wav' when directories/spaces are present)\n");
// printf (" (Windows - '\directory\audio file.wav' backslash, not forward slash)\n");
printf (" -s <rate> Sample Rate of wav input files (48000 or 96000) Mono only!\n");
printf (" -o <device> Audio output device (default is pulse audio)(null for no audio output)\n");
printf (" -o <device> Audio output device (default is /dev/dsp)\n");
printf (" null for no audio output\n");
printf (" pulse for pulse audio \n");
printf (" -d <dir> Create mbe data files, use this directory\n");
printf (" -r <files> Read/Play saved mbe data from file(s)\n");
printf (" -g <num> Audio output gain (default = 0 = auto, disable = -1)\n");
@ -869,6 +879,7 @@ usage ()
printf (" -q Reverse Mute - Mute Unencrypted Voice and Unmute Encrypted Voice\n");
printf (" -V Enable Audio Smoothing on Upsampled 48k/1 or 24k/2 Audio (Capital V)\n");
printf (" (Audio Smoothing is now disabled on all upsampled output by default -- fix crackle/buzz bug)\n");
printf (" -z Set TDMA Voice Slot Preference when using OSS audio output (prevent lag and stuttering)\n");
printf ("\n");
printf ("RTL-SDR options:\n");
printf (" WARNING! Old CLI Switch Handling has been depreciated in favor of rtl:<parms>\n");
@ -880,7 +891,7 @@ usage ()
printf (" bw <num> RTL-SDR VFO Bandwidth kHz (default = 12)(6, 8, 12, 24) \n");
printf (" sq <num> RTL-SDR Squelch Level (0 - Open, 25 - Little, 50 - Higher)\n");
printf (" udp <num> RTL-SDR UDP Remote Port (default = 6020)\n");
printf (" Example: dsd-fme -fp -i rtl:0:851.375M:22:-2:12:0:6021\n");
printf (" Example: dsd-fme-lite -fp -i rtl:0:851.375M:22:-2:12:0:6021\n");
printf ("\n");
printf ("Decoder options:\n");
printf (" -fa Legacy Auto Detection 8k/1 (old methods default)\n");
@ -956,8 +967,8 @@ usage ()
printf (" May vary based on system stregnth, etc.\n");
printf (" -t <secs> Set Trunking VC/sync loss hangtime in seconds. (default = 1 second)\n");
printf ("\n");
printf (" Trunking Example TCP: dsd-fme -fs -i tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.ans\n");
printf (" Trunking Example RTL: dsd-fme -fs -i rtl:0:450M:26:-2:8:0:6020 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans\n");
printf (" Trunking Example TCP: dsd-fme-lite -fs -i tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.ans\n");
printf (" Trunking Example RTL: dsd-fme-lite -fs -i rtl:0:450M:26:-2:8:0:6020 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans\n");
printf ("\n");
exit (0);
}
@ -1158,8 +1169,9 @@ main (int argc, char **argv)
}
//fprintf (stderr,"%s", KNRM); //change back to normal
fprintf (stderr, "Github Build Version: %s \n", GIT_TAG);
fprintf (stderr,"MBElib version %s\n", versionstr);
// git_tag not working in 32-bit cygwin? or issue with copy and paste, even with the .git folder?
// fprintf (stderr, "Github Build Version: %s \n", GIT_TAG);
// fprintf (stderr,"MBElib version %s\n", versionstr);
initOpts (&opts);
initState (&state);
@ -1187,6 +1199,13 @@ main (int argc, char **argv)
//Disabled the Serial Port Dev and Baud Rate, etc, If somebody uses that function, sorry...
case 'z':
sscanf (optarg, "%d", &opts.slot_preference);
opts.slot_preference--; //user inputs 1 or 2, internally we want 0 and 1
if (opts.slot_preference > 1) opts.slot_preference = 1;
fprintf (stderr, "TDMA (DMR and P2) Slot Voice Preference is Slot %d. \n", opts.slot_preference+1);
break;
//Enable Audio Smoothing for Upsampled Audio
case '0':
case 'V':
@ -1559,7 +1578,7 @@ main (int argc, char **argv)
opts.frame_dpmr = 0;
opts.frame_provoice = 0;
opts.frame_ysf = 0;
opts.pulse_digi_rate_out = 8000;
opts.pulse_digi_rate_out = 8000; //doesn't matter for /dev/dsp anyways
opts.pulse_digi_out_channels = 1;
opts.dmr_stereo = 0;
opts.dmr_mono = 1;
@ -1762,11 +1781,11 @@ main (int argc, char **argv)
state.rf_mod = 0;
opts.dmr_stereo = 1;
opts.dmr_mono = 0;
// opts.setmod_bw = 7000;
opts.setmod_bw = 7000;
opts.pulse_digi_rate_out = 24000;
opts.pulse_digi_out_channels = 2;
sprintf (opts.output_name, "DMR Stereo");
fprintf (stderr,"Decoding DMR Stereo BS/MS Simplex\n");
}
else if (optarg[0] == 't')
@ -2054,12 +2073,14 @@ main (int argc, char **argv)
{
opts.audio_in_type = 8;
state.audio_smoothing = 0; //disable smoothing to prevent random crackling/buzzing
fprintf (stderr, "TCP Connection Success!\n");
// openAudioInDevice(&opts); //do this to see if it makes it work correctly
}
else
{
opts.audio_in_type = 0;
opts.audio_in_type = 5;
fprintf (stderr, "TCP Connection Failure - Using Pulse Audio Input.\n");
sprintf (opts.audio_in_dev, "%s", "pulse");
sprintf (opts.audio_in_dev, "%s", "/dev/dsp");
}
}
@ -2141,61 +2162,137 @@ main (int argc, char **argv)
if (rtl_ok == 0) //not set, means rtl support isn't compiled/available
{
fprintf (stderr, "RTL Support not enabled/compiled, falling back to Pulse Audio Input.\n");
sprintf (opts.audio_in_dev, "%s", "pulse");
opts.audio_in_type = 0;
fprintf (stderr, "RTL Support not enabled/compiled, falling back to OSS /dev/dsp Audio Input.\n");
sprintf (opts.audio_in_dev, "%s", "/dev/dsp");
opts.audio_in_type = 5;
}
}
//still need to work out why I can't use this
//issues with samples received, may be using UDP DGRAMS incorrectly, incorrect procedure?
//doesn't work correctly, so just going to reroute to /dev/dsp instead
if((strncmp(opts.audio_in_dev, "udp", 3) == 0)) //udp socket input from SDR++, GQRX, and others
{
//also still needs err handling
opts.udp_sockfd = UDPBind(opts.udp_hostname, opts.udp_portno);
opts.audio_in_type = 6;
fprintf (stderr, "UDP Input not working, falling back to OSS /dev/dsp Audio Input.\n");
sprintf (opts.audio_in_dev, "%s", "/dev/dsp");
opts.audio_in_type = 5;
}
if((strncmp(opts.audio_in_dev, "/dev/dsp", 8) == 0))
{
sprintf (opts.audio_in_dev, "%s", "pulse");
fprintf (stderr, "OSS and PA Handling Disabled; Using Pulse Audio.\n");
opts.audio_in_type = 0;
}
int fmt;
int speed = 48000;
if((strncmp(opts.audio_in_dev, "/dev/audio", 10) == 0))
{
sprintf (opts.audio_in_dev, "%s", "pulse");
fprintf (stderr, "OSS and PA Handling Disabled; Using Pulse Audio.\n");
opts.audio_in_type = 0;
}
if((strncmp(opts.audio_out_dev, "/dev/dsp", 8) == 0))
{
sprintf (opts.audio_out_dev, "%s", "pulse");
fprintf (stderr, "OSS and PA Handling Disabled; Using Pulse Audio.\n");
opts.audio_out_type = 0;
}
if((strncmp(opts.audio_out_dev, "/dev/audio", 10) == 0))
{
sprintf (opts.audio_out_dev, "%s", "pulse");
fprintf (stderr, "OSS and PA Handling Disabled; Using Pulse Audio.\n");
opts.audio_out_type = 0;
}
if((strncmp(opts.audio_out_dev, "pa", 2) == 0))
{
sprintf (opts.audio_out_dev, "%s", "pulse");
fprintf (stderr, "OSS and PA Handling Disabled; Using Pulse Audio.\n");
opts.audio_out_type = 0;
sprintf (opts.audio_in_dev, "%s", "/dev/dsp");
fprintf (stderr, "Switching to /dev/dsp.\n");
}
if((strncmp(opts.audio_in_dev, "pa", 2) == 0))
{
sprintf (opts.audio_in_dev, "%s", "pulse");
fprintf (stderr, "OSS and PA Handling Disabled; Using Pulse Audio.\n");
opts.audio_out_type = 0;
sprintf (opts.audio_in_dev, "%s", "/dev/dsp");
fprintf (stderr, "Switching to /dev/dsp.\n");
}
if((strncmp(opts.audio_in_dev, "/dev/dsp", 8) == 0))
{
fprintf (stderr, "OSS Input %s.\n", opts.audio_in_dev);
opts.audio_in_fd = open (opts.audio_in_dev, O_RDWR);
if (opts.audio_in_fd == -1)
{
fprintf (stderr, "Error, couldn't open %s\n", opts.audio_in_dev);
opts.audio_out = 0;
}
fmt = 0;
if (ioctl (opts.audio_in_fd, SNDCTL_DSP_RESET) < 0)
{
fprintf (stderr, "ioctl reset error \n");
}
fmt = speed;
if (ioctl (opts.audio_in_fd, SNDCTL_DSP_SPEED, &fmt) < 0)
{
fprintf (stderr, "ioctl speed error \n");
}
fmt = 0;
if (ioctl (opts.audio_in_fd, SNDCTL_DSP_STEREO, &fmt) < 0)
{
fprintf (stderr, "ioctl stereo error \n");
}
fmt = AFMT_S16_LE;
if (ioctl (opts.audio_in_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
{
fprintf (stderr, "ioctl setfmt error \n");
}
opts.audio_in_type = 5; //5 will become OSS input type
}
if((strncmp(opts.audio_out_dev, "/dev/audio", 10) == 0))
{
sprintf (opts.audio_out_dev, "%s", "/dev/dsp");
fprintf (stderr, "Switching to /dev/dsp.\n");
}
if((strncmp(opts.audio_out_dev, "pa", 2) == 0))
{
sprintf (opts.audio_out_dev, "%s", "/dev/dsp");
fprintf (stderr, "Switching to /dev/dsp.\n");
}
if((strncmp(opts.audio_out_dev, "/dev/dsp", 8) == 0))
{
fprintf (stderr, "OSS Output %s.\n", opts.audio_out_dev);
opts.audio_out_fd = open (opts.audio_out_dev, O_RDWR); //O_WRONLY
opts.audio_out_fdR = open (opts.audio_out_dev, O_RDWR);
if (opts.audio_out_fd == -1)
{
fprintf (stderr, "Error, couldn't open #1 %s\n", opts.audio_out_dev);
opts.audio_out = 0;
exit(1);
}
if (opts.audio_out_fdR == -1)
{
fprintf (stderr, "Error, couldn't open #2 %s\n", opts.audio_out_dev);
opts.audio_out = 0;
exit(1);
}
fmt = 0;
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_RESET) < 0)
{
fprintf (stderr, "ioctl reset error \n");
}
if (ioctl (opts.audio_out_fdR, SNDCTL_DSP_RESET) < 0)
{
fprintf (stderr, "ioctl reset error \n");
}
fmt = speed;
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_SPEED, &fmt) < 0)
{
fprintf (stderr, "ioctl speed error \n");
}
if (ioctl (opts.audio_out_fdR, SNDCTL_DSP_SPEED, &fmt) < 0)
{
fprintf (stderr, "ioctl speed error \n");
}
fmt = 0;
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_STEREO, &fmt) < 0)
{
fprintf (stderr, "ioctl stereo error \n");
}
if (ioctl (opts.audio_out_fdR, SNDCTL_DSP_STEREO, &fmt) < 0)
{
fprintf (stderr, "ioctl stereo error \n");
}
fmt = AFMT_S16_LE;
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
{
fprintf (stderr, "ioctl setfmt error \n");
}
if (ioctl (opts.audio_out_fdR, SNDCTL_DSP_SETFMT, &fmt) < 0)
{
fprintf (stderr, "ioctl setfmt error \n");
}
opts.audio_out_type = 5; //5 will become OSS output type
}
if((strncmp(opts.audio_in_dev, "pulse", 5) == 0))
@ -2229,6 +2326,7 @@ main (int argc, char **argv)
openAudioOutDevice (&opts, SAMPLE_RATE_OUT);
}
}
else if (strcmp (opts.audio_in_dev, opts.audio_out_dev) != 0)
{
opts.split = 1;
@ -2263,13 +2361,14 @@ main (int argc, char **argv)
{
opts.pulse_digi_rate_out = 48000;
opts.pulse_digi_out_channels = 1;
openPulseOutput(&opts); //need to open it up for output
// openPulseOutput(&opts); //need to open it up for output?
openAudioInDevice (&opts); //needs to be tested, not sure if required
playMbeFiles (&opts, &state, argc, argv);
}
else
{
liveScanner (&opts, &state);
liveScanner (&opts, &state);
}
cleanupAndExit (&opts, &state);

View File

@ -126,6 +126,8 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
unsigned long long int k;
int x;
int preempt = 0; //TDMA dual voice slot preemption(when using OSS output)
for (i = 0; i < 88; i++)
{
@ -522,6 +524,14 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
}
//end reverse mute test
//OSS Specific Voice Preemption if dual voices on TDMA and one slot has preference over the other
if (opts->slot_preference == 1 && opts->audio_out_type == 5 && opts->audio_out == 1 && state->dmrburstR == 16)
{
opts->audio_out = 0;
preempt = 1;
if (opts->payload == 0) fprintf (stderr, " *MUTED*");
}
if (state->dmr_encL == 0 || opts->dmr_mute_encL == 0)
{
state->debug_audio_errors += state->errs2;
@ -578,6 +588,14 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
}
//end reverse mute test
//OSS Specific Voice Preemption if dual voices on TDMA and one slot has preference over the other
if (opts->slot_preference == 0 && opts->audio_out_type == 5 && opts->audio_out == 1 && state->dmrburstL == 16)
{
opts->audio_out = 0;
preempt = 1;
if (opts->payload == 0) fprintf (stderr, " *MUTED*");
}
if (state->dmr_encR == 0 || opts->dmr_mute_encR == 0)
{
state->debug_audio_errorsR += state->errs2R;
@ -632,6 +650,12 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
}
}
if (preempt == 1)
{
opts->audio_out = 1;
preempt = 0;
}
//reset audio out flag for next repitition
if (strcmp(mode, "B") == 0) opts->audio_out = 1;
//restore flag for null output type

View File

@ -125,7 +125,7 @@ char * DMRBusrtTypes[32] = {
"R-S ERR ",
"CRC ERR ",
"NULL ",
"Voice ",
"Voice ",
" ",
"INIT ",
"INIT ",
@ -150,9 +150,10 @@ void beeper (dsd_opts * opts, dsd_state * state, int type)
FILE *beep;
char wav_name[1024] = {0};
if (opts->pulse_digi_rate_out == 8000) strncpy(wav_name, "/usr/share/tone8.wav", 1023);
if (opts->pulse_digi_rate_out == 48000) strncpy(wav_name, "/usr/share/tone48.wav", 1023);
if (opts->pulse_digi_rate_out == 24000) strncpy(wav_name, "/usr/share/tone24.wav", 1023);
if (opts->pulse_digi_rate_out == 8000) strncpy(wav_name, "tone8.wav", 1023);
if (opts->pulse_digi_rate_out == 48000) strncpy(wav_name, "tone48.wav", 1023);
if (opts->pulse_digi_rate_out == 24000) strncpy(wav_name, "tone24.wav", 1023);
if (opts->audio_out_type == 5) strncpy(wav_name, "tone48.wav", 1023);
wav_name[1023] = '\0';
struct stat stat_buf;
if (stat(wav_name, &stat_buf) == 0)
@ -174,17 +175,20 @@ void beeper (dsd_opts * opts, dsd_state * state, int type)
//only beep on R if dmr_stereo is active and slot 2, else beep on L
if (type == 0 && opts->dmr_stereo == 1 && opts->audio_out == 1)
{
pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL);
if (opts->audio_out_type == 0) pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL);
if (opts->audio_out_type == 5) write (opts->audio_out_fd, buf, sizeof(buf));
//fprintf (stderr, "BEEP 0 24\n");
}
if (type == 1 && opts->dmr_stereo == 1 && opts->audio_out == 1)
{
pa_simple_write(opts->pulse_digi_dev_outR, buf, sizeof(buf), NULL);
if (opts->audio_out_type == 0) pa_simple_write(opts->pulse_digi_dev_outR, buf, sizeof(buf), NULL);
if (opts->audio_out_type == 5) write (opts->audio_out_fd, buf, sizeof(buf));
//fprintf (stderr, "BEEP 1 24\n");
}
if (opts->dmr_stereo == 0 && opts->audio_out == 1)
{
pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL);
if (opts->audio_out_type == 0) pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL);
if (opts->audio_out_type == 5) write (opts->audio_out_fd, buf, sizeof(buf));
//fprintf (stderr, "BEEP 0 8\n");
}
@ -199,7 +203,7 @@ void beeper (dsd_opts * opts, dsd_state * state, int type)
}
char * getDateN(void) {
char datename[99]; //bug in 32-bit Ubuntu when using date in filename, date is garbage text
char datename[80]; //bug in 32-bit Ubuntu when using date in filename, date is garbage text
char * curr2;
struct tm * to;
time_t t;
@ -410,7 +414,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
if (opts->audio_in_type == 5) //close UDP input SF file so we don't buffer audio while not decoding
{
sf_close(opts->udp_file_in); //disable for testing
// sf_close(opts->udp_file_in); //disable for testing
}
state->payload_keyid = 0;
@ -1663,7 +1667,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
if (opts->audio_in_type == 5) //re-open UDP input 'file'
{
opts->udp_file_in = sf_open_fd(opts->udp_sockfd, SFM_READ, opts->audio_in_file_info, 0);
// opts->udp_file_in = sf_open_fd(opts->udp_sockfd, SFM_READ, opts->audio_in_file_info, 0);
}
//update sync time on cc sync so we don't immediately go CC hunting when exiting the menu
@ -2057,7 +2061,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->ncurses_compact == 1)
{
printw ("------------------------------------------------------------------------------\n");
printw ("| Digital Speech Decoder: Florida Man Edition %s \n", GIT_TAG);
printw ("| Digital Speech Decoder: Florida Man Edition - Win32 %s \n", "v2.0.0-6-gc44e039 RC1");
}
if (opts->ncurses_compact == 0)
{
@ -2067,8 +2071,9 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
printw("%s", FM_bannerN[i]);
if (i == 1) printw (" ESC to Menu");
if (i == 2) printw (" 'q' to Quit ");
if (i == 5) printw (" MBElib %s", versionstr);
if (i == 6) printw (" %s \n", GIT_TAG);
if (i == 4) printw (" MBElib %s", versionstr);
if (i == 5) printw (" %s ", "Win32 RC1"); //printw (" %s \n", GIT_TAG);
if (i == 6) printw (" %s \n", "v2.0.0-6-gc44e039"); //printw (" %s \n", GIT_TAG);
else printw ("\n");
}
attroff(COLOR_PAIR(6)); //6
@ -2080,6 +2085,10 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
{
printw ("| Pulse Audio Input: [%2i] kHz [%i] Channel\n", opts->pulse_digi_rate_in/1000, opts->pulse_digi_in_channels);
}
if (opts->audio_in_type == 5)
{
printw ("| OSS Audio Input: [%2i] kHz [1] Channel\n", SAMPLE_RATE_IN);
}
if (opts->audio_in_type == 4)
{
printw ("| Direct Symbol Bin Input: %s \n", opts->audio_in_dev);
@ -2114,6 +2123,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (state->audio_smoothing == 1) printw (" - Smoothing On");
printw (" \n");
}
if (opts->audio_out_type == 5)
{
printw ("| OSS Audio Output: [%2i] kHz [1] Channel", SAMPLE_RATE_IN);
if (state->audio_smoothing == 1) printw (" - Smoothing On");
printw (" \n");
}
if (opts->monitor_input_audio == 1)
{
printw ("| Monitoring Source Audio when Carrier Present and No Sync Detected\n");
@ -2406,6 +2421,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
//This is the new one
printw ("%s | ", state->call_string[0]);
printw ("%s ", DMRBusrtTypes[state->dmrburstL]);
if (opts->slot_preference == 1 && opts->audio_out_type == 5 && opts->audio_out == 1 && state->dmrburstR == 16 && state->dmrburstL == 16) printw ("*M*");
printw ("\n");
printw ("| V XTRA | "); //10 spaces
@ -2601,6 +2617,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
//THIS IS THE NEW ONE
printw ("%s | ", state->call_string[1]);
printw ("%s ", DMRBusrtTypes[state->dmrburstR]);
if (opts->slot_preference == 0 && opts->audio_out_type == 5 && opts->audio_out == 1 && state->dmrburstR == 16 && state->dmrburstL == 16) printw ("*M*");
printw ("\n");
printw ("| V XTRA | "); //10 spaces

View File

@ -82,35 +82,24 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
}
// Read the new sample from the input
if(opts->audio_in_type == 0) // && state->menuopen == 0 still not quite working
if(opts->audio_in_type == 0) //pulse audio
{
pa_simple_read(opts->pulse_digi_dev_in, &sample, 2, NULL );
//look into how processAudio handles playback, not sure if latency issues, or garbage sample values crash pulse when written
// if (opts->monitor_input_audio == 1 && state->lastsynctype == -1 && sample < 32767 && sample > -32767)
if (opts->monitor_input_audio == 1 && state->lastsynctype == -1 && sample != 0)
{
state->pulse_raw_out_buffer = sample; //steal raw out buffer sample here?
pa_simple_write(opts->pulse_raw_dev_out, (void*)&state->pulse_raw_out_buffer, 2, NULL);
}
//playback is wrong, depends on samples_per_symbol, maybe make a buffer and store first?
//making buffer might also fix raw audio monitoring as well
if (opts->wav_out_file_raw[0] != 0) //if set for recording sample raw files
{
//writeRawSample (opts, state, sample);
}
pa_simple_read(opts->pulse_digi_dev_in, &sample, 2, NULL );
}
else if (opts->audio_in_type == 5) //OSS
{
read (opts->audio_in_fd, &sample, 2);
}
//stdin only, wav files moving to new number
else if (opts->audio_in_type == 1)
else if (opts->audio_in_type == 1) //won't work in windows, needs posix pipe (mintty)
{
result = sf_read_short(opts->audio_in_file, &sample, 1);
if(result == 0)
{
//cleanupAndExit (opts, state);
sf_close(opts->audio_in_file);
opts->audio_in_type = 0; //set input type
openPulseInput(opts); //open pulse inpput
sample = 0; //send zero sample
cleanupAndExit (opts, state);
}
}
//wav files, same but using seperate value so we can still manipulate ncurses menu
@ -122,10 +111,15 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
{
sf_close(opts->audio_in_file);
opts->audio_in_type = 0; //set input type
openPulseInput(opts); //open pulse inpput
sample = 0; //send zero sample
fprintf (stderr, "\n\nEnd of .wav file.\n");
//open pulse input if we are pulse output AND using ncurses terminal
if (opts->audio_out_type == 0 && opts->use_ncurses_terminal == 1)
{
opts->audio_in_type = 0; //set input type
openPulseInput(opts); //open pulse input
}
//else cleanup and exit
else cleanupAndExit(opts, state);
}
}
else if (opts->audio_in_type == 3)
@ -147,24 +141,28 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
{
result = sf_read_short(opts->tcp_file_in, &sample, 1);
if(result == 0) {
sf_close(opts->tcp_file_in);
opts->audio_in_type = 0; //set input type
openPulseInput(opts); //open pulse inpput
sample = 0; //zero sample on bad result, keep the ball rolling
fprintf (stderr, "Connection to TCP Server Disconnected.\n");
//open pulse input if we are pulse output AND using ncurses terminal
if (opts->audio_out_type == 0 && opts->use_ncurses_terminal == 1)
{
opts->audio_in_type = 0; //set input type
openPulseInput(opts); //open pulse input
}
//else cleanup and exit
else cleanupAndExit(opts, state);
}
}
//UDP Socket input...not working correct. Reads samples, but no sync
else if (opts->audio_in_type == 6)
{
// else if (opts->audio_in_type == 6)
// {
//I think this doesn't get the entire dgram when we run sf_read_short on the udp dgram
result = sf_read_short(opts->udp_file_in, &sample, 1);
// result = sf_read_short(opts->udp_file_in, &sample, 1);
// if (sample != 0)
// fprintf (stderr, "Result = %d Sample = %d \n", result, sample);
}
// }
if (opts->use_cosine_filter)
{
@ -383,6 +381,12 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
}
#endif
//test throttle on wav input files
if (opts->audio_in_type == 2)
{
if (state->use_throttle == 1) usleep(.003); //very environment specific, tuning to cygwin
}
//read op25/fme symbol bin files
if (opts->audio_in_type == 4)
{
@ -399,14 +403,23 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
useconds_t stime = state->symbol_throttle;
if (state->use_throttle == 1)
{
usleep(stime);
// usleep(stime);
usleep(.003); //very environment specific, tuning to cygwin
}
//fprintf(stderr, "%d", state->symbolc);
if( feof(opts->symbolfile) )
{
opts->audio_in_type = 0; //switch to pulse after playback, ncurses terminal can initiate replay if wanted
// opts->audio_in_type = 0; //switch to pulse after playback, ncurses terminal can initiate replay if wanted
fclose(opts->symbolfile);
openPulseInput(opts);
fprintf (stderr, "\n\nEnd of .bin file\n");
//open pulse input if we are pulse output AND using ncurses terminal
if (opts->audio_out_type == 0 && opts->use_ncurses_terminal == 1)
{
opts->audio_in_type = 0; //set input type
openPulseInput(opts); //open pulse input
}
//else cleanup and exit
else cleanupAndExit(opts, state);
}
//assign symbol/dibit values based on modulation type

View File

@ -480,7 +480,8 @@ decode_bch()
}
}
long int messagepp = 0x0;
//bugfix on 32-bit cygwin, probably overflowed here
unsigned long long int messagepp = 0x0;
//very simplified version, just to encode, get frame and compare
unsigned long long int edacs_bch (unsigned long long int message)

View File

@ -47,12 +47,13 @@ char * getTimeE(void) //get pretty hh:mm:ss timestamp
void edacs(dsd_opts * opts, dsd_state * state)
{
unsigned long long fr_1 = 0xFFFFFFFFFF; //40-bit frames
unsigned long long fr_2 = 0; //each is a 40 bit frame that repeats 3 times
unsigned long long fr_3 = 0; //two messages per frame
unsigned long long fr_4 = 0xFFFFFFFFFF;
unsigned long long fr_5 = 0;
unsigned long long fr_6 = 0;
//changed to ulli here for 32-bit cygwin (not sure if was an issue, but playing it safe)
unsigned long long int fr_1 = 0xFFFFFFFFFF; //40-bit frames
unsigned long long int fr_2 = 0; //each is a 40 bit frame that repeats 3 times
unsigned long long int fr_3 = 0; //two messages per frame
unsigned long long int fr_4 = 0xFFFFFFFFFF;
unsigned long long int fr_5 = 0;
unsigned long long int fr_6 = 0;
//BCH stuff
unsigned long long int fr_1m = 0xFFFFFFF; //28-bit 7X message portion to pass to bch handler

View File

@ -474,6 +474,10 @@ void process_4V (dsd_opts * opts, dsd_state * state)
fprintf (stderr, "\n");
}
//set to 16 for MBE OSS shim to preempt audio
if (state->currentslot == 0) state->dmrburstL = 16;
else state->dmrburstR = 16;
processMbeFrame (opts, state, NULL, ambe_fr1, NULL);
processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
@ -625,6 +629,10 @@ void process_2V (dsd_opts * opts, dsd_state * state)
fprintf (stderr, "\n");
}
//set to 16 for MBE OSS shim to preempt audio
if (state->currentslot == 0) state->dmrburstL = 16;
else state->dmrburstR = 16;
processMbeFrame (opts, state, NULL, ambe_fr1, NULL);
processMbeFrame (opts, state, NULL, ambe_fr2, NULL);

Binary file not shown.

Binary file not shown.

BIN
tone8.wav

Binary file not shown.

View File

@ -1,4 +0,0 @@
pacmd load-module module-null-sink sink_name=virtual_sink sink_properties=device.description=Virtual_Sink
pacmd load-module module-null-sink sink_name=virtual_sink2 sink_properties=device.description=Virtual_Sink2