Logo Search packages:      
Sourcecode: aubio version File versions  Download package

aubio_onsetdetection_t* new_aubio_onsetdetection ( aubio_onsetdetection_type  type,
uint_t  size,
uint_t  channels 
)

creation of an onset detection object

Parameters:
type onset detection mode
size length of the input spectrum frame
channels number of input channels

bug: must be complex array

Definition at line 209 of file onsetdetection.c.

References aubio_onset_complex, aubio_onset_energy, aubio_onset_hfc, aubio_onset_kl, aubio_onset_mkl, aubio_onset_phase, aubio_onset_specdiff, aubio_onsetdetection_energy(), aubio_onsetdetection_hfc(), _aubio_onsetdetection_t::dev1, _aubio_onsetdetection_t::funcpointer, _aubio_onsetdetection_t::histog, _aubio_onsetdetection_t::meas, _aubio_onsetdetection_t::oldmag, _aubio_onsetdetection_t::theta1, _aubio_onsetdetection_t::theta2, _aubio_onsetdetection_t::threshold, and _aubio_onsetdetection_t::type.

                                         {
      aubio_onsetdetection_t * o = AUBIO_NEW(aubio_onsetdetection_t);
      uint_t rsize = size/2+1;
  uint_t i;
      switch(type) {
            /* for both energy and hfc, only fftgrain->norm is required */
            case aubio_onset_energy: 
                  break;
            case aubio_onset_hfc:
                  break;
            /* the other approaches will need some more memory spaces */
            case aubio_onset_complex:
                  o->oldmag = new_fvec(rsize,channels);
                  /** bug: must be complex array */
                  o->meas = AUBIO_ARRAY(fft_data_t,size+1);
                  for (i=0; i<size+1; i++) o->meas[i] = 0;
                  o->dev1      = new_fvec(rsize,channels);
                  o->theta1 = new_fvec(rsize,channels);
                  o->theta2 = new_fvec(rsize,channels);
                  break;
            case aubio_onset_phase:
                  o->dev1      = new_fvec(rsize,channels);
                  o->theta1 = new_fvec(rsize,channels);
                  o->theta2 = new_fvec(rsize,channels);
                  o->histog = new_aubio_hist(0.0f, PI, 10, channels);
                  o->threshold = 0.1;
                  break;
            case aubio_onset_specdiff:
                  o->oldmag = new_fvec(rsize,channels);
                  o->dev1       = new_fvec(rsize,channels);
                  o->histog = new_aubio_hist(0.0f, PI, 10, channels);
                  o->threshold = 0.1;
                  break;
                case aubio_onset_kl:
                  o->oldmag = new_fvec(rsize,channels);
                        break;
                case aubio_onset_mkl:
                  o->oldmag = new_fvec(rsize,channels);
                        break;
            default:
                  break;
      }
      
      /* this switch could be in its own function to change between
       * detections on the fly. this would need getting rid of the switch
       * above and always allocate all the structure */

      switch(type) {
            case aubio_onset_energy:
                  o->funcpointer = aubio_onsetdetection_energy;
                  break;
            case aubio_onset_hfc:
                  o->funcpointer = aubio_onsetdetection_hfc;
                  break;
            case aubio_onset_complex:
                  o->funcpointer = aubio_onsetdetection_complex;
                  break;
            case aubio_onset_phase:
                  o->funcpointer = aubio_onsetdetection_phase;
                  break;
            case aubio_onset_specdiff:
                  o->funcpointer = aubio_onsetdetection_specdiff;
                  break;
                case aubio_onset_kl:
                  o->funcpointer = aubio_onsetdetection_kl;
                  break;
                case aubio_onset_mkl:
                  o->funcpointer = aubio_onsetdetection_mkl;
                  break;
            default:
                  break;
      }
      o->type = type;
      return o;
}


Generated by  Doxygen 1.6.0   Back to index