int main(){ /* allocate some memory */ uint_t win_s = 1024; /* window size */ fvec_t * in = new_fvec (win_s); /* input buffer */ fvec_t * out = new_fvec (win_s/4); /* input buffer */ /* allocate fft and other memory space */ aubio_beattracking_t * tempo = new_aubio_beattracking(win_s); uint_t i = 0; smpl_t curtempo, curtempoconf; while (i < 10) { aubio_beattracking_do(tempo,in,out); curtempo = aubio_beattracking_get_bpm(tempo); if (curtempo != 0.) { fprintf(stdout,"%f\n",curtempo); return 1; } curtempoconf = aubio_beattracking_get_confidence(tempo); if (curtempoconf != 0.) { fprintf(stdout,"%f\n",curtempo); return 1; } i++; }; del_aubio_beattracking(tempo); del_fvec(in); del_fvec(out); aubio_cleanup(); return 0; }
int main (void) { uint_t win_s = 16; // window size uint_t impulse_at = win_s / 2; fvec_t *in = new_fvec (win_s); // input buffer fvec_t *out = new_fvec (win_s); // input buffer aubio_filter_t *o = new_aubio_filter_c_weighting (44100); in->data[impulse_at] = 0.5; fvec_print (in); aubio_filter_do (o, in); fvec_print (in); del_aubio_filter (o); o = new_aubio_filter_a_weighting (32000); in->data[impulse_at] = 0.5; fvec_print (in); aubio_filter_do_outplace (o, in, out); fvec_print (out); aubio_filter_set_a_weighting (o, 32000); in->data[impulse_at] = 0.5; fvec_print (in); aubio_filter_do_filtfilt (o, in, out); fvec_print (out); del_fvec (in); del_fvec (out); del_aubio_filter (o); aubio_cleanup (); return 0; }
int main (int argc, char **argv) { uint_t err = 0; if (argc < 2) { err = 2; PRINT_ERR("not enough arguments\n"); PRINT_MSG("read a wave file as a mono vector\n"); PRINT_MSG("usage: %s <source_path> [samplerate] [win_size] [hop_size]\n", argv[0]); return err; } uint_t samplerate = 0; if ( argc >= 3 ) samplerate = atoi(argv[2]); uint_t win_size = 1024; // window size if ( argc >= 4 ) win_size = atoi(argv[3]); uint_t hop_size = win_size / 4; if ( argc >= 5 ) hop_size = atoi(argv[4]); uint_t n_frames = 0, read = 0; char_t *source_path = argv[1]; aubio_source_t * source = new_aubio_source(source_path, samplerate, hop_size); if (!source) { err = 1; goto beach; } if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(source); // create some vectors fvec_t * in = new_fvec (hop_size); // input audio buffer fvec_t * out = new_fvec (1); // output position // create tempo object aubio_tempo_t * o = new_aubio_tempo("default", win_size, hop_size, samplerate); do { // put some fresh data in input vector aubio_source_do(source, in, &read); // execute tempo aubio_tempo_do(o,in,out); // do something with the beats if (out->data[0] != 0) { PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2fbpm with confidence %.2f\n", aubio_tempo_get_last_ms(o), aubio_tempo_get_last_s(o), aubio_tempo_get_last(o), aubio_tempo_get_bpm(o), aubio_tempo_get_confidence(o)); } n_frames += read; } while ( read == hop_size ); PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n", n_frames * 1. / samplerate, n_frames, samplerate, n_frames / hop_size, source_path); // clean up memory del_aubio_tempo(o); del_fvec(in); del_fvec(out); del_aubio_source(source); beach: aubio_cleanup(); return err; }
aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels) { aubio_pvoc_t * pv = AUBIO_NEW(aubio_pvoc_t); if (win_s < 2*hop_s) { AUBIO_ERR("Hop size bigger than half the window size!\n"); AUBIO_ERR("Resetting hop size to half the window size.\n"); hop_s = win_s / 2; } if (hop_s < 1) { AUBIO_ERR("Hop size is smaller than 1!\n"); AUBIO_ERR("Resetting hop size to half the window size.\n"); hop_s = win_s / 2; } pv->fft = new_aubio_mfft(win_s,channels); /* remember old */ pv->data = new_fvec (win_s, channels); pv->synth = new_fvec (win_s, channels); /* new input output */ pv->dataold = new_fvec (win_s-hop_s, channels); pv->synthold = new_fvec (win_s-hop_s, channels); pv->w = AUBIO_ARRAY(smpl_t,win_s); aubio_window(pv->w,win_s,aubio_win_hanningz); pv->channels = channels; pv->hop_s = hop_s; pv->win_s = win_s; return pv; }
int main(){ /* allocate some memory */ uint_t win_s = 1024; /* window size */ fvec_t * in = new_fvec (win_s); /* input buffer */ fvec_t * out = new_fvec (2); /* input buffer */ aubio_tempo_t * o = new_aubio_tempo("complex", win_s, win_s/4, 44100.); uint_t i = 0; smpl_t curtempo, curtempoconf; while (i < 1000) { aubio_tempo_do(o,in,out); curtempo = aubio_tempo_get_bpm(o); if (curtempo != 0.) { fprintf(stdout,"%f\n",curtempo); return 1; } curtempoconf = aubio_tempo_get_confidence(o); if (curtempoconf != 0.) { fprintf(stdout,"%f\n",curtempo); return 1; } i++; }; del_aubio_tempo(o); del_fvec(in); del_fvec(out); aubio_cleanup(); return 0; }
//-------------------------------------------------------------- void aubioAnalyzer::setup(){ //the two variables that hold pitch and volume amplitude = 0; pitch = 0; //aubio stuff win_s = 1024; /* window size */ hop_s = win_s/4; /* hop size */ samplerate = 44100; /* samplerate */ channels = 1; /* number of channel */ mode = aubio_pitchm_freq; //change to aubio_pitchm_midi to get frequency as midi notes type = aubio_pitch_yinfft; //setup aubio buffer and pitch detection in = new_fvec (hop_s, channels); beats = new_fvec (win_s, channels); pitch_output = new_aubio_pitchdetection(win_s, hop_s, channels, samplerate, type, mode); tracker= new_aubio_beattracking(win_s, channels); pitch_color=pitch_color.blue; for (int x=0;x<440;x++){ top_pitches[x]= 0; } }
int main(){ /* allocate some memory */ uint_t win_s = 4096; /* window size */ uint_t channels = 100; /* number of channels */ fvec_t * in = new_fvec (win_s, channels); /* input buffer */ cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ fvec_t * out = new_fvec (win_s, channels); /* output buffer */ /* allocate fft and other memory space */ aubio_mfft_t * fft = new_aubio_mfft(win_s,channels); /* fill input with some data */ //printf("initialised\n"); /* execute stft */ aubio_mfft_do (fft,in,fftgrain); //printf("computed forward\n"); /* execute inverse fourier transform */ aubio_mfft_rdo(fft,fftgrain,out); //printf("computed backard\n"); del_aubio_mfft(fft); del_fvec(in); del_cvec(fftgrain); del_fvec(out); //printf("memory freed\n"); aubio_cleanup(); return 0; }
aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s) { aubio_pvoc_t * pv = AUBIO_NEW(aubio_pvoc_t); /* if (win_s < 2*hop_s) { AUBIO_WRN("Hop size bigger than half the window size!\n"); } */ if (hop_s < 1) { AUBIO_ERR("Hop size is smaller than 1!\n"); AUBIO_ERR("Resetting hop size to half the window size.\n"); hop_s = win_s / 2; } pv->fft = new_aubio_fft (win_s); /* remember old */ pv->data = new_fvec (win_s); pv->synth = new_fvec (win_s); /* new input output */ pv->dataold = new_fvec (win_s-hop_s); pv->synthold = new_fvec (win_s-hop_s); pv->w = new_aubio_window ("hanningz", win_s); pv->hop_s = hop_s; pv->win_s = win_s; return pv; }
static LV2_Handle instantiateTss(const LV2_Descriptor *descriptor, double s_rate, const char *path, const LV2_Feature * const * features) { tss_t *plugin_data = (tss_t *)malloc(sizeof(tss_t)); plugin_data->inbuff=new_fvec (HOP_SIZE,1); plugin_data->steadybuff=new_fvec (HOP_SIZE,1); plugin_data->transbuff=new_fvec(HOP_SIZE,1); memset(plugin_data->steadybuff->data[0],0,HOP_SIZE*sizeof(float)); memset(plugin_data->transbuff->data[0],0,HOP_SIZE*sizeof(float)); plugin_data->tss=new_aubio_tss (0.01, 3, 4, BUFFSIZE, HOP_SIZE, 1); plugin_data->pv = new_aubio_pvoc (BUFFSIZE,HOP_SIZE,1); plugin_data->pvt = new_aubio_pvoc(BUFFSIZE,HOP_SIZE,1); plugin_data->pvs = new_aubio_pvoc(BUFFSIZE,HOP_SIZE,1); plugin_data->ci=new_cvec (BUFFSIZE, 1); plugin_data->cs=new_cvec (BUFFSIZE, 1); plugin_data->ct=new_cvec (BUFFSIZE, 1); plugin_data->index=0; return (LV2_Handle)plugin_data; }
int main () { uint_t win_s = 64; // window size // create biquad filter with `b0`, `b1`, `b2`, `a1`, `a2` aubio_filter_t * o = new_aubio_filter_biquad(0.3,0.2,0.1,0.2,0.3); fvec_t * in_vec = new_fvec (win_s); // input buffer fvec_t * tmp_vec = new_fvec (win_s); // temporary buffer fvec_t * out_vec = new_fvec (win_s); // output buffer uint_t times = 100; while ( times-- ) { // copy to out, then filter out aubio_filter_do_outplace(o, in_vec, out_vec); // in-place filtering aubio_filter_do(o, in_vec); // in-place filtering aubio_filter_do_filtfilt(o, in_vec, out_vec); fvec_print(in_vec); } // memory clean-up, one for each new del_aubio_filter(o); del_fvec(in_vec); del_fvec(tmp_vec); del_fvec(out_vec); return 0; }
int main (void) { uint_t n = 10; // compute n times uint_t win_s = 1024; // window size uint_t hop_s = 256; // hop size // create some vectors fvec_t * in = new_fvec (hop_s); // input buffer cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase cvec_t * cstead = new_cvec (win_s); // fft norm and phase cvec_t * ctrans = new_cvec (win_s); // fft norm and phase fvec_t * stead = new_fvec (hop_s); // output buffer fvec_t * trans = new_fvec (hop_s); // output buffer // create phase vocoder for analysis of input signal aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s); // create transient/steady-state separation object aubio_tss_t * tss = new_aubio_tss(win_s,hop_s); // create phase vocoder objects for synthesis of output signals aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s); aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s); /* execute stft */ while ( n-- ) { // fftgrain = pv(in) aubio_pvoc_do (pv, in, fftgrain); // ctrans, cstead = tss (fftgrain) aubio_tss_do (tss, fftgrain, ctrans, cstead); // stead = pvt_inverse (cstead) // trans = pvt_inverse (ctrans) aubio_pvoc_rdo (pvt, cstead, stead); aubio_pvoc_rdo (pvs, ctrans, trans); } aubio_tss_set_alpha(tss, 4.); aubio_tss_set_beta(tss, 3.); aubio_tss_set_threshold(tss, 3.); del_aubio_pvoc(pv); del_aubio_pvoc(pvt); del_aubio_pvoc(pvs); del_aubio_tss(tss); del_fvec(in); del_cvec(fftgrain); del_cvec(cstead); del_cvec(ctrans); del_fvec(stead); del_fvec(trans); aubio_cleanup(); return 0; }
void AubioOnsetDetector :: initialise(){ //reinitialises our object o = new_aubio_onsetdetection(aubio_onset_complex, buffersize, 1);//initially in complex mode pv = (aubio_pvoc_t *)new_aubio_pvoc(buffersize, hopsize, 1); parms = new_aubio_peakpicker(threshold); vec = (fvec_t *)new_fvec(hopsize,1); pos = 0; fvec_write_sample(vec, 0.234, 0, pos); fftgrain = (cvec_t *)new_cvec(buffersize,1); onset = (fvec_t *)new_fvec(1,1); }
aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize) { aubio_pitchfcomb_t *p = AUBIO_NEW (aubio_pitchfcomb_t); p->fftSize = bufsize; p->stepSize = hopsize; p->winput = new_fvec (bufsize); p->fftOut = new_cvec (bufsize); p->fftLastPhase = new_fvec (bufsize); p->fft = new_aubio_fft (bufsize); p->win = new_aubio_window ("hanning", bufsize); return p; }
aubio_pitchmcomb_t * new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize) { aubio_pitchmcomb_t *p = AUBIO_NEW (aubio_pitchmcomb_t); /* bug: should check if size / 8 > post+pre+1 */ uint_t i, j; uint_t spec_size; p->spec_partition = 4; p->ncand = 5; p->npartials = 5; p->cutoff = 1.; p->threshold = 0.01; p->win_post = 8; p->win_pre = 7; // p->tau = samplerate/bufsize; p->alpha = 9.; p->goodcandidate = 0; p->phasefreq = bufsize / hopsize / TWO_PI; p->phasediff = TWO_PI * hopsize / bufsize; spec_size = bufsize / p->spec_partition; //p->pickerfn = quadpick; //p->biquad = new_biquad(0.1600,0.3200,0.1600, -0.5949, 0.2348); /* allocate temp memory */ p->newmag = new_fvec (spec_size); /* array for median */ p->scratch = new_fvec (spec_size); /* array for phase */ p->theta = new_fvec (spec_size); /* array for adaptative threshold */ p->scratch2 = new_fvec (p->win_post + p->win_pre + 1); /* array of spectral peaks */ p->peaks = AUBIO_ARRAY (aubio_spectralpeak_t, spec_size); for (i = 0; i < spec_size; i++) { p->peaks[i].bin = 0.; p->peaks[i].ebin = 0.; p->peaks[i].mag = 0.; } /* array of pointers to spectral candidates */ p->candidates = AUBIO_ARRAY (aubio_spectralcandidate_t *, p->ncand); for (i = 0; i < p->ncand; i++) { p->candidates[i] = AUBIO_NEW (aubio_spectralcandidate_t); p->candidates[i]->ecomb = AUBIO_ARRAY (smpl_t, spec_size); for (j = 0; j < spec_size; j++) { p->candidates[i]->ecomb[j] = 0.; } p->candidates[i]->ene = 0.; p->candidates[i]->ebin = 0.; p->candidates[i]->len = 0.; } return p; }
aubio_pitchspecacf_t * new_aubio_pitchspecacf (uint_t bufsize) { aubio_pitchspecacf_t *p = AUBIO_NEW (aubio_pitchspecacf_t); p->win = new_aubio_window ("hanningz", bufsize); p->winput = new_fvec (bufsize); p->fft = new_aubio_fft (bufsize); p->fftout = new_fvec (bufsize); p->sqrmag = new_fvec (bufsize); p->acf = new_fvec (bufsize / 2 + 1); p->tol = 1.; p->confidence = 0.; return p; }
aubio_notes_t * new_aubio_notes (const char_t * method, uint_t buf_size, uint_t hop_size, uint_t samplerate) { aubio_notes_t *o = AUBIO_NEW(aubio_notes_t); const char_t * onset_method = "default"; const char_t * pitch_method = "default"; o->onset_buf_size = buf_size; o->pitch_buf_size = buf_size * 4; o->hop_size = hop_size; o->onset_threshold = 0.; o->pitch_tolerance = 0.; o->samplerate = samplerate; o->median = 6; o->isready = 0; o->onset = new_aubio_onset (onset_method, o->onset_buf_size, o->hop_size, o->samplerate); if (o->onset_threshold != 0.) aubio_onset_set_threshold (o->onset, o->onset_threshold); o->onset_output = new_fvec (1); o->pitch = new_aubio_pitch (pitch_method, o->pitch_buf_size, o->hop_size, o->samplerate); if (o->pitch == NULL) goto fail; if (o->pitch_tolerance != 0.) aubio_pitch_set_tolerance (o->pitch, o->pitch_tolerance); aubio_pitch_set_unit (o->pitch, "midi"); o->pitch_output = new_fvec (1); if (strcmp(method, "default") != 0) { AUBIO_ERR("notes: unknown notes detection method \"%s\"\n", method); goto fail; } o->note_buffer = new_fvec(o->median); o->note_buffer2 = new_fvec(o->median); o->curnote = -1.; o->newnote = 0.; aubio_notes_set_silence(o, AUBIO_DEFAULT_NOTES_SILENCE); aubio_notes_set_minioi_ms (o, AUBIO_DEFAULT_NOTES_MINIOI_MS); return o; fail: del_aubio_notes(o); return NULL; }
int main(int argc, char **argv) { // override general settings from utils.c buffer_size = 1024; hop_size = 512; rgb_music_init(); examples_common_init(argc,argv); verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); verbmsg ("tempo method: %s, ", tempo_method); verbmsg ("buffer_size: %d, ", buffer_size); verbmsg ("hop_size: %d, ", hop_size); verbmsg ("threshold: %f\n", onset_threshold); tempo_out = new_fvec(2); tempo = new_aubio_tempo(tempo_method, buffer_size, hop_size, samplerate); if (onset_threshold != 0.) aubio_tempo_set_threshold (tempo, onset_threshold); pitch = new_aubio_pitch (pitch_method, buffer_size, hop_size, samplerate); if (pitch_tolerance != 0.) aubio_pitch_set_tolerance (pitch, pitch_tolerance); if (silence_threshold != -90.) aubio_pitch_set_silence (pitch, silence_threshold); if (pitch_unit != NULL) aubio_pitch_set_unit (pitch, pitch_unit); pitch_out = new_fvec (1); wavetable = new_aubio_wavetable (samplerate, hop_size); aubio_wavetable_set_freq ( wavetable, 2450.); //aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff"); examples_common_process((aubio_process_func_t)process_block,process_print); del_aubio_tempo(tempo); del_aubio_wavetable (wavetable); del_fvec(tempo_out); del_aubio_pitch (pitch); del_fvec (pitch_out); examples_common_del(); return 0; }
int main(int argc, char **argv) { // params buffer_size = 512; overlap_size = 256; examples_common_init(argc,argv); /* phase vocoder */ pv = new_aubio_pvoc (buffer_size, overlap_size); fftgrain = new_cvec (buffer_size); //populating the filter mfcc = new_aubio_mfcc(buffer_size, n_filters, n_coefs, samplerate); mfcc_out = new_fvec(n_coefs); //process examples_common_process(aubio_process,process_print); //destroying mfcc del_aubio_pvoc (pv); del_cvec (fftgrain); del_aubio_mfcc(mfcc); del_fvec(mfcc_out); examples_common_del(); debug("End of program.\n"); fflush(stderr); return 0; }
static PyObject * Py_filter_do(Py_filter * self, PyObject * args) { PyObject *input; fvec_t *vec; if (!PyArg_ParseTuple (args, "O:digital_filter.do", &input)) { return NULL; } if (input == NULL) { return NULL; } vec = PyAubio_ArrayToCFvec (input); if (vec == NULL) { return NULL; } // compute the function fvec_t * out = new_fvec(vec->length); aubio_filter_do_outplace (self->o, vec, out); return PyAubio_CFvecToArray(out); }
int main(int argc, char **argv) { // override general settings from utils.c buffer_size = 1024; hop_size = 512; examples_common_init(argc,argv); verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); verbmsg ("tempo method: %s, ", tempo_method); verbmsg ("buffer_size: %d, ", buffer_size); verbmsg ("hop_size: %d, ", hop_size); verbmsg ("threshold: %f\n", onset_threshold); tempo_out = new_fvec(2); tempo = new_aubio_tempo(tempo_method, buffer_size, hop_size, samplerate); // set silence threshold very low to output beats even during silence // aubio_tempo_set_silence(tempo, -1000.); if (onset_threshold != 0.) aubio_tempo_set_threshold (tempo, onset_threshold); wavetable = new_aubio_wavetable (samplerate, hop_size); aubio_wavetable_set_freq ( wavetable, 2450.); //aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff"); examples_common_process((aubio_process_func_t)process_block,process_print); del_aubio_tempo(tempo); del_aubio_wavetable (wavetable); del_fvec(tempo_out); examples_common_del(); return 0; }
int main () { uint_t win_s = 512; // fft size uint_t n_filters = 40; // number of filters uint_t n_coefs = 13; // number of coefficients smpl_t samplerate = 16000.; // samplerate cvec_t *in = new_cvec (win_s); // input buffer fvec_t *out = new_fvec (n_coefs); // output coefficients // create mfcc object aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coefs, samplerate); cvec_set_all_norm (in, 1.); aubio_mfcc_do (o, in, out); fvec_print (out); cvec_set_all_norm (in, .5); aubio_mfcc_do (o, in, out); fvec_print (out); // clean up del_aubio_mfcc (o); del_cvec (in); del_fvec (out); aubio_cleanup (); return 0; }
void Note2midi::set_plugin(){ o = new_aubio_onset (onset_method, PARAM_BUFFER_SIZE, PARAM_HOP_SIZE_ONSET, samplerate); if (onset_threshold != 0.) aubio_onset_set_threshold (o, onset_threshold); onset = new_fvec (1); pitch = new_aubio_pitch (pitch_method, PARAM_BUFFER_SIZE * PARAM_PITCH_BUFF_TIMES, PARAM_HOP_SIZE_PITCH, samplerate); if (pitch_tolerance != 0.) aubio_pitch_set_tolerance (pitch, pitch_tolerance); pitch_obuf = new_fvec (1); printf("%s\n", pitch_unit); if (median) { note_buffer = new_fvec (median); note_buffer2 = new_fvec (median); } }
aubio_tss_t * new_aubio_tss(uint_t buf_size, uint_t hop_size) { aubio_tss_t * o = AUBIO_NEW(aubio_tss_t); uint_t rsize = buf_size/2+1; o->threshold = 0.25; o->thrsfact = TWO_PI*hop_size/rsize; o->alpha = 3.; o->beta = 4.; o->parm = o->threshold*o->thrsfact; o->theta1 = new_fvec(rsize); o->theta2 = new_fvec(rsize); o->oft1 = new_fvec(rsize); o->oft2 = new_fvec(rsize); o->dev = new_fvec(rsize); return o; }
int main(int argc, char **argv) { buffer_size = 2048; examples_common_init(argc,argv); verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); verbmsg ("pitch method: %s, ", pitch_method); verbmsg ("pitch unit: %s, ", pitch_unit); verbmsg ("buffer_size: %d, ", buffer_size); verbmsg ("hop_size: %d, ", hop_size); verbmsg ("tolerance: %f\n", pitch_tolerance); o = new_aubio_pitch (pitch_method, buffer_size, hop_size, samplerate); if (pitch_tolerance != 0.) aubio_pitch_set_tolerance (o, pitch_tolerance); if (pitch_unit != NULL) aubio_pitch_set_unit (o, pitch_unit); pitch = new_fvec (1); wavetable = new_aubio_wavetable (samplerate, hop_size); aubio_wavetable_play ( wavetable ); examples_common_process((aubio_process_func_t)process_block,process_print); del_aubio_pitch (o); del_aubio_wavetable (wavetable); del_fvec (pitch); examples_common_del(); return 0; }
/* function Py_source_do */ static PyObject * Py_source_do(Py_source * self, PyObject * args) { /* output vectors prototypes */ fvec_t* read_to; uint_t read; /* creating output read_to as a new_fvec of length self->hop_size */ read_to = new_fvec (self->hop_size); read = 0; /* compute _do function */ aubio_source_do (self->o, read_to, &read); PyObject *outputs = PyList_New(0); PyList_Append( outputs, (PyObject *)PyAubio_CFvecToArray (read_to)); //del_fvec (read_to); PyList_Append( outputs, (PyObject *)PyLong_FromLong (read)); return outputs; }
void aubio_init(int c) { channels = c; /* phase vocoder */ pv = new_aubio_pvoc(buffer_size, overlap_size, channels); ibuf = new_fvec(overlap_size, channels); fftgrain = new_cvec(buffer_size, channels); o = new_aubio_onsetdetection(type_onset, buffer_size, channels); parms = new_aubio_peakpicker(threshold); onset = new_fvec(1, channels); pos = 0; onset_n = 0; if (usedoubled) { o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels); onset2 = new_fvec(1 , channels); } }
int main(int argc, char **argv) { // change some default params buffer_size = 512; hop_size = 256; examples_common_init(argc,argv); verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); verbmsg ("buffer_size: %d, ", buffer_size); verbmsg ("hop_size: %d\n", hop_size); pv = new_aubio_pvoc (buffer_size, hop_size); fftgrain = new_cvec (buffer_size); mfcc = new_aubio_mfcc(buffer_size, n_filters, n_coefs, samplerate); mfcc_out = new_fvec(n_coefs); examples_common_process((aubio_process_func_t)process_block, process_print); del_aubio_pvoc (pv); del_cvec (fftgrain); del_aubio_mfcc(mfcc); del_fvec(mfcc_out); examples_common_del(); return 0; }
AubioOnsetDetector :: AubioOnsetDetector(){ buffersize = 1024; hopsize = 512; //aubio related setup o = new_aubio_onsetdetection(aubio_onset_complex, buffersize, 1);//initially in complex mode pv = (aubio_pvoc_t *)new_aubio_pvoc(buffersize, hopsize, 1); parms = new_aubio_peakpicker(threshold); vec = (fvec_t *)new_fvec(hopsize,1); threshold = 1; threshold2 = -70.; maximumDetectionValue = 10.0; resetValues(); thresholdRelativeToMedian = 1.1; cutoffForRepeatOnsetsMillis = 100; medianSpeed = 15; pos = 0; detectionTriggerRatio = 0.5f; detectionTriggerThreshold = 10; }
aubio_wavetable_t *new_aubio_wavetable(uint_t samplerate, uint_t blocksize) { uint_t i = 0; aubio_wavetable_t *s = AUBIO_NEW(aubio_wavetable_t); if ((sint_t)samplerate <= 0) { AUBIO_ERR("Can not create wavetable with samplerate %d\n", samplerate); goto beach; } s->samplerate = samplerate; s->blocksize = blocksize; s->wavetable_length = WAVETABLE_LEN; s->wavetable = new_fvec(s->wavetable_length + 3); for (i = 0; i < s->wavetable_length; i++) { s->wavetable->data[i] = SIN(TWO_PI * i / (smpl_t) s->wavetable_length ); } s->wavetable->data[s->wavetable_length] = s->wavetable->data[0]; s->wavetable->data[s->wavetable_length + 1] = s->wavetable->data[1]; s->wavetable->data[s->wavetable_length + 2] = s->wavetable->data[2]; s->playing = 0; s->last_pos = 0.; s->freq = new_aubio_parameter( 0., s->samplerate / 2., 10 ); s->amp = new_aubio_parameter( 0., 1., 100 ); return s; beach: AUBIO_FREE(s); return NULL; }
void pitchDetector::setup(char_t * unit, char_t * method) { samplerate = 44100; uint_t win_s = 2048; // window size uint_t hop_s = 512; // hop size pitch_tolerance = 0; silence_threshold = -90.; pitch_unit = unit; pitch_method = method; blocks = 0; o = new_aubio_pitch (pitch_method, win_s, hop_s, samplerate); if (pitch_tolerance != 0.) aubio_pitch_set_tolerance (o, pitch_tolerance); if (silence_threshold != -90.) aubio_pitch_set_silence (o, silence_threshold); if (pitch_unit != NULL) aubio_pitch_set_unit (o, pitch_unit); pitch = new_fvec (1); }