public WaveRateConverter(WaveReader wave_reader, int rate) { reader = wave_reader; aRate = rate; bRate = reader.getSampleRate(); #if DEBUG sout.println("WaveRateConverter#.ctor; aRate=" + aRate + "; bRate=" + bRate); //sout.println( "type eny key to exit..." ); //Console.Read(); #endif int gcd = (int)math.gcd(aRate, bRate); bUnit = bRate / gcd; aUnit = aRate / gcd; aTotalSamples = (long)(aRate * (double)reader.getTotalSamples() / (double)bRate); // バッファの長さはbUnitの倍数にする(補間が楽なので) int numUnit = MAX_BUFLEN / bUnit; if (numUnit <= 0) { numUnit = 1; } bBuflen = numUnit * bUnit; bufLeft = new double[bBuflen]; bufRight = new double[bBuflen]; }
public void close() { if (reader == null) { return; } reader.close(); reader = null; }