mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-20 20:55:40 -05:00
Rewrite Call Alert; Switch to Generated Tone;
This commit is contained in:
@@ -9,12 +9,6 @@ read -p "Press enter to continue"
|
|||||||
|
|
||||||
git clone https://github.com/lwvmobile/dsd-fme
|
git clone https://github.com/lwvmobile/dsd-fme
|
||||||
cd 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
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
|
|||||||
@@ -45,12 +45,6 @@ cd ..
|
|||||||
|
|
||||||
git clone https://github.com/lwvmobile/dsd-fme
|
git clone https://github.com/lwvmobile/dsd-fme
|
||||||
cd 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
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
|
|||||||
@@ -97,12 +97,6 @@ Finish by running these steps to clone and build DSD-FME.
|
|||||||
```
|
```
|
||||||
git clone https://github.com/lwvmobile/dsd-fme
|
git clone https://github.com/lwvmobile/dsd-fme
|
||||||
cd 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
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
@@ -129,12 +123,6 @@ Then you can build and install using
|
|||||||
```
|
```
|
||||||
git clone https://github.com/lwvmobile/dsd-fme
|
git clone https://github.com/lwvmobile/dsd-fme
|
||||||
cd dsd-fme
|
cd dsd-fme
|
||||||
cp tone8.wav /usr/share/
|
|
||||||
cp tone24.wav /usr/share/
|
|
||||||
cp tone48.wav /usr/share/
|
|
||||||
chmod 777 /usr/share/tone8.wav
|
|
||||||
chmod 777 /usr/share/tone24.wav
|
|
||||||
chmod 777 /usr/share/tone48.wav
|
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
# -DAERO=ON is optional, but recommended if you want the older OSS support as well
|
# -DAERO=ON is optional, but recommended if you want the older OSS support as well
|
||||||
@@ -163,15 +151,4 @@ cmake ..
|
|||||||
make -j `nproc`
|
make -j `nproc`
|
||||||
sudo make install
|
sudo make install
|
||||||
sudo ldconfig
|
sudo ldconfig
|
||||||
```
|
|
||||||
|
|
||||||
If the call alert wav files aren't playing, then make sure to run the following in the dsd-fme folder to copy the wav files to the /usr/share/ folder and give them adequate permission to be accessed.
|
|
||||||
|
|
||||||
```
|
|
||||||
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
|
|
||||||
```
|
```
|
||||||
@@ -961,6 +961,7 @@ int getSymbol (dsd_opts * opts, dsd_state * state, int have_sync);
|
|||||||
void upsample (dsd_state * state, float invalue);
|
void upsample (dsd_state * state, float invalue);
|
||||||
void processDSTAR (dsd_opts * opts, dsd_state * state);
|
void processDSTAR (dsd_opts * opts, dsd_state * state);
|
||||||
|
|
||||||
|
void soft_tonef (float samp[160], int n, int ID, int AD);
|
||||||
//new p25lcw
|
//new p25lcw
|
||||||
void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t irrecoverable_errors);
|
void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t irrecoverable_errors);
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
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
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
*-----------------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
//TODO: Test All voice decoders with all combos (short mono, short stereo, float mono, float stereo)
|
//TODO: Test All voice decoders with all combos (short mono, short stereo, float mono, float stereo)
|
||||||
//TODO: Need Method To Dynamically Close and Open any OSS instances when changing decoding classes from Ncurses Menu (particularly rate and/or channel configs)
|
//TODO: Need Method To Dynamically Close and Open any OSS instances when changing decoding classes from Ncurses Menu (particularly rate and/or channel configs)
|
||||||
@@ -867,4 +868,25 @@ void playSynthesizedVoiceSS4 (dsd_opts * opts, dsd_state * state)
|
|||||||
state->audio_out_idx2R = 0;
|
state->audio_out_idx2R = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//largely borrowed from Boatbod OP25 (simplified single tone ID version)
|
||||||
|
void soft_tonef (float samp[160], int n, int ID, int AD)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
float step1, step2, amplitude, freq1, freq2;
|
||||||
|
|
||||||
|
// Synthesize tones
|
||||||
|
freq1 = 31.25 * ID; freq2 = freq1;
|
||||||
|
step1 = 2 * M_PI * freq1 / 8000.0f;
|
||||||
|
step2 = 2 * M_PI * freq2 / 8000.0f;
|
||||||
|
amplitude = AD * 75.0f;
|
||||||
|
|
||||||
|
for (i = 0; i < 160; i++)
|
||||||
|
{
|
||||||
|
samp[i] = (float) ( amplitude * (sin((n) * step1)/2 + sin((n) * step2)/2) );
|
||||||
|
samp[i] /= 8000.0f;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -135,120 +135,108 @@ char * DMRBusrtTypes[32] = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef TONES //NOTE: This option is purely for the precompiled version that gets distributed, not other user Cygwin builds
|
//Sorry Remus :(
|
||||||
void beeper (dsd_opts * opts, dsd_state * state, int type)
|
void beeper (dsd_opts * opts, dsd_state * state, int lr)
|
||||||
{
|
|
||||||
FILE *beep;
|
|
||||||
char wav_name[1024] = {0};
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
beep = fopen (wav_name, "ro");
|
|
||||||
uint8_t buf[1024];
|
|
||||||
memset (buf, 0, sizeof(buf));
|
|
||||||
short blip = 0;
|
|
||||||
int loop = 1;
|
|
||||||
while (loop == 1)
|
|
||||||
{
|
|
||||||
fread(buf, sizeof(buf), 1, beep);
|
|
||||||
if ( feof (beep) )
|
|
||||||
{
|
|
||||||
loop = 0;
|
|
||||||
}
|
|
||||||
if (loop == 1)
|
|
||||||
{
|
|
||||||
//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)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose (beep);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
void beeper (dsd_opts * opts, dsd_state * state, int type)
|
|
||||||
{
|
{
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
int i, j, n;
|
||||||
|
//use lr as left or right channel designation in stereo config
|
||||||
|
float samp_f[160]; //mono float sample
|
||||||
|
float samp_fs[320]; //stereo float sample
|
||||||
|
short samp_s[160]; //mono short sample
|
||||||
|
short samp_ss[320]; //stereo short sample
|
||||||
|
short samp_su[960]; //mono short upsample
|
||||||
|
short outbuf[6]; //temp storage for upsample
|
||||||
|
|
||||||
FILE *beep;
|
n = 0; //rolling sine wave 'degree'
|
||||||
char wav_name[1024] = {0};
|
|
||||||
|
|
||||||
if (opts->pulse_digi_rate_out == 8000) strncpy(wav_name, "/usr/share/tone8.wav", 1023);
|
//each j increment is 20 ms at 160 samples / 8 kHz
|
||||||
if (opts->pulse_digi_rate_out == 48000) strncpy(wav_name, "/usr/share/tone48.wav", 1023);
|
for (j = 0; j < 3; j++)
|
||||||
if (opts->pulse_digi_rate_out == 24000) strncpy(wav_name, "/usr/share/tone24.wav", 1023);
|
|
||||||
if (opts->audio_out_type == 5) strncpy(wav_name, "/usr/share/tone24.wav", 1023);
|
|
||||||
wav_name[1023] = '\0';
|
|
||||||
struct stat stat_buf;
|
|
||||||
if (stat(wav_name, &stat_buf) == 0)
|
|
||||||
{
|
{
|
||||||
beep = fopen (wav_name, "ro");
|
//'zero' out stereo mix samples
|
||||||
uint8_t buf[1024];
|
memset (samp_fs, 0.1f, sizeof(samp_fs));
|
||||||
memset (buf, 0, sizeof(buf));
|
memset (samp_ss, 0, sizeof(samp_ss));
|
||||||
int loop = 1;
|
|
||||||
while (loop == 1)
|
//generate a tone (ID=45, AD=103, rolling n value)
|
||||||
|
soft_tonef(samp_f, n, 45, 103);
|
||||||
|
|
||||||
|
//convert float to short if required
|
||||||
|
if (opts->floating_point == 0)
|
||||||
{
|
{
|
||||||
fread(buf, sizeof(buf), 1, beep);
|
mbe_floattoshort(samp_f, samp_s);
|
||||||
if ( feof (beep) )
|
for (i = 0; i < 160; i++)
|
||||||
{
|
{
|
||||||
loop = 0;
|
samp_s[i] *= 4000; //apply gain
|
||||||
|
samp_ss[(i*2)+lr] = samp_s[i];
|
||||||
}
|
}
|
||||||
if (loop == 1)
|
|
||||||
{
|
|
||||||
//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);
|
|
||||||
//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);
|
|
||||||
//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);
|
|
||||||
//fprintf (stderr, "BEEP 0 8\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (beep);
|
//load returned tone sample into appropriate channel -- left = +0; right = +1;
|
||||||
|
for (i = 0; i < 160; i++)
|
||||||
|
samp_fs[(i*2)+lr] = samp_f[i];
|
||||||
|
|
||||||
|
//play sample 3 times (20ms x 3 = 60ms)
|
||||||
|
if (opts->audio_out_type == 0) //Pulse Audio
|
||||||
|
{
|
||||||
|
if (opts->pulse_digi_out_channels == 2 && opts->floating_point == 1)
|
||||||
|
pa_simple_write(opts->pulse_digi_dev_out, samp_fs, 320*4, NULL);
|
||||||
|
|
||||||
|
if (opts->pulse_digi_out_channels == 1 && opts->floating_point == 1)
|
||||||
|
pa_simple_write(opts->pulse_digi_dev_out, samp_f, 160*4, NULL);
|
||||||
|
|
||||||
|
if (opts->pulse_digi_out_channels == 2 && opts->floating_point == 0)
|
||||||
|
pa_simple_write(opts->pulse_digi_dev_out, samp_ss, 320*2, NULL);
|
||||||
|
|
||||||
|
if (opts->pulse_digi_out_channels == 1 && opts->floating_point == 0)
|
||||||
|
pa_simple_write(opts->pulse_digi_dev_out, samp_s, 160*2, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (opts->audio_out_type == 1) //STDOUT
|
||||||
|
{
|
||||||
|
if (opts->pulse_digi_out_channels == 2 && opts->floating_point == 1)
|
||||||
|
write(opts->audio_out_fd, samp_fs, 320*4);
|
||||||
|
|
||||||
|
if (opts->pulse_digi_out_channels == 1 && opts->floating_point == 1)
|
||||||
|
write(opts->audio_out_fd, samp_f, 160*4);
|
||||||
|
|
||||||
|
if (opts->pulse_digi_out_channels == 2 && opts->floating_point == 0)
|
||||||
|
write(opts->audio_out_fd, samp_ss, 320*2);
|
||||||
|
|
||||||
|
if (opts->pulse_digi_out_channels == 1 && opts->floating_point == 0)
|
||||||
|
write(opts->audio_out_fd, samp_s, 160*2);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (opts->audio_out_type == 2) //OSS Variable Output (no float)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (opts->pulse_digi_out_channels == 2 && opts->floating_point == 0)
|
||||||
|
write(opts->audio_out_fd, samp_ss, 320*2);
|
||||||
|
|
||||||
|
if (opts->pulse_digi_out_channels == 1 && opts->floating_point == 0)
|
||||||
|
write(opts->audio_out_fd, samp_s, 160*2);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (opts->audio_out_type == 5) //OSS 48k/1 configuration with upsample
|
||||||
|
{
|
||||||
|
short prev = 0;
|
||||||
|
for (i = 0; i < 160; i++)
|
||||||
|
{
|
||||||
|
upsampleS (samp_s[i], prev, outbuf);
|
||||||
|
samp_su[(i*6)+0] = outbuf[0];
|
||||||
|
samp_su[(i*6)+1] = outbuf[1];
|
||||||
|
samp_su[(i*6)+2] = outbuf[2];
|
||||||
|
samp_su[(i*6)+3] = outbuf[3];
|
||||||
|
samp_su[(i*6)+4] = outbuf[4];
|
||||||
|
samp_su[(i*6)+5] = outbuf[5];
|
||||||
|
}
|
||||||
|
|
||||||
|
write (opts->audio_out_fd, samp_su, 960*2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
char * getDateN(void) {
|
char * getDateN(void) {
|
||||||
char datename[80]; //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
|
||||||
|
|||||||
BIN
tone24.wav
BIN
tone24.wav
Binary file not shown.
BIN
tone48.wav
BIN
tone48.wav
Binary file not shown.
Reference in New Issue
Block a user