Changes in / [cefa29d:4bc10e2]


Ignore:
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • doc/aubionotes.txt

    rcefa29d r4bc10e2  
    77  aubionotes [[-i] source]
    88             [-r rate] [-B win] [-H hop]
    9              [-O method] [-t thres]
     9             [-O method] [-t thres] [-d drop]
    1010             [-p method] [-u unit] [-l thres]
    1111             [-T time-format]
     
    6969  loudest ones. A value of -90.0 would select all onsets. Defaults to -90.0.
    7070
     71  -d, --release-drop  Set the release drop threshold, in dB. If the level is
     72  found to drop more than this amount since the last note has started, the
     73  note will be turned-off. Defaults to 10.
     74
    7175  -T, --timeformat format  Set time format (samples, ms, seconds). Defaults to
    7276  seconds.
  • examples/aubionotes.c

    rcefa29d r4bc10e2  
    2222#define PROG_HAS_PITCH 1
    2323#define PROG_HAS_ONSET 1
     24#define PROG_HAS_NOTES 1
    2425#define PROG_HAS_SILENCE 1
    2526#define PROG_HAS_JACK 1
     
    8384    }
    8485  }
     86  if (release_drop != 10.) {
     87    if (aubio_notes_set_release_drop (notes, release_drop) != 0) {
     88      errmsg ("failed setting notes release drop to %.2f\n",
     89          release_drop);
     90    }
     91  }
    8592
    8693  examples_common_process((aubio_process_func_t)process_block, process_print);
  • examples/parse_args.h

    rcefa29d r4bc10e2  
    4848// more general stuff
    4949extern smpl_t silence_threshold;
     50extern smpl_t release_drop;
    5051extern uint_t mix_input;
    5152// midi tap
     
    108109      "                 a value in dB, for instance -70, or -100; default=-90\n"
    109110#endif /* PROG_HAS_SILENCE */
     111#ifdef PROG_HAS_NOTES
     112      "       -d      --release-drop     select release drop threshold\n"
     113      "                 a positive value in dB; default=10\n"
     114#endif
    110115      "       -T      --time-format      select time values output format\n"
    111116      "                 (samples, ms, seconds) default=seconds\n"
     
    158163    "s:"
    159164#endif /* PROG_HAS_SILENCE */
     165#ifdef PROG_HAS_NOTES
     166    "d:"
     167#endif /* PROG_HAS_SILENCE */
    160168#ifdef PROG_HAS_OUTPUT
    161169    "mf"
     
    193201    {"silence",               1, NULL, 's'},
    194202#endif /* PROG_HAS_SILENCE */
     203#ifdef PROG_HAS_NOTES
     204    {"release-drop",          1, NULL, 'd'},
     205#endif /* PROG_HAS_NOTES */
    195206    {"time-format",           1, NULL, 'T'},
    196207#ifdef PROG_HAS_OUTPUT
     
    274285      case 's':                /* silence threshold */
    275286        silence_threshold = (smpl_t) atof (optarg);
     287        break;
     288      case 'd':                /* release-drop threshold */
     289        release_drop = (smpl_t) atof (optarg);
    276290        break;
    277291      case 'm':                /* mix_input flag */
  • examples/utils.c

    rcefa29d r4bc10e2  
    5555// more general stuff
    5656smpl_t silence_threshold = -90.;
     57smpl_t release_drop = 10.;
    5758uint_t mix_input = 0;
    5859
  • python/lib/aubio/cmd.py

    rcefa29d r4bc10e2  
    102102    subparser.add_input()
    103103    subparser.add_buf_hop_size()
     104    subparser.add_silence()
     105    subparser.add_release_drop()
    104106    subparser.add_time_format()
    105107    subparser.add_verbose_help()
     
    207209                action="store", dest="silence", default=-70,
    208210                help="silence threshold")
     211
     212    def add_release_drop(self):
     213        self.add_argument("-d", "--release-drop",
     214                metavar = "<value>", type=float,
     215                action="store", dest="release_drop", default=10,
     216                help="release drop threshold")
    209217
    210218    def add_minioi(self, default="12ms"):
     
    383391        self.parse_options(args, self.valid_opts)
    384392        self.notes = aubio.notes(**self.options)
     393        if args.silence is not None:
     394            self.notes.set_silence(args.silence)
     395        if args.release_drop is not None:
     396            self.notes.set_release_drop(args.release_drop)
    385397        super(process_notes, self).__init__(args)
    386398    def __call__(self, block):
  • python/tests/test_notes.py

    rcefa29d r4bc10e2  
    66
    77AUBIO_DEFAULT_NOTES_SILENCE = -70.
     8AUBIO_DEFAULT_NOTES_RELEASE_DROP = 10.
    89AUBIO_DEFAULT_NOTES_MINIOI_MS = 30.
    910
     
    3839        self.o.set_silence(val)
    3940        assert_equal (self.o.get_silence(), val)
     41
     42    def test_get_release_drop(self):
     43        assert_equal (self.o.get_release_drop(), AUBIO_DEFAULT_NOTES_RELEASE_DROP)
     44
     45    def test_set_release_drop(self):
     46        val = 50
     47        self.o.set_release_drop(val)
     48        assert_equal (self.o.get_release_drop(), val)
     49
     50    def test_set_release_drop_wrong(self):
     51        val = -10
     52        with self.assertRaises(ValueError):
     53            self.o.set_release_drop(val)
    4054
    4155from .utils import list_all_sounds
  • src/notes/notes.c

    rcefa29d r4bc10e2  
    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;
  • src/notes/notes.h

    rcefa29d r4bc10e2  
    107107uint_t aubio_notes_set_minioi_ms (aubio_notes_t *o, smpl_t minioi_ms);
    108108
     109/** get notes object release drop level, in dB
     110
     111  \param o notes detection object as returned by new_aubio_notes()
     112
     113  \return current release drop level, in dB
     114
     115 */
     116smpl_t aubio_notes_get_release_drop (const aubio_notes_t *o);
     117
     118/** set note release drop level, in dB
     119
     120  This function sets the release_drop_level parameter, in dB. When a new note
     121  is found, the current level in dB is measured. If the measured level drops
     122  under that initial level - release_drop_level, then a note-off will be
     123  emitted.
     124
     125  Defaults to `10`, in dB.
     126
     127  \note This parameter was added in version `0.4.8`. Results obtained with
     128  earlier versions can be reproduced by setting this value to `100`, so that
     129  note-off will not be played until the next note.
     130
     131  \param o notes detection object as returned by new_aubio_notes()
     132  \param release_drop new release drop level, in dB
     133
     134  \return 0 on success, non-zero otherwise
     135
     136*/
     137uint_t aubio_notes_set_release_drop (aubio_notes_t *o, smpl_t release_drop);
     138
    109139#ifdef __cplusplus
    110140}
Note: See TracChangeset for help on using the changeset viewer.