Changeset f5e0a54 for src/onset/onset.c
- Timestamp:
- Mar 15, 2013, 10:24:00 PM (12 years ago)
- 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:
- 35f73b8c
- Parents:
- 376946a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/onset/onset.c
r376946a rf5e0a54 31 31 struct _aubio_onset_t { 32 32 aubio_pvoc_t * pv; /**< phase vocoder */ 33 aubio_specdesc_t * od; /**< onset detection */33 aubio_specdesc_t * od; /**< onset description function */ 34 34 aubio_peakpicker_t * pp; /**< peak picker */ 35 35 cvec_t * fftgrain; /**< phase vocoder output */ … … 38 38 smpl_t silence; /**< silence threhsold */ 39 39 uint_t minioi; /**< minimum inter onset interval */ 40 fvec_t * wasonset; /**< number of frames since last onset */ 40 uint_t delay; /**< constant delay, in samples, removed from detected onset times */ 41 fvec_t * wasonset; /**< number of blocks since last onset */ 41 42 uint_t samplerate; /**< sampling rate of the input signal */ 42 uint_t hop_size; /**< number of samples between two runs */ 43 uint_t hop_size; /**< number of samples between two runs */ 44 45 uint_t total_frames; /**< total number of frames processed since the beginning */ 46 uint_t last_onset; /**< last detected onset location, in frames */ 43 47 }; 44 48 … … 60 64 if (wasonset > o->minioi) { 61 65 wasonset = 0; 66 o->last_onset = o->total_frames + isonset * o->hop_size; 62 67 } else { 63 68 isonset = 0; … … 69 74 //AUBIO_MSG("beginning of file is not silent, marking as onset\n", 70 75 // wasonset, aubio_silence_detection(input, o->silence)); 71 isonset = 4; 76 isonset = o->delay / o->hop_size; 77 o->last_onset = o->delay; 72 78 wasonset = 0; 73 79 } … … 75 81 } 76 82 o->wasonset->data[0] = wasonset; 83 //onset->data[0] = isonset * o->hop_size - o->delay; 77 84 onset->data[0] = isonset; 85 // also keep a copy of the offset for use in get_last_onset 86 o->total_frames += o->hop_size; 78 87 return; 79 88 } 80 89 90 smpl_t aubio_onset_get_last_onset (aubio_onset_t *o) 91 { 92 return o->last_onset - o->delay; 93 } 94 95 smpl_t aubio_onset_get_last_onset_s (aubio_onset_t *o) 96 { 97 return aubio_onset_get_last_onset (o) / (smpl_t) (o->samplerate); 98 } 99 100 smpl_t aubio_onset_get_last_onset_ms (aubio_onset_t *o) 101 { 102 return aubio_onset_get_last_onset_s (o) / 1000.; 103 } 104 81 105 smpl_t aubio_onset_get_descriptor(aubio_onset_t * o) { 82 106 return o->of->data[0]; 83 107 } 84 108 85 109 smpl_t aubio_onset_get_thresholded_descriptor(aubio_onset_t * o) { 86 87 110 fvec_t * thresholded = aubio_peakpicker_get_thresholded_input(o->pp); 111 return thresholded->data[0]; 88 112 } 89 113 … … 104 128 } 105 129 130 uint_t aubio_onset_get_minioi(aubio_onset_t * o) { 131 return o->minioi; 132 } 133 134 uint_t aubio_onset_set_delay(aubio_onset_t * o, uint_t delay) { 135 o->delay = delay; 136 return AUBIO_OK; 137 } 138 139 uint_t aubio_onset_get_delay(aubio_onset_t * o) { 140 return o->delay; 141 } 142 143 uint_t aubio_onset_set_delay_s(aubio_onset_t * o, smpl_t delay) { 144 return aubio_onset_set_delay (o, delay * o->samplerate); 145 } 146 147 smpl_t aubio_onset_get_delay_s(aubio_onset_t * o) { 148 return aubio_onset_get_delay (o) / (smpl_t) o->samplerate; 149 } 150 151 uint_t aubio_onset_set_delay_ms(aubio_onset_t * o, smpl_t delay) { 152 return aubio_onset_set_delay_s (o, delay / 1000.); 153 } 154 155 smpl_t aubio_onset_get_delay_ms(aubio_onset_t * o) { 156 return aubio_onset_get_delay_s (o) * 1000.; 157 } 158 106 159 /* Allocate memory for an onset detection */ 107 160 aubio_onset_t * new_aubio_onset (char_t * onset_mode, … … 110 163 aubio_onset_t * o = AUBIO_NEW(aubio_onset_t); 111 164 /** set some default parameter */ 165 o->last_onset = 0; 112 166 o->threshold = 0.3; 113 o->minioi = 4; 167 o->delay = 4.3 * hop_size; 168 o->minioi = 5; 114 169 o->silence = -70; 115 170 o->wasonset = new_fvec(1); 116 171 o->wasonset->data[0] = -1.; 172 o->total_frames = 0; 117 173 o->samplerate = samplerate; 118 174 o->hop_size = hop_size;
Note: See TracChangeset
for help on using the changeset viewer.