aubio: test-lvec.c

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;
}
aubio.h
Global aubio include file.
lvec_ones
void lvec_ones(lvec_t *s)
set all elements to ones
lvec_zeros
void lvec_zeros(lvec_t *s)
set all elements to zero
del_lvec
void del_lvec(lvec_t *s)
lvec_t buffer deletion function
lvec_get_sample
lsmp_t lvec_get_sample(lvec_t *s, uint_t position)
read sample value in a buffer
new_lvec
lvec_t * new_lvec(uint_t length)
lvec_t buffer creation function
lvec_set_all
void lvec_set_all(lvec_t *s, smpl_t val)
set all elements to a given value
lvec_set_sample
void lvec_set_sample(lvec_t *s, lsmp_t data, uint_t position)
write sample value in a buffer
lvec_print
void lvec_print(const lvec_t *s)
print out lvec data
lvec_get_data
lsmp_t * lvec_get_data(const lvec_t *s)
read data from a buffer
lvec_t
Buffer for real data in double precision.
Definition lvec.h:43
lvec_t::length
uint_t length
length of buffer
Definition lvec.h:44
lvec_t::data
lsmp_t * data
data array of size [length]
Definition lvec.h:45
AUBIO_LSMP_FMT
#define AUBIO_LSMP_FMT
print format for sample in double precision
Definition types.h:53
uint_t
unsigned int uint_t
unsigned integer
Definition types.h:60
lsmp_t
double lsmp_t
long sample format (64 bits or more)
Definition types.h:51