Changeset f3617e7 for examples


Ignore:
Timestamp:
Nov 4, 2013, 3:28:24 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
e97d0b3
Parents:
509e8f9
Message:

examples/: use wavetable to play pitch and to replace woodblock

Location:
examples
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • examples/aubionotes.c

    r509e8f9 rf3617e7  
    8989
    9090                      for (pos = 0; pos < overlap_size; pos++){
    91                               obuf->data[pos] = woodblock->data[pos];
     91                              //obuf->data[pos] = woodblock->data[pos];
    9292                      }
    9393              }
  • examples/aubioonset.c

    r509e8f9 rf3617e7  
    2121#include "utils.h"
    2222
    23 unsigned int pos = 0; /*frames%dspblocksize*/
     23uint_t pos = 0; /*frames%dspblocksize*/
    2424
    2525aubio_onset_t *o;
     26aubio_wavetable_t *wavetable;
    2627fvec_t *onset;
    2728
     
    3839    if (pos == overlap_size-1) {
    3940      /* block loop */
     41      fvec_zeros(obuf);
    4042      aubio_onset_do (o, ibuf, onset);
    4143      if ( fvec_read_sample(onset, 0) ) {
    42         fvec_copy (woodblock, obuf);
     44        aubio_wavetable_play ( wavetable );
    4345      } else {
    44         fvec_zeros (obuf);
     46        aubio_wavetable_stop ( wavetable );
    4547      }
     48      aubio_wavetable_do (wavetable, ibuf, obuf);
    4649      /* end of block loop */
    4750      pos = -1; /* so it will be zero next j loop */
     
    7376  onset = new_fvec (1);
    7477
     78  wavetable = new_aubio_wavetable (samplerate, overlap_size);
     79  aubio_wavetable_set_freq ( wavetable, 2450.);
     80  //aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff");
     81
    7582  examples_common_process(aubio_process,process_print);
    7683
    7784  del_aubio_onset (o);
     85  del_aubio_wavetable (wavetable);
    7886  del_fvec (onset);
    7987
  • examples/aubiopitch.c

    r509e8f9 rf3617e7  
    2424
    2525aubio_pitch_t *o;
     26aubio_wavetable_t *wavetable;
    2627fvec_t *pitch;
    2728
     
    3940      /* block loop */
    4041      aubio_pitch_do (o, ibuf, pitch);
    41       if (fvec_read_sample(pitch, 0)) {
    42         for (pos = 0; pos < overlap_size; pos++){
    43           // TODO, play sine at this freq
    44         }
     42      smpl_t freq = fvec_read_sample(pitch, 0);
     43      smpl_t amp = powf(10., aubio_db_spl(ibuf)*.05 );
     44      aubio_wavetable_set_amp ( wavetable, amp );
     45      if (freq != 0.0) {
     46        aubio_wavetable_set_freq ( wavetable, freq );
    4547      } else {
    46         fvec_zeros (obuf);
     48        aubio_wavetable_set_freq ( wavetable, 0.0 );
    4749      }
     50      aubio_wavetable_do (wavetable, obuf, obuf);
    4851      /* end of block loop */
    4952      pos = -1; /* so it will be zero next j loop */
     
    6770  pitch = new_fvec (1);
    6871
     72  wavetable = new_aubio_wavetable (samplerate, overlap_size);
     73  aubio_wavetable_play ( wavetable );
     74
    6975  examples_common_process(aubio_process,process_print);
    7076
    7177  del_aubio_pitch (o);
     78  del_aubio_wavetable (wavetable);
    7279  del_fvec (pitch);
    7380
  • examples/aubiotrack.c

    r509e8f9 rf3617e7  
    1919*/
    2020
    21 #include <aubio.h>
    2221#include "utils.h"
    2322
    2423uint_t pos = 0;    /* frames%dspblocksize */
     24aubio_tempo_t * bt = NULL;
     25aubio_wavetable_t *wavetable;
    2526fvec_t * tempo_out = NULL;
    26 aubio_tempo_t * bt = NULL;
    2727smpl_t istactus = 0;
    2828smpl_t isonset = 0;
     
    3838    }
    3939    /*time for fft*/
    40     if (pos == overlap_size-1) {         
     40    if (pos == overlap_size-1) {
    4141      /* block loop */
    4242      aubio_tempo_do (bt,ibuf,tempo_out);
    4343      istactus = fvec_read_sample (tempo_out, 0);
    4444      isonset = fvec_read_sample (tempo_out, 1);
     45      fvec_zeros (obuf);
    4546      if (istactus > 0.) {
    46         fvec_copy (woodblock, obuf);
     47        aubio_wavetable_play ( wavetable );
    4748      } else {
    48         fvec_zeros (obuf);
     49        aubio_wavetable_stop ( wavetable );
    4950      }
     51      aubio_wavetable_do (wavetable, ibuf, obuf);
    5052      /* end of block loop */
    5153      pos = -1; /* so it will be zero next j loop */
     
    5759
    5860static void process_print (void) {
    59         if (sink_uri == NULL) {
    60                 if (istactus) {
    61                         outmsg("%f\n",((smpl_t)(frames*overlap_size)+(istactus-1.)*overlap_size)/(smpl_t)samplerate);
    62                 }
    63                 if (isonset && verbose)
    64                         outmsg(" \t \t%f\n",(frames)*overlap_size/(float)samplerate);
    65         }
     61  if (sink_uri == NULL) {
     62    if (istactus) {
     63      outmsg("%f\n",((smpl_t)(frames*overlap_size)+(istactus-1.)*overlap_size)/(smpl_t)samplerate);
     64    }
     65    if (isonset && verbose)
     66      outmsg(" \t \t%f\n",(frames)*overlap_size/(float)samplerate);
     67  }
    6668}
    6769
     
    7779  if (threshold != 0.) aubio_tempo_set_threshold (bt, threshold);
    7880
     81  wavetable = new_aubio_wavetable (samplerate, overlap_size);
     82  aubio_wavetable_set_freq ( wavetable, 2450.);
     83  //aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff");
     84
    7985  examples_common_process(aubio_process,process_print);
    8086
    8187  del_aubio_tempo(bt);
     88  del_aubio_wavetable (wavetable);
    8289  del_fvec(tempo_out);
    8390
  • examples/utils.c

    r509e8f9 rf3617e7  
    6666fvec_t *ibuf;
    6767fvec_t *obuf;
    68 fvec_t *woodblock;
    6968
    7069/* badly redeclare some things */
     
    246245#endif /* HAVE_LASH */
    247246
    248   woodblock = new_fvec (overlap_size);
    249   //TODO create woodblock sound
    250 
    251247  ibuf = new_fvec (overlap_size);
    252248  obuf = new_fvec (overlap_size);
     
    259255  del_fvec (ibuf);
    260256  del_fvec (obuf);
    261   del_fvec (woodblock);
    262257  aubio_cleanup ();
    263258}
  • examples/utils.h

    r509e8f9 rf3617e7  
    7777extern fvec_t *ibuf;
    7878extern fvec_t *obuf;
    79 extern fvec_t *woodblock;
Note: See TracChangeset for help on using the changeset viewer.