示例#1
0
void aubio_notes_do (aubio_notes_t *o, const fvec_t * input, fvec_t * notes)
{
  smpl_t new_pitch, curlevel;
  fvec_zeros(notes);
  aubio_onset_do(o->onset, input, o->onset_output);

  aubio_pitch_do (o->pitch, input, o->pitch_output);
  new_pitch = o->pitch_output->data[0];
  if(o->median){
    note_append(o->note_buffer, new_pitch);
  }

  /* curlevel is negatif or 1 if silence */
  curlevel = aubio_level_detection(input, o->silence_threshold);
  if (o->onset_output->data[0] != 0) {
    /* test for silence */
    if (curlevel == 1.) {
      if (o->median) o->isready = 0;
      /* send note off */
      //send_noteon(o->curnote,0);
      //notes->data[0] = o->curnote;
      //notes->data[1] = 0.;
      notes->data[2] = o->curnote;
    } else {
      if (o->median) {
        o->isready = 1;
      } else {
        /* kill old note */
        //send_noteon(o->curnote,0, o->samplerate);
        notes->data[2] = o->curnote;
        /* get and send new one */
        //send_noteon(new_pitch,127+(int)floor(curlevel), o->samplerate);
        notes->data[0] = new_pitch;
        notes->data[1] = 127 + (int)floor(curlevel);
        o->curnote = new_pitch;
      }
    }
  } else {
    if (o->median) {
      if (o->isready > 0)
        o->isready++;
      if (o->isready == o->median)
      {
        /* kill old note */
        //send_noteon(curnote,0);
        notes->data[2] = o->curnote;
        o->newnote = aubio_notes_get_latest_note(o);
        o->curnote = o->newnote;
        /* get and send new one */
        if (o->curnote>45){
          //send_noteon(curnote,127+(int)floor(curlevel));
          notes->data[0] = o->curnote;
          notes->data[1] = 127 + (int) floor(curlevel);
        }
      }
    } // if median
  }
}
示例#2
0
void Note2midi::process_block (){


    smpl_t new_pitch, curlevel;
    // fvec_zeros(obuf);
    aubio_onset_do(o, ibuf, onset);

    aubio_pitch_do (pitch, ibuf, pitch_obuf);
    new_pitch = fvec_get_sample(pitch_obuf, 0);
    if(median){
        note_append(note_buffer, new_pitch);
    }

  /* curlevel is negatif or 1 if silence */
    curlevel = aubio_level_detection(ibuf, *_silence_threshold);
    if (fvec_get_sample(onset, 0)) {
    /* test for silence */
        if (curlevel == 1.) {
            if (median) isready = 0;
      /* send note off */
            send_noteon(curnote, 0);
        } else {
            if (median) {
                isready = 1;
            } else {
        /* kill old note */
                send_noteon(curnote, 0);
        /* get and send new one */
                send_noteon(new_pitch, 127+(int)floor(curlevel));
                curnote = new_pitch;
            }
        }
    } 
    else {
        if (median) {
            if (isready > 0)
                isready++;
            if (isready == median){
        /* kill old note */
                send_noteon(curnote, 0);
                newnote = get_note(note_buffer, note_buffer2);
                curnote = newnote;
        /* get and send new one */
                if (curnote>45){
                    send_noteon(curnote, 127+(int)floor(curlevel));
                }
            }
        } // if median
    }

    // lv2_atom_sequence_append_event(this->out, out_capacity, &note.event);
}