void process_block(fvec_t * ibuf, fvec_t *obuf) { aubio_tempo_do (tempo, ibuf, tempo_out); is_beat = fvec_get_sample (tempo_out, 0); //smpl_t bpm = aubio_tempo_get_bpm(tempo); //uint_t last_beat = aubio_tempo_get_last(tempo); aubio_pitch_do (pitch, ibuf, pitch_out); smpl_t freq = fvec_get_sample(pitch_out, 0); if (silence_threshold != -90.) is_silence = aubio_silence_detection(ibuf, silence_threshold); fvec_zeros (obuf); if ( is_beat && !is_silence ) { samples_per_beat = total_frames - my_last_beat; my_last_beat = total_frames; aubio_wavetable_play ( wavetable ); } else { aubio_wavetable_stop ( wavetable ); } if (mix_input) aubio_wavetable_do (wavetable, ibuf, obuf); else aubio_wavetable_do (wavetable, obuf, obuf); rgb_music_iterate(my_last_beat, samples_per_beat, total_frames, freq); total_frames += hop_size; }
void Note2midi::process_block (){ smpl_t new_pitch, curlevel; // fvec_zeros(obuf); aubio_onset_do(o, ibuf, onset); aubio_pitch_do (pitch, ibuf, pitch_obuf); new_pitch = fvec_get_sample(pitch_obuf, 0); if(median){ note_append(note_buffer, new_pitch); } /* curlevel is negatif or 1 if silence */ curlevel = aubio_level_detection(ibuf, *_silence_threshold); if (fvec_get_sample(onset, 0)) { /* test for silence */ if (curlevel == 1.) { if (median) isready = 0; /* send note off */ send_noteon(curnote, 0); } else { if (median) { isready = 1; } else { /* kill old note */ send_noteon(curnote, 0); /* get and send new one */ send_noteon(new_pitch, 127+(int)floor(curlevel)); curnote = new_pitch; } } } else { if (median) { if (isready > 0) isready++; if (isready == median){ /* kill old note */ send_noteon(curnote, 0); newnote = get_note(note_buffer, note_buffer2); curnote = newnote; /* get and send new one */ if (curnote>45){ send_noteon(curnote, 127+(int)floor(curlevel)); } } } // if median } // lv2_atom_sequence_append_event(this->out, out_capacity, ¬e.event); }
void process_block(fvec_t * ibuf, fvec_t *obuf) { aubio_tempo_do (tempo, ibuf, tempo_out); is_beat = fvec_get_sample (tempo_out, 0); if (silence_threshold != -90.) is_silence = aubio_silence_detection(ibuf, silence_threshold); fvec_zeros (obuf); if ( is_beat && !is_silence ) { aubio_wavetable_play ( wavetable ); } else { aubio_wavetable_stop ( wavetable ); } if (mix_input) aubio_wavetable_do (wavetable, ibuf, obuf); else aubio_wavetable_do (wavetable, obuf, obuf); }
int main (void) { uint_t length = 10; uint_t i; fvec_t * vec = new_fvec (length); fvec_t * other_vec = new_fvec (length); assert (vec); assert (other_vec); // vec->length matches requested size assert(vec->length == length); // all elements are initialized to `0.` for ( i = 0; i < vec->length; i++ ) { assert(vec->data[i] == 0.); } // all elements can be set to `1.` fvec_ones(vec); assert_fvec_all_equal(vec, 1.); // all elements can be set to `0.` fvec_zeros(vec); assert_fvec_all_equal(vec, 0.); // each element can be accessed directly for ( i = 0; i < vec->length; i++ ) { vec->data[i] = i; assert(vec->data[i] == i); } fvec_print(vec); fvec_set_sample(vec, 3, 2); assert(fvec_get_sample(vec, 2) == 3); assert(fvec_get_data(vec) == vec->data); // wrong parameters assert(new_fvec(-1) == NULL); // copy to an identical size works fvec_copy(vec, other_vec); del_fvec(other_vec); // copy to a different size fail other_vec = new_fvec(length + 1); fvec_copy(vec, other_vec); del_fvec(other_vec); // copy to a different size fail other_vec = new_fvec(length - 1); fvec_copy(vec, other_vec); // now destroys the vector if (vec) del_fvec(vec); if (other_vec) del_fvec(other_vec); return 0; }
void pitchDetector::process_pitch(fvec_t * in) { aubio_pitch_do (o, in, pitch); pitchFound = fvec_get_sample(pitch, 0); }