Changeset f761f06 for src/notes


Ignore:
Timestamp:
Oct 2, 2018, 2:56:52 PM (6 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
Children:
6bba139
Parents:
c7155e9
Message:

src/notes/notes.c: emit note-off earlier (see #203)

  • emit note-off when the level drops by a given threshold after onset
  • default drop threshold is set to 10dB
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/notes/notes.c

    rc7155e9 rf761f06  
    2626
    2727#define AUBIO_DEFAULT_NOTES_SILENCE -70.
     28#define AUBIO_DEFAULT_NOTES_LEVEL_DROP 10.
    2829// increase to 10. for .1  cent precision
    2930//      or to 100. for .01 cent precision
     
    5758
    5859  uint_t isready;
     60
     61  smpl_t last_onset_level;
     62  smpl_t level_delta_db;
    5963};
    6064
     
    101105  aubio_notes_set_silence(o, AUBIO_DEFAULT_NOTES_SILENCE);
    102106  aubio_notes_set_minioi_ms (o, AUBIO_DEFAULT_NOTES_MINIOI_MS);
     107
     108  o->last_onset_level = AUBIO_DEFAULT_NOTES_SILENCE;
     109  o->level_delta_db = AUBIO_DEFAULT_NOTES_LEVEL_DROP;
    103110
    104111  return o;
     
    185192      //notes->data[0] = o->curnote;
    186193      //notes->data[1] = 0.;
     194      //AUBIO_WRN("notes: sending note-off at onset, not enough level\n");
    187195      notes->data[2] = o->curnote;
    188196    } else {
     
    192200        /* kill old note */
    193201        //send_noteon(o->curnote,0, o->samplerate);
     202        //AUBIO_WRN("notes: sending note-off at onset, new onset detected\n");
    194203        notes->data[2] = o->curnote;
    195204        /* get and send new one */
     
    199208        o->curnote = new_pitch;
    200209      }
     210      o->last_onset_level = curlevel;
    201211    }
    202212  } else {
    203     if (o->median) {
     213    if (curlevel < o->last_onset_level - o->level_delta_db)
     214    {
     215      // send note off
     216      //AUBIO_WRN("notes: sending note-off, release detected\n");
     217      notes->data[0] = 0;
     218      notes->data[1] = 0;
     219      notes->data[2] = o->curnote;
     220      // reset last_onset_level to silence_threshold
     221      o->last_onset_level = o->silence_threshold;
     222      o->curnote = 0;
     223    }
     224    else if (o->median)
     225    {
    204226      if (o->isready > 0)
    205227        o->isready++;
     
    208230        /* kill old note */
    209231        //send_noteon(curnote,0);
    210         notes->data[2] = o->curnote;
     232        if (o->curnote != 0)
     233        {
     234          //AUBIO_WRN("notes: sending note-off, new note detected\n");
     235          notes->data[2] = o->curnote;
     236        }
    211237        o->newnote = aubio_notes_get_latest_note(o);
    212238        o->curnote = o->newnote;
Note: See TracChangeset for help on using the changeset viewer.