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; }
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); }
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; }
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); } }
static void gst_aubio_pitch_init (GstAubioPitch * filter, GstAubioPitchClass * gclass) { filter->silent = TRUE; filter->buf_size = 2048; filter->hop_size = 256; filter->samplerate = 44100; filter->channels = 1; filter->ibuf = new_fvec(filter->hop_size); filter->obuf = new_fvec(1); filter->t = new_aubio_pitch("yinfft", filter->buf_size, filter->hop_size, filter->samplerate); aubio_pitch_set_tolerance(filter->t, 0.7); }
void Note2midi::run(LV2_Handle instance, uint32_t SampleCount) { Note2midi *plugin = (Note2midi *) instance; unsigned int new_onset_method = (unsigned int)(*plugin->_onset_method); unsigned int new_pitch_method = (unsigned int)(*plugin->_pitch_method); char_t* on_meth; char_t* pi_meth; silence_threshold = *(plugin->_silence_threshold); aubio_onset_set_threshold(plugin->o, *plugin->_onset_threshold); aubio_pitch_set_tolerance(plugin->pitch, *plugin->_pitch_method); if(0 <= new_onset_method && 16 >= new_onset_method && new_onset_method != plugin->current_onset_method){ del_aubio_onset(plugin->o); switch(new_onset_method){ case ONSET_METHOD_ENERGY: on_meth = "energy"; break; case ONSET_METHOD_SPECDIFF: on_meth = "specdiff"; break; case ONSET_METHOD_HFC: on_meth = "hfc"; break; case ONSET_METHOD_COMPLEXDOMAIN: on_meth = "complexdomain"; break; case ONSET_METHOD_COMPLEX: on_meth = "complex"; break; case ONSET_METHOD_PHASE: on_meth = "phase"; break; case ONSET_METHOD_MKL: on_meth = "mkl"; break; case ONSET_METHOD_KL: on_meth = "kl"; break; case ONSET_METHOD_SPECFLUX: on_meth = "specflux"; break; case ONSET_METHOD_CENTROID: on_meth = "centroid"; break; case ONSET_METHOD_SPREAD: on_meth = "spread"; break; case ONSET_METHOD_SKEWNESS: on_meth = "skewness"; break; case ONSET_METHOD_KURTOSIS: on_meth = "kurtosis"; break; case ONSET_METHOD_SLOPE: on_meth = "slope"; break; case ONSET_METHOD_DECREASE: on_meth = "decrease"; break; case ONSET_METHOD_ROLLOFF: on_meth = "rolloff"; break; default: on_meth = "default"; break; } plugin->o = new_aubio_onset (on_meth, PARAM_BUFFER_SIZE, PARAM_HOP_SIZE_ONSET, plugin->samplerate); plugin->current_onset_method = new_onset_method; } if(0 <= new_pitch_method && 6 >= new_pitch_method && new_pitch_method != plugin->current_pitch_method){ del_aubio_pitch(plugin->pitch); switch(new_pitch_method){ case PITCH_METHOD_MCOMB: pi_meth = "mcomb"; break; case PITCH_METHOD_YINFFT: pi_meth = "yinfft"; break; case PITCH_METHOD_YIN: pi_meth = "yin"; break; case PITCH_METHOD_SCHMITT: pi_meth = "schmitt"; break; case PITCH_METHOD_FCOMB: pi_meth = "fcomb"; break; case PITCH_METHOD_SPECACF: pi_meth = "specacf"; break; default: pi_meth = "default"; break; } plugin->pitch = new_aubio_pitch (pi_meth, PARAM_BUFFER_SIZE * PARAM_PITCH_BUFF_TIMES, PARAM_HOP_SIZE_PITCH, plugin->samplerate); // aubio_pitch_set_unit (plugin->pitch, plugin->pitch_unit); plugin->current_pitch_method = new_pitch_method; } out_capacity = plugin->out->atom.size; plugin->out->atom.type = plugin->atom_sequence; lv2_atom_sequence_clear(plugin->out); plugin->ibuf->data = (smpl_t *) plugin->in; counter++; if(counter++ >= PARAM_BUFFER_SIZE) counter = 0; plugin->process_block(); }