declare functions and variables static, if so

This commit is contained in:
Holger Vogt 2020-08-01 17:16:48 +02:00
parent 4acb405d8a
commit c637a4f776
2 changed files with 40 additions and 41 deletions

View File

@ -10,16 +10,16 @@
#include "ngspice/ngspice.h"
int o_samplerate = 48000;
int o_sndfmt = (SF_FORMAT_WAV | SF_FORMAT_PCM_24);
float o_mult = 1.0;
float o_off = 0.0;
static int o_samplerate = 48000;
static int o_sndfmt = (SF_FORMAT_WAV | SF_FORMAT_PCM_24);
static float o_mult = 1.0;
static float o_off = 0.0;
////////////////////////////////// aliki //////////////////////////////////
#define HDRSIZE 256
void* my_open_aliki(char* fn, int nchannel) {
static void* my_open_aliki(char* fn, int nchannel) {
char p[HDRSIZE];
FILE* aldfile;
if ((aldfile = fopen(fn, "w")) == 0) {
@ -49,11 +49,11 @@ void* my_open_aliki(char* fn, int nchannel) {
return ((void*)aldfile);
}
size_t my_write_aliki(void* d, float val) {
static size_t my_write_aliki(void* d, float val) {
return(fwrite(&val, sizeof(float), 1, (FILE*)d));
}
void my_close_aliki(void* d) {
static void my_close_aliki(void* d) {
fclose((FILE*)d);
}
@ -67,8 +67,7 @@ typedef struct {
float* sf_buf;
} SSFILE;
void* my_open_sf(char* fn, int nchannel) {
static void* my_open_sf(char* fn, int nchannel) {
SSFILE* d = calloc(1, sizeof(SSFILE));
SF_INFO sfinfo;
@ -94,7 +93,7 @@ void* my_open_sf(char* fn, int nchannel) {
return ((void*)d);
}
int my_write_sf(void* d, float val) {
static int my_write_sf(void* d, float val) {
SSFILE* p = (SSFILE*)d;
p->sf_buf[p->sf_bptr++] = val;
if (p->sf_bptr >= p->sf_channels) {
@ -104,7 +103,7 @@ int my_write_sf(void* d, float val) {
return (1);
}
void my_close_sf(void* d) {
static void my_close_sf(void* d) {
sf_close(((SSFILE*)d)->outfile);
free(((SSFILE*)d)->sf_buf);
free((SSFILE*)d);
@ -121,15 +120,15 @@ typedef struct SP_BUF {
double* val;
} SP_BUF;
void (*p_close)(void*);
void* (*p_open)(char*, int);
int (*p_write)(void*, float);
void* outfile;
uint32_t sample;
int sp_nchannel;
static void (*p_close)(void*);
static void* (*p_open)(char*, int);
static int (*p_write)(void*, float);
static void* outfile;
static uint32_t sample;
static int sp_nchannel;
#define SP_MAX (2)
SP_BUF* sp_buf;
char* filename = NULL;
static char* filename = NULL;
#define HAVE_SRC
@ -138,15 +137,15 @@ char* filename = NULL;
#else
#include <samplerate.h>
#define OBUFSIZE 256
int oversampling = 64;
static int oversampling = 64;
#define OVERSAMPLING ((double) oversampling)
SRC_STATE* rabbit;
int rabbit_err;
float* interleaved;
float* resampled;
int iptr = 0;
static SRC_STATE* rabbit;
static int rabbit_err;
static float* interleaved;
static float* resampled;
static int iptr = 0;
int resample_wrapper(void* d, float val) {
static int resample_wrapper(void* d, float val) {
interleaved[iptr++] = val;
size_t ibufsize = sp_nchannel * OBUFSIZE * oversampling;
size_t obufsize = sp_nchannel * OBUFSIZE;

View File

@ -9,28 +9,28 @@
#include <inttypes.h>
#define VS_BUFSIZ 1024
#include "ngspice/ngspice.h""
#include "ngspice/ngspice.h"
#define MAX_D 6
char* (sources[MAX_D]);
static char* (sources[MAX_D]);
SNDFILE* m_sndfile[MAX_D];
int m_channels[MAX_D]; //< number of channles in src-file
uint32_t m_samplerate[MAX_D]; //< samplerate of source
uint32_t m_frames[MAX_D]; //< duration of source in frames
float* (interleaved[MAX_D]); //< internal soundfile buffer
uint32_t ilb_start[MAX_D]; //< first sample in buffer
uint32_t ilb_end[MAX_D]; //< last sample in buffer
static SNDFILE* m_sndfile[MAX_D];
static int m_channels[MAX_D]; //< number of channles in src-file
static uint32_t m_samplerate[MAX_D]; //< samplerate of source
static uint32_t m_frames[MAX_D]; //< duration of source in frames
static float* (interleaved[MAX_D]); //< internal soundfile buffer
static uint32_t ilb_start[MAX_D]; //< first sample in buffer
static uint32_t ilb_end[MAX_D]; //< last sample in buffer
#define HAVE_SRC
#ifdef HAVE_SRC
#include <samplerate.h>
double src_ratio = 64.0;
#define SRC_RATIO src_ratio
SRC_STATE* rabbit[MAX_D];
int rabbit_err[MAX_D];
float* (resampled[MAX_D]); //< internal soundfile buffer
static double src_ratio = 64.0;
#define SRC_RATIO 64
static SRC_STATE* rabbit[MAX_D];
static int rabbit_err[MAX_D];
static float* (resampled[MAX_D]); //< internal soundfile buffer
#endif
void vsjack_initialize(void) {
@ -102,7 +102,7 @@ void load_buffer(int d, uint32_t sample) {
sf_seek(m_sndfile[d], sample, SEEK_SET);
ilb_start[d] = sample;
uint32_t nframes;
if ((nframes = sf_readf_float(m_sndfile[d], (interleaved[d]), VS_BUFSIZ)) > 0) {
if ((nframes = (uint32_t)sf_readf_float(m_sndfile[d], (interleaved[d]), VS_BUFSIZ)) > 0) {
ilb_end[d] = ilb_start[d] + nframes;
}
else {
@ -139,7 +139,7 @@ double get_value(int d, double time, int channel) {
}
#ifdef HAVE_SRC
int offset = floor((sample - ilb_start[d]) * SRC_RATIO);
int offset = (int)floor((sample - ilb_start[d]) * SRC_RATIO);
if (offset > VS_BUFSIZ * SRC_RATIO || offset < 0) {
printf("value not in buffer:%i.\n", d);
return (0.0); // nan ?