ReMAS  1.5
Real-time Musical Accompaniment System
Macros | Functions
CPUFunctions.h File Reference

Header file for using ReMAS with CPU, both x86_64 and ARM. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <unistd.h>
#include <stdbool.h>
#include <fftw3.h>
#include "../common/defines.h"

Go to the source code of this file.

Functions

int AllocDataCPU (MyType **, int **, int **, int **, int **, int **, int *, const int, const int, DTWfiles)
 AllocDataCPU creates and initializes some structures reading info from files. More...
 
int AllocDTWCPU (MyType **, MyType **, const int, const int, const int)
 AllocDTWCPU Allocates memory for DTW vectors and initializes them. More...
 
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 vectors. More...
 
int AllocFFTCPU (MyFFTCPUType *, MyType **, MyType **, MyType **, int *, int *, const int, DTWfiles)
 AllocFFTCPU Allocates memory for FFT vector and reads some fft information from files. More...
 
int AllocAuxiCPU (MyType **, short **, MyType **, MyType **, const int, const int, const int)
 AllocAuxiCPU Memory reservation for norms, frame, v_cfreq and v_dxState vectors. More...
 
void ApplyWindow (MyType *__restrict, const short *, const MyType *, const int, const int)
 
void ComputeNorms (MyType *, MyType *, const MyType *, const int, const int, const MyType)
 ComputeNorms fills norms vector. More...
 
void FFT (MyType *, const int *, const int *, MyType *, MyType *, MyType *, MyFFTCPUType, const int, const int)
 FFT computes FFT and updates v_cfreq vector. More...
 
int DTWProc (const MyType *, const MyType *, MyType *__restrict, const int, const int, const int)
 
void ApplyDist (const MyType *, MyType *, const int *, const int, const MyType)
 ApplyDist applies distortion. More...
 
void ComputeDist (const MyType *, MyType *__restrict, MyType *, const MyType *, const MyType *, const MyType *, const MyType, const int, const int)
 
int ReadWavCPU1st (short *, FILE *)
 ReadWavCPU1st reads first audio (frame) from WAV file when ARM is used. More...
 
int ReadWavCPU (short *, FILE *)
 ReadWavCPU reads current audio (frame) from WAV file when ARM is used. More...
 
int SeqIdamin (const int, const MyType *)
 SeqIdamin returns the pos of the minimum in a vector. More...
 
void BetaNorm (MyType *, const int, MyType)
 BetaNorm normalizes v_cfreq vector to have beta-norm 1. More...
 

Detailed Description

Header file for using ReMAS with CPU, both x86_64 and ARM.

Author
Information Retrieval and Parallel Computing Group, University of Oviedo, Spain
Interdisciplinary Computation and Communication Group, Universitat Politecnica de Valencia, Spain
Signal Processing and Telecommunication Systems Research Group, University of Jaen, Spain.
Contact: remas.nosp@m.pack.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Date
February 13, 2017

Definition in file CPUFunctions.h.

Function Documentation

◆ AllocAuxiCPU()

int AllocAuxiCPU ( MyType **  norms,
short **  frame,
MyType **  v_cfreq,
MyType **  v_dxState,
const int  nbases,
const int  tamframe,
const int  nmidi 
)

AllocAuxiCPU Memory reservation for norms, frame, v_cfreq and v_dxState vectors.

Parameters
norms(out) Norms vector
frame(out) Vector for frames
v_cfreq(out) v_cfreq vector
v_dxState(out) v_dxState vector
nbases(in) Number of bases/combinations, sizeof norms and v_dxState
tamframe(in) Size of frames in samples
nmidi(in) Number of midi notes, sizeof v_cfreq
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 152 of file CPUFunctions.c.

◆ AllocDataCPU()

int AllocDataCPU ( MyType **  v_hanning,
int **  states_time_i,
int **  states_time_e,
int **  states_seq,
int **  states_corr,
int **  I_SxD,
int *  DTWSize,
const int  tamframe,
const int  nstates,
DTWfiles  NameFiles 
)

AllocDataCPU creates and initializes some structures reading info from files.

Parameters
v_hanning(out) v_hanning vector
states_time_i(out) states_time_i vector, contains the start-time of each state in frames
states_time_e(out) states_time_e vector, contains the end-time of each state in frames
states_seq(out) states_seq vector, contains the base/combination that is performed in each state
states_corr(out) states_corr vector
I_SxD(out) I_SxD vector
DTWSize(in) Size of DTW vectors
tamframe(in) Size of frames in samples
nstates(in) Number of states
NameFiles(in) Struct with the file names
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 310 of file CPUFunctions.c.

◆ AllocDTWCPU()

int AllocDTWCPU ( MyType **  pV,
MyType **  v_SxD,
const int  DTWSize,
const int  DTWSizePlusPad,
const int  startin 
)

AllocDTWCPU Allocates memory for DTW vectors and initializes them.

