parent
f3a243fd1f
commit
70a1c3fc6e
|
|
@ -506,7 +506,7 @@ com_sndprint(wordlist* wl)
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
snd_close();
|
snd_close();
|
||||||
printf("wrote %i audio-samples from %i data-points\n", i / ngood, j);
|
printf("Info: wrote %i audio-samples from %i data-points\n", i / ngood, j);
|
||||||
/* Get rid of the vectors. */
|
/* Get rid of the vectors. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -522,7 +522,7 @@ com_sndparam(wordlist* wl)
|
||||||
int fmt = -1;
|
int fmt = -1;
|
||||||
double mult = 1.0;
|
double mult = 1.0;
|
||||||
double off = 0.0;
|
double off = 0.0;
|
||||||
int oversampling = 1;
|
int oversampling = 4;
|
||||||
|
|
||||||
while (wl) {
|
while (wl) {
|
||||||
copypath = cp_unquote(wl->wl_word);
|
copypath = cp_unquote(wl->wl_word);
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ typedef struct SP_BUF {
|
||||||
|
|
||||||
static void (*p_close)(void*);
|
static void (*p_close)(void*);
|
||||||
static void* (*p_open)(char*, int);
|
static void* (*p_open)(char*, int);
|
||||||
static size_t (*p_write)(void*, float);
|
static size_t (*p_write)(void*, float);
|
||||||
static void* outfile;
|
static void* outfile;
|
||||||
static uint32_t sample;
|
static uint32_t sample;
|
||||||
static int sp_nchannel;
|
static int sp_nchannel;
|
||||||
|
|
@ -135,7 +135,7 @@ static char* filename = NULL;
|
||||||
#else
|
#else
|
||||||
#include <samplerate.h>
|
#include <samplerate.h>
|
||||||
#define OBUFSIZE 256
|
#define OBUFSIZE 256
|
||||||
static int oversampling = 64;
|
static int oversampling = 4;
|
||||||
#define OVERSAMPLING ((double) oversampling)
|
#define OVERSAMPLING ((double) oversampling)
|
||||||
static SRC_STATE* rabbit;
|
static SRC_STATE* rabbit;
|
||||||
static int rabbit_err;
|
static int rabbit_err;
|
||||||
|
|
@ -166,11 +166,11 @@ static int resample_wrapper(void* d, float val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src_data.output_frames_gen * sp_nchannel != obufsize) {
|
if (src_data.output_frames_gen * sp_nchannel != obufsize) {
|
||||||
fprintf(stderr, "resample warning: out %li != %i\n", src_data.output_frames_gen * sp_nchannel, (int)obufsize);
|
fprintf(stderr, "Warning: resample: out %li != %i\n", src_data.output_frames_gen * sp_nchannel, (int)obufsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src_data.input_frames_used * sp_nchannel != iptr) {
|
if (src_data.input_frames_used * sp_nchannel != iptr) {
|
||||||
printf("resample warning: in: %li != %i\n", src_data.input_frames_used * sp_nchannel, iptr);
|
fprintf(stderr, "Warning: resample: in: %li != %i\n", src_data.input_frames_used * sp_nchannel, iptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -224,7 +224,7 @@ void snd_init(int nchannel) {
|
||||||
if (!filename) snd_configure("spice.wav", 48000, o_sndfmt, o_mult, o_off, oversampling);
|
if (!filename) snd_configure("spice.wav", 48000, o_sndfmt, o_mult, o_off, oversampling);
|
||||||
outfile = p_open(filename, nchannel);
|
outfile = p_open(filename, nchannel);
|
||||||
sp_nchannel = nchannel;
|
sp_nchannel = nchannel;
|
||||||
sp_buf = calloc(nchannel, sizeof(SP_BUF));
|
sp_buf = calloc(SP_MAX, sizeof(SP_BUF));
|
||||||
for (i = 0; i < SP_MAX; i++) {
|
for (i = 0; i < SP_MAX; i++) {
|
||||||
sp_buf[i].tme = 0.0;
|
sp_buf[i].tme = 0.0;
|
||||||
sp_buf[i].val = calloc(nchannel, sizeof(double));
|
sp_buf[i].val = calloc(nchannel, sizeof(double));
|
||||||
|
|
@ -242,6 +242,7 @@ void snd_init(int nchannel) {
|
||||||
int snd_send(double tme, int c, double out) {
|
int snd_send(double tme, int c, double out) {
|
||||||
int i;
|
int i;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
static bool shown = FALSE;
|
||||||
if (c == 0) for (i = SP_MAX - 1; i > 0; i--) {
|
if (c == 0) for (i = SP_MAX - 1; i > 0; i--) {
|
||||||
memcpy(&(sp_buf[i]), &(sp_buf[i - 1]), sizeof(SP_BUF));
|
memcpy(&(sp_buf[i]), &(sp_buf[i - 1]), sizeof(SP_BUF));
|
||||||
}
|
}
|
||||||
|
|
@ -258,10 +259,16 @@ int snd_send(double tme, int c, double out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sample) < ceil(tme * OVERSAMPLING)) {
|
if ((sample) < ceil(tme * OVERSAMPLING)) {
|
||||||
if (!(sp_buf[0].tme > sample)) printf("error 1 %f !> %i\n", sp_buf[0].tme, sample);
|
if (!(sp_buf[0].tme > sample))
|
||||||
if ((sp_buf[1].tme > sample)) printf("error 2 %f !< %i\n", sp_buf[1].tme, sample);
|
fprintf(stderr, "Error: Oversampling error 1 %f !> %i\n", sp_buf[0].tme, sample);
|
||||||
#if 1 // DEBUG
|
if (!shown && (sp_buf[1].tme > sample)) {
|
||||||
if ((sp_buf[0].tme - sample) > 1.0) printf("error 3 large timestep: dv/dt=%e dt:%f dv:%e\n",
|
fprintf(stderr, "Error: Oversampling error 2 %f !< %i\n", sp_buf[1].tme, sample);
|
||||||
|
fprintf(stderr, " Time step too large\n");
|
||||||
|
shown = TRUE;
|
||||||
|
}
|
||||||
|
#if 0 // DEBUG
|
||||||
|
if ((sp_buf[0].tme - sample) > 1.0)
|
||||||
|
fprintf(stderr, "Error: Oversampling error 3 large timestep: dv/dt=%e dt:%f dv:%e\n",
|
||||||
(sp_buf[0].val[c] - sp_buf[1].val[c]) / (sp_buf[0].tme - sample),
|
(sp_buf[0].val[c] - sp_buf[1].val[c]) / (sp_buf[0].tme - sample),
|
||||||
(sp_buf[0].tme - sample), (sp_buf[0].val[c] - sp_buf[1].val[c]));
|
(sp_buf[0].tme - sample), (sp_buf[0].val[c] - sp_buf[1].val[c]));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue