mirror of https://github.com/drowe67/LPCNet.git
traced click problem to PRNG rteunfign RAND_MAX, fixed now, and lpcnet_enc/lpcnet_dec work OK on Windows (wine) without clicks
parent
7878ce9074
commit
43bf0950f9
|
|
@ -56,8 +56,8 @@ static RNN_INLINE int lin2ulaw(float x)
|
|||
}
|
||||
|
||||
|
||||
/** RNNoise wrapper for malloc(). To do your own dynamic allocation, all you need t
|
||||
o do is replace this function and rnnoise_free */
|
||||
/** RNNoise wrapper for malloc(). To do your own dynamic allocation,
|
||||
all you need to do is replace this function and rnnoise_free */
|
||||
#ifndef OVERRIDE_RNNOISE_ALLOC
|
||||
static RNN_INLINE void *rnnoise_alloc (size_t size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,13 @@
|
|||
|
||||
1;
|
||||
|
||||
function check_vec(fig_num, name, vec1, vec2)
|
||||
function [vec1 vec2] = check_vec(fig_num, name, vec1, vec2)
|
||||
# vector may be supplied as matrix that we need to reshape, e.g. for excitation signal
|
||||
[rows cols] = size(vec1);
|
||||
if cols != 1
|
||||
vec1 = reshape(vec1', 1, rows*cols);
|
||||
vec2= reshape(vec2', 1, rows*cols);
|
||||
end
|
||||
figure(fig_num); clf;
|
||||
plot(vec1); hold on; plot(vec2); hold off;
|
||||
title(name);
|
||||
|
|
@ -79,9 +85,9 @@ check_vec(fig++, "pitch_gain", linux(:,st), windows(:,st)); st += n_pitch_gain;
|
|||
en = st + n_lpc-1; check_matrix(fig++, "lpc", linux(:,st:en), windows(:,st:en)); st += n_lpc;
|
||||
en = st + n_condition-1; check_matrix(fig++, "condition", linux(:,st:en), windows(:,st:en)); st += n_condition;
|
||||
en = st + n_gru_a-1; check_matrix(fig++, "gru a", linux(:,st:en), windows(:,st:en)); st += n_gru_a;
|
||||
en = st + n_last_sig-1; check_matrix(fig++, "last_sig", linux(:,st:en), windows(:,st:en)); st += n_last_sig;
|
||||
en = st + n_pred-1; check_matrix(fig++, "pred", linux(:,st:en), windows(:,st:en)); st += n_pred;
|
||||
en = st + n_exc-1; check_matrix(fig++, "exc", linux(:,st:en), windows(:,st:en)); st += n_exc;
|
||||
en = st + n_pcm-1; check_matrix(fig++, "pcm", linux(:,st:en), windows(:,st:en)); st += n_pcm;
|
||||
|
||||
en = st + n_last_sig-1; last_sig = check_vec(fig++, "last_sig", linux(:,st:en), windows(:,st:en)); st += n_last_sig;
|
||||
en = st + n_pred-1; pred = check_vec(fig++, "pred", linux(:,st:en), windows(:,st:en)); st += n_pred;
|
||||
en = st + n_exc-1; exc = check_vec(fig++, "exc", linux(:,st:en), windows(:,st:en)); st += n_exc;
|
||||
en = st + n_pcm-1; pcm = check_vec(fig++, "pcm", linux(:,st:en), windows(:,st:en)); st += n_pcm;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ p=$PWD
|
|||
|
||||
# Windows
|
||||
cd build_win/src && make tdump test_lpcnet lpcnet_enc lpcnet_dec
|
||||
wine lpcnet_enc.exe --infile ../../wav/$w.wav --outfile $w.bin
|
||||
wine lpcnet_dec.exe --infile $w.bin --outfile $w'q_out.raw'
|
||||
wine lpcnet_enc.exe -s --infile ../../wav/$w.wav --outfile $w.bin
|
||||
wine lpcnet_dec.exe -s --infile $w.bin --outfile $w'q_out.raw'
|
||||
#wine tdump.exe ../../wav/$w.wav $w.f32
|
||||
#wine test_lpcnet.exe $w.f32 $w'_out.raw'
|
||||
cd $p
|
||||
|
||||
# Linux
|
||||
cd build_linux/src && make test_lpcnet lpcnet_enc lpcnet_dec diff32
|
||||
./lpcnet_dec --infile ../../build_win/src/$w.bin --outfile $w'q_out'.raw
|
||||
./lpcnet_dec -s --infile ../../build_win/src/$w.bin --outfile $w'q_out'.raw
|
||||
#./test_lpcnet ../../build_win/src/$w.f32 $w'_out.raw'
|
||||
./diff32 test_lpcnet_statesq.f32 ../../build_win/src/test_lpcnet_statesq.f32 1842
|
||||
cd $p
|
||||
|
|
|
|||
|
|
@ -203,6 +203,9 @@ void lpcnet_synthesize(LPCNetState *lpcnet, short *output, const float *features
|
|||
pred_ulaw = lin2ulaw(pred);
|
||||
run_sample_network(&lpcnet->nnet, pdf, condition, gru_a_condition, lpcnet->last_exc, last_sig_ulaw, pred_ulaw);
|
||||
exc = sample_from_pdf(pdf, DUAL_FC_OUT_SIZE, MAX16(0, 1.5f*pitch_gain - .5f), PDF_FLOOR);
|
||||
if (fabs(ulaw2lin(exc)) > 30000) {
|
||||
fprintf(stderr, "count: %d exc: %d %f\n", count, exc, (float)ulaw2lin(exc));
|
||||
}
|
||||
pcm = pred + ulaw2lin(exc);
|
||||
RNN_MOVE(&lpcnet->last_sig[1], &lpcnet->last_sig[0], LPC_ORDER-1);
|
||||
lpcnet->last_sig[0] = pcm;
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ void accum_embedding(const EmbeddingLayer *layer, float *output, int input)
|
|||
|
||||
/* needed to replace Windows/gcc rand() with our own rand() function
|
||||
to get click free synthesised audio - not sure why */
|
||||
#define NNET_RAND_MAX 32767
|
||||
#define NNET_RAND_MAX 32768
|
||||
static uint32_t next = 1;
|
||||
uint16_t nnet_rand(void) {
|
||||
next = next * 1103515245 + 12345;
|
||||
|
|
@ -402,12 +402,14 @@ int sample_from_pdf(const float *pdf, int N, float exp_boost, float pdf_floor)
|
|||
tmp[i] = tmp[i-1] + MAX16(0, norm*tmp[i] - pdf_floor);
|
||||
}
|
||||
/* Do the sampling (from the cdf). */
|
||||
float arand = ((float)nnet_rand()/NNET_RAND_MAX);
|
||||
float annr = (float)nnet_rand();
|
||||
float arand = (annr/NNET_RAND_MAX);
|
||||
r = tmp[N-1] * arand;
|
||||
|
||||
for (i=0;i<N-1;i++)
|
||||
{
|
||||
if (r < tmp[i]) return i;
|
||||
}
|
||||
fprintf(stderr, "DUAL_FC_OUT_SIZE: %d annr: %f arand: %f\n", DUAL_FC_OUT_SIZE, annr, arand);
|
||||
return N-1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue