Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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);
}