assert(w > 0.0); assert (w <= PI);
- m = floor(w/model->Wo + 0.5);
+ m = floorf(w/model->Wo + 0.5);
f = (w - m*model->Wo)/w;
assert(f <= 1.0);
if (m < 1) {
- log_amp = f*log10(model->A[1] + 1E-6);
+ log_amp = f*log10f(model->A[1] + 1E-6);
}
else if ((m+1) > model->L) {
- log_amp = (1.0-f)*log10(model->A[model->L] + 1E-6);
+ log_amp = (1.0-f)*log10f(model->A[model->L] + 1E-6);
}
else {
- log_amp = (1.0-f)*log10(model->A[m] + 1E-6) +
- f*log10(model->A[m+1] + 1E-6);
+ log_amp = (1.0-f)*log10f(model->A[m] + 1E-6) +
+ f*log10f(model->A[m+1] + 1E-6);
}
return log_amp;
/* Interpolate LPC energy in log domain */
- e = pow(10.0, (log10(prev_e) + log10(next_e))/2.0);
+ e = powf(10.0, (log10f(prev_e) + log10f(next_e))/2.0);
//printf(" interp: e: %f\n", e);
/* convert back to amplitudes */
float interp_energy(float prev_e, float next_e)
{
- return pow(10.0, (log10(prev_e) + log10(next_e))/2.0);
+ return powf(10.0, (log10f(prev_e) + log10f(next_e))/2.0);
}
float interp_energy2(float prev_e, float next_e, float weight)
{
- return pow(10.0, (1.0 - weight)*log10(prev_e) + weight*log10(next_e));
+ return powf(10.0, (1.0 - weight)*log10f(prev_e) + weight*log10f(next_e));
}
e = 0.0;
for(i=0; i<k; i++) {
diff = cb[j*k+i]-vec[i];
- e += pow(diff*w[i],2.0);
+ e += powf(diff*w[i],2.0);
}
if (e < beste) {
beste = e;
model->A[m] = Am;
}
- *snr = 10.0*log10(signal/noise);
+ *snr = 10.0*log10f(signal/noise);
TIMER_SAMPLE_AND_LOG2(tpf, " rec");
}
float norm;
norm = (Wo - Wo_min)/(Wo_max - Wo_min);
- index = floor(WO_LEVELS * norm + 0.5);
+ index = floorf(WO_LEVELS * norm + 0.5);
if (index < 0 ) index = 0;
if (index > (WO_LEVELS-1)) index = WO_LEVELS-1;
*/
for(i=0; i<=order; i++)
- ak[i] *= pow(0.994,(float)i);
+ ak[i] *= powf(0.994,(float)i);
roots = lpc_to_lsp(ak, order, lsp, 5, LSP_DELTA1);
if (roots != order) {
step = 25;
for(i=0; i<2; i++) {
lsp_hz = lsps[i]*4000.0/PI;
- lsp_hz = floor(lsp_hz/step + 0.5)*step;
+ lsp_hz = floorf(lsp_hz/step + 0.5)*step;
lsps[i] = lsp_hz*PI/4000.0;
if (i) {
if (lsps[i] == lsps[i-1])
step = 50;
for(i=2; i<4; i++) {
lsp_hz = lsps[i]*4000.0/PI;
- lsp_hz = floor(lsp_hz/step + 0.5)*step;
+ lsp_hz = floorf(lsp_hz/step + 0.5)*step;
lsps[i] = lsp_hz*PI/4000.0;
if (i) {
if (lsps[i] == lsps[i-1])
step = 100;
for(i=4; i<10; i++) {
lsp_hz = lsps[i]*4000.0/PI;
- lsp_hz = floor(lsp_hz/step + 0.5)*step;
+ lsp_hz = floorf(lsp_hz/step + 0.5)*step;
lsps[i] = lsp_hz*PI/4000.0;
if (i) {
if (lsps[i] == lsps[i-1])
float e_max = E_MAX_DB;
float norm;
- e = 10.0*log10(e);
+ e = 10.0*log10f(e);
norm = (e - e_min)/(e_max - e_min);
- index = floor(E_LEVELS * norm + 0.5);
+ index = floorf(E_LEVELS * norm + 0.5);
if (index < 0 ) index = 0;
if (index > (E_LEVELS-1)) index = E_LEVELS-1;
step = (e_max - e_min)/E_LEVELS;
e = e_min + step*(index);
- e = pow(10.0,e/10.0);
+ e = powf(10.0,e/10.0);
return e;
}
w[1] *= .3;
}
/* Higher weight if pitch is stable */
- if (fabs(x[0]-xp[0])<.2)
+ if (fabsf(x[0]-xp[0])<.2)
{
w[0] *= 2;
w[1] *= 1.5;
- } else if (fabs(x[0]-xp[0])>.5) /* Lower if not stable */
+ } else if (fabsf(x[0]-xp[0])>.5) /* Lower if not stable */
{
w[0] *= .5;
}
float Wo_min = TWO_PI/P_MAX;
float Wo_max = TWO_PI/P_MIN;
- x[0] = log10((model->Wo/PI)*4000.0/50.0)/log10(2);
- x[1] = 10.0*log10(1e-4 + *e);
+ x[0] = log10f((model->Wo/PI)*4000.0/50.0)/log10f(2);
+ x[1] = 10.0*log10f(1e-4 + *e);
compute_weights2(x, xq, w, ndim);
for (i=0;i<ndim;i++)
Wo = (2^x)*(PI*50)/4000;
*/
- model->Wo = pow(2.0, xq[0])*(PI*50.0)/4000.0;
+ model->Wo = powf(2.0, xq[0])*(PI*50.0)/4000.0;
/* bit errors can make us go out of range leading to all sorts of
probs like seg faults */
model->L = PI/model->Wo; /* if we quantise Wo re-compute L */
- *e = pow(10.0, xq[1]/10.0);
+ *e = powf(10.0, xq[1]/10.0);
}
/*---------------------------------------------------------------------------*\
if (e < 0.0) e = 0; /* occasional small negative energies due LPC round off I guess */
- x[0] = log10((model->Wo/PI)*4000.0/50.0)/log10(2);
- x[1] = 10.0*log10(1e-4 + e);
+ x[0] = log10f((model->Wo/PI)*4000.0/50.0)/log10f(2);
+ x[1] = 10.0*log10f(1e-4 + e);
compute_weights2(x, xq, w, ndim);
for (i=0;i<ndim;i++)
}
//printf("dec: %f %f\n", xq[0], xq[1]);
- model->Wo = pow(2.0, xq[0])*(PI*50.0)/4000.0;
+ model->Wo = powf(2.0, xq[0])*(PI*50.0)/4000.0;
/* bit errors can make us go out of range leading to all sorts of
probs like seg faults */
model->L = PI/model->Wo; /* if we quantise Wo re-compute L */
- *e = pow(10.0, xq[1]/10.0);
+ *e = powf(10.0, xq[1]/10.0);
}
for(i=0; i<M/2-NW/2; i++)
w[i] = 0.0;
for(i=M/2-NW/2,j=0; i<M/2+NW/2; i++,j++) {
- w[i] = 0.5 - 0.5*cos(TWO_PI*j/(NW-1));
+ w[i] = 0.5 - 0.5*cosf(TWO_PI*j/(NW-1));
m += w[i]*w[i];
}
for(i=M/2+NW/2; i<M; i++)
/* Normalise - makes freq domain amplitude estimation straight
forward */
- m = 1.0/sqrt(m*FFT_ENC);
+ m = 1.0/sqrtf(m*FFT_ENC);
for(i=0; i<M; i++) {
w[i] *= m;
}
}
}
- snr = 10.0*log10(sig/error);
+ snr = 10.0*log10f(sig/error);
if (snr > V_THRESH)
model->voiced = 1;
else
for(l=model->L/2; l<=model->L; l++) {
ehigh += model->A[l]*model->A[l];
}
- eratio = 10.0*log10(elow/ehigh);
+ eratio = 10.0*log10f(elow/ehigh);
/* Look for Type 1 errors, strongly V speech that has been
accidentally declared UV */
CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -nostartfiles -mcpu=cortex-m4
ifeq ($(FLOAT_TYPE), hard)
-#CFLAGS += -fsingle-precision-constant -Wdouble-promotion
-CFLAGS += -fsingle-precision-constant
+CFLAGS += -fsingle-precision-constant -Wdouble-promotion
+#CFLAGS += -fsingle-precision-constant
CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__FPU_PRESENT=1 -D__FPU_USED=1
else
CFLAGS += -msoft-float
###################################################
-all: libstm32f4.a $(PROJ_NAME).elf fft_test.elf dactest.elf
+all: libstm32f4.a $(PROJ_NAME).elf fft_test.elf ut_dac.elf
dl/$(PERIPHLIBZIP):
mkdir -p dl
DAC_TEST=$(PERIPHLIBDIR)/Project/STM32F4xx_StdPeriph_Examples/DAC/DAC_SignalsGeneration
DAC_TEST_SRCS=\
-$(DAC_TEST)/main.c \
+src/ut_dac.c \
$(DAC_TEST)/stm32f4xx_it.c \
$(DAC_TEST)/system_stm32f4xx.c \
$(PERIPHLIBDIR)/Utilities/STM32_EVAL/STM3240_41_G_EVAL/stm324xg_eval.c \
src/startup_stm32f4xx.s \
src/init.c
-dactest.elf: $(DAC_TEST_SRCS)
+ut_dac.elf: $(DAC_TEST_SRCS)
$(CC) $(CFLAGS) -DUSE_STM324xG_EVAL -I$(PERIPHLIBDIR)/Utilities/STM32_EVAL/STM3240_41_G_EVAL -I$(PERIPHLIBDIR)/Utilities/STM32_EVAL/Common $^ -o $@ $(LIBPATHS) $(LIBS)
clean: