-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbufferCircular.c
More file actions
33 lines (26 loc) · 973 Bytes
/
bufferCircular.c
File metadata and controls
33 lines (26 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "MT-10.h"
// =============
// funcion que implementa un buffer Circular,
// introduce un dato leído y lo atenúa guardándolo, devolviendolo un retardo posterior
// =============
int bufferCircular (int tension, int *buffer) {
static int *puntero_buffer = 0;
static int flag = 0; // marca cuando empezamos a sacar del buffer
int muestra = 0;
if ( !puntero_buffer)
puntero_buffer = buffer;
if( puntero_buffer < buffer + retardo_reverberacion){
if( flag )// si ya se ha recorrido el buffer una vez empezamos a sacar datos almacenados, sino devolvemos 0
muestra = *puntero_buffer;
*puntero_buffer = tension / atenuacion_reverberacion;
puntero_buffer++;
}
else{
flag = 1;
puntero_buffer = buffer;
muestra = *puntero_buffer;
*puntero_buffer = tension / atenuacion_reverberacion;
puntero_buffer++;
}
return muestra;
}