organize, remove bad comments, hardcode pilot volume and change the volumes (4.05 to 4.5, deviation is 7.500 khz, not 75, wonder why tho, also if it doesnt compile, too bad, report that)
This commit is contained in:
parent
08e93f4172
commit
d8cd1b34cf
|
|
@ -177,7 +177,6 @@ now you know what you can pass as the args to the program, but theres a pipe sti
|
||||||
`COA` - change compressor attack<br>
|
`COA` - change compressor attack<br>
|
||||||
`RDV` - gain but not audio but rds gain<br>
|
`RDV` - gain but not audio but rds gain<br>
|
||||||
`PAU` - pause, kinda, it will cancel out any audio, you could use `GAI 0` but you could forgor the old gain value, right?<br>
|
`PAU` - pause, kinda, it will cancel out any audio, you could use `GAI 0` but you could forgor the old gain value, right?<br>
|
||||||
`PIV` - gain but not audio or rds but stereo pilot gain (default = 0.9)<br>
|
|
||||||
`COM` - toggle, like rds but it doesnt toggle the rds, it does toggle the COMPRESSOR<br>
|
`COM` - toggle, like rds but it doesnt toggle the rds, it does toggle the COMPRESSOR<br>
|
||||||
`CMG` - change compressor max gain recip<br>
|
`CMG` - change compressor max gain recip<br>
|
||||||
`LIM` - same as that arg<br>
|
`LIM` - same as that arg<br>
|
||||||
|
|
|
||||||
|
|
@ -227,14 +227,6 @@ ResultAndArg poll_control_pipe(int log) {
|
||||||
}
|
}
|
||||||
resarg.res = CONTROL_PIPE_PAUSE_SET;
|
resarg.res = CONTROL_PIPE_PAUSE_SET;
|
||||||
resarg.arg_int = togg;
|
resarg.arg_int = togg;
|
||||||
} else if(fifo[0] == 'P' && fifo[1] == 'I' && fifo[2] == 'V') {
|
|
||||||
if(log==1) {
|
|
||||||
printf("Set Stereo Pilot Volume to ");
|
|
||||||
printf(arg);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
resarg.res = CONTROL_PIPE_PILVOL_SET;
|
|
||||||
resarg.arg = arg;
|
|
||||||
} else if(fifo[0] == 'M' && fifo[1] == 'P' && fifo[2] == 'X') {
|
} else if(fifo[0] == 'M' && fifo[1] == 'P' && fifo[2] == 'X') {
|
||||||
int mpx = ( strcmp(arg, "ON") == 0 );
|
int mpx = ( strcmp(arg, "ON") == 0 );
|
||||||
if(log==1) {
|
if(log==1) {
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,11 @@
|
||||||
#define CONTROL_PIPE_CT_SET 16
|
#define CONTROL_PIPE_CT_SET 16
|
||||||
#define CONTROL_PIPE_RDSVOL_SET 17
|
#define CONTROL_PIPE_RDSVOL_SET 17
|
||||||
#define CONTROL_PIPE_PAUSE_SET 18
|
#define CONTROL_PIPE_PAUSE_SET 18
|
||||||
#define CONTROL_PIPE_PILVOL_SET 19 //fitting, isn't it?
|
#define CONTROL_PIPE_MPXGEN_SET 19
|
||||||
#define CONTROL_PIPE_MPXGEN_SET 20
|
#define CONTROL_PIPE_COMPRESSOR_SET 20
|
||||||
#define CONTROL_PIPE_COMPRESSOR_SET 21
|
#define CONTROL_PIPE_COMPRESSORMAXGAINRECIP_SET 21
|
||||||
#define CONTROL_PIPE_COMPRESSORMAXGAINRECIP_SET 23
|
#define CONTROL_PIPE_LIMITERTHRESHOLD_SET 22
|
||||||
#define CONTROL_PIPE_LIMITERTHRESHOLD_SET 24
|
#define CONTROL_PIPE_GENERIC_SET 23
|
||||||
#define CONTROL_PIPE_GENERIC_SET 25
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int res;
|
int res;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
monaural or stereo audio.
|
monaural or stereo audio.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "fm_mpx.h"
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
@ -43,7 +44,6 @@ size_t length;
|
||||||
// coefficients of the low-pass FIR filter
|
// coefficients of the low-pass FIR filter
|
||||||
float low_pass_fir[FIR_PHASES][FIR_TAPS];
|
float low_pass_fir[FIR_PHASES][FIR_TAPS];
|
||||||
|
|
||||||
|
|
||||||
float carrier_38[] = {0.0, 0.8660254037844386, 0.8660254037844388, 1.2246467991473532e-16, -0.8660254037844384, -0.8660254037844386};
|
float carrier_38[] = {0.0, 0.8660254037844386, 0.8660254037844388, 1.2246467991473532e-16, -0.8660254037844384, -0.8660254037844386};
|
||||||
|
|
||||||
float carrier_19[] = {0.0, 0.5, 0.8660254037844386, 1.0, 0.8660254037844388, 0.5, 1.2246467991473532e-16, -0.5, -0.8660254037844384, -1.0, -0.8660254037844386, -0.5};
|
float carrier_19[] = {0.0, 0.5, 0.8660254037844386, 1.0, 0.8660254037844388, 0.5, 1.2246467991473532e-16, -0.5, -0.8660254037844384, -1.0, -0.8660254037844386, -0.5};
|
||||||
|
|
@ -148,14 +148,13 @@ int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int raw
|
||||||
// Choose a cutoff frequency for the low-pass FIR filter
|
// Choose a cutoff frequency for the low-pass FIR filter
|
||||||
if(in_samplerate/2 < cutoff_freq) cutoff_freq = in_samplerate/2 * .8;
|
if(in_samplerate/2 < cutoff_freq) cutoff_freq = in_samplerate/2 * .8;
|
||||||
|
|
||||||
|
|
||||||
// Create the low-pass FIR filter, with pre-emphasis
|
// Create the low-pass FIR filter, with pre-emphasis
|
||||||
double window, firlowpass, firpreemph , sincpos;
|
double window, firlowpass, firpreemph, sincpos;
|
||||||
double taup, deltap, bp, ap, a0, a1, b1;
|
double taup, deltap, bp, ap, a0, a1, b1;
|
||||||
if(preemphasis != 0) {
|
if(preemphasis != 0) {
|
||||||
// IIR pre-emphasis filter
|
// IIR pre-emphasis filter
|
||||||
// Reference material: http://jontio.zapto.org/hda1/preempiir.pdf
|
// Reference material: http://jontio.zapto.org/hda1/preempiir.pdf
|
||||||
double tau=preemphasis; //why? well im gonna listen to rule: "if it works dont touch it"
|
double tau=preemphasis;
|
||||||
double delta=1/(2*PI*20000);//double delta=1.96e-6;
|
double delta=1/(2*PI*20000);//double delta=1.96e-6;
|
||||||
taup=1.0/(2.0*(in_samplerate*FIR_PHASES))/tan( 1.0/(2*tau*(in_samplerate*FIR_PHASES) ));
|
taup=1.0/(2.0*(in_samplerate*FIR_PHASES))/tan( 1.0/(2*tau*(in_samplerate*FIR_PHASES) ));
|
||||||
deltap=1.0/(2.0*(in_samplerate*FIR_PHASES))/tan( 1.0/(2*delta*(in_samplerate*FIR_PHASES) ));
|
deltap=1.0/(2.0*(in_samplerate*FIR_PHASES))/tan( 1.0/(2*delta*(in_samplerate*FIR_PHASES) ));
|
||||||
|
|
@ -215,13 +214,12 @@ int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int raw
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// samples provided by this function are in 0..10: they need to be divided by
|
// samples provided by this function are in 0..10: they need to be divided by
|
||||||
// 10 after.
|
// 10 after.
|
||||||
int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int disablestereo, float gain, int enablecompressor, int rds_ct_enabled, float rds_volume, int paused, float pilot_volume, int generate_multiplex, float limiter_threshold) {
|
int fm_mpx_get_samples(float *mpx_buffer, fm_mpx_data *data) {
|
||||||
*audio_buffer = 0.0;
|
*audio_buffer = 0.0;
|
||||||
int stereo_capable = (channels > 1) && (!disablestereo); //chatgpt
|
int stereo_capable = (channels > 1) && (!data->disablestereo);
|
||||||
if(!drds && generate_multiplex) get_rds_samples(mpx_buffer, length, stereo_capable, rds_ct_enabled, rds_volume);
|
if(!data->drds && data->generate_multiplex) get_rds_samples(mpx_buffer, length, stereo_capable, data->rds_ct_enabled, data->rds_volume);
|
||||||
|
|
||||||
if(inf == NULL) return 0; // if there is no audio, stop here
|
if(inf == NULL) return 0; // if there is no audio, stop here
|
||||||
|
|
||||||
|
|
@ -293,8 +291,8 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply by the gain
|
// Multiply by the gain
|
||||||
out_left = out_left * gain;
|
out_left = out_left * data->gain;
|
||||||
if(channels > 1) out_right = out_right * gain;
|
if(channels > 1) out_right = out_right * data->gain;
|
||||||
|
|
||||||
// Simple broadcast compressor
|
// Simple broadcast compressor
|
||||||
//
|
//
|
||||||
|
|
@ -308,11 +306,11 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa
|
||||||
left_abs=fabsf(out_left);
|
left_abs=fabsf(out_left);
|
||||||
if( left_abs>left_max )
|
if( left_abs>left_max )
|
||||||
{
|
{
|
||||||
left_max+= (left_abs-left_max)*compressor_attack;
|
left_max+= (left_abs-left_max)*data->compressor_attack;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
left_max*=compressor_decay;
|
left_max*=data->compressor_decay;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( channels > 1 )
|
if( channels > 1 )
|
||||||
|
|
@ -320,11 +318,11 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa
|
||||||
right_abs=fabsf(out_right);
|
right_abs=fabsf(out_right);
|
||||||
if( right_abs>right_max )
|
if( right_abs>right_max )
|
||||||
{
|
{
|
||||||
right_max+= (right_abs-right_max)*compressor_attack;
|
right_max+= (right_abs-right_max)*data->compressor_attack;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
right_max*=compressor_decay;
|
right_max*=data->compressor_decay;
|
||||||
}
|
}
|
||||||
if( 1 )// Experimental joint compressor mode
|
if( 1 )// Experimental joint compressor mode
|
||||||
{
|
{
|
||||||
|
|
@ -333,37 +331,37 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa
|
||||||
else if( left_max < right_max )
|
else if( left_max < right_max )
|
||||||
left_max=right_max;
|
left_max=right_max;
|
||||||
}
|
}
|
||||||
if(enablecompressor) out_right=out_right/(right_max+compressor_max_gain_recip);
|
if(data->enablecompressor) out_right=out_right/(right_max+data->compressor_max_gain_recip); // Adjust volume with limited maximum gain
|
||||||
}
|
}
|
||||||
if(enablecompressor) out_left= out_left/(left_max+compressor_max_gain_recip); // Adjust volume with limited maximum gain
|
if(data->enablecompressor) out_left= out_left/(left_max+data->compressor_max_gain_recip); // Adjust volume with limited maximum gain
|
||||||
if(drds) mpx_buffer[i] = 0.0;
|
if(data->drds) mpx_buffer[i] = 0.0;
|
||||||
if(paused) {
|
if(data->paused) {
|
||||||
out_left = 0;
|
out_left = 0;
|
||||||
if(channels > 1) out_right = 0;
|
if(channels > 1) out_right = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_left = limiter(out_left, limiter_threshold, 1);
|
out_left = limiter(out_left, data->limiter_threshold, 1);
|
||||||
if( channels > 1 ) out_right = limiter(out_right, limiter_threshold, 1);
|
if( channels > 1 ) out_right = limiter(out_right, data->limiter_threshold, 1);
|
||||||
|
|
||||||
out_left = clip(out_left, 1); //max is gonna be 1.0 (0 db), lowest is -1.0 (-inf db)
|
out_left = clip(out_left, 1); //max is gonna be 1.0 (0 db), lowest is -1.0 (-inf db)
|
||||||
if(channels>1) out_right = clip(out_right, 1);
|
if(channels>1) out_right = clip(out_right, 1);
|
||||||
|
|
||||||
// Generate the stereo mpx
|
// Generate the stereo mpx
|
||||||
if( channels > 1 ) {
|
if( channels > 1 ) {
|
||||||
if(!disablestereo) {
|
if(!data->disablestereo) {
|
||||||
if(generate_multiplex) {
|
if(generate_multiplex) {
|
||||||
if(1) {
|
if(1) {
|
||||||
mpx_buffer[i] += 4.05*(out_left+out_right) + // Stereo sum signal
|
// 4.5 and 0.9 are the volumes, thats because we dont have 75000 khz of deviation, instead we have 7500 khz, so that needs to be louder by 10 times than normal
|
||||||
4.05 * carrier_38[phase_38] * (out_left-out_right) + // Stereo difference signal
|
mpx_buffer[i] += 4.5*(out_left+out_right) + // Stereo sum signal
|
||||||
pilot_volume*carrier_19[phase_19]; // Stereo pilot tone
|
4.5 * carrier_38[phase_38] * (out_left-out_right) + // Stereo difference signal
|
||||||
|
0.9*carrier_19[phase_19]; // Stereo pilot tone
|
||||||
phase_19++;
|
phase_19++;
|
||||||
phase_38++;
|
phase_38++;
|
||||||
if(phase_19 >= 12) phase_19 = 0;
|
if(phase_19 >= 12) phase_19 = 0;
|
||||||
if(phase_38 >= 6) phase_38 = 0;
|
if(phase_38 >= 6) phase_38 = 0;
|
||||||
} else { // polar stereo (https://forums.stereotool.com/viewtopic.php?t=6233, https://personal.utdallas.edu/~dlm/3350%20comm%20sys/ITU%20std%20on%20FM%20--%20R-REC-BS.450-3-200111-I!!PDF-E.pdf)
|
} else { // polar stereo (https://forums.stereotool.com/viewtopic.php?t=6233, https://personal.utdallas.edu/~dlm/3350%20comm%20sys/ITU%20std%20on%20FM%20--%20R-REC-BS.450-3-200111-I!!PDF-E.pdf)
|
||||||
mpx_buffer[i] += 4.05*(out_left+out_right) + // Stereo sum signal (L+R)
|
mpx_buffer[i] += 4.5*(out_left+out_right) + // Stereo sum signal (L+R)
|
||||||
4.05 * carrier_3125[phase_3125] * (out_left-out_right); // Stereo difference signal
|
4.5 * carrier_3125[phase_3125] * (out_left-out_right); // Stereo difference signal
|
||||||
//NO PIOT TONE!!!!!!!!!!!!!!!!!!!!!!!!!!!! (its missplelled correctly probably just like misspelled)
|
|
||||||
phase_3125++;
|
phase_3125++;
|
||||||
if(phase_3125 >= 8) phase_3125 = 0;
|
if(phase_3125 >= 8) phase_3125 = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -372,7 +370,7 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa
|
||||||
if(generate_multiplex) {
|
if(generate_multiplex) {
|
||||||
mpx_buffer[i] =
|
mpx_buffer[i] =
|
||||||
mpx_buffer[i] +
|
mpx_buffer[i] +
|
||||||
4.05*(out_left+out_right); // Unmodulated L+R signal
|
4.5*(out_left+out_right); // Unmodulated L+R signal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -381,12 +379,12 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa
|
||||||
if(generate_multiplex) {
|
if(generate_multiplex) {
|
||||||
mpx_buffer[i] =
|
mpx_buffer[i] =
|
||||||
mpx_buffer[i] +
|
mpx_buffer[i] +
|
||||||
4.05*out_left; // Unmodulated monophonic signal
|
4.5*out_left; // Unmodulated monophonic signal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!generate_multiplex) {
|
if(!generate_multiplex) {
|
||||||
mpx_buffer[i] =
|
mpx_buffer[i] =
|
||||||
0.0; //nothing, rpitx works like this (i think): theres a array with data and rpitx goes thought it to transmit it, now here the functions with the mpx_buffer such as this one update the array, but what if the array is not updated? well, then it keeps transmitting the exact same thing, it doesnt update whats its transmitting, no really, take a sdr and remove this and turn off the mpx gen, if no music then look at rds
|
0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_pos++;
|
audio_pos++;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,22 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int rawSampleRate, int rawChannels, float cutoff_freq);
|
typedef struct {
|
||||||
extern int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int disablestereo, float gain, int enablecompressor, int rds_ct_enabled, float rds_volume, int paused, float pilot_volume, int generate_multiplex, float limiter_threshold);
|
int drds;
|
||||||
extern int fm_mpx_close();
|
float compressor_decay;
|
||||||
|
float compressor_attack;
|
||||||
|
float compressor_max_gain_recip;
|
||||||
|
int disablestereo;
|
||||||
|
float gain;
|
||||||
|
int enablecompressor;
|
||||||
|
int rds_ct_enabled;
|
||||||
|
float rds_volume;
|
||||||
|
int paused;
|
||||||
|
float pilot_volume;
|
||||||
|
int generate_multiplex;
|
||||||
|
float limiter_threshold;
|
||||||
|
} fm_mpx_data;
|
||||||
|
|
||||||
|
int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int rawSampleRate, int rawChannels, float cutoff_freq);
|
||||||
|
int fm_mpx_get_samples(float *mpx_buffer, fm_mpx_data *data);
|
||||||
|
int fm_mpx_close();
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,38 @@ static void fatal(char *fmt, ...)
|
||||||
terminate(0);
|
terminate(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, char *control_pipe, int pty, int *af_array, int raw, int drds, double preemp, int power, int rawSampleRate, int rawChannels, int deviation, int ta, int tp, float cutoff_freq, float gaim, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int enablecompressor, int rds_ct_enabled, float rds_volume, float pilot_volume, int disablestereo, int log, float limiter_threshold) {
|
typedef struct tx_data {
|
||||||
|
uint32_t carrier_freq;
|
||||||
|
char *audio_file;
|
||||||
|
uint16_t pi;
|
||||||
|
char *ps;
|
||||||
|
char *rt;
|
||||||
|
char *control_pipe;
|
||||||
|
int pty;
|
||||||
|
int *af_array;
|
||||||
|
int raw;
|
||||||
|
int drds;
|
||||||
|
double preemp;
|
||||||
|
int power;
|
||||||
|
int rawSampleRate;
|
||||||
|
int rawChannels;
|
||||||
|
int deviation;
|
||||||
|
int ta;
|
||||||
|
int tp;
|
||||||
|
float cutoff_freq;
|
||||||
|
float audio_gain;
|
||||||
|
float compressor_decay;
|
||||||
|
float compressor_attack;
|
||||||
|
float compressor_max_gain_recip;
|
||||||
|
int enablecompressor;
|
||||||
|
int rds_ct_enabled;
|
||||||
|
float rds_volume;
|
||||||
|
int disablestereo;
|
||||||
|
int log;
|
||||||
|
float limiter_threshold;
|
||||||
|
} tx_data;
|
||||||
|
|
||||||
|
int tx(tx_data *data) {
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
memset(&sa, 0, sizeof(sa));
|
memset(&sa, 0, sizeof(sa));
|
||||||
sa.sa_handler = terminate;
|
sa.sa_handler = terminate;
|
||||||
|
|
@ -59,25 +90,34 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
||||||
int data_index = 0;
|
int data_index = 0;
|
||||||
|
|
||||||
int generate_multiplex = 1;
|
int generate_multiplex = 1;
|
||||||
int dstereo = disablestereo;
|
int dstereo = data->disablestereo;
|
||||||
|
int drds = data->drds;
|
||||||
|
float audio_gain = data->audio_gain;
|
||||||
|
float compressor_decay = data->compressor_decay;
|
||||||
|
float compressor_attack = data->compressor_attack;
|
||||||
|
float compressor_max_gain_recip = data->compressor_max_gain_recip;
|
||||||
|
int enablecompressor = data->enablecompressor;
|
||||||
|
int rds_ct_enabled = data->rds_ct_enabled;
|
||||||
|
float rds_volume = data->rds_volume;
|
||||||
|
float limiter_threshold = data->limiter_threshold;
|
||||||
|
|
||||||
//set the power
|
//set the power
|
||||||
padgpio gpiopad;
|
padgpio gpiopad;
|
||||||
gpiopad.setlevel(power);
|
gpiopad.setlevel(data->power);
|
||||||
|
|
||||||
// Initialize the baseband generator
|
// Initialize the baseband generator
|
||||||
if(fm_mpx_open(audio_file, DATA_SIZE, raw, preemp, rawSampleRate, rawChannels, cutoff_freq) < 0) return 1;
|
if(fm_mpx_open(data->audio_file, DATA_SIZE, data->raw, data->preemp, data->rawSampleRate, data->rawChannels, data->cutoff_freq) < 0) return 1;
|
||||||
|
|
||||||
// Initialize the RDS modulator
|
// Initialize the RDS modulator
|
||||||
char myps[9] = {0};
|
char myps[9] = {0};
|
||||||
set_rds_pi(pi);
|
set_rds_pi(data->pi);
|
||||||
set_rds_ps(ps);
|
set_rds_ps(data->ps);
|
||||||
set_rds_rt(rt);
|
set_rds_rt(data->rt);
|
||||||
set_rds_pty(pty);
|
set_rds_pty(data->pty);
|
||||||
set_rds_ab(0);
|
set_rds_ab(0);
|
||||||
set_rds_ms(1);
|
set_rds_ms(1); // yes
|
||||||
set_rds_tp(tp);
|
set_rds_tp(data->tp);
|
||||||
set_rds_ta(ta);
|
set_rds_ta(data->ta);
|
||||||
if(dstereo == 1) {
|
if(dstereo == 1) {
|
||||||
set_rds_di(0);
|
set_rds_di(0);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -85,7 +125,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
||||||
}
|
}
|
||||||
uint16_t count = 0;
|
uint16_t count = 0;
|
||||||
uint16_t count2 = 0;
|
uint16_t count2 = 0;
|
||||||
if(log) {
|
if(data->log) {
|
||||||
if(drds == 1) {
|
if(drds == 1) {
|
||||||
printf("RDS Disabled (you can enable with control fifo with the RDS command)\n");
|
printf("RDS Disabled (you can enable with control fifo with the RDS command)\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -93,11 +133,11 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
||||||
printf("RT: \"%s\"\n", rt);
|
printf("RT: \"%s\"\n", rt);
|
||||||
|
|
||||||
if(af_array[0]) {
|
if(af_array[0]) {
|
||||||
set_rds_af(af_array);
|
set_rds_af(data->af_array);
|
||||||
printf("AF: ");
|
printf("AF: ");
|
||||||
int f;
|
int f;
|
||||||
for(f = 1; f < af_array[0]+1; f++) {
|
for(f = 1; f < data->af_array[0]+1; f++) {
|
||||||
printf("%f Mhz ", (float)(af_array[f]+875)/10);
|
printf("%f Mhz ", (float)(data->af_array[f]+875)/10);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
@ -105,24 +145,24 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the control pipe reader
|
// Initialize the control pipe reader
|
||||||
if(control_pipe) {
|
if(data->control_pipe) {
|
||||||
if(open_control_pipe(control_pipe) == 0) {
|
if(open_control_pipe(data->control_pipe) == 0) {
|
||||||
if(log) printf("Reading control commands on %s.\n", control_pipe);
|
if(data->log) printf("Reading control commands on %s.\n", data->control_pipe);
|
||||||
} else {
|
} else {
|
||||||
if(log) printf("Failed to open control pipe: %s.\n", control_pipe);
|
if(data->log) printf("Failed to open control pipe: %s.\n", data->control_pipe);
|
||||||
control_pipe = NULL;
|
data->control_pipe = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(log) printf("Starting to transmit on %3.1f MHz.\n", carrier_freq/1e6);
|
if(data->log) printf("Starting to transmit on %3.1f MHz.\n", carrier_freq/1e6);
|
||||||
float deviation_scale_factor;
|
float deviation_scale_factor;
|
||||||
// The deviation specifies how wide the signal is (from its lowest bandwidht to its highest, but not including sub-carriers).
|
// The deviation specifies how wide the signal is (from its lowest bandwidht to its highest, but not including sub-carriers).
|
||||||
// Use 75kHz for WFM (broadcast radio, or 50khz can be used)
|
// Use 75kHz for WFM (broadcast radio, or 50khz can be used)
|
||||||
// and about 2.5kHz for NFM (walkie-talkie style radio)
|
// and about 2.5kHz for NFM (walkie-talkie style radio)
|
||||||
deviation_scale_factor= 0.1 * (deviation) ; // todo PPM
|
deviation_scale_factor= 0.1 * (data->deviation);
|
||||||
int paused = 0;
|
int paused = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if(control_pipe) {
|
if(data->control_pipe) {
|
||||||
ResultAndArg pollResult = poll_control_pipe(log);
|
ResultAndArg pollResult = poll_control_pipe(log);
|
||||||
if(pollResult.res == CONTROL_PIPE_RDS_SET) {
|
if(pollResult.res == CONTROL_PIPE_RDS_SET) {
|
||||||
drds = pollResult.arg_int;
|
drds = pollResult.arg_int;
|
||||||
|
|
@ -130,12 +170,12 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
||||||
padgpio gpiopad;
|
padgpio gpiopad;
|
||||||
gpiopad.setlevel(pollResult.arg_int);
|
gpiopad.setlevel(pollResult.arg_int);
|
||||||
} else if(pollResult.res == CONTROL_PIPE_DEVIATION_SET) {
|
} else if(pollResult.res == CONTROL_PIPE_DEVIATION_SET) {
|
||||||
deviation = std::stoi(pollResult.arg);
|
data->deviation = std::stoi(pollResult.arg);
|
||||||
deviation_scale_factor= 0.1 * (deviation );
|
deviation_scale_factor= 0.1 * (data->deviation);
|
||||||
} else if(pollResult.res == CONTROL_PIPE_STEREO_SET) {
|
} else if(pollResult.res == CONTROL_PIPE_STEREO_SET) {
|
||||||
dstereo = pollResult.arg_int;
|
dstereo = pollResult.arg_int;
|
||||||
} else if(pollResult.res == CONTROL_PIPE_GAIN_SET) {
|
} else if(pollResult.res == CONTROL_PIPE_GAIN_SET) {
|
||||||
gaim = std::stof(pollResult.arg);
|
audio_gain = std::stof(pollResult.arg);
|
||||||
} else if(pollResult.res == CONTROL_PIPE_COMPRESSORDECAY_SET) {
|
} else if(pollResult.res == CONTROL_PIPE_COMPRESSORDECAY_SET) {
|
||||||
compressor_decay = std::stof(pollResult.arg);
|
compressor_decay = std::stof(pollResult.arg);
|
||||||
} else if(pollResult.res == CONTROL_PIPE_COMPRESSORATTACK_SET) {
|
} else if(pollResult.res == CONTROL_PIPE_COMPRESSORATTACK_SET) {
|
||||||
|
|
@ -146,8 +186,6 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
||||||
rds_volume = std::stof(pollResult.arg);
|
rds_volume = std::stof(pollResult.arg);
|
||||||
} else if(pollResult.res == CONTROL_PIPE_PAUSE_SET) {
|
} else if(pollResult.res == CONTROL_PIPE_PAUSE_SET) {
|
||||||
paused = pollResult.arg_int;
|
paused = pollResult.arg_int;
|
||||||
} else if(pollResult.res == CONTROL_PIPE_PILVOL_SET) {
|
|
||||||
pilot_volume = std::stof(pollResult.arg);
|
|
||||||
} else if(pollResult.res == CONTROL_PIPE_MPXGEN_SET) {
|
} else if(pollResult.res == CONTROL_PIPE_MPXGEN_SET) {
|
||||||
generate_multiplex = pollResult.arg_int;
|
generate_multiplex = pollResult.arg_int;
|
||||||
} else if(pollResult.res == CONTROL_PIPE_COMPRESSOR_SET) {
|
} else if(pollResult.res == CONTROL_PIPE_COMPRESSOR_SET) {
|
||||||
|
|
@ -158,7 +196,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
||||||
limiter_threshold = std::stof(pollResult.arg);
|
limiter_threshold = std::stof(pollResult.arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fm_mpx_get_samples(data, drds, compressor_decay, compressor_attack, compressor_max_gain_recip, dstereo, gaim, enablecompressor, rds_ct_enabled, rds_volume, paused, pilot_volume, generate_multiplex, limiter_threshold) < 0 ) terminate(0);
|
if(fm_mpx_get_samples(data, drds, compressor_decay, compressor_attack, compressor_max_gain_recip, dstereo, audio_gain, enablecompressor, rds_ct_enabled, rds_volume, paused, pilot_volume, generate_multiplex, limiter_threshold) < 0 ) terminate(0);
|
||||||
data_len = DATA_SIZE;
|
data_len = DATA_SIZE;
|
||||||
for(int i=0;i< data_len;i++) {
|
for(int i=0;i< data_len;i++) {
|
||||||
devfreq[i] = data[i]*deviation_scale_factor;
|
devfreq[i] = data[i]*deviation_scale_factor;
|
||||||
|
|
@ -170,40 +208,44 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
char *audio_file = NULL;
|
tx_data data = {
|
||||||
char *control_pipe = NULL;
|
.audio_file = NULL,
|
||||||
uint32_t carrier_freq = 100000000; //100 mhz
|
.control_pipe = NULL,
|
||||||
char *ps = "Pi-FmSa";
|
.carrier_freq = 100000000,
|
||||||
char *rt = "Broadcasting on a Raspberry Pi: Simply Advanced";
|
.ps = "Pi-FmSa",
|
||||||
uint16_t pi = 0x00ff;
|
.rt = "Broadcasting on a Raspberry Pi: Simply Advanced",
|
||||||
int pty = 0;
|
.pi = 0x00ff,
|
||||||
float compressor_decay = 0.999995;
|
.pty = 0,
|
||||||
float compressor_attack = 1.0;
|
.compressor_decay = 0.999995,
|
||||||
float compressor_max_gain_recip = 0.01;
|
.compressor_attack = 1.0,
|
||||||
int enable_compressor = 1;
|
.compressor_max_gain_recip = 0.01,
|
||||||
float rds_volume = 1.0;
|
.enablecompressor = 1,
|
||||||
float pilot_volume = 0.9;
|
.rds_volume = 1.0,
|
||||||
float limiter_threshold = 0.9;
|
.limiter_threshold = 0.9,
|
||||||
int log = 1;
|
.log = 1,
|
||||||
int ta = 0;
|
.ta = 0,
|
||||||
int tp = 0;
|
.tp = 0,
|
||||||
|
.af_array = {0},
|
||||||
|
.raw = 0,
|
||||||
|
.drds = 0,
|
||||||
|
.disablestereo = 0,
|
||||||
|
.power = 7,
|
||||||
|
.audio_gain = 1,
|
||||||
|
.rawSampleRate = 44100,
|
||||||
|
.rawChannels = 2,
|
||||||
|
.preemp = 50e-6,
|
||||||
|
.deviation = 75000,
|
||||||
|
.rds_ct_enabled = 1,
|
||||||
|
.cutoff_freq = 15000,
|
||||||
|
};
|
||||||
|
|
||||||
int af_size = 0;
|
int af_size = 0;
|
||||||
int gpiopin = 4;
|
int gpiopin = 4;
|
||||||
int raw = 0;
|
|
||||||
int drds = 0;
|
|
||||||
int dstereo = 0;
|
|
||||||
int power = 7;
|
|
||||||
float gain = 1;
|
|
||||||
int rawSampleRate = 44100;
|
|
||||||
int rawChannels = 2;
|
|
||||||
int compressorchanges = 0;
|
int compressorchanges = 0;
|
||||||
int limiterchanges = 0;
|
int limiterchanges = 0;
|
||||||
double preemp = 50e-6; //eu
|
|
||||||
int deviation = 75000;
|
|
||||||
int alternative_freq[100] = {};
|
int alternative_freq[100] = {};
|
||||||
int bypassfreqrange = 0;
|
int bypassfreqrange = 0;
|
||||||
int ct = 1;
|
|
||||||
float cutofffreq = 15000; // up to standard
|
|
||||||
// Parse command-line arguments
|
// Parse command-line arguments
|
||||||
for(int i=1; i<argc; i++) {
|
for(int i=1; i<argc; i++) {
|
||||||
char *arg = argv[i];
|
char *arg = argv[i];
|
||||||
|
|
@ -211,48 +253,45 @@ int main(int argc, char **argv) {
|
||||||
if(arg[0] == '-' && i+1 < argc) param = argv[i+1];
|
if(arg[0] == '-' && i+1 < argc) param = argv[i+1];
|
||||||
if((strcmp("-audio", arg)==0) && param != NULL) {
|
if((strcmp("-audio", arg)==0) && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
audio_file = param;
|
data.audio_file = param;
|
||||||
} else if(strcmp("-freq", arg)==0 && param != NULL) {
|
} else if(strcmp("-freq", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
carrier_freq = 1e6 * atof(param);
|
data.carrier_freq = (uint32_t)(atof(param)*1e6);
|
||||||
if((carrier_freq < 64e6 || carrier_freq > 108e6) && !bypassfreqrange) fatal("Incorrect frequency specification. Must be in megahertz, of the form 107.9, between 64 and 108. (going that low for UKF radios, such as the UNITRA Jowita or other old band FM Radios)\n");
|
if(data.carrier_freq < 64e6 || data.carrier_freq > 108e6) fatal("Incorrect frequency specification. Must be in megahertz, of the form 107.9, between 64 and 108.\n");
|
||||||
} else if(strcmp("-pi", arg)==0 && param != NULL) {
|
} else if(strcmp("-pi", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
pi = (uint16_t) strtol(param, NULL, 16);
|
data.pi = atoi(param);
|
||||||
} else if(strcmp("-ps", arg)==0 && param != NULL) {
|
} else if(strcmp("-ps", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
ps = param;
|
data.ps = param;
|
||||||
} else if(strcmp("-rt", arg)==0 && param != NULL) {
|
} else if(strcmp("-rt", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
rt = param;
|
data.rt = param;
|
||||||
} else if(strcmp("-compressordecay", arg)==0 && param != NULL) {
|
} else if(strcmp("-compressordecay", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
compressor_decay = atof(param);
|
data.compressor_decay = atof(param);
|
||||||
compressorchanges = 1;
|
compressorchanges = 1;
|
||||||
} else if(strcmp("-compressorattack", arg)==0 && param != NULL) {
|
} else if(strcmp("-compressorattack", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
compressor_attack = atof(param);
|
data.compressor_attack = atof(param);
|
||||||
compressorchanges = 1;
|
compressorchanges = 1;
|
||||||
} else if(strcmp("-compressormaxgainrecip", arg)==0 && param != NULL) {
|
} else if(strcmp("-compressormaxgainrecip", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
compressor_max_gain_recip = atof(param);
|
data.compressor_max_gain_recip = atof(param);
|
||||||
compressorchanges = 1;
|
compressorchanges = 1;
|
||||||
} else if(strcmp("-limiterthreshold", arg)==0 && param != NULL) {
|
} else if(strcmp("-limiterthreshold", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
limiter_threshold = atof(param);
|
data.limiter_threshold = atof(param);
|
||||||
limiterchanges = 1;
|
limiterchanges = 1;
|
||||||
if(1 && limiter_threshold > 4) { //if you dont want this for some reason than change the 1 to a 0
|
if(data.limiter_threshold > 3.5) {
|
||||||
fatal("Nuh uh (limiter threshold cant be bigger than 4)\n");
|
fatal("Limiter threshold too high!\n");
|
||||||
}
|
}
|
||||||
} else if(strcmp("-rdsvolume", arg)==0 && param != NULL) {
|
} else if(strcmp("-rdsvolume", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
rds_volume = atof(param);
|
data.rds_volume = atof(param);
|
||||||
} else if(strcmp("-pilotvolume", arg)==0 && param != NULL) {
|
|
||||||
i++;
|
|
||||||
pilot_volume = atof(param);
|
|
||||||
} else if(strcmp("-pty", arg)==0 && param != NULL) {
|
} else if(strcmp("-pty", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
pty = atoi(param);
|
data.pty = atoi(param);
|
||||||
} else if(strcmp("-gpiopin", arg)==0 && param != NULL) {
|
} else if(strcmp("-gpiopin", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
printf("GPIO pin setting disabled, mod librpitx and pifmsa (pifm simply advanced) for this\n");
|
printf("GPIO pin setting disabled, mod librpitx and pifmsa (pifm simply advanced) for this\n");
|
||||||
|
|
@ -264,61 +303,61 @@ int main(int argc, char **argv) {
|
||||||
// }
|
// }
|
||||||
} else if(strcmp("-disablelogging", arg)==0) {
|
} else if(strcmp("-disablelogging", arg)==0) {
|
||||||
i++;
|
i++;
|
||||||
log = 0;
|
data.log = 0;
|
||||||
} else if(strcmp("-ta", arg)==0) {
|
} else if(strcmp("-ta", arg)==0) {
|
||||||
i++;
|
i++;
|
||||||
ta = 1;
|
data.ta = 1;
|
||||||
} else if(strcmp("-bfr", arg)==0) {
|
} else if(strcmp("-bfr", arg)==0) {
|
||||||
i++;
|
i++;
|
||||||
bypassfreqrange = 1;
|
bypassfreqrange = 1;
|
||||||
} else if(strcmp("-tp", arg)==0) {
|
} else if(strcmp("-tp", arg)==0) {
|
||||||
i++;
|
i++;
|
||||||
tp = 1;
|
data.tp = 1;
|
||||||
} else if(strcmp("-ctl", arg)==0 && param != NULL) {
|
} else if(strcmp("-ctl", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
control_pipe = param;
|
data.control_pipe = param;
|
||||||
} else if(strcmp("-deviation", arg)==0 && param != NULL) {
|
} else if(strcmp("-deviation", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
if(strcmp("small", param)==0) {
|
if(strcmp("mono", param)==0) {
|
||||||
deviation = 50000;
|
data.deviation = 50000;
|
||||||
} else if(strcmp("nfm", param)==0) {
|
} else if(strcmp("nfm", param)==0) {
|
||||||
deviation = 2500;
|
data.deviation = 2500;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deviation = atoi(param);
|
data.deviation = atoi(param);
|
||||||
}
|
}
|
||||||
} else if(strcmp("-rawchannels", arg)==0 && param != NULL) {
|
} else if(strcmp("-rawchannels", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
rawChannels = atoi(param);
|
data.rawChannels = atoi(param);
|
||||||
} else if(strcmp("-rawsamplerate", arg)==0 && param != NULL) {
|
} else if(strcmp("-rawsamplerate", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
rawSampleRate = atoi(param);
|
data.rawSampleRate = atoi(param);
|
||||||
} else if(strcmp("-cutofffreq", arg)==0 && param != NULL) {
|
} else if(strcmp("-cutofffreq", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
cutofffreq = atoi(param);
|
data.cutoff_freq = atof(param);
|
||||||
} else if(strcmp("-audiogain", arg)==0 && param != NULL) {
|
} else if(strcmp("-audiogain", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
gain = atoi(param);
|
data.audio_gain = atof(param);
|
||||||
} else if(strcmp("-power", arg)==0 && param != NULL) {
|
} else if(strcmp("-power", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
int tpower = atoi(param);
|
int tpower = atoi(param);
|
||||||
if(tpower > 7 || tpower < 0) fatal("Power can be between 0 and 7");
|
if(tpower > 7 || tpower < 0) fatal("Power can be between 0 and 7");
|
||||||
else power = tpower;
|
data.power = tpower;
|
||||||
} else if(strcmp("-raw", arg)==0) {
|
} else if(strcmp("-raw", arg)==0) {
|
||||||
i++;
|
i++;
|
||||||
raw = 1;
|
data.raw = 1;
|
||||||
} else if(strcmp("-disablerds", arg)==0) {
|
} else if(strcmp("-disablerds", arg)==0) {
|
||||||
i++;
|
i++;
|
||||||
drds = 1;
|
data.drds = 1;
|
||||||
} else if(strcmp("-disablestereo", arg)==0) {
|
} else if(strcmp("-disablestereo", arg)==0) {
|
||||||
i++;
|
i++;
|
||||||
dstereo = 1;
|
data.disablestereo = 1;
|
||||||
} else if(strcmp("-disablecompressor", arg)==0) {
|
} else if(strcmp("-disablecompressor", arg)==0) {
|
||||||
i++;
|
i++;
|
||||||
enable_compressor = 0;
|
data.enablecompressor = 0;
|
||||||
} else if(strcmp("-disablect", arg)==0) {
|
} else if(strcmp("-disablect", arg)==0) {
|
||||||
i++;
|
i++;
|
||||||
ct = 0;
|
data.rds_ct_enabled = 0;
|
||||||
} else if(strcmp("-preemphasis", arg)==0 && param != NULL) {
|
} else if(strcmp("-preemphasis", arg)==0 && param != NULL) {
|
||||||
i++;
|
i++;
|
||||||
if(strcmp("us", param)==0) {
|
if(strcmp("us", param)==0) {
|
||||||
|
|
@ -336,7 +375,8 @@ int main(int argc, char **argv) {
|
||||||
af_size++;
|
af_size++;
|
||||||
alternative_freq[af_size] = (int)(10*atof(param))-875;
|
alternative_freq[af_size] = (int)(10*atof(param))-875;
|
||||||
if(alternative_freq[af_size] < 1 || alternative_freq[af_size] > 204)
|
if(alternative_freq[af_size] < 1 || alternative_freq[af_size] > 204)
|
||||||
fatal("Alternative Frequency has to be set in range of 87.6 Mhz - 107.9 Mhz\n"); //honestly i have no idea why 87.5 and 108 isn't in here, i copied this code, okay?
|
fatal("Alternative Frequency has to be set in range of 87.6 Mhz - 107.9 Mhz\n");
|
||||||
|
data.af_array = alternative_freq;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fatal("Unrecognised argument: %s.\n"
|
fatal("Unrecognised argument: %s.\n"
|
||||||
|
|
@ -344,23 +384,11 @@ int main(int argc, char **argv) {
|
||||||
" [-ps ps_text] [-rt rt_text] [-ctl control_pipe] [-pty program_type] [-raw play raw audio from stdin] [-disablerds] [-af alt freq] [-preemphasis us] [-rawchannels when using the raw option you can change this] [-rawsamplerate same business] [-deviation the deviation, default is 75000] [-tp] [-ta]\n", arg);
|
" [-ps ps_text] [-rt rt_text] [-ctl control_pipe] [-pty program_type] [-raw play raw audio from stdin] [-disablerds] [-af alt freq] [-preemphasis us] [-rawchannels when using the raw option you can change this] [-rawsamplerate same business] [-deviation the deviation, default is 75000] [-tp] [-ta]\n", arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(compressorchanges) {
|
|
||||||
printf("You've changed the compressor settings, just don't set it too low, so the deviation won't go crazy\n");
|
|
||||||
}
|
|
||||||
if(limiterchanges) {
|
|
||||||
if(limiter_threshold > 0.8) {
|
|
||||||
printf("You changed the limiter settings, audio might be quiet now\n");
|
|
||||||
} else { //we've incremented it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (69 lol)
|
|
||||||
printf("You changed the limiter settings, be careful.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!enable_compressor) {
|
|
||||||
printf("DUDE YOU ARE CRAZY?\n");
|
|
||||||
}
|
|
||||||
alternative_freq[0] = af_size;
|
alternative_freq[0] = af_size;
|
||||||
int FifoSize=DATA_SIZE*2;
|
int FifoSize=DATA_SIZE*2;
|
||||||
//fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false, gpiopin); //you can mod
|
//fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false, gpiopin); //you can mod
|
||||||
fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false);
|
fmmod=new ngfmdmasync(data.carrier_freq,228000,14,FifoSize, false);
|
||||||
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, control_pipe, pty, alternative_freq, raw, drds, preemp, power, rawSampleRate, rawChannels, deviation, ta, tp, cutofffreq, gain, compressor_decay, compressor_attack, compressor_max_gain_recip, enable_compressor, ct, rds_volume, pilot_volume, dstereo, log, limiter_threshold);
|
int errcode = tx(&data);
|
||||||
terminate(errcode);
|
terminate(errcode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ void get_rds_group(int *buffer, int stereo, int ct_clock_enabled) { //ptyn?
|
||||||
if(!get_rds_ct_group(blocks, ct_clock_enabled)) { // CT (clock time) has priority on other group types (when its on)
|
if(!get_rds_ct_group(blocks, ct_clock_enabled)) { // CT (clock time) has priority on other group types (when its on)
|
||||||
if(state < 4) {
|
if(state < 4) {
|
||||||
blocks[1] = 0x0000 | rds_params.tp << 10 | rds_params.pty << 5 | rds_params.ta << 4 | rds_params.ms << 3 | ps_state;
|
blocks[1] = 0x0000 | rds_params.tp << 10 | rds_params.pty << 5 | rds_params.ta << 4 | rds_params.ms << 3 | ps_state;
|
||||||
blocks[1] |= ((rds_params.di >> (3 - ps_state)) & 0x01) << 2; // from micrords
|
blocks[1] |= ((rds_params.di >> (3 - ps_state)) & 0x01) << 2;
|
||||||
if(rds_params.af[0]) { // AF
|
if(rds_params.af[0]) { // AF
|
||||||
if(af_state == 0) {
|
if(af_state == 0) {
|
||||||
blocks[2] = (rds_params.af[0] + 224) << 8 | rds_params.af[1]; // Send number of AFs and the first AF
|
blocks[2] = (rds_params.af[0] + 224) << 8 | rds_params.af[1]; // Send number of AFs and the first AF
|
||||||
|
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
/*
|
|
||||||
PiFmRds - FM/RDS transmitter for the Raspberry Pi
|
|
||||||
Copyright (C) 2014 Christophe Jacquet, F8FTK
|
|
||||||
|
|
||||||
See https://github.com/ChristopheJacquet/PiFmRds
|
|
||||||
|
|
||||||
rds_wav.c is a test program that writes a RDS baseband signal to a WAV
|
|
||||||
file. It requires libsndfile.
|
|
||||||
|
|
||||||
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 <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <sndfile.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "rds.h"
|
|
||||||
#include "fm_mpx.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define LENGTH 114000
|
|
||||||
|
|
||||||
|
|
||||||
/* Simple test program */
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
if(argc < 4) {
|
|
||||||
fprintf(stderr, "Error: missing argument.\n");
|
|
||||||
fprintf(stderr, "Syntax: rds_wav <in_audio.wav> <out_mpx.wav> <text>\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_rds_pi(0x1234);
|
|
||||||
set_rds_ps(argv[3]);
|
|
||||||
set_rds_rt(argv[3]);
|
|
||||||
|
|
||||||
char *in_file = argv[1];
|
|
||||||
if(strcmp("NONE", argv[1]) == 0) in_file = NULL;
|
|
||||||
|
|
||||||
if(fm_mpx_open(in_file, LENGTH, 0, 0, 44100, 2) != 0) {
|
|
||||||
printf("Could not setup FM mulitplex generator.\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set the format of the output file
|
|
||||||
SNDFILE *outf;
|
|
||||||
SF_INFO sfinfo;
|
|
||||||
|
|
||||||
sfinfo.frames = LENGTH;
|
|
||||||
sfinfo.samplerate = 228000;
|
|
||||||
sfinfo.channels = 1;
|
|
||||||
sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
|
|
||||||
sfinfo.sections = 1;
|
|
||||||
sfinfo.seekable = 0;
|
|
||||||
|
|
||||||
// Open the output file
|
|
||||||
char *out_file = argv[2];
|
|
||||||
if (! (outf = sf_open(out_file, SFM_WRITE, &sfinfo))) {
|
|
||||||
fprintf(stderr, "Error: could not open output file %s.\n", out_file);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
float mpx_buffer[LENGTH];
|
|
||||||
|
|
||||||
for(int j=0; j<40; j++) {
|
|
||||||
if( fm_mpx_get_samples(mpx_buffer, 0) < 0 ) break;
|
|
||||||
|
|
||||||
// scale samples
|
|
||||||
for(int i=0; i<LENGTH; i++) {
|
|
||||||
mpx_buffer[i] /= 10.;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sf_write_float(outf, mpx_buffer, LENGTH) != LENGTH) {
|
|
||||||
fprintf(stderr, "Error: writing to file %s.\n", argv[1]);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sf_close(outf) ) {
|
|
||||||
fprintf(stderr, "Error: closing file %s.\n", argv[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fm_mpx_close();
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
sudo ./pifmrds -bfr sekretnawiadomosc -freq "$1" -audio "$2
|
sudo ./pifmrds -bfr secretmessage -freq "$1" -audio "$2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue