예제 #1
0
파일: aubiopitch.c 프로젝트: iKala/aubio
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;
}
예제 #2
0
파일: notes.c 프로젝트: anthonylauzon/aubio
void del_aubio_notes (aubio_notes_t *o) {
  if (o->note_buffer) del_fvec(o->note_buffer);
  if (o->note_buffer2) del_fvec(o->note_buffer2);
  if (o->pitch_output) del_fvec(o->pitch_output);
  if (o->pitch) del_aubio_pitch(o->pitch);
  if (o->onset_output) del_fvec(o->onset_output);
  if (o->onset) del_aubio_onset(o->onset);
  AUBIO_FREE(o);
}
예제 #3
0
파일: main.c 프로젝트: karshan/rgb_music
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;
}
예제 #4
0
int main(int argc, char **argv) {
  examples_common_init(argc,argv);

  o = new_aubio_pitch (pitch_mode, buffer_size, overlap_size, samplerate);
  pitch = new_fvec (1);

  examples_common_process(aubio_process,process_print);

  del_aubio_pitch (o);
  del_fvec (pitch);

  examples_common_del();
  debug("End of program.\n");
  fflush(stderr);
  return 0;
}
예제 #5
0
static void
gst_aubio_pitch_finalize (GObject * obj)
{
  GstAubioPitch * aubio_pitch = GST_AUBIO_PITCH (obj);

  if (aubio_pitch->t) {
    del_aubio_pitch(aubio_pitch->t);
  }
  if (aubio_pitch->ibuf) {
    del_fvec(aubio_pitch->ibuf);
  }
  if (aubio_pitch->obuf) {
    del_fvec(aubio_pitch->obuf);
  }

  G_OBJECT_CLASS (parent_class)->finalize (obj);
}
예제 #6
0
void Note2midi::cleanup(LV2_Handle instance)
{
    Note2midi *plugin;
    plugin = (Note2midi *) instance;


    plugin->send_noteon(plugin->curnote, 0);

    lv2_atom_sequence_append_event(plugin->out, out_capacity, &(plugin->note.event));

    del_aubio_pitch (plugin->pitch);
    if (plugin->median) {
        del_fvec (plugin->note_buffer);
        del_fvec (plugin->note_buffer2);
    }
    del_fvec (plugin->pitch_obuf);

    del_fvec (plugin->ibuf);

    delete ((Note2midi *) instance);
}
예제 #7
0
int
main ()
{
  /* allocate some memory */
  uint_t win_s = 1024;          /* window size */
  uint_t hop_s = win_s / 4;     /* hop size */
  uint_t samplerate = 44100;    /* samplerate */
  fvec_t *in = new_fvec (hop_s);      /* input buffer */
  fvec_t *out = new_fvec (1); /* input buffer */
  aubio_pitch_t *o =
      new_aubio_pitch ("default", win_s, hop_s, samplerate);
  uint_t i = 0;

  while (i < 100) {
    aubio_pitch_do (o, in, out);
    i++;
  };

  del_aubio_pitch (o);
  del_fvec (in);
  aubio_cleanup ();

  return 0;
}
예제 #8
0
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();
}
void pitchDetector::cleanup() {
    del_aubio_pitch (o);
    del_fvec (pitch);
}