Changeset 8247249


Ignore:
Timestamp:
Oct 27, 2013, 11:36:06 PM (10 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, pitchshift, sampler, timestretch, yinfft+
Children:
650cae3
Parents:
dc467b5d
Message:

src/synth/wavetable.c: fix frequency interpolation, add amp to do_multi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/synth/wavetable.c

    rdc467b5d r8247249  
    8686    smpl_t pos = s->last_pos;
    8787    for (i = 0; i < output->length; i++) {
    88       if (s->freq != s->target_freq)
     88      if ( ABS(s->freq - s->target_freq) > ABS(s->inc_freq) )
    8989        s->freq += s->inc_freq;
     90      else
     91        s->freq = s->target_freq;
    9092      smpl_t inc = s->freq * (smpl_t)(s->wavetable_length) / (smpl_t) (s->samplerate);
    9193      pos += inc;
     
    117119    smpl_t pos = s->last_pos;
    118120    for (j = 0; j < output->length; j++) {
    119       if (s->freq != s->target_freq)
     121      if ( ABS(s->freq - s->target_freq) > ABS(s->inc_freq) )
    120122        s->freq += s->inc_freq;
     123      else
     124        s->freq = s->target_freq;
    121125      smpl_t inc = s->freq * (smpl_t)(s->wavetable_length) / (smpl_t) (s->samplerate);
    122126      pos += inc;
     
    124128        pos -= s->wavetable_length;
    125129      }
     130      if ( ABS(s->amp - s->target_amp) > ABS(s->inc_amp) )
     131        s->amp += s->inc_amp;
     132      else
     133        s->amp = s->target_amp;
    126134      for (i = 0; i < output->height; i++) {
    127         output->data[i][j] = interp_2(s->wavetable, pos);
     135        output->data[i][j] = s->amp * interp_2(s->wavetable, pos);
    128136      }
    129137    }
Note: See TracChangeset for help on using the changeset viewer.