}
for (pos = 0; pos < overlap_size; pos++){
- obuf->data[pos] = woodblock->data[pos];
+ //obuf->data[pos] = woodblock->data[pos];
}
}
} else {
#include "utils.h"
-unsigned int pos = 0; /*frames%dspblocksize*/
+uint_t pos = 0; /*frames%dspblocksize*/
aubio_onset_t *o;
+aubio_wavetable_t *wavetable;
fvec_t *onset;
static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
/*time for fft*/
if (pos == overlap_size-1) {
/* block loop */
+ fvec_zeros(obuf);
aubio_onset_do (o, ibuf, onset);
if ( fvec_read_sample(onset, 0) ) {
- fvec_copy (woodblock, obuf);
+ aubio_wavetable_play ( wavetable );
} else {
- fvec_zeros (obuf);
+ aubio_wavetable_stop ( wavetable );
}
+ aubio_wavetable_do (wavetable, ibuf, obuf);
/* end of block loop */
pos = -1; /* so it will be zero next j loop */
}
if (threshold != 0.) aubio_onset_set_threshold (o, threshold);
onset = new_fvec (1);
+ wavetable = new_aubio_wavetable (samplerate, overlap_size);
+ aubio_wavetable_set_freq ( wavetable, 2450.);
+ //aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff");
+
examples_common_process(aubio_process,process_print);
del_aubio_onset (o);
+ del_aubio_wavetable (wavetable);
del_fvec (onset);
examples_common_del();
unsigned int pos = 0; /*frames%dspblocksize*/
aubio_pitch_t *o;
+aubio_wavetable_t *wavetable;
fvec_t *pitch;
static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
if (pos == overlap_size-1) {
/* block loop */
aubio_pitch_do (o, ibuf, pitch);
- if (fvec_read_sample(pitch, 0)) {
- for (pos = 0; pos < overlap_size; pos++){
- // TODO, play sine at this freq
- }
+ smpl_t freq = fvec_read_sample(pitch, 0);
+ smpl_t amp = powf(10., aubio_db_spl(ibuf)*.05 );
+ aubio_wavetable_set_amp ( wavetable, amp );
+ if (freq != 0.0) {
+ aubio_wavetable_set_freq ( wavetable, freq );
} else {
- fvec_zeros (obuf);
+ aubio_wavetable_set_freq ( wavetable, 0.0 );
}
+ aubio_wavetable_do (wavetable, obuf, obuf);
/* end of block loop */
pos = -1; /* so it will be zero next j loop */
}
o = new_aubio_pitch (pitch_mode, buffer_size, overlap_size, samplerate);
pitch = new_fvec (1);
+ wavetable = new_aubio_wavetable (samplerate, overlap_size);
+ aubio_wavetable_play ( wavetable );
+
examples_common_process(aubio_process,process_print);
del_aubio_pitch (o);
+ del_aubio_wavetable (wavetable);
del_fvec (pitch);
examples_common_del();
*/
-#include <aubio.h>
#include "utils.h"
uint_t pos = 0; /* frames%dspblocksize */
-fvec_t * tempo_out = NULL;
aubio_tempo_t * bt = NULL;
+aubio_wavetable_t *wavetable;
+fvec_t * tempo_out = NULL;
smpl_t istactus = 0;
smpl_t isonset = 0;
output[0][j] = fvec_read_sample(obuf, pos);
}
/*time for fft*/
- if (pos == overlap_size-1) {
+ if (pos == overlap_size-1) {
/* block loop */
aubio_tempo_do (bt,ibuf,tempo_out);
istactus = fvec_read_sample (tempo_out, 0);
isonset = fvec_read_sample (tempo_out, 1);
+ fvec_zeros (obuf);
if (istactus > 0.) {
- fvec_copy (woodblock, obuf);
+ aubio_wavetable_play ( wavetable );
} else {
- fvec_zeros (obuf);
+ aubio_wavetable_stop ( wavetable );
}
+ aubio_wavetable_do (wavetable, ibuf, obuf);
/* end of block loop */
pos = -1; /* so it will be zero next j loop */
}
}
static void process_print (void) {
- if (sink_uri == NULL) {
- if (istactus) {
- outmsg("%f\n",((smpl_t)(frames*overlap_size)+(istactus-1.)*overlap_size)/(smpl_t)samplerate);
- }
- if (isonset && verbose)
- outmsg(" \t \t%f\n",(frames)*overlap_size/(float)samplerate);
- }
+ if (sink_uri == NULL) {
+ if (istactus) {
+ outmsg("%f\n",((smpl_t)(frames*overlap_size)+(istactus-1.)*overlap_size)/(smpl_t)samplerate);
+ }
+ if (isonset && verbose)
+ outmsg(" \t \t%f\n",(frames)*overlap_size/(float)samplerate);
+ }
}
int main(int argc, char **argv) {
bt = new_aubio_tempo(onset_mode,buffer_size,overlap_size, samplerate);
if (threshold != 0.) aubio_tempo_set_threshold (bt, threshold);
+ wavetable = new_aubio_wavetable (samplerate, overlap_size);
+ aubio_wavetable_set_freq ( wavetable, 2450.);
+ //aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff");
+
examples_common_process(aubio_process,process_print);
del_aubio_tempo(bt);
+ del_aubio_wavetable (wavetable);
del_fvec(tempo_out);
examples_common_del();
fvec_t *ibuf;
fvec_t *obuf;
-fvec_t *woodblock;
/* badly redeclare some things */
smpl_t threshold;
}
#endif /* HAVE_LASH */
- woodblock = new_fvec (overlap_size);
- //TODO create woodblock sound
-
ibuf = new_fvec (overlap_size);
obuf = new_fvec (overlap_size);
{
del_fvec (ibuf);
del_fvec (obuf);
- del_fvec (woodblock);
aubio_cleanup ();
}
extern fvec_t *ibuf;
extern fvec_t *obuf;
-extern fvec_t *woodblock;