/* execute onset detection function on iput buffer */ void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset) { smpl_t isonset = 0; aubio_pvoc_do (o->pv,input, o->fftgrain); aubio_specdesc_do (o->od, o->fftgrain, o->desc); aubio_peakpicker_do(o->pp, o->desc, onset); isonset = onset->data[0]; if (isonset > 0.) { if (aubio_silence_detection(input, o->silence)==1) { //AUBIO_DBG ("silent onset, not marking as onset\n"); isonset = 0; } else { uint_t new_onset = o->total_frames + (uint_t)ROUND(isonset * o->hop_size); if (o->last_onset + o->minioi < new_onset) { //AUBIO_DBG ("accepted detection, marking as onset\n"); o->last_onset = new_onset; } else { //AUBIO_DBG ("doubled onset, not marking as onset\n"); isonset = 0; } } } else { // we are at the beginning of the file, and we don't find silence if (o->total_frames == 0 && aubio_silence_detection(input, o->silence) == 0) { //AUBIO_DBG ("beginning of file is not silent, marking as onset\n"); isonset = o->delay / o->hop_size; o->last_onset = o->delay; } } onset->data[0] = isonset; o->total_frames += o->hop_size; return; }
/* execute onset detection function on iput buffer */ void aubio_onset_do (aubio_onset_t *o, const fvec_t * input, fvec_t * onset) { smpl_t isonset = 0; aubio_pvoc_do (o->pv,input, o->fftgrain); /* if (apply_filtering) { } */ if (o->apply_awhitening) { aubio_spectral_whitening_do(o->spectral_whitening, o->fftgrain); } if (o->apply_compression) { cvec_logmag(o->fftgrain, o->lambda_compression); } aubio_specdesc_do (o->od, o->fftgrain, o->desc); aubio_peakpicker_do(o->pp, o->desc, onset); isonset = onset->data[0]; if (isonset > 0.) { if (aubio_silence_detection(input, o->silence)==1) { //AUBIO_DBG ("silent onset, not marking as onset\n"); isonset = 0; } else { // we have an onset uint_t new_onset = o->total_frames + (uint_t)ROUND(isonset * o->hop_size); // check if last onset time was more than minioi ago if (o->last_onset + o->minioi < new_onset) { // start of file: make sure (new_onset - delay) >= 0 if (o->last_onset > 0 && o->delay > new_onset) { isonset = 0; } else { //AUBIO_DBG ("accepted detection, marking as onset\n"); o->last_onset = MAX(o->delay, new_onset); } } else { //AUBIO_DBG ("doubled onset, not marking as onset\n"); isonset = 0; } } } else { // we are at the beginning of the file if (o->total_frames <= o->delay) { // and we don't find silence if (aubio_silence_detection(input, o->silence) == 0) { uint_t new_onset = o->total_frames; if (o->total_frames == 0 || o->last_onset + o->minioi < new_onset) { isonset = o->delay / o->hop_size; o->last_onset = o->total_frames + o->delay; } } } } onset->data[0] = isonset; o->total_frames += o->hop_size; return; }
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; }
/* do method, calling the detection callback, then the conversion callback */ void aubio_pitch_do (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) { p->detect_cb (p, ibuf, obuf); if (aubio_silence_detection(ibuf, p->silence) == 1) { obuf->data[0] = 0.; } obuf->data[0] = p->conv_cb (obuf->data[0], p->samplerate, p->bufsize); }
bool AubioOnsetDetector :: processframe(float* frame, const int& n){ bool newFrameResult = false; //Paul Brossier's aubioonsetclass~ code ported from Pd int j,isonset; for (j=0;j<n;j++) { // write input to datanew fvec_write_sample(vec, frame[j], 0, pos);//vec->data[0][pos] = frame[j] //time for fft if (pos == hopsize-1) { //hopsize is 512 newFrameResult = true; aubioOnsetFound = false; // block loop aubio_pvoc_do (pv,vec, fftgrain); fftgrain->norm[0][0] = fabs(fftgrain->norm[0][0]); //added hack to solve bug that norm[0][0] is negative sometimes. aubio_onsetdetection(o, fftgrain, onset); rawDetectionValue = onset->data[0][0]; //Paul Brossier's method to return value of peak picking process postProcessing(); // smpl_t my_sample_value; //peakPickedDetectionValue = aubio_peakpick_pimrt_getval(parms); //peakPickedDetectionValue = my_sample_value; //Paul Brossier's onset detection method isonset = aubio_peakpick_pimrt(onset,parms); if (isonset) { // test for silence if (aubio_silence_detection(vec, threshold2)==1){ isonset=0; } else{ // outlet_bang(x->bangoutlet); aubioOnsetFound = true; } }//end if (isonset) // end of block loop pos = -1; // so it will be zero next j loop } pos++; }//end for j //end of Paul's code return newFrameResult; }
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 *aubio_process(t_sample *sample, float *input, sf_count_t nframes) { unsigned int j, i; int *result; for (j=0; j < nframes; j++) { for (i=0; i < channels; i++) { /* write input to datanew */ fvec_write_sample(ibuf, input[channels*j+i], i, pos % overlap_size); } /*time for fft*/ if (pos % overlap_size == (overlap_size - 1)) { int isonset; /* block loop */ aubio_pvoc_do(pv, ibuf, fftgrain); aubio_onsetdetection(o, fftgrain, onset); if (usedoubled) { aubio_onsetdetection(o2,fftgrain, onset2); onset->data[0][0] *= onset2->data[0][0]; } isonset = aubio_peakpick_pimrt(onset, parms); if (isonset) { /* test for silence */ if (aubio_silence_detection(ibuf, silence)==1) { printf("silence.\n"); isonset=0; } else { printf("onset! %d\n", pos); onsets[onset_n++] = pos; } } } pos++; } result = (int *) calloc(1, sizeof(int) * (onset_n + 1)); memcpy(result, onsets, sizeof(int) * onset_n); result[onset_n] = -1; printf("found %d onsets\n", onset_n); return(result); }
/* execute tempo detection function on iput buffer */ void aubio_tempo(aubio_tempo_t *o, fvec_t * input, fvec_t * tempo) { uint_t i; uint_t winlen = o->winlen; uint_t step = o->step; aubio_pvoc_do (o->pv, input, o->fftgrain); aubio_onsetdetection(o->od, o->fftgrain, o->of); /*if (usedoubled) { aubio_onsetdetection(o2,fftgrain, onset2); onset->data[0][0] *= onset2->data[0][0]; }*/ /* execute every overlap_size*step */ if (o->blockpos == (signed)step -1 ) { /* check dfframe */ aubio_beattracking_do(o->bt,o->dfframe,o->out); /* rotate dfframe */ for (i = 0 ; i < winlen - step; i++ ) o->dfframe->data[0][i] = o->dfframe->data[0][i+step]; for (i = winlen - step ; i < winlen; i++ ) o->dfframe->data[0][i] = 0.; o->blockpos = -1; } o->blockpos++; tempo->data[0][1] = aubio_peakpick_pimrt_wt(o->of,o->pp, &(o->dfframe->data[0][winlen - step + o->blockpos])); /* end of second level loop */ tempo->data[0][0] = 0; /* reset tactus */ i=0; for (i = 1; i < o->out->data[0][0]; i++ ) { /* if current frame is a predicted tactus */ if (o->blockpos == o->out->data[0][i]) { /* test for silence */ if (aubio_silence_detection(input, o->silence)==1) { tempo->data[0][1] = 0; /* unset onset */ tempo->data[0][0] = 0; /* unset tactus */ } else { tempo->data[0][0] = 1; /* set tactus */ } } } }
static t_int *aubioquiet_tilde_perform(t_int *w) { t_aubioquiet_tilde *x = (t_aubioquiet_tilde *)(w[1]); t_sample *in = (t_sample *)(w[2]); int n = (int)(w[3]); int j; for (j=0;j<n;j++) { /* write input to datanew */ fvec_set_sample(x->vec, in[j], x->pos); /*time for fft*/ if (x->pos == x->hopsize-1) { /* block loop */ if (aubio_silence_detection(x->vec, x->silence)==1) { if (x->wassilence==1) { x->issilence = 1; } else { x->issilence = 2; outlet_bang(x->quietbang); } x->wassilence=1; } else { if (x->wassilence<=0) { x->issilence = 0; } else { x->issilence = -1; outlet_bang(x->noisybang); } x->wassilence=0; } /* end of block loop */ x->pos = -1; /* so it will be zero next j loop */ } x->pos++; } return (w+4); }
bool AubioOnsetDetector :: processframe(float frame[], int n){ bool newFrameResult = false; //Paul Brossier's aubioonsetclass~ code ported from Pd int j,isonset; for (j=0;j<n;j++) { // write input to datanew fvec_write_sample(vec, frame[j], 0, pos);//vec->data[0][pos] = frame[j] //time for fft if (pos == hopsize-1) { //hopsize is 512 newFrameResult = true; aubioOnsetFound = false; // block loop aubio_pvoc_do (pv,vec, fftgrain); fftgrain->norm[0][0] = fabs(fftgrain->norm[0][0]); //added hack to solve bug that norm[0][0] is negative sometimes. aubio_onsetdetection(o, fftgrain, onset); rawDetectionValue = onset->data[0][0]; //Paul Brossier's method to return value of peak picking process anrMedianProcessedOnsetFound = checkForMedianOnset(rawDetectionValue); bestSlopeValue = getBestSlopeValue(rawDetectionValue); anrBestSlopeOnset = checkForSlopeOnset(bestSlopeValue); // smpl_t my_sample_value; peakPickedDetectionValue = aubio_peakpick_pimrt_getval(parms); //peakPickedDetectionValue = my_sample_value; //this was what got sent from max object:: // outlet_float(x->detectionFunctionOutlet, my_sample_value); // outlet_float(x->rawDetectionFunctionOutlet, x->onset->data[0][0]); isonset = aubio_peakpick_pimrt(onset,parms); if (isonset) { // test for silence if (aubio_silence_detection(vec, -ofGetMouseX())==1) { printf("silence \n"); isonset=0; } else{ // outlet_bang(x->bangoutlet); aubioOnsetFound = true; } }//end if (isonset) // end of block loop pos = -1; // so it will be zero next j loop } pos++; // outL[j] = frame[j];//have added this so signal is "see through": outputting the input signal } //end of Paul's code return newFrameResult; }