author | never |
Mon, 12 Jul 2010 22:27:18 -0700 | |
changeset 5926 | a36f90d986b6 |
parent 5506 | 202f599c92aa |
child 6502 | 13b20559a04a |
permissions | -rw-r--r-- |
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. |
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
4 |
* |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
10 |
* |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
15 |
* accompanied this code). |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
16 |
* |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
20 |
* |
5506 | 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. |
|
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
24 |
*/ |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
25 |
package com.sun.media.sound; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
26 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
27 |
import java.io.IOException; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
28 |
import java.io.InputStream; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
29 |
import javax.sound.sampled.AudioFormat; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
30 |
import javax.sound.sampled.AudioInputStream; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
31 |
import javax.sound.sampled.AudioSystem; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
32 |
import javax.sound.sampled.AudioFormat.Encoding; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
33 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
34 |
/** |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
35 |
* Wavetable oscillator for pre-loaded data. |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
36 |
* |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
37 |
* @author Karl Helgason |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
38 |
*/ |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
39 |
public class ModelByteBufferWavetable implements ModelWavetable { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
40 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
41 |
private class Buffer8PlusInputStream extends InputStream { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
42 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
43 |
private boolean bigendian; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
44 |
private int framesize_pc; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
45 |
int pos = 0; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
46 |
int pos2 = 0; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
47 |
int markpos = 0; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
48 |
int markpos2 = 0; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
49 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
50 |
public Buffer8PlusInputStream() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
51 |
framesize_pc = format.getFrameSize() / format.getChannels(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
52 |
bigendian = format.isBigEndian(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
53 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
54 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
55 |
public int read(byte[] b, int off, int len) throws IOException { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
56 |
int avail = available(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
57 |
if (avail <= 0) |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
58 |
return -1; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
59 |
if (len > avail) |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
60 |
len = avail; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
61 |
byte[] buff1 = buffer.array(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
62 |
byte[] buff2 = buffer8.array(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
63 |
pos += buffer.arrayOffset(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
64 |
pos2 += buffer8.arrayOffset(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
65 |
if (bigendian) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
66 |
for (int i = 0; i < len; i += (framesize_pc + 1)) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
67 |
System.arraycopy(buff1, pos, b, i, framesize_pc); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
68 |
System.arraycopy(buff2, pos2, b, i + framesize_pc, 1); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
69 |
pos += framesize_pc; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
70 |
pos2 += 1; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
71 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
72 |
} else { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
73 |
for (int i = 0; i < len; i += (framesize_pc + 1)) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
74 |
System.arraycopy(buff2, pos2, b, i, 1); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
75 |
System.arraycopy(buff1, pos, b, i + 1, framesize_pc); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
76 |
pos += framesize_pc; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
77 |
pos2 += 1; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
78 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
79 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
80 |
pos -= buffer.arrayOffset(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
81 |
pos2 -= buffer8.arrayOffset(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
82 |
return len; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
83 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
84 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
85 |
public long skip(long n) throws IOException { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
86 |
int avail = available(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
87 |
if (avail <= 0) |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
88 |
return -1; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
89 |
if (n > avail) |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
90 |
n = avail; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
91 |
pos += (n / (framesize_pc + 1)) * (framesize_pc); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
92 |
pos2 += n / (framesize_pc + 1); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
93 |
return super.skip(n); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
94 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
95 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
96 |
public int read(byte[] b) throws IOException { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
97 |
return read(b, 0, b.length); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
98 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
99 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
100 |
public int read() throws IOException { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
101 |
byte[] b = new byte[1]; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
102 |
int ret = read(b, 0, 1); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
103 |
if (ret == -1) |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
104 |
return -1; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
105 |
return 0 & 0xFF; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
106 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
107 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
108 |
public boolean markSupported() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
109 |
return true; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
110 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
111 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
112 |
public int available() throws IOException { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
113 |
return (int)buffer.capacity() + (int)buffer8.capacity() - pos - pos2; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
114 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
115 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
116 |
public synchronized void mark(int readlimit) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
117 |
markpos = pos; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
118 |
markpos2 = pos2; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
119 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
120 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
121 |
public synchronized void reset() throws IOException { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
122 |
pos = markpos; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
123 |
pos2 = markpos2; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
124 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
125 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
126 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
127 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
128 |
private float loopStart = -1; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
129 |
private float loopLength = -1; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
130 |
private ModelByteBuffer buffer; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
131 |
private ModelByteBuffer buffer8 = null; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
132 |
private AudioFormat format = null; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
133 |
private float pitchcorrection = 0; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
134 |
private float attenuation = 0; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
135 |
private int loopType = LOOP_TYPE_OFF; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
136 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
137 |
public ModelByteBufferWavetable(ModelByteBuffer buffer) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
138 |
this.buffer = buffer; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
139 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
140 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
141 |
public ModelByteBufferWavetable(ModelByteBuffer buffer, |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
142 |
float pitchcorrection) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
143 |
this.buffer = buffer; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
144 |
this.pitchcorrection = pitchcorrection; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
145 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
146 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
147 |
public ModelByteBufferWavetable(ModelByteBuffer buffer, AudioFormat format) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
148 |
this.format = format; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
149 |
this.buffer = buffer; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
150 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
151 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
152 |
public ModelByteBufferWavetable(ModelByteBuffer buffer, AudioFormat format, |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
153 |
float pitchcorrection) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
154 |
this.format = format; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
155 |
this.buffer = buffer; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
156 |
this.pitchcorrection = pitchcorrection; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
157 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
158 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
159 |
public void set8BitExtensionBuffer(ModelByteBuffer buffer) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
160 |
buffer8 = buffer; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
161 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
162 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
163 |
public ModelByteBuffer get8BitExtensionBuffer() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
164 |
return buffer8; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
165 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
166 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
167 |
public ModelByteBuffer getBuffer() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
168 |
return buffer; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
169 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
170 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
171 |
public AudioFormat getFormat() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
172 |
if (format == null) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
173 |
if (buffer == null) |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
174 |
return null; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
175 |
InputStream is = buffer.getInputStream(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
176 |
AudioFormat format = null; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
177 |
try { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
178 |
format = AudioSystem.getAudioFileFormat(is).getFormat(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
179 |
} catch (Exception e) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
180 |
//e.printStackTrace(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
181 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
182 |
try { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
183 |
is.close(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
184 |
} catch (IOException e) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
185 |
//e.printStackTrace(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
186 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
187 |
return format; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
188 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
189 |
return format; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
190 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
191 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
192 |
public AudioFloatInputStream openStream() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
193 |
if (buffer == null) |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
194 |
return null; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
195 |
if (format == null) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
196 |
InputStream is = buffer.getInputStream(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
197 |
AudioInputStream ais = null; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
198 |
try { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
199 |
ais = AudioSystem.getAudioInputStream(is); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
200 |
} catch (Exception e) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
201 |
//e.printStackTrace(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
202 |
return null; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
203 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
204 |
return AudioFloatInputStream.getInputStream(ais); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
205 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
206 |
if (buffer.array() == null) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
207 |
return AudioFloatInputStream.getInputStream(new AudioInputStream( |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
208 |
buffer.getInputStream(), format, buffer.capacity())); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
209 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
210 |
if (buffer8 != null) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
211 |
if (format.getEncoding().equals(Encoding.PCM_SIGNED) |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
212 |
|| format.getEncoding().equals(Encoding.PCM_UNSIGNED)) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
213 |
InputStream is = new Buffer8PlusInputStream(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
214 |
AudioFormat format2 = new AudioFormat( |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
215 |
format.getEncoding(), |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
216 |
format.getSampleRate(), |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
217 |
format.getSampleSizeInBits() + 8, |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
218 |
format.getChannels(), |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
219 |
format.getFrameSize() + (1 * format.getChannels()), |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
220 |
format.getFrameRate(), |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
221 |
format.isBigEndian()); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
222 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
223 |
AudioInputStream ais = new AudioInputStream(is, format2, |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
224 |
buffer.capacity() / format.getFrameSize()); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
225 |
return AudioFloatInputStream.getInputStream(ais); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
226 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
227 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
228 |
return AudioFloatInputStream.getInputStream(format, buffer.array(), |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
229 |
(int)buffer.arrayOffset(), (int)buffer.capacity()); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
230 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
231 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
232 |
public int getChannels() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
233 |
return getFormat().getChannels(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
234 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
235 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
236 |
public ModelOscillatorStream open(float samplerate) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
237 |
// ModelWavetableOscillator doesn't support ModelOscillatorStream |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
238 |
return null; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
239 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
240 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
241 |
// attenuation is in cB |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
242 |
public float getAttenuation() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
243 |
return attenuation; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
244 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
245 |
// attenuation is in cB |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
246 |
public void setAttenuation(float attenuation) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
247 |
this.attenuation = attenuation; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
248 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
249 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
250 |
public float getLoopLength() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
251 |
return loopLength; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
252 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
253 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
254 |
public void setLoopLength(float loopLength) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
255 |
this.loopLength = loopLength; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
256 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
257 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
258 |
public float getLoopStart() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
259 |
return loopStart; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
260 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
261 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
262 |
public void setLoopStart(float loopStart) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
263 |
this.loopStart = loopStart; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
264 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
265 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
266 |
public void setLoopType(int loopType) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
267 |
this.loopType = loopType; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
268 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
269 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
270 |
public int getLoopType() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
271 |
return loopType; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
272 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
273 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
274 |
public float getPitchcorrection() { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
275 |
return pitchcorrection; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
276 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
277 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
278 |
public void setPitchcorrection(float pitchcorrection) { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
279 |
this.pitchcorrection = pitchcorrection; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
280 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
281 |
} |