public static double Vector_getValueAtX (WavData sound, double x, int ilevel, int interpolation) {
      
        double tN = sound.t0 + sound.getFrameSize()*(sound.getNumSamples()-1);
	double leftEdge = sound.t0 - 0.5 * sound.getFrameSize(), rightEdge = leftEdge + sound.sampleSize * sound.getFrameSize();
	if (x <  leftEdge || x > rightEdge) return NUMundefined;
	if (ilevel >= Vector_CHANNEL_AVERAGE) {
            if(ilevel >= sound.numberOfChannels)
                System.err.println("WTF>!>!>");
            return interpolate_sinc (sound.getSamples(ilevel), sound.getNumSamples(), SampledUtils.xToIndex (sound.t0,sound.getFrameSize(),x),
			interpolation == Vector_VALUE_INTERPOLATION_SINC70 ? NUM_VALUE_INTERPOLATE_SINC70 :
			interpolation == Vector_VALUE_INTERPOLATION_SINC700 ? NUM_VALUE_INTERPOLATE_SINC700 :
			interpolation);
	}
	double sum = 0.0;
	for (int channel = 0; channel < sound.numberOfChannels; channel ++) {
            sum += interpolate_sinc (sound.getSamples(channel), sound.getNumSamples(), SampledUtils.xToIndex (sound.t0,sound.getFrameSize(),x),
			interpolation == Vector_VALUE_INTERPOLATION_SINC70 ? NUM_VALUE_INTERPOLATE_SINC70 :
			interpolation == Vector_VALUE_INTERPOLATION_SINC700 ? NUM_VALUE_INTERPOLATE_SINC700 :
			interpolation);
	}
	return sum / sound.numberOfChannels;
  }