Changeset 088760e for src/notes/notes.c


Ignore:
Timestamp:
Oct 31, 2018, 10:26:52 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/constantq
Children:
c03d191
Parents:
45c2c5c (diff), 7a54b37 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into feature/constantq

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/notes/notes.c

    r45c2c5c r088760e  
    11/*
    2   Copyright (C) 2014 Paul Brossier <piem@aubio.org>
     2  Copyright (C) 2014-2018 Paul Brossier <piem@aubio.org>
    33
    44  This file is part of aubio.
     
    2626
    2727#define AUBIO_DEFAULT_NOTES_SILENCE -70.
     28#define AUBIO_DEFAULT_NOTES_RELEASE_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 release_drop_level;
    5963};
    6064
     
    102106  aubio_notes_set_minioi_ms (o, AUBIO_DEFAULT_NOTES_MINIOI_MS);
    103107
     108  o->last_onset_level = AUBIO_DEFAULT_NOTES_SILENCE;
     109  o->release_drop_level = AUBIO_DEFAULT_NOTES_RELEASE_DROP;
     110
    104111  return o;
    105112
     
    139146{
    140147  return aubio_onset_get_minioi_ms(o->onset);
     148}
     149
     150uint_t aubio_notes_set_release_drop(aubio_notes_t *o, smpl_t release_drop_level)
     151{
     152  uint_t err = AUBIO_OK;
     153  if (release_drop_level <= 0.) {
     154    AUBIO_ERR("notes: release_drop should be >= 0, got %f\n", release_drop_level);
     155    err = AUBIO_FAIL;
     156  } else {
     157    o->release_drop_level = release_drop_level;
     158  }
     159  return err;
     160}
     161
     162smpl_t aubio_notes_get_release_drop(const aubio_notes_t *o)
     163{
     164  return o->release_drop_level;
    141165}
    142166
     
    185209      //notes->data[0] = o->curnote;
    186210      //notes->data[1] = 0.;
     211      //AUBIO_WRN("notes: sending note-off at onset, not enough level\n");
    187212      notes->data[2] = o->curnote;
    188213    } else {
     
    192217        /* kill old note */
    193218        //send_noteon(o->curnote,0, o->samplerate);
     219        //AUBIO_WRN("notes: sending note-off at onset, new onset detected\n");
    194220        notes->data[2] = o->curnote;
    195221        /* get and send new one */
     
    199225        o->curnote = new_pitch;
    200226      }
     227      o->last_onset_level = curlevel;
    201228    }
    202229  } else {
    203     if (o->median) {
     230    if (curlevel < o->last_onset_level - o->release_drop_level)
     231    {
     232      // send note off
     233      //AUBIO_WRN("notes: sending note-off, release detected\n");
     234      notes->data[0] = 0;
     235      notes->data[1] = 0;
     236      notes->data[2] = o->curnote;
     237      // reset last_onset_level to silence_threshold
     238      o->last_onset_level = o->silence_threshold;
     239      o->curnote = 0;
     240    }
     241    else if (o->median)
     242    {
    204243      if (o->isready > 0)
    205244        o->isready++;
     
    208247        /* kill old note */
    209248        //send_noteon(curnote,0);
    210         notes->data[2] = o->curnote;
     249        if (o->curnote != 0)
     250        {
     251          //AUBIO_WRN("notes: sending note-off, new note detected\n");
     252          notes->data[2] = o->curnote;
     253        }
    211254        o->newnote = aubio_notes_get_latest_note(o);
    212255        o->curnote = o->newnote;
Note: See TracChangeset for help on using the changeset viewer.