private void wavesSynth(WaveSynthParams synthParams,WavesData wavesInfo,WaveEnvelope envelope,boolean phaseShift,int regOffset,float[] out){
  int waveParam=wavesInfo.startIndex;
  for (int wn=0; wn < wavesInfo.numWavs; wn++, waveParam++) {
    double amp=amp_sf_tab[synthParams.waves[waveParam].ampSf] * (synthParams.amplitudeMode == 0 ? (synthParams.waves[waveParam].ampIndex + 1) / 15.13f : 1.0f);
    int inc=synthParams.waves[waveParam].freqIndex;
    int pos=DEQUANT_PHASE(synthParams.waves[waveParam].phaseIndex) - (regOffset ^ 128) * inc & 2047;
    for (int i=0; i < 128; i++) {
      out[i]+=sine_table[pos] * amp;
      pos=(pos + inc) & 2047;
    }
  }
  if (phaseShift) {
    for (int i=0; i < 128; i++) {
      out[i]=-out[i];
    }
  }
  if (envelope.hasStartPoint) {
    int pos=(envelope.startPos << 2) - regOffset;
    if (pos > 0 && pos <= 128) {
      Arrays.fill(out,0,pos,0f);
      if (!envelope.hasStopPoint || envelope.startPos != envelope.stopPos) {
        out[pos + 0]*=hann_window[0];
        out[pos + 1]*=hann_window[32];
        out[pos + 2]*=hann_window[64];
        out[pos + 3]*=hann_window[96];
      }
    }
  }
  if (envelope.hasStopPoint) {
    int pos=(envelope.stopPos + 1 << 2) - regOffset;
    if (pos > 0 && pos <= 128) {
      out[pos - 4]*=hann_window[96];
      out[pos - 3]*=hann_window[64];
      out[pos - 2]*=hann_window[32];
      out[pos - 1]*=hann_window[0];
      Arrays.fill(out,pos,128,0f);
    }
  }
}

private void wavesSynth ( WaveSynthParams synthParams , WavesData wavesInfo , WaveEnvelope envelope , boolean phaseShift , int regOffset , float [ ] out ) { int waveParam = wavesInfo . startIndex ; for ( int wn = 0 ; wn < wavesInfo . numWavs ; wn ++ , waveParam ++ ) { double amp = amp_sf_tab [ synthParams . waves [ waveParam ] . ampSf ] * ( synthParams . amplitudeMode == 0 ? ( synthParams . waves [ waveParam ] . ampIndex + 1 ) / 15.13f : 1.0f ) ; int inc = synthParams . waves [ waveParam ] . freqIndex ; int pos = DEQUANT_PHASE ( synthParams . waves [ waveParam ] . phaseIndex ) - ( regOffset ^ 128 ) * inc & 2047 ; for ( int i = 0 ; i < 128 ; i ++ ) { out [ i ] += sine_table [ pos ] * amp ; pos = ( pos + inc ) & 2047 ; } } if ( phaseShift ) { for ( int i = 0 ; i < 128 ; i ++ ) { out [ i ] = - out [ i ] ; } } if ( envelope . hasStartPoint ) { int pos = ( envelope . startPos << 2 ) - regOffset ; if ( pos > 0 && pos <= 128 ) { Arrays . fill ( out , 0 , pos , 0f ) ; if ( ! envelope . hasStopPoint || envelope . startPos != envelope . stopPos ) { out [ pos + 0 ] *= hann_window [ 0 ] ; out [ pos + 1 ] *= hann_window [ 32 ] ; out [ pos + 2 ] *= hann_window [ 64 ] ; out [ pos + 3 ] *= hann_window [ 96 ] ; } } } if ( envelope . hasStopPoint ) { int pos = ( envelope . stopPos + 1 << 2 ) - regOffset ; if ( pos > 0 && pos <= 128 ) { out [ pos - 4 ] *= hann_window [ 96 ] ; out [ pos - 3 ] *= hann_window [ 64 ] ; out [ pos - 2 ] *= hann_window [ 32 ] ; out [ pos - 1 ] *= hann_window [ 0 ] ; Arrays . fill ( out , pos , 128 , 0f ) ; } } }
synthesize sine waves according to given parameters .
