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 (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; }
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; }
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; }
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; }
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); }
int main(){ int i; uint_t win_s = 1024; /* window size */ uint_t hop_s = 256; /* hop size */ uint_t channels = 4; /* number of channels */ /* allocate some memory */ fvec_t * in = new_fvec (hop_s, channels); /* input buffer */ cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ cvec_t * cstead = new_cvec (win_s, channels); /* fft norm and phase */ cvec_t * ctrans = new_cvec (win_s, channels); /* fft norm and phase */ fvec_t * stead = new_fvec (hop_s, channels); /* output buffer */ fvec_t * trans = new_fvec (hop_s, channels); /* output buffer */ /* allocate fft and other memory space */ aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s,channels); aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s,channels); aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s,channels); aubio_tss_t * tss = new_aubio_tss(0.01,3.,4.,win_s,hop_s,channels); /* fill input with some data */ printf("initialised\n"); /* execute stft */ for (i = 0; i < 10; i++) { aubio_pvoc_do (pv,in,fftgrain); aubio_tss_do (tss,fftgrain,ctrans,cstead); aubio_pvoc_rdo(pvt,cstead,stead); aubio_pvoc_rdo(pvs,ctrans,trans); } del_aubio_pvoc(pv); del_fvec(in); del_cvec(fftgrain); del_cvec(cstead); del_cvec(ctrans); del_fvec(stead); del_fvec(trans); aubio_cleanup(); printf("memory freed\n"); return 0; }
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); } }
/* Allocate memory for an onset detection */ aubio_onset_t * new_aubio_onset (const char_t * onset_mode, uint_t buf_size, uint_t hop_size, uint_t samplerate) { aubio_onset_t * o = AUBIO_NEW(aubio_onset_t); /* check parameters are valid */ if ((sint_t)hop_size < 1) { AUBIO_ERR("onset: got hop_size %d, but can not be < 1\n", hop_size); goto beach; } else if ((sint_t)buf_size < 2) { AUBIO_ERR("onset: got buffer_size %d, but can not be < 2\n", buf_size); goto beach; } else if (buf_size < hop_size) { AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", hop_size, buf_size); goto beach; } else if ((sint_t)samplerate < 1) { AUBIO_ERR("onset: samplerate (%d) can not be < 1\n", samplerate); goto beach; } /* store creation parameters */ o->samplerate = samplerate; o->hop_size = hop_size; /* allocate memory */ o->pv = new_aubio_pvoc(buf_size, o->hop_size); o->pp = new_aubio_peakpicker(); o->od = new_aubio_specdesc(onset_mode,buf_size); if (o->od == NULL) goto beach_specdesc; o->fftgrain = new_cvec(buf_size); o->desc = new_fvec(1); o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate); /* initialize internal variables */ aubio_onset_set_default_parameters (o, onset_mode); aubio_onset_reset(o); return o; beach_specdesc: del_aubio_peakpicker(o->pp); del_aubio_pvoc(o->pv); beach: AUBIO_FREE(o); return NULL; }
/* Allocate memory for an onset detection */ aubio_onset_t * new_aubio_onset (const char_t * onset_mode, uint_t buf_size, uint_t hop_size, uint_t samplerate) { aubio_onset_t * o = AUBIO_NEW(aubio_onset_t); /* check parameters are valid */ if ((sint_t)hop_size < 1) { AUBIO_ERR("onset: got hop_size %d, but can not be < 1\n", hop_size); goto beach; } else if ((sint_t)buf_size < 2) { AUBIO_ERR("onset: got buffer_size %d, but can not be < 2\n", buf_size); goto beach; } else if (buf_size < hop_size) { AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", buf_size, hop_size); goto beach; } else if ((sint_t)samplerate < 1) { AUBIO_ERR("onset: samplerate (%d) can not be < 1\n", samplerate); goto beach; } /* store creation parameters */ o->samplerate = samplerate; o->hop_size = hop_size; /* allocate memory */ o->pv = new_aubio_pvoc(buf_size, o->hop_size); o->pp = new_aubio_peakpicker(); o->od = new_aubio_specdesc(onset_mode,buf_size); o->fftgrain = new_cvec(buf_size); o->desc = new_fvec(1); /* set some default parameter */ aubio_onset_set_threshold (o, 0.3); aubio_onset_set_delay(o, 4.3 * hop_size); aubio_onset_set_minioi_ms(o, 20.); aubio_onset_set_silence(o, -70.); /* initialize internal variables */ o->last_onset = 0; o->total_frames = 0; return o; beach: AUBIO_FREE(o); return NULL; }
int main (void) { uint_t n = 6; // compute n times uint_t win_s = 32; // window size uint_t hop_s = win_s / 4; // hop size fvec_t * in = new_fvec (hop_s); // input buffer cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase fvec_t * out = new_fvec (hop_s); // output buffer // allocate fft and other memory space aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s); // fill input with some data fvec_set_all (in, 1.); fvec_print (in); while ( n-- ) { // get some fresh input data // .. // execute phase vocoder aubio_pvoc_do (pv,in,fftgrain); // do something with fftgrain // ... cvec_print (fftgrain); // optionally rebuild the signal aubio_pvoc_rdo(pv,fftgrain,out); // and do something with the result // ... fvec_print (out); } // clean up del_fvec(in); del_cvec(fftgrain); del_fvec(out); del_aubio_pvoc(pv); aubio_cleanup(); return 0; }
void ofxAubioMelBands::setup(string method, int buf_s, int hop_s, int samplerate) { ofxAubioBlock::setup(method, buf_s, hop_s, samplerate); pv = new_aubio_pvoc(buf_s, hop_s); spectrum = new_cvec(buf_s); fb = new_aubio_filterbank(40, buf_s); aubio_filterbank_set_mel_coeffs_slaney(fb, samplerate); bands = new_fvec(40); energies = bands->data; if (pv && fb) { ofLogNotice() << "created ofxAubioMelBands(" << method << ", " << buf_size << ", " << hop_size << ", " << samplerate << ")"; } }
/* Allocate memory for an onset detection */ aubio_onset_t * new_aubio_onset (char_t * onset_mode, uint_t buf_size, uint_t hop_size, uint_t samplerate) { aubio_onset_t * o = AUBIO_NEW(aubio_onset_t); /** set some default parameter */ o->samplerate = samplerate; o->hop_size = hop_size; o->last_onset = 0; o->threshold = 0.3; o->delay = 4.3 * hop_size; o->minioi = 5 * hop_size; o->silence = -70; o->total_frames = 0; o->pv = new_aubio_pvoc(buf_size, o->hop_size); o->pp = new_aubio_peakpicker(); aubio_peakpicker_set_threshold (o->pp, o->threshold); o->od = new_aubio_specdesc(onset_mode,buf_size); o->fftgrain = new_cvec(buf_size); o->desc = new_fvec(1); return o; }
/* Allocate memory for an tempo detection */ aubio_tempo_t * new_aubio_tempo (char_t * tempo_mode, uint_t buf_size, uint_t hop_size, uint_t samplerate) { aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t); char_t specdesc_func[20]; o->samplerate = samplerate; /* length of observations, worth about 6 seconds */ o->winlen = aubio_next_power_of_two(5.8 * samplerate / hop_size); o->step = o->winlen/4; o->blockpos = 0; o->threshold = 0.3; o->silence = -90.; o->total_frames = 0; o->last_beat = 0; o->delay = 0; o->hop_size = hop_size; o->dfframe = new_fvec(o->winlen); o->fftgrain = new_cvec(buf_size); o->out = new_fvec(o->step); o->pv = new_aubio_pvoc(buf_size, hop_size); o->pp = new_aubio_peakpicker(); aubio_peakpicker_set_threshold (o->pp, o->threshold); if ( strcmp(tempo_mode, "default") == 0 ) { strcpy(specdesc_func, "specflux"); } else { strcpy(specdesc_func, tempo_mode); } o->od = new_aubio_specdesc(specdesc_func,buf_size); o->of = new_fvec(1); o->bt = new_aubio_beattracking(o->winlen, o->hop_size, o->samplerate); o->onset = new_fvec(1); /*if (usedoubled) { o2 = new_aubio_specdesc(type_onset2,buffer_size); onset2 = new_fvec(1); }*/ return o; }
/* Allocate memory for an tempo detection */ aubio_tempo_t * new_aubio_tempo (aubio_onsetdetection_type type_onset, uint_t buf_size, uint_t hop_size, uint_t channels) { aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t); o->winlen = SQR(512)/hop_size; o->step = o->winlen/4; o->blockpos = 0; o->threshold = 0.3; o->silence = -90; o->blockpos = 0; o->dfframe = new_fvec(o->winlen,channels); o->fftgrain = new_cvec(buf_size, channels); o->out = new_fvec(o->step,channels); o->pv = new_aubio_pvoc(buf_size, hop_size, channels); o->pp = new_aubio_peakpicker(o->threshold); o->od = new_aubio_onsetdetection(type_onset,buf_size,channels); o->of = new_fvec(1, channels); o->bt = new_aubio_beattracking(o->winlen,channels); /*if (usedoubled) { o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels); onset2 = new_fvec(1 , channels); }*/ return o; }
int main (int argc, char** argv) { sint_t err = 0; if (argc < 2) { err = 2; PRINT_WRN("no arguments, running tests\n"); err = test_wrong_params(); PRINT_MSG("usage: %s <input_path> [samplerate] [hop_size]\n", argv[0]); return err; } uint_t win_s; // fft size uint_t hop_s = 256; // block size uint_t samplerate = 0; // samplerate uint_t n_filters = 40; // number of filters uint_t n_coeffs = 13; // number of coefficients uint_t read = 0; char_t *source_path = argv[1]; if ( argc >= 3 ) samplerate = atoi(argv[2]); if ( argc >= 4 ) hop_s = atoi(argv[3]); win_s = 2 * hop_s; aubio_source_t *source = 0; aubio_pvoc_t *pv = 0; aubio_mfcc_t *mfcc = 0; fvec_t *in = new_fvec (hop_s); // phase vocoder input cvec_t *fftgrain = new_cvec (win_s); // pvoc output / mfcc input fvec_t *out = new_fvec (n_coeffs); // mfcc output if (!in || !fftgrain || !out) { err = 1; goto failure; } // source source = new_aubio_source(source_path, samplerate, hop_s); if (!source) { err = 1; goto failure; } if (samplerate == 0) samplerate = aubio_source_get_samplerate(source); // phase vocoder pv = new_aubio_pvoc(win_s, hop_s); if (!pv) { err = 1; goto failure; } // mfcc object mfcc = new_aubio_mfcc (win_s, n_filters, n_coeffs, samplerate); if (!mfcc) { err = 1; goto failure; } // processing loop do { aubio_source_do(source, in, &read); aubio_pvoc_do(pv, in, fftgrain); aubio_mfcc_do(mfcc, fftgrain, out); fvec_print(out); } while (read == hop_s); failure: if (mfcc) del_aubio_mfcc(mfcc); if (pv) del_aubio_pvoc(pv); if (source) del_aubio_source(source); if (in) del_fvec(in); if (fftgrain) del_cvec(fftgrain); if (out) del_fvec(out); aubio_cleanup(); return err; }
void wav2midi_init(JNIEnv* env, jobject thiz) { LOGV("Aubio init"); JNIenv = env; counter = 0; const char * type_pitch_str; const char * type_onset_str; /* Read the member values from the Java Object that called sendSPAPacket() method */ jclass c = (*env)->GetObjectClass(env, thiz); jfieldID fid = (*env)->GetFieldID(env, c, "srcfilename", "Ljava/lang/String;"); jstring jaccess = (*env)->GetObjectField(env, thiz, fid); input_filename = (*env)->GetStringUTFChars(env, jaccess, 0); LOGD("Setting Input File: %s", input_filename); c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "type_pitch", "Ljava/lang/String;"); jaccess = (*env)->GetObjectField(env, thiz, fid); type_pitch_str = (*env)->GetStringUTFChars(env, jaccess, 0); LOGD("Setting Aubio Pitch Algorithm: %s", type_pitch_str); set_pitch_type(type_pitch_str); c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "type_onset", "Ljava/lang/String;"); jaccess = (*env)->GetObjectField(env, thiz, fid); type_onset_str = (*env)->GetStringUTFChars(env, jaccess, 0); LOGD("Setting Aubio Onset Algorithm: %s", type_onset_str); set_onset_type(type_onset_str); c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "type_onset2", "Ljava/lang/String;"); jaccess = (*env)->GetObjectField(env, thiz, fid); type_onset_str = (*env)->GetStringUTFChars(env, jaccess, 0); LOGD("Setting Aubio Onset 2nd Algorithm: %s", type_onset_str); set_onset_type2(type_onset_str); c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "samplerate", "I"); samplerate = (*env)->GetIntField(env, thiz, fid); LOGV("Setting Aubio SampleRate: %d", samplerate); c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "buffer_size", "I"); buffer_size = (*env)->GetIntField(env, thiz, fid); LOGV("Setting Aubio buffer_size: %d", buffer_size); c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "overlap_size", "I"); overlap_size = (*env)->GetIntField(env, thiz, fid); LOGV("Setting Aubio overlap_size: %d", overlap_size); /* c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "bitspersample", "I"); bitspersample = (*env)->GetIntField(env, thiz, fid); LOGV("PCM Bits per sample: %d", bitspersample); */ c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "channels", "I"); channels = (*env)->GetIntField(env, thiz, fid); LOGV("Setting Aubio Channels: %d", channels); c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "threshold", "F"); if (fid != NULL) { threshold = (*env)->GetFloatField(env, thiz, fid); } LOGD("Setting Aubio threshold: %f", threshold); c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "silence", "F"); if (fid != NULL) { silence = (*env)->GetFloatField(env, thiz, fid); } LOGD("Setting Aubio silence: %f", silence); c = (*env)->GetObjectClass(env, thiz); fid = (*env)->GetFieldID(env, c, "averaging", "F"); if (fid != NULL) { averaging = (*env)->GetFloatField(env, thiz, fid); } LOGD("Setting Aubio averaging: %f", averaging); debug("Read Java object Notes.\n"); Note = (*env)->FindClass(env, "com.atm.android.atm.midi.Note"); if (Note == NULL) { debug("Could not find Note class.\n"); return ; } midCtor = (*env)->GetMethodID(env, Note, "<init>", "(IIF)V"); debug("After init \n"); if (midCtor == NULL){ debug("Could not find Contructor method.\n"); return ; } notesArray = (*env)->NewObjectArray(env, 1000, Note, NULL); /* Sanity checks */ if (input_filename == NULL) { LOGV("Error: Need a file"); return; } debug("Opening input file: %s\n", input_filename); file = new_aubio_sndfile_ro(input_filename); debug("Opening input file finished: %s\n", input_filename); if (file == NULL) { outmsg("Could not open input file %s.\n", input_filename); debug("Could not open input file %s.\n", input_filename); exit(15); } verbose = 1; woodblock = new_fvec(buffer_size, 1); //Init Aubio with params if (verbose) aubio_sndfile_info(file); channels = aubio_sndfile_channels(file); samplerate = aubio_sndfile_samplerate(file); ibuf = new_fvec(overlap_size, channels); obuf = new_fvec(overlap_size, channels); fftgrain = new_cvec(buffer_size, channels); if (usepitch) { pitchdet = new_aubio_pitchdetection(buffer_size * 4, overlap_size, channels, samplerate, type_pitch, mode_pitch); aubio_pitchdetection_set_yinthresh(pitchdet, 0.7); if (median) { note_buffer = new_fvec(median, 1); note_buffer2 = new_fvec(median, 1); } } /* phase vocoder */ pv = new_aubio_pvoc(buffer_size, overlap_size, channels); /* onsets */ parms = new_aubio_peakpicker(threshold); o = new_aubio_onsetdetection(type_onset, buffer_size, channels); onset = new_fvec(1, channels); if (usedoubled) { o2 = new_aubio_onsetdetection(type_onset2, buffer_size, channels); onset2 = new_fvec(1, channels); } }
aubio_pitch_t * new_aubio_pitch (const char_t * pitch_mode, uint_t bufsize, uint_t hopsize, uint_t samplerate) { aubio_pitch_t *p = AUBIO_NEW (aubio_pitch_t); aubio_pitch_type pitch_type; if (strcmp (pitch_mode, "mcomb") == 0) pitch_type = aubio_pitcht_mcomb; else if (strcmp (pitch_mode, "yinfft") == 0) pitch_type = aubio_pitcht_yinfft; else if (strcmp (pitch_mode, "yin") == 0) pitch_type = aubio_pitcht_yin; else if (strcmp (pitch_mode, "schmitt") == 0) pitch_type = aubio_pitcht_schmitt; else if (strcmp (pitch_mode, "fcomb") == 0) pitch_type = aubio_pitcht_fcomb; else if (strcmp (pitch_mode, "specacf") == 0) pitch_type = aubio_pitcht_specacf; else if (strcmp (pitch_mode, "default") == 0) pitch_type = aubio_pitcht_default; else { AUBIO_ERR ("unknown pitch detection method %s, using default.\n", pitch_mode); pitch_type = aubio_pitcht_default; } // check parameters are valid if ((sint_t)hopsize < 1) { AUBIO_ERR("pitch: got hopsize %d, but can not be < 1\n", hopsize); goto beach; } else if ((sint_t)bufsize < 1) { AUBIO_ERR("pitch: got buffer_size %d, but can not be < 1\n", bufsize); goto beach; } else if (bufsize < hopsize) { AUBIO_ERR("pitch: hop size (%d) is larger than win size (%d)\n", bufsize, hopsize); goto beach; } else if ((sint_t)samplerate < 1) { AUBIO_ERR("pitch: samplerate (%d) can not be < 1\n", samplerate); goto beach; } p->samplerate = samplerate; p->type = pitch_type; aubio_pitch_set_unit (p, "default"); p->bufsize = bufsize; p->silence = DEFAULT_PITCH_SILENCE; p->conf_cb = NULL; switch (p->type) { case aubio_pitcht_yin: p->buf = new_fvec (bufsize); p->p_object = new_aubio_pitchyin (bufsize); p->detect_cb = aubio_pitch_do_yin; p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyin_get_confidence; aubio_pitchyin_set_tolerance (p->p_object, 0.15); break; case aubio_pitcht_mcomb: p->filtered = new_fvec (hopsize); p->pv = new_aubio_pvoc (bufsize, hopsize); p->fftgrain = new_cvec (bufsize); p->p_object = new_aubio_pitchmcomb (bufsize, hopsize); p->filter = new_aubio_filter_c_weighting (samplerate); p->detect_cb = aubio_pitch_do_mcomb; break; case aubio_pitcht_fcomb: p->buf = new_fvec (bufsize); p->p_object = new_aubio_pitchfcomb (bufsize, hopsize); p->detect_cb = aubio_pitch_do_fcomb; break; case aubio_pitcht_schmitt: p->buf = new_fvec (bufsize); p->p_object = new_aubio_pitchschmitt (bufsize); p->detect_cb = aubio_pitch_do_schmitt; break; case aubio_pitcht_yinfft: p->buf = new_fvec (bufsize); p->p_object = new_aubio_pitchyinfft (samplerate, bufsize); p->detect_cb = aubio_pitch_do_yinfft; p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyinfft_get_confidence; aubio_pitchyinfft_set_tolerance (p->p_object, 0.85); break; case aubio_pitcht_specacf: p->buf = new_fvec (bufsize); p->p_object = new_aubio_pitchspecacf (bufsize); p->detect_cb = aubio_pitch_do_specacf; p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchspecacf_get_tolerance; aubio_pitchspecacf_set_tolerance (p->p_object, 0.85); break; default: break; } return p; beach: AUBIO_FREE(p); return NULL; }