Changeset 79c2e52 for src


Ignore:
Timestamp:
Aug 22, 2005, 10:59:13 PM (19 years ago)
Author:
Paul Brossier <piem@altern.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:
3ec9d9c
Parents:
98ef4df
Message:

added bintomidi, freqtobin, miditofreq

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r98ef4df r79c2e52  
    346346
    347347smpl_t aubio_freqtomidi(smpl_t freq) {
    348   smpl_t midi = freq/6.875;
    349   /* log(freq/A-2)/log(2) */
    350   midi = LOG(midi)/0.69314718055995;
    351   midi *= 12;
    352   midi -= 3; 
    353   return midi;
     348        /* log(freq/A-2)/log(2) */
     349        smpl_t midi = freq/6.875;
     350        midi = LOG(midi)/0.69314718055995;
     351        midi *= 12;
     352        midi -= 3; 
     353        return midi;
     354}
     355
     356smpl_t aubio_miditofreq(smpl_t midi) {
     357        smpl_t freq = (midi+3.)/12.;
     358        freq = EXP(freq*0.69314718055995);
     359        freq *= 6.875;
     360        return freq;
    354361}
    355362
     
    359366}
    360367
    361 
    362368smpl_t aubio_bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize) {
    363369  smpl_t midi = aubio_bintofreq(bin,samplerate,fftsize);
    364370  return aubio_freqtomidi(midi);
     371}
     372
     373smpl_t aubio_freqtobin(smpl_t freq, smpl_t samplerate, smpl_t fftsize) {
     374  smpl_t bin = fftsize/samplerate;
     375  return freq*bin;
     376}
     377
     378smpl_t aubio_miditobin(smpl_t midi, smpl_t samplerate, smpl_t fftsize) {
     379  smpl_t freq = aubio_miditofreq(midi);
     380  return aubio_freqtobin(freq,samplerate,fftsize);
    365381}
    366382
  • src/mathutils.h

    r98ef4df r79c2e52  
    231231
    232232smpl_t aubio_bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
     233smpl_t aubio_miditobin(smpl_t midi, smpl_t samplerate, smpl_t fftsize);
    233234smpl_t aubio_bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
     235smpl_t aubio_freqtobin(smpl_t freq, smpl_t samplerate, smpl_t fftsize);
    234236smpl_t aubio_freqtomidi(smpl_t freq);
     237smpl_t aubio_miditofreq(smpl_t midi);
    235238
    236239uint_t aubio_silence_detection(fvec_t * ibuf, smpl_t threshold);
Note: See TracChangeset for help on using the changeset viewer.