declare functions and variables static, if so

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

View File

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

View File

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