예제 #1
0
static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
  unsigned int j;       /*frames*/
  for (j=0;j<(unsigned)nframes;j++) {
    if(usejack) {
      /* write input to datanew */
      fvec_write_sample(ibuf, input[0][j], pos);
      /* put synthnew in output */
      output[0][j] = fvec_read_sample(obuf, pos);
    }
    /*time for fft*/
    if (pos == overlap_size-1) {         
      /* block loop */
      aubio_pitch_do (o, ibuf, pitch);
      if (fvec_read_sample(pitch, 0)) {
        for (pos = 0; pos < overlap_size; pos++){
          // TODO, play sine at this freq
        }
      } else {
        fvec_zeros (obuf);
      }
      /* end of block loop */
      pos = -1; /* so it will be zero next j loop */
    }
    pos++;
  }
  return 1;
}
예제 #2
0
static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
  unsigned int i;       /*channels*/
  unsigned int j;       /*frames*/
  for (j=0;j<(unsigned)nframes;j++) {
    if(usejack) {
      /* write input to datanew */
      fvec_write_sample(ibuf, input[0][j], pos);
      /* put synthnew in output */
      output[0][j] = fvec_read_sample(obuf, pos);
    }
    /*time for fft*/
    if (pos == overlap_size-1) {
      /* block loop */
      aubio_onset_do (o, ibuf, onset);
      if ( fvec_read_sample(onset, 0) ) {
        fvec_copy (woodblock, obuf);
      } else {
        fvec_zeros (obuf);
      }
      /* end of block loop */
      pos = -1; /* so it will be zero next j loop */
    }
    pos++;
  }
  return 1;
}
// this is 64-bit perform method for Max 6
void aubioOnset_perform64(t_aubioOnset *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam)
{
    int j, n;
    //t_double *inL = ins[0];		// we get audio for each inlet of the object from the **ins argument
    t_sample *in = ins[0];
    //t_double *outL = outs[0];	// we get audio for each outlet of the object from the **outs argument
    n = sampleframes;

    for (j = 0; j < n; j++) {
        /* write input to datanew */
        fvec_write_sample (x->in, in[j], 0, x->pos);
        /*time to do something */
        if (x->pos == x->hopsize - 1) {
            /* block loop */
            aubio_onset (x->o, x->in, x->out);
            if (fvec_read_sample (x->out, 0, 0) > 0.) {
                outlet_bang (x->onsetbang);
            }
            /* end of block loop */
            x->pos = -1;              /* so it will be zero next j loop */
        }
        x->pos++;
    }


    // this perform method simply copies the input to the output, offsetting the value
    //while (n--)
    //	*outL++ = *inL++ + x->offset;
}
// this is the 32-bit perform method for Max 5 and earlier
t_int *aubioOnset_perform(t_int *w)
{
    int j, n;
    // DO NOT CALL post IN HERE, but you can call defer_low (not defer)

    // args are in a vector, sized as specified in aubioOnset_dsp method
    // w[0] contains &aubioOnset_perform, so we start at w[1]
    t_aubioOnset *x = (t_aubioOnset *)(w[1]);
    //t_float *inL = (t_float *)(w[2]);
    //t_float *outL = (t_float *)(w[3]);
    t_sample *in = (t_float *)(w[2]);
    n = (int)w[3];

    for (j = 0; j < n; j++) {
        /* write input to datanew */
        fvec_write_sample (x->in, in[j], 0, x->pos);
        /*time to do something */
        if (x->pos == x->hopsize - 1) {
            /* block loop */
            aubio_onset (x->o, x->in, x->out);
            if (fvec_read_sample (x->out, 0, 0) > 0.) {
                outlet_bang (x->onsetbang);
            }
            /* end of block loop */
            x->pos = -1;              /* so it will be zero next j loop */
        }
        x->pos++;
    }

    // you have to return the NEXT pointer in the array OR MAX WILL CRASH
    return w + 4;
}
예제 #5
0
파일: aubiomfcc.c 프로젝트: daphne-yu/aubio
static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
  unsigned int j;       /*frames*/
  
  for (j=0;j<(unsigned)nframes;j++) {
    if(usejack) {
      /* write input to datanew */
      fvec_write_sample(ibuf, input[0][j], pos);
      /* put synthnew in output */
      output[0][j] = fvec_read_sample(obuf, pos);
    }
    /*time for fft*/
    if (pos == overlap_size-1) {         
      /* block loop */
      
      //compute mag spectrum
      aubio_pvoc_do (pv, ibuf, fftgrain);
     
      //compute mfccs
      aubio_mfcc_do(mfcc, fftgrain, mfcc_out);
      
      /* end of block loop */
      pos = -1; /* so it will be zero next j loop */
    }
    pos++;
  }
  return 1;
}
예제 #6
0
int aubio_process(float **input, float **output, int nframes) {
  unsigned int i;       /*channels*/
  unsigned int j;       /*frames*/
  for (j=0;j<(unsigned)nframes;j++) {
    if(usejack) {
      for (i=0;i<channels;i++) {
        /* write input to datanew */
        fvec_write_sample(ibuf, input[i][j], i, pos);
        /* put synthnew in output */
        output[i][j] = fvec_read_sample(obuf, i, pos);
      }
    }
    /*time for fft*/
    if (pos == overlap_size-1) {         
      /* block loop */
      aubio_tempo(bt,ibuf,out);
      if (out->data[0][0]==1) 
        istactus = 1;
      else 
        istactus = 0;
      if (istactus) {
              for (pos = 0; pos < overlap_size; pos++)
                      obuf->data[0][pos] = woodblock->data[0][pos];
      } else {
              for (pos = 0; pos < overlap_size; pos++)
                      obuf->data[0][pos] = 0.;
      }
      /* end of block loop */
      pos = -1; /* so it will be zero next j loop */
    }
    pos++;
  }
  return 1;
}
예제 #7
0
static void
process_print (void)
{
  /* output times in seconds, taking back some delay to ensure the label is
   * _before_ the actual onset */
  if (!verbose && usejack)
    return;
  smpl_t onset_found = fvec_read_sample (onset, 0);
  if (onset_found) {
    outmsg ("%f\n", aubio_onset_get_last_onset_s (o) );
  }
}
예제 #8
0
파일: aubiopitch.c 프로젝트: iKala/aubio
void
process_block(fvec_t * ibuf, fvec_t * obuf) {
  fvec_zeros(obuf);
  aubio_pitch_do (o, ibuf, pitch);
  smpl_t freq = fvec_read_sample(pitch, 0);
  aubio_wavetable_set_amp ( wavetable, aubio_level_lin (ibuf) );
  aubio_wavetable_set_freq ( wavetable, freq );

  if (mix_input)
    aubio_wavetable_do (wavetable, ibuf, obuf);
  else
    aubio_wavetable_do (wavetable, obuf, obuf);
}
예제 #9
0
파일: aubiomfcc.c 프로젝트: daphne-yu/aubio
static void process_print (void) {
      /* output times in seconds
         write extracted mfccs
      */
      
      uint_t coef_cnt;
      if (output_filename == NULL) {
        outmsg("%f\t",frames*overlap_size/(float)samplerate);
        for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) {
            outmsg("%f ", fvec_read_sample (mfcc_out, coef_cnt) );
        }
        outmsg("\n");
      }
}
예제 #10
0
static void
process_print (void)
{
  /* output times in seconds, taking back some delay to ensure the label is
   * _before_ the actual onset */
  if (!verbose && usejack)
    return;
  smpl_t onset_found = fvec_read_sample (onset, 0);
  if (onset_found) {
    if (frames >= 4) {
      outmsg ("%f\n", (frames - frames_delay + onset_found)
          * overlap_size / (float) samplerate);
    } else if (frames < frames_delay) {
      outmsg ("%f\n", 0.);
    }
  }
}
예제 #11
0
static t_int *
aubioOnset_tilde_perform (t_int * w)
{
    t_aubioOnset_tilde *x = (t_aubioOnset_tilde *) (w[1]);
    t_sample *in = (t_sample *) (w[2]);
    int n = (int) (w[3]);
    int j;
    for (j = 0; j < n; j++) {
        /* write input to datanew */
        fvec_write_sample (x->in, in[j], 0, x->pos);
        /*time to do something */
        if (x->pos == x->hopsize - 1) {
            /* block loop */
            aubio_onset (x->o, x->in, x->out);
            if (fvec_read_sample (x->out, 0, 0) > 0.) {
                outlet_bang (x->onsetbang);
            }
            /* end of block loop */
            x->pos = -1;              /* so it will be zero next j loop */
        }
        x->pos++;
    }
    return (w + 4);
}
예제 #12
0
static void process_print (void) {
      if (!verbose && usejack) return;
      smpl_t pitch_found = fvec_read_sample(pitch, 0);
      outmsg("%f %f\n",(frames) 
              *overlap_size/(float)samplerate, pitch_found);
}
예제 #13
0
파일: aubiopitch.c 프로젝트: iKala/aubio
void
process_print (void) {
  smpl_t pitch_found = fvec_read_sample(pitch, 0);
  outmsg("%f %f\n",(blocks)
      *hop_size/(float)samplerate, pitch_found);
}