5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.sun.media.sound;
26
27 import java.util.Arrays;
28
29 import javax.sound.sampled.AudioFormat;
30
31 /**
32 * This class is used to store audio buffer.
33 *
34 * @author Karl Helgason
35 */
36 public final class SoftAudioBuffer {
37
38 private int size;
39 private float[] buffer;
40 private boolean empty = true;
41 private AudioFormat format;
42 private AudioFloatConverter converter;
43 private byte[] converter_buffer;
44
106 converter_buffer = new byte[c_len];
107
108 if (format.getChannels() == 1) {
109 converter.toByteArray(array(), size, buffer);
110 } else {
111 converter.toByteArray(array(), size, converter_buffer);
112 if (channel >= format.getChannels())
113 return;
114 int z_stepover = format.getChannels() * framesize_pc;
115 int k_stepover = framesize_pc;
116 for (int j = 0; j < framesize_pc; j++) {
117 int k = j;
118 int z = channel * framesize_pc + j;
119 for (int i = 0; i < size; i++) {
120 buffer[z] = converter_buffer[k];
121 z += z_stepover;
122 k += k_stepover;
123 }
124 }
125 }
126
127 }
128 }
|
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.media.sound;
27
28 import java.util.Arrays;
29
30 import javax.sound.sampled.AudioFormat;
31
32 /**
33 * This class is used to store audio buffer.
34 *
35 * @author Karl Helgason
36 */
37 public final class SoftAudioBuffer {
38
39 private int size;
40 private float[] buffer;
41 private boolean empty = true;
42 private AudioFormat format;
43 private AudioFloatConverter converter;
44 private byte[] converter_buffer;
45
107 converter_buffer = new byte[c_len];
108
109 if (format.getChannels() == 1) {
110 converter.toByteArray(array(), size, buffer);
111 } else {
112 converter.toByteArray(array(), size, converter_buffer);
113 if (channel >= format.getChannels())
114 return;
115 int z_stepover = format.getChannels() * framesize_pc;
116 int k_stepover = framesize_pc;
117 for (int j = 0; j < framesize_pc; j++) {
118 int k = j;
119 int z = channel * framesize_pc + j;
120 for (int i = 0; i < size; i++) {
121 buffer[z] = converter_buffer[k];
122 z += z_stepover;
123 k += k_stepover;
124 }
125 }
126 }
127 }
128 }
|