ReMAS  1.5
Real-time Musical Accompaniment System
CPUFunctions.h
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright (C) 2017 by "Information Retrieval and Parallel Computing" *
3  * group (University of Oviedo, Spain), "Interdisciplinary Computation *
4  * and Communication" group (Polytechnic University of Valencia, Spain) *
5  * and "Signal Processing and Telecommunication Systems Research" group *
6  * (University of Jaen, Spain) *
7  * Contact: remaspack@gmail.com *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the *
21  * Free Software Foundation, Inc., *
22  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23  **************************************************************************
24 */
34 #pragma once
35 
36 #ifndef PREPROCESS_H
37 #define PREPROCESS_H
38 
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <math.h>
43 #include <float.h>
44 #include <unistd.h>
45 #include <stdbool.h> /* For docker and AppImage versions */
46 
47 #ifdef OMP
48  #include <omp.h>
49 #endif
50 
51 #ifdef MKL
52  #ifdef CBLAS
53  #include <mkl.h>
54  #endif
55 #else
56  #ifdef CBLAS
57  #include <cblas.h>
58  #endif
59 #endif
60 
61 #include <fftw3.h>
62 
63 #ifdef ALSA
64  #include <asoundlib.h>
65 #endif
66 
67 #include "../common/defines.h"
68 
69 int AllocDataCPU(MyType **, int **, int **, int **, int **, int **, int *, const int, const int, DTWfiles);
70 
71 int AllocDTWCPU(MyType **, MyType **, const int, const int, const int);
72 
73 int AllocS_fkCPU(MyType **, MyType **, MyType **, const MyType, const int, const int, DTWfiles);
74 
75 int AllocFFTCPU(MyFFTCPUType *, MyType **, MyType **, MyType **, int*, int*, const int, DTWfiles);
76 
77 int AllocAuxiCPU(MyType **, short **, MyType **, MyType **, const int, const int, const int);
78 
79 void ApplyWindow(MyType * __restrict, const short *, const MyType *, const int, const int);
80 
81 void ComputeNorms(MyType *, MyType *, const MyType *, const int, const int, const MyType);
82 
83 void FFT(MyType *, const int *, const int *, MyType *, MyType *, MyType *, MyFFTCPUType, const int, const int);
84 
85 int DTWProc(const MyType *, const MyType *, MyType * __restrict, const int, const int, const int);
86 
87 void ApplyDist(const MyType *, MyType *, const int *, const int, const MyType);
88 
89 void ComputeDist(const MyType *, MyType * __restrict, MyType *, const MyType *, const MyType *, const MyType *,
90  const MyType, const int, const int);
91 
92 int ReadWavCPU1st(short *, FILE *);
93 int ReadWavCPU (short *, FILE *);
94 
95 #ifdef ALSA
96  int ReadAlsaCPU1st(short *, snd_pcm_t *, FILE *);
97  int ReadAlsaCPU (short *, snd_pcm_t *, FILE *);
98 #endif
99 
100 int SeqIdamin(const int, const MyType *);
101 
102 #ifdef OMP
103  int ParIdamin(const int, const MyType *);
104 #endif
105 
106 #endif
107 
108 void BetaNorm(MyType *, const int, MyType);
Struct for store the name of input/verificaton files. Each composition needs a file with values for ...
Definition: defines.h:228
int AllocAuxiCPU(MyType **, short **, MyType **, MyType **, const int, const int, const int)
AllocAuxiCPU Memory reservation for norms, frame, v_cfreq and v_dxState vectors.
Definition: CPUFunctions.c:152
int AllocS_fkCPU(MyType **, MyType **, MyType **, const MyType, const int, const int, DTWfiles)
AllocS_fkCPU Allocates memory for S_fk vector, read its data from file and initializes other auxiliar...
Definition: CPUFunctions.c:231
int AllocDataCPU(MyType **, int **, int **, int **, int **, int **, int *, const int, const int, DTWfiles)
AllocDataCPU creates and initializes some structures reading info from files.
Definition: CPUFunctions.c:310
int DTWProc(const MyType *Sequence, const MyType *Costs, MyType *__restrict pD, const int NSeq, const int Where, const int NST)
DTWProc performs the Online-DTW process for the current frame.
Definition: CPUFunctions.c:485
void ApplyDist(const MyType *, MyType *, const int *, const int, const MyType)
ApplyDist applies distortion.
Definition: CPUFunctions.c:550
void BetaNorm(MyType *, const int, MyType)
BetaNorm normalizes v_cfreq vector to have beta-norm 1.
Definition: CPUFunctions.c:817
int SeqIdamin(const int, const MyType *)
SeqIdamin returns the pos of the minimum in a vector.
Definition: CPUFunctions.c:462
int ReadWavCPU(short *, FILE *)
ReadWavCPU reads current audio (frame) from WAV file when ARM is used.
Definition: CPUFunctions.c:756
void ComputeNorms(MyType *, MyType *, const MyType *, const int, const int, const MyType)
ComputeNorms fills norms vector.
Definition: CPUFunctions.c:73
void ApplyWindow(MyType *__restrict X_fft, const short *frame, const MyType *v_hanning, const int framesize, const int xfftsize)
ApplyWindow applies hanning window to the current frame and store the result en vector X_fft...
Definition: CPUFunctions.c:48
int AllocDTWCPU(MyType **, MyType **, const int, const int, const int)
AllocDTWCPU Allocates memory for DTW vectors and initializes them.
Definition: CPUFunctions.c:270
void FFT(MyType *, const int *, const int *, MyType *, MyType *, MyType *, MyFFTCPUType, const int, const int)
FFT computes FFT and updates v_cfreq vector.
Definition: CPUFunctions.c:356
int ReadWavCPU1st(short *, FILE *)
ReadWavCPU1st reads first audio (frame) from WAV file when ARM is used.
Definition: CPUFunctions.c:742
void ComputeDist(const MyType *v_cfreq, MyType *__restrict v_dxStates, MyType *tauxi, const MyType *norms, const MyType *s_fk, const MyType *ts_fk, const MyType BETA, const int nbases, const int nmidi)
ComputeDist computes distortion.
Definition: CPUFunctions.c:600
int AllocFFTCPU(MyFFTCPUType *, MyType **, MyType **, MyType **, int *, int *, const int, DTWfiles)
AllocFFTCPU Allocates memory for FFT vector and reads some fft information from files.
Definition: CPUFunctions.c:177