Parameters
pV(out) DTW pV vector
v_SxD(out) v_SxD vector
DTWSize(in) Size of DTW vectors
DTWSizePlusPad(in) Size of DTW vectors plus padding
startin(in) Where we start to store data within circular-buffer
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 270 of file CPUFunctions.c.

◆ AllocFFTCPU()

int AllocFFTCPU ( MyFFTCPUType *  plan,
MyType **  X_fft,
MyType **  Out_fft,
MyType **  Mod_fft,
int *  kmin_fft,
int *  kmax_fft,
const int  nfft,
DTWfiles  NameFiles 
)

AllocFFTCPU Allocates memory for FFT vector and reads some fft information from files.

Parameters
plan(out) FFT scheduler
X_fft(out) X_fft vector
Out_fft(out) Out_fft vector
Mod_fft(out) Mod_fft vector
kmin_fft(out) Where kmin_fft is stored
kmax_fft(out) Where kmax_fft is stored
nfft(in) As is to be, Mod_fft and Out_fft size
NameFiles(in) Struct with the file names
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 177 of file CPUFunctions.c.

◆ AllocS_fkCPU()

int AllocS_fkCPU ( MyType **  s_fk,
MyType **  tauxi,
MyType **  ts_fk,
const MyType  BETA,
const int  nmidi,
const int  nbases,
DTWfiles  NameFiles 
)

AllocS_fkCPU Allocates memory for S_fk vector, read its data from file and initializes other auxiliar vectors.

Parameters
s_fk(out) s_fk vector
tauxi(out) Auxiliar vector tauxi
ts_fk(out) Auxiliar vector ts_fk
BETA(in) BETA value
nmidi(in) Number of midi notes
nbases(in) Number of bases/combinations
NameFiles(in) Struct with the file names
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 231 of file CPUFunctions.c.

◆ ApplyDist()

void ApplyDist ( const MyType *  v_dxState,
MyType *  v_SxD,
const int *  I_SxD,
const int  size,
const MyType  ALPHA 
)

ApplyDist applies distortion.

Parameters
v_dxState(in) v_dxState vector
v_SxD(out) v_SxD vector
I_SxD(in) I_SxD vector
size(in) Size of the vectors
ALPHA(in) ALPHA value
Returns
: Nothing, it is void

Definition at line 550 of file CPUFunctions.c.

◆ BetaNorm()

void BetaNorm ( MyType *  v_cfreq,
const int  nmidi,
MyType  BETA 
)

BetaNorm normalizes v_cfreq vector to have beta-norm 1.

Parameters
v_cfreq(inout) v_cfreq vector
BETA(in) BETA value
nmidi(in) Number of midi notes
Returns
: Nothing, it is void

Definition at line 817 of file CPUFunctions.c.

◆ ComputeNorms()

void ComputeNorms ( MyType *  norms,
MyType *  ts_fk,
const MyType *  s_fk,
const int  nmidi,
const int  nbases,
const MyType  beta 
)

ComputeNorms fills norms vector.

Parameters
norms(out) Vector with the norms
ts_fk(in) Auxiliar vector
s_fk(in) Vector s_fk
nmidi(in) Number of midi notes
nbases(in) Number of bases/combinations
beta(in) BETA value
Returns
: Nothing, it is void

Definition at line 73 of file CPUFunctions.c.

◆ FFT()

void FFT ( MyType *  v_cfreq,
const int *  kmin,
const int *  kmax,
MyType *  X_fft,
MyType *  Mod_fft,
MyType *  Out_fft,
MyFFTCPUType  plan,
const int  nfft,
const int  nmidi 
)

FFT computes FFT and updates v_cfreq vector.

Parameters
v_cfreq(out) v_cfreq vector
kmin(input) kmin vector
kmax(input) kmax vector
X_fft(inout) X_fft vector
Mod_fft(inout) Mod_fft vector
Out_fft(inout) Out_fft vector
plan(out) FFT scheduler
nfft(in) As is to be, Mod_fft and Out_fft size
nmidi(in) Number of midi notes
Returns
: Nothing, it is void

Definition at line 356 of file CPUFunctions.c.

◆ ReadWavCPU()

int ReadWavCPU ( short *  frame,
FILE *  fp 
)

ReadWavCPU reads current audio (frame) from WAV file when ARM is used.

Parameters
frame(out) Vector to store the current frame
fp(in) ID of file with data
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 756 of file CPUFunctions.c.

◆ ReadWavCPU1st()

int ReadWavCPU1st ( short *  frame,
FILE *  fp 
)

ReadWavCPU1st reads first audio (frame) from WAV file when ARM is used.

Parameters
frame(out) Vector to store the first frame
fp(in) ID of file with the information
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 742 of file CPUFunctions.c.

◆ SeqIdamin()

int SeqIdamin ( const int  N,
const MyType *  v 
)

SeqIdamin returns the pos of the minimum in a vector.

When minimum's number of occurrences > 1 => returns the position of the 1st occurrence

Parameters
N(in) Vector size
v(in) The vector
Returns
: The pos of the minimum

Definition at line 462 of file CPUFunctions.c.