Ejemplo n.º 1
0
  @Override
  protected void uGenerate(float[] channels) {
    float sampleStep = value.getLastValue();

    // for 0 or negative rate values, we just stop generating audio
    // effectively pausing generation of the patched ugen.
    if (sampleStep <= 0.f) {
      for (int i = 0; i < channels.length; ++i) {
        channels[i] = 0.f;
      }

      return;
    }

    if (bInterpolate) {
      for (int i = 0; i < channels.length; ++i) {
        float sampleDiff = nextSample[i] - currentSample[i];
        channels[i] = currentSample[i] + sampleDiff * sampleCount;
      }
    } else {
      System.arraycopy(currentSample, 0, channels, 0, channels.length);
    }

    if (audio != null) {
      sampleCount += sampleStep;

      while (sampleCount >= 1.f) {
        System.arraycopy(nextSample, 0, currentSample, 0, nextSample.length);
        audio.tick(nextSample);
        sampleCount -= 1.f;
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  public void setAudioChannelCount(int numberOfChannels) {
    if (currentSample.length != numberOfChannels) {
      super.setAudioChannelCount(numberOfChannels);

      currentSample = new float[numberOfChannels];
      nextSample = new float[numberOfChannels];

      if (audio != null) {
        audio.setAudioChannelCount(numberOfChannels);
        audio.tick(currentSample);
        audio.tick(nextSample);
        sampleCount = 0;
      }
    }
  }
Ejemplo n.º 3
0
 @Override
 protected void sampleRateChanged() {
   if (audio != null) {
     audio.setSampleRate(sampleRate());
   }
 }
Ejemplo n.º 4
0
 @Override
 protected void addInput(UGen in) {
   audio = in;
   audio.setAudioChannelCount(currentSample.length);
 }