ref: c34336ecfd4d5bd0740d7cddf0a76eeb7910f3ba
parent: 5d10ac1882948152e9628c6fea144137274d607c
author: Paul Brossier <piem@piem.org>
date: Tue Dec 17 06:13:28 EST 2013
src/fvec.h: clean up fvec api
--- a/examples/aubionotes.c
+++ b/examples/aubionotes.c
@@ -51,7 +51,7 @@
aubio_onset_do(o, ibuf, onset);
aubio_pitch_do (pitch, ibuf, pitch_obuf);
- smpl_t new_pitch = fvec_read_sample(pitch_obuf, 0);
+ smpl_t new_pitch = fvec_get_sample(pitch_obuf, 0);
if(median){
note_append(note_buffer, new_pitch);
}
@@ -58,7 +58,7 @@
/* curlevel is negatif or 1 if silence */
smpl_t curlevel = aubio_level_detection(ibuf, silence_threshold);
- if (fvec_read_sample(onset, 0)) {
+ if (fvec_get_sample(onset, 0)) {
/* test for silence */
if (curlevel == 1.) {
if (median) isready = 0;
--- a/examples/aubioonset.c
+++ b/examples/aubioonset.c
@@ -33,7 +33,7 @@
process_block(fvec_t *ibuf, fvec_t *obuf) {
fvec_zeros(obuf);
aubio_onset_do (o, ibuf, onset);
- is_onset = fvec_read_sample(onset, 0);
+ is_onset = fvec_get_sample(onset, 0);
if ( is_onset ) {
aubio_wavetable_play ( wavetable );
} else {
--- a/examples/aubiopitch.c
+++ b/examples/aubiopitch.c
@@ -32,7 +32,7 @@
process_block(fvec_t * ibuf, fvec_t * obuf) {
fvec_zeros(obuf);
aubio_pitch_do (o, ibuf, pitch);
- smpl_t freq = fvec_read_sample(pitch, 0);
+ smpl_t freq = fvec_get_sample(pitch, 0);
aubio_wavetable_set_amp ( wavetable, aubio_level_lin (ibuf) );
aubio_wavetable_set_freq ( wavetable, freq );
@@ -44,7 +44,7 @@
void
process_print (void) {
- smpl_t pitch_found = fvec_read_sample(pitch, 0);
+ smpl_t pitch_found = fvec_get_sample(pitch, 0);
outmsg("%f %f\n",(blocks)
*hop_size/(float)samplerate, pitch_found);
}
@@ -69,6 +69,7 @@
aubio_pitch_set_silence (o, silence_threshold);
if (pitch_unit != NULL)
aubio_pitch_set_unit (o, pitch_unit);
+
pitch = new_fvec (1);
wavetable = new_aubio_wavetable (samplerate, hop_size);
--- a/examples/aubiotrack.c
+++ b/examples/aubiotrack.c
@@ -28,13 +28,11 @@
aubio_wavetable_t *wavetable;
fvec_t * tempo_out;
smpl_t is_beat = 0;
-smpl_t is_onset = 0;
uint_t is_silence = 0.;
void process_block(fvec_t * ibuf, fvec_t *obuf) {
aubio_tempo_do (tempo, ibuf, tempo_out);
- is_beat = fvec_read_sample (tempo_out, 0);
- is_onset = fvec_read_sample (tempo_out, 1);
+ is_beat = fvec_get_sample (tempo_out, 0);
if (silence_threshold != -90.)
is_silence = aubio_silence_detection(ibuf, silence_threshold);
fvec_zeros (obuf);
@@ -53,8 +51,6 @@
if ( is_beat && !is_silence ) {
outmsg("%f\n", aubio_tempo_get_last_s(tempo) );
}
- //if ( is_onset )
- // outmsg(" \t \t%f\n",(blocks)*hop_size/(float)samplerate);
}
int main(int argc, char **argv) {
--- a/examples/jackio.c
+++ b/examples/jackio.c
@@ -252,9 +252,9 @@
unsigned int j; /*frames*/
for (j=0;j<(unsigned)nframes;j++) {
/* put synthnew in output */
- output[0][j] = fvec_read_sample(dev->obuf, dev->pos);
+ output[0][j] = fvec_get_sample(dev->obuf, dev->pos);
/* write input to datanew */
- fvec_write_sample(dev->ibuf, input[0][j], dev->pos);
+ fvec_set_sample(dev->ibuf, input[0][j], dev->pos);
/*time for fft*/
if (dev->pos == (int)(dev->hop_size) - 1) {
/* block loop */
--- a/src/fvec.c
+++ b/src/fvec.c
@@ -36,11 +36,11 @@
AUBIO_FREE(s);
}
-void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position) {
+void fvec_set_sample(fvec_t *s, smpl_t data, uint_t position) {
s->data[position] = data;
}
-smpl_t fvec_read_sample(fvec_t *s, uint_t position) {
+smpl_t fvec_get_sample(fvec_t *s, uint_t position) {
return s->data[position];
}
@@ -58,7 +58,7 @@
AUBIO_MSG("\n");
}
-void fvec_set(fvec_t *s, smpl_t val) {
+void fvec_set_all (fvec_t *s, smpl_t val) {
uint_t j;
for (j=0; j< s->length; j++) {
s->data[j] = val;
@@ -69,12 +69,12 @@
#if HAVE_MEMCPY_HACKS
memset(s->data, 0, s->length * sizeof(smpl_t));
#else
- fvec_set(s, 0.);
+ fvec_set_all (s, 0.);
#endif
}
void fvec_ones(fvec_t *s) {
- fvec_set(s, 1.);
+ fvec_set_all (s, 1.);
}
void fvec_rev(fvec_t *s) {
--- a/src/fvec.h
+++ b/src/fvec.h
@@ -75,6 +75,7 @@
*/
fvec_t * new_fvec(uint_t length);
+
/** fvec_t buffer deletion function
\param s buffer to delete as returned by new_fvec()
@@ -81,6 +82,7 @@
*/
void del_fvec(fvec_t *s);
+
/** read sample value in a buffer
Note that this function is not used in the aubio library, since the same
@@ -91,7 +93,8 @@
\param position sample position to read from
*/
-smpl_t fvec_read_sample(fvec_t *s, uint_t position);
+smpl_t fvec_get_sample(fvec_t *s, uint_t position);
+
/** write sample value in a buffer
Note that this function is not used in the aubio library, since the same
@@ -103,7 +106,7 @@
\param position sample position to write to
*/
-void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position);
+void fvec_set_sample(fvec_t *s, smpl_t data, uint_t position);
/** read data from a buffer
@@ -129,7 +132,7 @@
\param val value to set elements to
*/
-void fvec_set(fvec_t *s, smpl_t val);
+void fvec_set_all (fvec_t *s, smpl_t val);
/** set all elements to zero
--- a/tests/src/spectral/test-phasevoc-jack.c
+++ b/tests/src/spectral/test-phasevoc-jack.c
@@ -74,9 +74,9 @@
for (j=0;j<(unsigned)nframes;j++) {
for (i=0;i<channels;i++) {
/* write input to datanew */
- fvec_write_sample(in[i], input[i][j], pos);
+ fvec_set_sample(in[i], input[i][j], pos);
/* put synthnew in output */
- output[i][j] = fvec_read_sample(out[i], pos);
+ output[i][j] = fvec_get_sample(out[i], pos);
}
/*time for fft*/
if (pos == hop_s-1) {
--- a/tests/src/spectral/test-phasevoc.c
+++ b/tests/src/spectral/test-phasevoc.c
@@ -14,7 +14,7 @@
aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);
// fill input with some data
- fvec_set (in, 1.);
+ fvec_set_all (in, 1.);
fvec_print (in);
while ( n-- ) {
--
⑨