aubio 0.4.9
Loading...
Searching...
No Matches
test-lvec.c
#include "aubio.h"
#include "utils_tests.h"
void assert_lvec_all_equal(lvec_t *vec, lsmp_t scalar)
{
uint_t i;
for (i = 0; i < vec->length; i++) {
assert(vec->data[i] == scalar);
}
}
int main (void)
{
uint_t length = 32; // window size
lvec_t * vec = new_lvec (length); // input buffer
assert(vec);
assert(vec->length == length);
lvec_set_sample (vec, 3., 0);
assert(lvec_get_sample(vec, 0) == 3.);
assert(lvec_get_data(vec) == vec->data);
lvec_print (vec);
// note AUBIO_LSMP_FMT can be used to print lsmp_t
PRINT_MSG(AUBIO_LSMP_FMT "\n", lvec_get_sample (vec, 0));
lvec_set_all (vec, 2.);
assert_lvec_all_equal(vec, 2.);
lvec_ones (vec);
assert_lvec_all_equal(vec, 1.);
lvec_zeros (vec);
assert_lvec_all_equal(vec, 0.);
del_lvec(vec);
// wrong parameters
assert(new_lvec(0) == NULL);
assert(new_lvec(-1) == NULL);
return 0;
}
Global aubio include file.
void lvec_ones(lvec_t *s)
set all elements to ones
void lvec_zeros(lvec_t *s)
set all elements to zero
void del_lvec(lvec_t *s)
lvec_t buffer deletion function
lsmp_t lvec_get_sample(lvec_t *s, uint_t position)
read sample value in a buffer
lvec_t * new_lvec(uint_t length)
lvec_t buffer creation function
void lvec_set_all(lvec_t *s, smpl_t val)
set all elements to a given value
void lvec_set_sample(lvec_t *s, lsmp_t data, uint_t position)
write sample value in a buffer
void lvec_print(const lvec_t *s)
print out lvec data
lsmp_t * lvec_get_data(const lvec_t *s)
read data from a buffer
Buffer for real data in double precision.
Definition lvec.h:43
uint_t length
length of buffer
Definition lvec.h:44
lsmp_t * data
data array of size [length]
Definition lvec.h:45
#define AUBIO_LSMP_FMT
print format for sample in double precision
Definition types.h:53
unsigned int uint_t
unsigned integer
Definition types.h:60
double lsmp_t
long sample format (64 bits or more)
Definition types.h:51