src/java.desktop/share/classes/com/sun/media/sound/EmergencySoundbank.java

Print this page

        

*** 35,45 **** * * @author Karl Helgason */ public final class EmergencySoundbank { ! private final static String[] general_midi_instruments = { "Acoustic Grand Piano", "Bright Acoustic Piano", "Electric Grand Piano", "Honky-tonk Piano", "Electric Piano 1", --- 35,45 ---- * * @author Karl Helgason */ public final class EmergencySoundbank { ! private static final String[] general_midi_instruments = { "Acoustic Grand Piano", "Bright Acoustic Piano", "Electric Grand Piano", "Honky-tonk Piano", "Electric Piano 1",
*** 2562,2576 **** } return ins; } ! static public void ifft(double[] data) { new FFT(data.length / 2, 1).transform(data); } ! static public void fft(double[] data) { new FFT(data.length / 2, -1).transform(data); } public static void complexGaussianDist(double[] cdata, double m, double s, double v) { --- 2562,2576 ---- } return ins; } ! public static void ifft(double[] data) { new FFT(data.length / 2, 1).transform(data); } ! public static void fft(double[] data) { new FFT(data.length / 2, -1).transform(data); } public static void complexGaussianDist(double[] cdata, double m, double s, double v) {
*** 2578,2606 **** cdata[x * 2] += v * (1.0 / (s * Math.sqrt(2 * Math.PI)) * Math.exp((-1.0 / 2.0) * Math.pow((x - m) / s, 2.0))); } } ! static public void randomPhase(double[] data) { for (int i = 0; i < data.length; i += 2) { double phase = Math.random() * 2 * Math.PI; double d = data[i]; data[i] = Math.sin(phase) * d; data[i + 1] = Math.cos(phase) * d; } } ! static public void randomPhase(double[] data, Random random) { for (int i = 0; i < data.length; i += 2) { double phase = random.nextDouble() * 2 * Math.PI; double d = data[i]; data[i] = Math.sin(phase) * d; data[i + 1] = Math.cos(phase) * d; } } ! static public void normalize(double[] data, double target) { double maxvalue = 0; for (int i = 0; i < data.length; i++) { if (data[i] > maxvalue) maxvalue = data[i]; if (-data[i] > maxvalue) --- 2578,2606 ---- cdata[x * 2] += v * (1.0 / (s * Math.sqrt(2 * Math.PI)) * Math.exp((-1.0 / 2.0) * Math.pow((x - m) / s, 2.0))); } } ! public static void randomPhase(double[] data) { for (int i = 0; i < data.length; i += 2) { double phase = Math.random() * 2 * Math.PI; double d = data[i]; data[i] = Math.sin(phase) * d; data[i + 1] = Math.cos(phase) * d; } } ! public static void randomPhase(double[] data, Random random) { for (int i = 0; i < data.length; i += 2) { double phase = random.nextDouble() * 2 * Math.PI; double d = data[i]; data[i] = Math.sin(phase) * d; data[i + 1] = Math.cos(phase) * d; } } ! public static void normalize(double[] data, double target) { double maxvalue = 0; for (int i = 0; i < data.length; i++) { if (data[i] > maxvalue) maxvalue = data[i]; if (-data[i] > maxvalue)
*** 2611,2621 **** double gain = target / maxvalue; for (int i = 0; i < data.length; i++) data[i] *= gain; } ! static public void normalize(float[] data, double target) { double maxvalue = 0.5; for (int i = 0; i < data.length; i++) { if (data[i * 2] > maxvalue) maxvalue = data[i * 2]; if (-data[i * 2] > maxvalue) --- 2611,2621 ---- double gain = target / maxvalue; for (int i = 0; i < data.length; i++) data[i] *= gain; } ! public static void normalize(float[] data, double target) { double maxvalue = 0.5; for (int i = 0; i < data.length; i++) { if (data[i * 2] > maxvalue) maxvalue = data[i * 2]; if (-data[i * 2] > maxvalue)
*** 2624,2675 **** double gain = target / maxvalue; for (int i = 0; i < data.length; i++) data[i * 2] *= gain; } ! static public double[] realPart(double[] in) { double[] out = new double[in.length / 2]; for (int i = 0; i < out.length; i++) { out[i] = in[i * 2]; } return out; } ! static public double[] imgPart(double[] in) { double[] out = new double[in.length / 2]; for (int i = 0; i < out.length; i++) { out[i] = in[i * 2]; } return out; } ! static public float[] toFloat(double[] in) { float[] out = new float[in.length]; for (int i = 0; i < out.length; i++) { out[i] = (float) in[i]; } return out; } ! static public byte[] toBytes(float[] in, AudioFormat format) { byte[] out = new byte[in.length * format.getFrameSize()]; return AudioFloatConverter.getConverter(format).toByteArray(in, out); } ! static public void fadeUp(double[] data, int samples) { double dsamples = samples; for (int i = 0; i < samples; i++) data[i] *= i / dsamples; } ! static public void fadeUp(float[] data, int samples) { double dsamples = samples; for (int i = 0; i < samples; i++) data[i] *= i / dsamples; } ! static public double[] loopExtend(double[] data, int newsize) { double[] outdata = new double[newsize]; int p_len = data.length; int p_ps = 0; for (int i = 0; i < outdata.length; i++) { outdata[i] = data[p_ps]; --- 2624,2675 ---- double gain = target / maxvalue; for (int i = 0; i < data.length; i++) data[i * 2] *= gain; } ! public static double[] realPart(double[] in) { double[] out = new double[in.length / 2]; for (int i = 0; i < out.length; i++) { out[i] = in[i * 2]; } return out; } ! public static double[] imgPart(double[] in) { double[] out = new double[in.length / 2]; for (int i = 0; i < out.length; i++) { out[i] = in[i * 2]; } return out; } ! public static float[] toFloat(double[] in) { float[] out = new float[in.length]; for (int i = 0; i < out.length; i++) { out[i] = (float) in[i]; } return out; } ! public static byte[] toBytes(float[] in, AudioFormat format) { byte[] out = new byte[in.length * format.getFrameSize()]; return AudioFloatConverter.getConverter(format).toByteArray(in, out); } ! public static void fadeUp(double[] data, int samples) { double dsamples = samples; for (int i = 0; i < samples; i++) data[i] *= i / dsamples; } ! public static void fadeUp(float[] data, int samples) { double dsamples = samples; for (int i = 0; i < samples; i++) data[i] *= i / dsamples; } ! public static double[] loopExtend(double[] data, int newsize) { double[] outdata = new double[newsize]; int p_len = data.length; int p_ps = 0; for (int i = 0; i < outdata.length; i++) { outdata[i] = data[p_ps];
*** 2678,2688 **** p_ps = 0; } return outdata; } ! static public float[] loopExtend(float[] data, int newsize) { float[] outdata = new float[newsize]; int p_len = data.length; int p_ps = 0; for (int i = 0; i < outdata.length; i++) { outdata[i] = data[p_ps]; --- 2678,2688 ---- p_ps = 0; } return outdata; } ! public static float[] loopExtend(float[] data, int newsize) { float[] outdata = new float[newsize]; int p_len = data.length; int p_ps = 0; for (int i = 0; i < outdata.length; i++) { outdata[i] = data[p_ps];