mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
remove some includes as well as add missing functions
This commit is contained in:
@@ -5,7 +5,8 @@ float dbr_to_deviation(float dbr) {
|
||||
}
|
||||
|
||||
float deviation_to_dbr(float deviation) {
|
||||
return 10 * log10f((deviation + 1e-6f) / 19000.0f);
|
||||
if(deviation == 0.0f) return -100.0f;
|
||||
return 10 * log10f(deviation / 19000.0f);
|
||||
}
|
||||
|
||||
void init_modulation_power_measure(MPXPowerMeasurement* mpx, int sample_rate) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
#ifdef BS412_DEBUG
|
||||
#include "../lib/debug.h"
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "constants.h"
|
||||
#include "../lib/optimization.h"
|
||||
#include "oscillator.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
39
io/audio.c
39
io/audio.c
@@ -32,6 +32,38 @@ int init_PulseInputDevice(PulseInputDevice* dev, int sample_rate, int channels,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int init_PulseInputDevicef(PulseInputDevice* dev, int sample_rate, int channels, char* app_name, char *stream_name, char* device, pa_buffer_attr* buffer_attr, enum pa_sample_format format) {
|
||||
if (dev->initialized) return -1;
|
||||
pa_sample_spec sample_spec = {
|
||||
.format = format,
|
||||
.channels = channels,
|
||||
.rate = sample_rate
|
||||
};
|
||||
pa_buffer_attr new_buffer_attr = *buffer_attr;
|
||||
dev->sample_spec = sample_spec;
|
||||
dev->buffer_attr = new_buffer_attr;
|
||||
|
||||
dev->app_name = strdup(app_name);
|
||||
dev->stream_name = strdup(stream_name);
|
||||
dev->device = strdup(device);
|
||||
|
||||
int error;
|
||||
dev->dev = pa_simple_new(
|
||||
NULL,
|
||||
app_name,
|
||||
PA_STREAM_RECORD,
|
||||
device,
|
||||
stream_name,
|
||||
&sample_spec,
|
||||
NULL,
|
||||
&new_buffer_attr,
|
||||
&error
|
||||
);
|
||||
if (!dev->dev) return error;
|
||||
dev->initialized = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int read_PulseInputDevice(PulseInputDevice* dev, float* buffer, size_t size) {
|
||||
if (!dev->initialized) return -1;
|
||||
int error;
|
||||
@@ -39,6 +71,13 @@ int read_PulseInputDevice(PulseInputDevice* dev, float* buffer, size_t size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int read_PulseInputDevicef(PulseInputDevice* dev, void* buffer, size_t size) {
|
||||
if (!dev->initialized) return -1;
|
||||
int error;
|
||||
if (pa_simple_read(dev->dev, buffer, size, &error) < 0) return error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void free_PulseInputDevice(PulseInputDevice* dev) {
|
||||
if (dev->dev && dev->initialized) pa_simple_free(dev->dev);
|
||||
free(dev->app_name);
|
||||
|
||||
@@ -17,7 +17,9 @@ typedef struct
|
||||
} PulseInputDevice;
|
||||
|
||||
int init_PulseInputDevice(PulseInputDevice *dev, int sample_rate, int channels, char *app_name, char *stream_name, char *device, pa_buffer_attr *buffer_attr);
|
||||
int init_PulseInputDevicef(PulseInputDevice *dev, int sample_rate, int channels, char *app_name, char *stream_name, char *device, pa_buffer_attr *buffer_attr, pa_sample_format_t format);
|
||||
int read_PulseInputDevice(PulseInputDevice *dev, float *buffer, size_t size);
|
||||
int read_PulseInputDevicef(PulseInputDevice *dev, void *buffer, size_t size);
|
||||
void free_PulseInputDevice(PulseInputDevice *dev);
|
||||
|
||||
typedef PulseInputDevice PulseOutputDevice;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
#include <liquid/liquid.h>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
@@ -8,12 +6,9 @@
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define buffer_maxlength 12288
|
||||
#define buffer_tlength_fragsize 12288
|
||||
|
||||
Reference in New Issue
Block a user