Restructure: Move sample from common code to 'libsample'
This commit is contained in:
parent
d5bf0e6291
commit
0197bed50d
|
@ -21,7 +21,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "compandor.h"
|
||||
|
||||
//#define db2level(db) pow(10, (double)db / 20.0)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "dtmf_encode.h"
|
||||
|
||||
#define PI M_PI
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../common/debug.h"
|
||||
#include "../libfilter/iir_filter.h"
|
||||
#include "emphasis.h"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "iir_filter.h"
|
||||
|
||||
#define PI M_PI
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "fm.h"
|
||||
|
||||
//#define FAST_SINE
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../common/debug.h"
|
||||
#include "fsk.h"
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../common/debug.h"
|
||||
#include "goertzel.h"
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../common/debug.h"
|
||||
#include "jitter.h"
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../libsamplerate/samplerate.h"
|
||||
#include "../libjitter/jitter.h"
|
||||
#include "../common/debug.h"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../common/debug.h"
|
||||
#include "../common/call.h"
|
||||
#include "cause.h"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <sys/un.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../common/debug.h"
|
||||
#include "../common/call.h"
|
||||
#include "cause.h"
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
|
||||
|
||||
noinst_LIBRARIES = libsample.a
|
||||
|
||||
libsample_a_SOURCES = \
|
||||
sample.c
|
|
@ -0,0 +1,64 @@
|
|||
/* Sample definition
|
||||
*
|
||||
* (C) 2017 by Andreas Eversberg <jolly@eversberg.eu>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "sample.h"
|
||||
|
||||
/*
|
||||
* A regular voice conversation takes place at this factor below the full range
|
||||
* of 16 bits signed value:
|
||||
*/
|
||||
static double int_16_speech_level = SPEECH_LEVEL * 0.7079; /* 16 dBm below dBm0, which is about 3dBm below full 16 bit range */
|
||||
|
||||
/* A sample_t is a value that has virtually infinite precision but will also
|
||||
* support high numbers. 'double' or 'float' types are sufficient.
|
||||
*
|
||||
* When using sample_t inside signal processing of each base station, the
|
||||
* level of +- 1 is relative to the normal speach evenlope.
|
||||
*
|
||||
* When converting sample_t to int16_t, the level of +- 1 is reduced by factor.
|
||||
* This way the speech may be louder before clipping happens.
|
||||
*
|
||||
* When using sample_t to modulate (SDR or sound card), the level is changed,
|
||||
* so it represents the frequency deviation in Hz. The deviation of speech
|
||||
* envelope is network dependant.
|
||||
*/
|
||||
|
||||
void samples_to_int16(int16_t *spl, sample_t *samples, int length)
|
||||
{
|
||||
int32_t value;
|
||||
|
||||
while (length--) {
|
||||
value = *samples++ * int_16_speech_level * 32768.0;
|
||||
if (value > 32767.0)
|
||||
*spl++ = 32767;
|
||||
else if (value < -32767.0)
|
||||
*spl++ = -32767;
|
||||
else
|
||||
*spl++ = (uint16_t)value;
|
||||
}
|
||||
}
|
||||
|
||||
void int16_to_samples(sample_t *samples, int16_t *spl, int length)
|
||||
{
|
||||
while (length--) {
|
||||
*samples++ = (double)(*spl++) / 32767.0 / int_16_speech_level;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
typedef double sample_t;
|
||||
|
||||
#define SPEECH_LEVEL 0.1585
|
||||
|
||||
void samples_to_int16(int16_t *spl, sample_t *samples, int length);
|
||||
void int16_to_samples(sample_t *samples, int16_t *spl, int length);
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "samplerate.h"
|
||||
|
||||
int init_samplerate(samplerate_t *state, double low_samplerate, double high_samplerate, double filter_cutoff)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "scrambler.h"
|
||||
|
||||
#define PI M_PI
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <math.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../common/sender.h"
|
||||
|
||||
/* must be odd value! */
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../common/sender.h"
|
||||
#include "../libfft/fft.h"
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ enum paging_signal;
|
|||
#define __USE_GNU
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../libfm/fm.h"
|
||||
#include "../libtimer/timer.h"
|
||||
#include "../common/sender.h"
|
||||
|
|
|
@ -24,7 +24,7 @@ enum paging_signal;
|
|||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "sdr.h"
|
||||
#include "sdr_config.h"
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include <alsa/asoundlib.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../common/debug.h"
|
||||
#include "../common/sender.h"
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include "../common/sample.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "wave.h"
|
||||
|
||||
/* NOTE: No locking required for writing and reading buffer pointers, since 'int' is atomic on >=32 bit machines */
|
||||
|
|
Loading…
Reference in New Issue