diff options
author | Björn Stenberg <bjorn@haxx.se> | 2007-01-08 23:53:00 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2007-01-08 23:53:00 +0000 |
commit | 7039a05147b8bbfc829babea1c65bd436450b505 (patch) | |
tree | 4ba555eb84ed97b72b0575034d5b0530a393713e /songdbj/javazoom/spi/vorbis/sampled | |
parent | 6d4c19707ef95942e323cbdc89fbbfdbe45e7cc5 (diff) | |
download | rockbox-7039a05147b8bbfc829babea1c65bd436450b505.tar.gz rockbox-7039a05147b8bbfc829babea1c65bd436450b505.zip |
Splitting out songdbj
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11953 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'songdbj/javazoom/spi/vorbis/sampled')
7 files changed, 0 insertions, 1498 deletions
diff --git a/songdbj/javazoom/spi/vorbis/sampled/convert/DecodedVorbisAudioInputStream.java b/songdbj/javazoom/spi/vorbis/sampled/convert/DecodedVorbisAudioInputStream.java deleted file mode 100644 index b8e8577e13..0000000000 --- a/songdbj/javazoom/spi/vorbis/sampled/convert/DecodedVorbisAudioInputStream.java +++ /dev/null | |||
@@ -1,519 +0,0 @@ | |||
1 | /* | ||
2 | * DecodedVorbisAudioInputStream | ||
3 | * | ||
4 | * JavaZOOM : vorbisspi@javazoom.net | ||
5 | * http://www.javazoom.net | ||
6 | * | ||
7 | * ---------------------------------------------------------------------------- | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU Library General Public License as published | ||
10 | * by the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU Library General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Library General Public | ||
19 | * License along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | * ---------------------------------------------------------------------------- | ||
22 | */ | ||
23 | |||
24 | package javazoom.spi.vorbis.sampled.convert; | ||
25 | |||
26 | import java.io.IOException; | ||
27 | import java.io.InputStream; | ||
28 | import java.util.HashMap; | ||
29 | import java.util.Map; | ||
30 | |||
31 | import javax.sound.sampled.AudioFormat; | ||
32 | import javax.sound.sampled.AudioInputStream; | ||
33 | |||
34 | import javazoom.spi.PropertiesContainer; | ||
35 | |||
36 | import org.tritonus.share.TDebug; | ||
37 | import org.tritonus.share.sampled.convert.TAsynchronousFilteredAudioInputStream; | ||
38 | |||
39 | import com.jcraft.jogg.Packet; | ||
40 | import com.jcraft.jogg.Page; | ||
41 | import com.jcraft.jogg.StreamState; | ||
42 | import com.jcraft.jogg.SyncState; | ||
43 | import com.jcraft.jorbis.Block; | ||
44 | import com.jcraft.jorbis.Comment; | ||
45 | import com.jcraft.jorbis.DspState; | ||
46 | import com.jcraft.jorbis.Info; | ||
47 | |||
48 | /** | ||
49 | * This class implements the Vorbis decoding. | ||
50 | */ | ||
51 | public class DecodedVorbisAudioInputStream extends TAsynchronousFilteredAudioInputStream implements PropertiesContainer | ||
52 | { | ||
53 | private InputStream oggBitStream_ = null; | ||
54 | |||
55 | private SyncState oggSyncState_ = null; | ||
56 | private StreamState oggStreamState_ = null; | ||
57 | private Page oggPage_ = null; | ||
58 | private Packet oggPacket_ = null; | ||
59 | private Info vorbisInfo = null; | ||
60 | private Comment vorbisComment = null; | ||
61 | private DspState vorbisDspState = null; | ||
62 | private Block vorbisBlock = null; | ||
63 | |||
64 | static final int playState_NeedHeaders = 0; | ||
65 | static final int playState_ReadData = 1; | ||
66 | static final int playState_WriteData = 2; | ||
67 | static final int playState_Done = 3; | ||
68 | static final int playState_BufferFull = 4; | ||
69 | static final int playState_Corrupt = -1; | ||
70 | private int playState; | ||
71 | |||
72 | private int bufferMultiple_ = 4; | ||
73 | private int bufferSize_ = bufferMultiple_ * 256 * 2; | ||
74 | private int convsize = bufferSize_ * 2; | ||
75 | private byte[] convbuffer = new byte[convsize]; | ||
76 | private byte[] buffer = null; | ||
77 | private int bytes = 0; | ||
78 | private float[][][] _pcmf = null; | ||
79 | private int[] _index = null; | ||
80 | private int index = 0; | ||
81 | private int i = 0; | ||
82 | // bout is now a global so that we can continue from when we have a buffer full. | ||
83 | int bout = 0; | ||
84 | |||
85 | private HashMap properties = null; | ||
86 | private long currentBytes = 0; | ||
87 | |||
88 | /** | ||
89 | * Constructor. | ||
90 | */ | ||
91 | public DecodedVorbisAudioInputStream(AudioFormat outputFormat, AudioInputStream bitStream) | ||
92 | { | ||
93 | super(outputFormat, -1); | ||
94 | this.oggBitStream_ = bitStream; | ||
95 | init_jorbis(); | ||
96 | index = 0; | ||
97 | playState = playState_NeedHeaders; | ||
98 | properties = new HashMap(); | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * Initializes all the jOrbis and jOgg vars that are used for song playback. | ||
103 | */ | ||
104 | private void init_jorbis() | ||
105 | { | ||
106 | oggSyncState_ = new SyncState(); | ||
107 | oggStreamState_ = new StreamState(); | ||
108 | oggPage_ = new Page(); | ||
109 | oggPacket_ = new Packet(); | ||
110 | vorbisInfo = new Info(); | ||
111 | vorbisComment = new Comment(); | ||
112 | vorbisDspState = new DspState(); | ||
113 | vorbisBlock = new Block(vorbisDspState); | ||
114 | buffer = null; | ||
115 | bytes = 0; | ||
116 | currentBytes = 0L; | ||
117 | oggSyncState_.init(); | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * Return dynamic properties. | ||
122 | * | ||
123 | * <ul> | ||
124 | * <li><b>ogg.position.byte</b> [Long], current position in bytes in the stream. | ||
125 | *</ul> | ||
126 | */ | ||
127 | public Map properties() | ||
128 | { | ||
129 | properties.put("ogg.position.byte",new Long(currentBytes)); | ||
130 | return properties; | ||
131 | } | ||
132 | /** | ||
133 | * Main loop. | ||
134 | */ | ||
135 | public void execute() | ||
136 | { | ||
137 | if(TDebug.TraceAudioConverter) | ||
138 | { | ||
139 | switch(playState) | ||
140 | { | ||
141 | case playState_NeedHeaders: | ||
142 | TDebug.out("playState = playState_NeedHeaders"); | ||
143 | break; | ||
144 | case playState_ReadData: | ||
145 | TDebug.out("playState = playState_ReadData"); | ||
146 | break; | ||
147 | case playState_WriteData: | ||
148 | TDebug.out("playState = playState_WriteData"); | ||
149 | break; | ||
150 | case playState_Done: | ||
151 | TDebug.out("playState = playState_Done"); | ||
152 | break; | ||
153 | case playState_BufferFull: | ||
154 | TDebug.out("playState = playState_BufferFull"); | ||
155 | break; | ||
156 | case playState_Corrupt: | ||
157 | TDebug.out("playState = playState_Corrupt"); | ||
158 | break; | ||
159 | } | ||
160 | } | ||
161 | // This code was developed by the jCraft group, as JOrbisPlayer.java, slightly | ||
162 | // modified by jOggPlayer developer and adapted by JavaZOOM to suit the JavaSound | ||
163 | // SPI. Then further modified by Tom Kimpton to correctly play ogg files that | ||
164 | // would hang the player. | ||
165 | switch(playState) | ||
166 | { | ||
167 | case playState_NeedHeaders: | ||
168 | try | ||
169 | { | ||
170 | // Headers (+ Comments). | ||
171 | readHeaders(); | ||
172 | } | ||
173 | catch(IOException ioe) | ||
174 | { | ||
175 | playState = playState_Corrupt; | ||
176 | return; | ||
177 | } | ||
178 | playState = playState_ReadData; | ||
179 | break; | ||
180 | |||
181 | case playState_ReadData: | ||
182 | int result; | ||
183 | index = oggSyncState_.buffer(bufferSize_); | ||
184 | buffer = oggSyncState_.data; | ||
185 | bytes = readFromStream(buffer, index, bufferSize_); | ||
186 | if(TDebug.TraceAudioConverter) TDebug.out("More data : " + bytes); | ||
187 | if(bytes == -1) | ||
188 | { | ||
189 | playState = playState_Done; | ||
190 | if(TDebug.TraceAudioConverter) TDebug.out("Ogg Stream empty. Settings playState to playState_Done."); | ||
191 | break; | ||
192 | } | ||
193 | else | ||
194 | { | ||
195 | oggSyncState_.wrote(bytes); | ||
196 | if(bytes == 0) | ||
197 | { | ||
198 | if((oggPage_.eos() != 0) || (oggStreamState_.e_o_s != 0) || (oggPacket_.e_o_s != 0)) | ||
199 | { | ||
200 | if(TDebug.TraceAudioConverter) TDebug.out("oggSyncState wrote 0 bytes: settings playState to playState_Done."); | ||
201 | playState = playState_Done; | ||
202 | } | ||
203 | if(TDebug.TraceAudioConverter) TDebug.out("oggSyncState wrote 0 bytes: but stream not yet empty."); | ||
204 | break; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | result = oggSyncState_.pageout(oggPage_); | ||
209 | if(result == 0) | ||
210 | { | ||
211 | if(TDebug.TraceAudioConverter) TDebug.out("Setting playState to playState_ReadData."); | ||
212 | playState = playState_ReadData; | ||
213 | break; | ||
214 | } // need more data | ||
215 | if(result == -1) | ||
216 | { // missing or corrupt data at this page position | ||
217 | if(TDebug.TraceAudioConverter) TDebug.out("Corrupt or missing data in bitstream; setting playState to playState_ReadData"); | ||
218 | playState = playState_ReadData; | ||
219 | break; | ||
220 | } | ||
221 | |||
222 | oggStreamState_.pagein(oggPage_); | ||
223 | |||
224 | if(TDebug.TraceAudioConverter) TDebug.out("Setting playState to playState_WriteData."); | ||
225 | playState = playState_WriteData; | ||
226 | break; | ||
227 | |||
228 | case playState_WriteData: | ||
229 | // Decoding ! | ||
230 | if(TDebug.TraceAudioConverter) TDebug.out("Decoding"); | ||
231 | while(true) | ||
232 | { | ||
233 | result = oggStreamState_.packetout(oggPacket_); | ||
234 | if(result == 0) | ||
235 | { | ||
236 | if(TDebug.TraceAudioConverter) TDebug.out("Packetout returned 0, going to read state."); | ||
237 | playState = playState_ReadData; | ||
238 | break; | ||
239 | } // need more data | ||
240 | else if(result == -1) | ||
241 | { | ||
242 | // missing or corrupt data at this page position | ||
243 | // no reason to complain; already complained above | ||
244 | if(TDebug.TraceAudioConverter) TDebug.out("Corrupt or missing data in packetout bitstream; going to read state..."); | ||
245 | // playState = playState_ReadData; | ||
246 | // break; | ||
247 | continue; | ||
248 | } | ||
249 | else | ||
250 | { | ||
251 | // we have a packet. Decode it | ||
252 | if(vorbisBlock.synthesis(oggPacket_) == 0) | ||
253 | { // test for success! | ||
254 | vorbisDspState.synthesis_blockin(vorbisBlock); | ||
255 | } | ||
256 | else | ||
257 | { | ||
258 | //if(TDebug.TraceAudioConverter) TDebug.out("vorbisBlock.synthesis() returned !0, going to read state"); | ||
259 | if(TDebug.TraceAudioConverter) TDebug.out("VorbisBlock.synthesis() returned !0, continuing."); | ||
260 | continue; | ||
261 | } | ||
262 | |||
263 | outputSamples(); | ||
264 | if(playState == playState_BufferFull) | ||
265 | return; | ||
266 | |||
267 | } // else result != -1 | ||
268 | } // while(true) | ||
269 | if(oggPage_.eos() != 0) | ||
270 | { | ||
271 | if(TDebug.TraceAudioConverter) TDebug.out("Settings playState to playState_Done."); | ||
272 | playState = playState_Done; | ||
273 | } | ||
274 | break; | ||
275 | case playState_BufferFull: | ||
276 | continueFromBufferFull(); | ||
277 | break; | ||
278 | |||
279 | case playState_Corrupt: | ||
280 | if(TDebug.TraceAudioConverter) TDebug.out("Corrupt Song."); | ||
281 | // drop through to playState_Done... | ||
282 | case playState_Done: | ||
283 | oggStreamState_.clear(); | ||
284 | vorbisBlock.clear(); | ||
285 | vorbisDspState.clear(); | ||
286 | vorbisInfo.clear(); | ||
287 | oggSyncState_.clear(); | ||
288 | if(TDebug.TraceAudioConverter) TDebug.out("Done Song."); | ||
289 | try | ||
290 | { | ||
291 | if(oggBitStream_ != null) | ||
292 | { | ||
293 | oggBitStream_.close(); | ||
294 | } | ||
295 | getCircularBuffer().close(); | ||
296 | } | ||
297 | catch(Exception e) | ||
298 | { | ||
299 | if(TDebug.TraceAudioConverter) TDebug.out(e.getMessage()); | ||
300 | } | ||
301 | break; | ||
302 | } // switch | ||
303 | } | ||
304 | |||
305 | /** | ||
306 | * This routine was extracted so that when the output buffer fills up, | ||
307 | * we can break out of the loop, let the music channel drain, then | ||
308 | * continue from where we were. | ||
309 | */ | ||
310 | private void outputSamples() | ||
311 | { | ||
312 | int samples; | ||
313 | while((samples = vorbisDspState.synthesis_pcmout(_pcmf, _index)) > 0) | ||
314 | { | ||
315 | float[][] pcmf = _pcmf[0]; | ||
316 | bout = (samples < convsize ? samples : convsize); | ||
317 | double fVal = 0.0; | ||
318 | // convert doubles to 16 bit signed ints (host order) and | ||
319 | // interleave | ||
320 | for(i = 0; i < vorbisInfo.channels; i++) | ||
321 | { | ||
322 | int pointer = i * 2; | ||
323 | //int ptr=i; | ||
324 | int mono = _index[i]; | ||
325 | for(int j = 0; j < bout; j++) | ||
326 | { | ||
327 | fVal = pcmf[i][mono + j] * 32767.; | ||
328 | int val = (int) (fVal); | ||
329 | if(val > 32767) | ||
330 | { | ||
331 | val = 32767; | ||
332 | } | ||
333 | if(val < -32768) | ||
334 | { | ||
335 | val = -32768; | ||
336 | } | ||
337 | if(val < 0) | ||
338 | { | ||
339 | val = val | 0x8000; | ||
340 | } | ||
341 | convbuffer[pointer] = (byte) (val); | ||
342 | convbuffer[pointer + 1] = (byte) (val >>> 8); | ||
343 | pointer += 2 * (vorbisInfo.channels); | ||
344 | } | ||
345 | } | ||
346 | if(TDebug.TraceAudioConverter) TDebug.out("about to write: " + 2 * vorbisInfo.channels * bout); | ||
347 | if(getCircularBuffer().availableWrite() < 2 * vorbisInfo.channels * bout) | ||
348 | { | ||
349 | if(TDebug.TraceAudioConverter) TDebug.out("Too much data in this data packet, better return, let the channel drain, and try again..."); | ||
350 | playState = playState_BufferFull; | ||
351 | return; | ||
352 | } | ||
353 | getCircularBuffer().write(convbuffer, 0, 2 * vorbisInfo.channels * bout); | ||
354 | if(bytes < bufferSize_) | ||
355 | if(TDebug.TraceAudioConverter) TDebug.out("Finished with final buffer of music?"); | ||
356 | if(vorbisDspState.synthesis_read(bout) != 0) | ||
357 | { | ||
358 | if(TDebug.TraceAudioConverter) TDebug.out("VorbisDspState.synthesis_read returned -1."); | ||
359 | } | ||
360 | } // while(samples...) | ||
361 | playState = playState_ReadData; | ||
362 | } | ||
363 | |||
364 | private void continueFromBufferFull() | ||
365 | { | ||
366 | if(getCircularBuffer().availableWrite() < 2 * vorbisInfo.channels * bout) | ||
367 | { | ||
368 | if(TDebug.TraceAudioConverter) TDebug.out("Too much data in this data packet, better return, let the channel drain, and try again..."); | ||
369 | // Don't change play state. | ||
370 | return; | ||
371 | } | ||
372 | getCircularBuffer().write(convbuffer, 0, 2 * vorbisInfo.channels * bout); | ||
373 | // Don't change play state. Let outputSamples change play state, if necessary. | ||
374 | outputSamples(); | ||
375 | } | ||
376 | /** | ||
377 | * Reads headers and comments. | ||
378 | */ | ||
379 | private void readHeaders() throws IOException | ||
380 | { | ||
381 | if(TDebug.TraceAudioConverter) TDebug.out("readHeaders("); | ||
382 | index = oggSyncState_.buffer(bufferSize_); | ||
383 | buffer = oggSyncState_.data; | ||
384 | bytes = readFromStream(buffer, index, bufferSize_); | ||
385 | if(bytes == -1) | ||
386 | { | ||
387 | if(TDebug.TraceAudioConverter) TDebug.out("Cannot get any data from selected Ogg bitstream."); | ||
388 | throw new IOException("Cannot get any data from selected Ogg bitstream."); | ||
389 | } | ||
390 | oggSyncState_.wrote(bytes); | ||
391 | if(oggSyncState_.pageout(oggPage_) != 1) | ||
392 | { | ||
393 | if(bytes < bufferSize_) | ||
394 | { | ||
395 | throw new IOException("EOF"); | ||
396 | } | ||
397 | if(TDebug.TraceAudioConverter) TDebug.out("Input does not appear to be an Ogg bitstream."); | ||
398 | throw new IOException("Input does not appear to be an Ogg bitstream."); | ||
399 | } | ||
400 | oggStreamState_.init(oggPage_.serialno()); | ||
401 | vorbisInfo.init(); | ||
402 | vorbisComment.init(); | ||
403 | if(oggStreamState_.pagein(oggPage_) < 0) | ||
404 | { | ||
405 | // error; stream version mismatch perhaps | ||
406 | if(TDebug.TraceAudioConverter) TDebug.out("Error reading first page of Ogg bitstream data."); | ||
407 | throw new IOException("Error reading first page of Ogg bitstream data."); | ||
408 | } | ||
409 | if(oggStreamState_.packetout(oggPacket_) != 1) | ||
410 | { | ||
411 | // no page? must not be vorbis | ||
412 | if(TDebug.TraceAudioConverter) TDebug.out("Error reading initial header packet."); | ||
413 | throw new IOException("Error reading initial header packet."); | ||
414 | } | ||
415 | if(vorbisInfo.synthesis_headerin(vorbisComment, oggPacket_) < 0) | ||
416 | { | ||
417 | // error case; not a vorbis header | ||
418 | if(TDebug.TraceAudioConverter) TDebug.out("This Ogg bitstream does not contain Vorbis audio data."); | ||
419 | throw new IOException("This Ogg bitstream does not contain Vorbis audio data."); | ||
420 | } | ||
421 | //int i = 0; | ||
422 | i = 0; | ||
423 | while(i < 2) | ||
424 | { | ||
425 | while(i < 2) | ||
426 | { | ||
427 | int result = oggSyncState_.pageout(oggPage_); | ||
428 | if(result == 0) | ||
429 | { | ||
430 | break; | ||
431 | } // Need more data | ||
432 | if(result == 1) | ||
433 | { | ||
434 | oggStreamState_.pagein(oggPage_); | ||
435 | while(i < 2) | ||
436 | { | ||
437 | result = oggStreamState_.packetout(oggPacket_); | ||
438 | if(result == 0) | ||
439 | { | ||
440 | break; | ||
441 | } | ||
442 | if(result == -1) | ||
443 | { | ||
444 | if(TDebug.TraceAudioConverter) TDebug.out("Corrupt secondary header. Exiting."); | ||
445 | throw new IOException("Corrupt secondary header. Exiting."); | ||
446 | } | ||
447 | vorbisInfo.synthesis_headerin(vorbisComment, oggPacket_); | ||
448 | i++; | ||
449 | } | ||
450 | } | ||
451 | } | ||
452 | index = oggSyncState_.buffer(bufferSize_); | ||
453 | buffer = oggSyncState_.data; | ||
454 | bytes = readFromStream(buffer, index, bufferSize_); | ||
455 | if(bytes == -1) | ||
456 | { | ||
457 | break; | ||
458 | } | ||
459 | if(bytes == 0 && i < 2) | ||
460 | { | ||
461 | if(TDebug.TraceAudioConverter) TDebug.out("End of file before finding all Vorbis headers!"); | ||
462 | throw new IOException("End of file before finding all Vorbis headers!"); | ||
463 | } | ||
464 | oggSyncState_.wrote(bytes); | ||
465 | } | ||
466 | |||
467 | byte[][] ptr = vorbisComment.user_comments; | ||
468 | String currComment = ""; | ||
469 | |||
470 | for(int j = 0; j < ptr.length; j++) | ||
471 | { | ||
472 | if(ptr[j] == null) | ||
473 | { | ||
474 | break; | ||
475 | } | ||
476 | currComment = (new String(ptr[j], 0, ptr[j].length - 1)).trim(); | ||
477 | if(TDebug.TraceAudioConverter) TDebug.out("Comment: " + currComment); | ||
478 | } | ||
479 | convsize = bufferSize_ / vorbisInfo.channels; | ||
480 | vorbisDspState.synthesis_init(vorbisInfo); | ||
481 | vorbisBlock.init(vorbisDspState); | ||
482 | _pcmf = new float[1][][]; | ||
483 | _index = new int[vorbisInfo.channels]; | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Reads from the oggBitStream_ a specified number of Bytes(bufferSize_) worth | ||
488 | * starting at index and puts them in the specified buffer[]. | ||
489 | * | ||
490 | * @param buffer | ||
491 | * @param index | ||
492 | * @param bufferSize_ | ||
493 | * @return the number of bytes read or -1 if error. | ||
494 | */ | ||
495 | private int readFromStream(byte[] buffer, int index, int bufferSize_) | ||
496 | { | ||
497 | int bytes = 0; | ||
498 | try | ||
499 | { | ||
500 | bytes = oggBitStream_.read(buffer, index, bufferSize_); | ||
501 | } | ||
502 | catch(Exception e) | ||
503 | { | ||
504 | if(TDebug.TraceAudioConverter) TDebug.out("Cannot Read Selected Song"); | ||
505 | bytes = -1; | ||
506 | } | ||
507 | currentBytes = currentBytes + bytes; | ||
508 | return bytes; | ||
509 | } | ||
510 | |||
511 | /** | ||
512 | * Close the stream. | ||
513 | */ | ||
514 | public void close() throws IOException | ||
515 | { | ||
516 | super.close(); | ||
517 | oggBitStream_.close(); | ||
518 | } | ||
519 | } | ||
diff --git a/songdbj/javazoom/spi/vorbis/sampled/convert/VorbisFormatConversionProvider.java b/songdbj/javazoom/spi/vorbis/sampled/convert/VorbisFormatConversionProvider.java deleted file mode 100644 index d1321f2590..0000000000 --- a/songdbj/javazoom/spi/vorbis/sampled/convert/VorbisFormatConversionProvider.java +++ /dev/null | |||
@@ -1,244 +0,0 @@ | |||
1 | /* | ||
2 | * VorbisFormatConversionProvider. | ||
3 | * | ||
4 | * JavaZOOM : vorbisspi@javazoom.net | ||
5 | * http://www.javazoom.net | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU Library General Public License as published | ||
9 | * by the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU Library General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Library General Public | ||
18 | * License along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | package javazoom.spi.vorbis.sampled.convert; | ||
24 | |||
25 | import java.util.Arrays; | ||
26 | import javazoom.spi.vorbis.sampled.file.VorbisEncoding; | ||
27 | import javax.sound.sampled.AudioFormat; | ||
28 | import javax.sound.sampled.AudioInputStream; | ||
29 | |||
30 | import org.tritonus.share.sampled.convert.TMatrixFormatConversionProvider; | ||
31 | |||
32 | /** | ||
33 | * ConversionProvider for VORBIS files. | ||
34 | */ | ||
35 | public class VorbisFormatConversionProvider extends TMatrixFormatConversionProvider | ||
36 | { | ||
37 | private static final AudioFormat[] INPUT_FORMATS = | ||
38 | { | ||
39 | new AudioFormat(VorbisEncoding.VORBISENC, 32000.0F, -1, 1, -1, -1, false), // 0 | ||
40 | new AudioFormat(VorbisEncoding.VORBISENC, 32000.0F, -1, 2, -1, -1, false), // 1 | ||
41 | new AudioFormat(VorbisEncoding.VORBISENC, 44100.0F, -1, 1, -1, -1, false), // 2 | ||
42 | new AudioFormat(VorbisEncoding.VORBISENC, 44100.0F, -1, 2, -1, -1, false), // 3 | ||
43 | new AudioFormat(VorbisEncoding.VORBISENC, 48000.0F, -1, 1, -1, -1, false), // 4 | ||
44 | new AudioFormat(VorbisEncoding.VORBISENC, 48000.0F, -1, 2, -1, -1, false), // 5 | ||
45 | |||
46 | new AudioFormat(VorbisEncoding.VORBISENC, 16000.0F, -1, 1, -1, -1, false), // 18 | ||
47 | new AudioFormat(VorbisEncoding.VORBISENC, 16000.0F, -1, 2, -1, -1, false), // 19 | ||
48 | new AudioFormat(VorbisEncoding.VORBISENC, 22050.0F, -1, 1, -1, -1, false), // 20 | ||
49 | new AudioFormat(VorbisEncoding.VORBISENC, 22050.0F, -1, 2, -1, -1, false), // 21 | ||
50 | new AudioFormat(VorbisEncoding.VORBISENC, 24000.0F, -1, 1, -1, -1, false), // 22 | ||
51 | new AudioFormat(VorbisEncoding.VORBISENC, 24000.0F, -1, 2, -1, -1, false), // 23 | ||
52 | |||
53 | new AudioFormat(VorbisEncoding.VORBISENC, 8000.0F, -1, 1, -1, -1, false), // 36 | ||
54 | new AudioFormat(VorbisEncoding.VORBISENC, 8000.0F, -1, 2, -1, -1, false), // 37 | ||
55 | new AudioFormat(VorbisEncoding.VORBISENC, 11025.0F, -1, 1, -1, -1, false), // 38 | ||
56 | new AudioFormat(VorbisEncoding.VORBISENC, 11025.0F, -1, 2, -1, -1, false), // 39 | ||
57 | new AudioFormat(VorbisEncoding.VORBISENC, 12000.0F, -1, 1, -1, -1, false), // 40 | ||
58 | new AudioFormat(VorbisEncoding.VORBISENC, 12000.0F, -1, 2, -1, -1, false), // 41 | ||
59 | }; | ||
60 | |||
61 | private static final AudioFormat[] OUTPUT_FORMATS = | ||
62 | { | ||
63 | new AudioFormat(8000.0F, 16, 1, true, false), // 0 | ||
64 | new AudioFormat(8000.0F, 16, 1, true, true), // 1 | ||
65 | new AudioFormat(8000.0F, 16, 2, true, false), // 2 | ||
66 | new AudioFormat(8000.0F, 16, 2, true, true), // 3 | ||
67 | /* 24 and 32 bit not yet possible | ||
68 | new AudioFormat(8000.0F, 24, 1, true, false), | ||
69 | new AudioFormat(8000.0F, 24, 1, true, true), | ||
70 | new AudioFormat(8000.0F, 24, 2, true, false), | ||
71 | new AudioFormat(8000.0F, 24, 2, true, true), | ||
72 | new AudioFormat(8000.0F, 32, 1, true, false), | ||
73 | new AudioFormat(8000.0F, 32, 1, true, true), | ||
74 | new AudioFormat(8000.0F, 32, 2, true, false), | ||
75 | new AudioFormat(8000.0F, 32, 2, true, true), | ||
76 | */ | ||
77 | new AudioFormat(11025.0F, 16, 1, true, false), // 4 | ||
78 | new AudioFormat(11025.0F, 16, 1, true, true), // 5 | ||
79 | new AudioFormat(11025.0F, 16, 2, true, false), // 6 | ||
80 | new AudioFormat(11025.0F, 16, 2, true, true), // 7 | ||
81 | /* 24 and 32 bit not yet possible | ||
82 | new AudioFormat(11025.0F, 24, 1, true, false), | ||
83 | new AudioFormat(11025.0F, 24, 1, true, true), | ||
84 | new AudioFormat(11025.0F, 24, 2, true, false), | ||
85 | new AudioFormat(11025.0F, 24, 2, true, true), | ||
86 | new AudioFormat(11025.0F, 32, 1, true, false), | ||
87 | new AudioFormat(11025.0F, 32, 1, true, true), | ||
88 | new AudioFormat(11025.0F, 32, 2, true, false), | ||
89 | new AudioFormat(11025.0F, 32, 2, true, true), | ||
90 | */ | ||
91 | new AudioFormat(12000.0F, 16, 1, true, false), // 8 | ||
92 | new AudioFormat(12000.0F, 16, 1, true, true), // 9 | ||
93 | new AudioFormat(12000.0F, 16, 2, true, false), // 10 | ||
94 | new AudioFormat(12000.0F, 16, 2, true, true), // 11 | ||
95 | /* 24 and 32 bit not yet possible | ||
96 | new AudioFormat(12000.0F, 24, 1, true, false), | ||
97 | new AudioFormat(12000.0F, 24, 1, true, true), | ||
98 | new AudioFormat(12000.0F, 24, 2, true, false), | ||
99 | new AudioFormat(12000.0F, 24, 2, true, true), | ||
100 | new AudioFormat(12000.0F, 32, 1, true, false), | ||
101 | new AudioFormat(12000.0F, 32, 1, true, true), | ||
102 | new AudioFormat(12000.0F, 32, 2, true, false), | ||
103 | new AudioFormat(12000.0F, 32, 2, true, true), | ||
104 | */ | ||
105 | new AudioFormat(16000.0F, 16, 1, true, false), // 12 | ||
106 | new AudioFormat(16000.0F, 16, 1, true, true), // 13 | ||
107 | new AudioFormat(16000.0F, 16, 2, true, false), // 14 | ||
108 | new AudioFormat(16000.0F, 16, 2, true, true), // 15 | ||
109 | /* 24 and 32 bit not yet possible | ||
110 | new AudioFormat(16000.0F, 24, 1, true, false), | ||
111 | new AudioFormat(16000.0F, 24, 1, true, true), | ||
112 | new AudioFormat(16000.0F, 24, 2, true, false), | ||
113 | new AudioFormat(16000.0F, 24, 2, true, true), | ||
114 | new AudioFormat(16000.0F, 32, 1, true, false), | ||
115 | new AudioFormat(16000.0F, 32, 1, true, true), | ||
116 | new AudioFormat(16000.0F, 32, 2, true, false), | ||
117 | new AudioFormat(16000.0F, 32, 2, true, true), | ||
118 | */ | ||
119 | new AudioFormat(22050.0F, 16, 1, true, false), // 16 | ||
120 | new AudioFormat(22050.0F, 16, 1, true, true), // 17 | ||
121 | new AudioFormat(22050.0F, 16, 2, true, false), // 18 | ||
122 | new AudioFormat(22050.0F, 16, 2, true, true), // 19 | ||
123 | /* 24 and 32 bit not yet possible | ||
124 | new AudioFormat(22050.0F, 24, 1, true, false), | ||
125 | new AudioFormat(22050.0F, 24, 1, true, true), | ||
126 | new AudioFormat(22050.0F, 24, 2, true, false), | ||
127 | new AudioFormat(22050.0F, 24, 2, true, true), | ||
128 | new AudioFormat(22050.0F, 32, 1, true, false), | ||
129 | new AudioFormat(22050.0F, 32, 1, true, true), | ||
130 | new AudioFormat(22050.0F, 32, 2, true, false), | ||
131 | new AudioFormat(22050.0F, 32, 2, true, true), | ||
132 | */ | ||
133 | new AudioFormat(24000.0F, 16, 1, true, false), // 20 | ||
134 | new AudioFormat(24000.0F, 16, 1, true, true), // 21 | ||
135 | new AudioFormat(24000.0F, 16, 2, true, false), // 22 | ||
136 | new AudioFormat(24000.0F, 16, 2, true, true), // 23 | ||
137 | /* 24 and 32 bit not yet possible | ||
138 | new AudioFormat(24000.0F, 24, 1, true, false), | ||
139 | new AudioFormat(24000.0F, 24, 1, true, true), | ||
140 | new AudioFormat(24000.0F, 24, 2, true, false), | ||
141 | new AudioFormat(24000.0F, 24, 2, true, true), | ||
142 | new AudioFormat(24000.0F, 32, 1, true, false), | ||
143 | new AudioFormat(24000.0F, 32, 1, true, true), | ||
144 | new AudioFormat(24000.0F, 32, 2, true, false), | ||
145 | new AudioFormat(24000.0F, 32, 2, true, true), | ||
146 | */ | ||
147 | new AudioFormat(32000.0F, 16, 1, true, false), // 24 | ||
148 | new AudioFormat(32000.0F, 16, 1, true, true), // 25 | ||
149 | new AudioFormat(32000.0F, 16, 2, true, false), // 26 | ||
150 | new AudioFormat(32000.0F, 16, 2, true, true), // 27 | ||
151 | /* 24 and 32 bit not yet possible | ||
152 | new AudioFormat(32000.0F, 24, 1, true, false), | ||
153 | new AudioFormat(32000.0F, 24, 1, true, true), | ||
154 | new AudioFormat(32000.0F, 24, 2, true, false), | ||
155 | new AudioFormat(32000.0F, 24, 2, true, true), | ||
156 | new AudioFormat(32000.0F, 32, 1, true, false), | ||
157 | new AudioFormat(32000.0F, 32, 1, true, true), | ||
158 | new AudioFormat(32000.0F, 32, 2, true, false), | ||
159 | new AudioFormat(32000.0F, 32, 2, true, true), | ||
160 | */ | ||
161 | new AudioFormat(44100.0F, 16, 1, true, false), // 28 | ||
162 | new AudioFormat(44100.0F, 16, 1, true, true), // 29 | ||
163 | new AudioFormat(44100.0F, 16, 2, true, false), // 30 | ||
164 | new AudioFormat(44100.0F, 16, 2, true, true), // 31 | ||
165 | /* 24 and 32 bit not yet possible | ||
166 | new AudioFormat(44100.0F, 24, 1, true, false), | ||
167 | new AudioFormat(44100.0F, 24, 1, true, true), | ||
168 | new AudioFormat(44100.0F, 24, 2, true, false), | ||
169 | new AudioFormat(44100.0F, 24, 2, true, true), | ||
170 | new AudioFormat(44100.0F, 32, 1, true, false), | ||
171 | new AudioFormat(44100.0F, 32, 1, true, true), | ||
172 | new AudioFormat(44100.0F, 32, 2, true, false), | ||
173 | new AudioFormat(44100.0F, 32, 2, true, true), | ||
174 | */ | ||
175 | new AudioFormat(48000.0F, 16, 1, true, false), // 32 | ||
176 | new AudioFormat(48000.0F, 16, 1, true, true), // 33 | ||
177 | new AudioFormat(48000.0F, 16, 2, true, false), // 34 | ||
178 | new AudioFormat(48000.0F, 16, 2, true, true), // 35 | ||
179 | /* 24 and 32 bit not yet possible | ||
180 | new AudioFormat(48000.0F, 24, 1, true, false), | ||
181 | new AudioFormat(48000.0F, 24, 1, true, true), | ||
182 | new AudioFormat(48000.0F, 24, 2, true, false), | ||
183 | new AudioFormat(48000.0F, 24, 2, true, true), | ||
184 | new AudioFormat(48000.0F, 32, 1, true, false), | ||
185 | new AudioFormat(48000.0F, 32, 1, true, true), | ||
186 | new AudioFormat(48000.0F, 32, 2, true, false), | ||
187 | new AudioFormat(48000.0F, 32, 2, true, true), | ||
188 | */ | ||
189 | }; | ||
190 | |||
191 | private static final boolean t = true; | ||
192 | private static final boolean f = false; | ||
193 | |||
194 | /* | ||
195 | * One row for each source format. | ||
196 | */ | ||
197 | private static final boolean[][] CONVERSIONS = | ||
198 | { | ||
199 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,t,t,f,f,f,f, f,f,f,f,f,f}, // 0 | ||
200 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,t,t,f,f, f,f,f,f,f,f}, // 1 | ||
201 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,t,t, f,f,f,f,f,f}, // 2 | ||
202 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, t,t,f,f,f,f}, // 3 | ||
203 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,t,t,f,f}, // 4 | ||
204 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,t,t}, // 5 | ||
205 | |||
206 | {f,f,f,f,f,f,f,f,f,f, f,f,t,t,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 18 | ||
207 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,t,t,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 19 | ||
208 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,t,t,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 20 | ||
209 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,t,t, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 21 | ||
210 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, t,t,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 22 | ||
211 | {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,t,t,f,f,f,f,f,f, f,f,f,f,f,f}, // 23 | ||
212 | |||
213 | {t,t,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 36 | ||
214 | {f,f,t,t,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 37 | ||
215 | {f,f,f,f,t,t,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 38 | ||
216 | {f,f,f,f,f,f,t,t,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 39 | ||
217 | {f,f,f,f,f,f,f,f,t,t, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 40 | ||
218 | {f,f,f,f,f,f,f,f,f,f, t,t,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 41 | ||
219 | |||
220 | }; | ||
221 | |||
222 | /** | ||
223 | * Constructor. | ||
224 | */ | ||
225 | public VorbisFormatConversionProvider() | ||
226 | { | ||
227 | super(Arrays.asList(INPUT_FORMATS), Arrays.asList(OUTPUT_FORMATS), CONVERSIONS); | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Returns converted AudioInputStream. | ||
232 | */ | ||
233 | public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream) | ||
234 | { | ||
235 | if (isConversionSupported(targetFormat, audioInputStream.getFormat())) | ||
236 | { | ||
237 | return new DecodedVorbisAudioInputStream(targetFormat, audioInputStream); | ||
238 | } | ||
239 | else | ||
240 | { | ||
241 | throw new IllegalArgumentException("conversion not supported"); | ||
242 | } | ||
243 | } | ||
244 | } | ||
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileFormat.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileFormat.java deleted file mode 100644 index 28b7c92a2a..0000000000 --- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileFormat.java +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | /* | ||
2 | * VorbisAudioFileFormat. | ||
3 | * | ||
4 | * JavaZOOM : vorbisspi@javazoom.net | ||
5 | * http://www.javazoom.net | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU Library General Public License as published | ||
9 | * by the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU Library General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Library General Public | ||
18 | * License along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | package javazoom.spi.vorbis.sampled.file; | ||
24 | |||
25 | import java.util.Map; | ||
26 | |||
27 | import javax.sound.sampled.AudioFormat; | ||
28 | |||
29 | import org.tritonus.share.sampled.file.TAudioFileFormat; | ||
30 | |||
31 | /** | ||
32 | * @author JavaZOOM | ||
33 | */ | ||
34 | public class VorbisAudioFileFormat extends TAudioFileFormat | ||
35 | { | ||
36 | /** | ||
37 | * Contructor. | ||
38 | * @param type | ||
39 | * @param audioFormat | ||
40 | * @param nLengthInFrames | ||
41 | * @param nLengthInBytes | ||
42 | */ | ||
43 | public VorbisAudioFileFormat(Type type, AudioFormat audioFormat, int nLengthInFrames, int nLengthInBytes, Map properties) | ||
44 | { | ||
45 | super(type, audioFormat, nLengthInFrames, nLengthInBytes, properties); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * Ogg Vorbis audio file format parameters. | ||
50 | * Some parameters might be unavailable. So availability test is required before reading any parameter. | ||
51 | * | ||
52 | * <br>AudioFileFormat parameters. | ||
53 | * <ul> | ||
54 | * <li><b>duration</b> [Long], duration in microseconds. | ||
55 | * <li><b>title</b> [String], Title of the stream. | ||
56 | * <li><b>author</b> [String], Name of the artist of the stream. | ||
57 | * <li><b>album</b> [String], Name of the album of the stream. | ||
58 | * <li><b>date</b> [String], The date (year) of the recording or release of the stream. | ||
59 | * <li><b>copyright</b> [String], Copyright message of the stream. | ||
60 | * <li><b>comment</b> [String], Comment of the stream. | ||
61 | * </ul> | ||
62 | * <br>Ogg Vorbis parameters. | ||
63 | * <ul> | ||
64 | * <li><b>ogg.length.bytes</b> [Integer], length in bytes. | ||
65 | * <li><b>ogg.bitrate.min.bps</b> [Integer], minimum bitrate. | ||
66 | * <li><b>ogg.bitrate.nominal.bps</b> [Integer], nominal bitrate. | ||
67 | * <li><b>ogg.bitrate.max.bps</b> [Integer], maximum bitrate. | ||
68 | * <li><b>ogg.channels</b> [Integer], number of channels 1 : mono, 2 : stereo. | ||
69 | * <li><b>ogg.frequency.hz</b> [Integer], sampling rate in hz. | ||
70 | * <li><b>ogg.version</b> [Integer], version. | ||
71 | * <li><b>ogg.serial</b> [Integer], serial number. | ||
72 | * <li><b>ogg.comment.track</b> [String], track number. | ||
73 | * <li><b>ogg.comment.genre</b> [String], genre field. | ||
74 | * <li><b>ogg.comment.encodedby</b> [String], encoded by field. | ||
75 | * <li><b>ogg.comment.ext</b> [String], extended comments (indexed): | ||
76 | * <br>For instance : | ||
77 | * <br>ogg.comment.ext.1=Something | ||
78 | * <br>ogg.comment.ext.2=Another comment | ||
79 | * </ul> | ||
80 | */ | ||
81 | public Map properties() | ||
82 | { | ||
83 | return super.properties(); | ||
84 | } | ||
85 | } | ||
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileReader.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileReader.java deleted file mode 100644 index 40bc9cadee..0000000000 --- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileReader.java +++ /dev/null | |||
@@ -1,502 +0,0 @@ | |||
1 | /* | ||
2 | * VorbisAudioFileReader. | ||
3 | * | ||
4 | * JavaZOOM : vorbisspi@javazoom.net | ||
5 | * http://www.javazoom.net | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU Library General Public License as published | ||
9 | * by the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU Library General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Library General Public | ||
18 | * License along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | package javazoom.spi.vorbis.sampled.file; | ||
24 | |||
25 | import java.io.BufferedInputStream; | ||
26 | import java.io.File; | ||
27 | import java.io.FileInputStream; | ||
28 | import java.io.IOException; | ||
29 | import java.io.InputStream; | ||
30 | import java.net.URL; | ||
31 | import java.util.HashMap; | ||
32 | import java.util.StringTokenizer; | ||
33 | |||
34 | import javax.sound.sampled.AudioFileFormat; | ||
35 | import javax.sound.sampled.AudioFormat; | ||
36 | import javax.sound.sampled.AudioInputStream; | ||
37 | import javax.sound.sampled.AudioSystem; | ||
38 | import javax.sound.sampled.UnsupportedAudioFileException; | ||
39 | |||
40 | import org.tritonus.share.TDebug; | ||
41 | import org.tritonus.share.sampled.file.TAudioFileReader; | ||
42 | |||
43 | import com.jcraft.jogg.Packet; | ||
44 | import com.jcraft.jogg.Page; | ||
45 | import com.jcraft.jogg.StreamState; | ||
46 | import com.jcraft.jogg.SyncState; | ||
47 | import com.jcraft.jorbis.Block; | ||
48 | import com.jcraft.jorbis.Comment; | ||
49 | import com.jcraft.jorbis.DspState; | ||
50 | import com.jcraft.jorbis.Info; | ||
51 | import com.jcraft.jorbis.JOrbisException; | ||
52 | import com.jcraft.jorbis.VorbisFile; | ||
53 | |||
54 | /** | ||
55 | * This class implements the AudioFileReader class and provides an | ||
56 | * Ogg Vorbis file reader for use with the Java Sound Service Provider Interface. | ||
57 | */ | ||
58 | public class VorbisAudioFileReader extends TAudioFileReader | ||
59 | { | ||
60 | private SyncState oggSyncState_ = null; | ||
61 | private StreamState oggStreamState_ = null; | ||
62 | private Page oggPage_ = null; | ||
63 | private Packet oggPacket_ = null; | ||
64 | private Info vorbisInfo = null; | ||
65 | private Comment vorbisComment = null; | ||
66 | private DspState vorbisDspState = null; | ||
67 | private Block vorbisBlock = null; | ||
68 | private int bufferMultiple_ = 4; | ||
69 | private int bufferSize_ = bufferMultiple_ * 256 * 2; | ||
70 | private int convsize = bufferSize_ * 2; | ||
71 | private byte[] convbuffer = new byte[convsize]; | ||
72 | private byte[] buffer = null; | ||
73 | private int bytes = 0; | ||
74 | private int rate = 0; | ||
75 | private int channels = 0; | ||
76 | |||
77 | private int index = 0; | ||
78 | private InputStream oggBitStream_ = null; | ||
79 | |||
80 | private static final int INITAL_READ_LENGTH = 64000; | ||
81 | private static final int MARK_LIMIT = INITAL_READ_LENGTH + 1; | ||
82 | |||
83 | public VorbisAudioFileReader() | ||
84 | { | ||
85 | super(MARK_LIMIT, true); | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * Return the AudioFileFormat from the given file. | ||
90 | */ | ||
91 | public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException | ||
92 | { | ||
93 | if (TDebug.TraceAudioFileReader) TDebug.out("getAudioFileFormat(File file)"); | ||
94 | InputStream inputStream = null; | ||
95 | try | ||
96 | { | ||
97 | inputStream = new BufferedInputStream(new FileInputStream(file)); | ||
98 | inputStream.mark(MARK_LIMIT); | ||
99 | AudioFileFormat aff = getAudioFileFormat(inputStream); | ||
100 | inputStream.reset(); | ||
101 | // Get Vorbis file info such as length in seconds. | ||
102 | VorbisFile vf = new VorbisFile(file.getAbsolutePath()); | ||
103 | return getAudioFileFormat(inputStream,(int) file.length(), (int) Math.round((vf.time_total(-1))*1000)); | ||
104 | } | ||
105 | catch (JOrbisException e) | ||
106 | { | ||
107 | throw new IOException(e.getMessage()); | ||
108 | } | ||
109 | finally | ||
110 | { | ||
111 | if (inputStream != null) inputStream.close(); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * Return the AudioFileFormat from the given URL. | ||
117 | */ | ||
118 | public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException | ||
119 | { | ||
120 | if (TDebug.TraceAudioFileReader) TDebug.out("getAudioFileFormat(URL url)"); | ||
121 | InputStream inputStream = url.openStream(); | ||
122 | try | ||
123 | { | ||
124 | return getAudioFileFormat(inputStream); | ||
125 | } | ||
126 | finally | ||
127 | { | ||
128 | if (inputStream != null) inputStream.close(); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * Return the AudioFileFormat from the given InputStream. | ||
134 | */ | ||
135 | public AudioFileFormat getAudioFileFormat(InputStream inputStream) throws UnsupportedAudioFileException, IOException | ||
136 | { | ||
137 | if (TDebug.TraceAudioFileReader) TDebug.out("getAudioFileFormat(InputStream inputStream)"); | ||
138 | try | ||
139 | { | ||
140 | if (!inputStream.markSupported()) inputStream = new BufferedInputStream(inputStream); | ||
141 | inputStream.mark(MARK_LIMIT); | ||
142 | return getAudioFileFormat(inputStream, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED); | ||
143 | } | ||
144 | finally | ||
145 | { | ||
146 | inputStream.reset(); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * Return the AudioFileFormat from the given InputStream and length in bytes. | ||
152 | */ | ||
153 | public AudioFileFormat getAudioFileFormat(InputStream inputStream, long medialength) throws UnsupportedAudioFileException, IOException | ||
154 | { | ||
155 | return getAudioFileFormat(inputStream, (int) medialength, AudioSystem.NOT_SPECIFIED); | ||
156 | } | ||
157 | |||
158 | |||
159 | /** | ||
160 | * Return the AudioFileFormat from the given InputStream, length in bytes and length in milliseconds. | ||
161 | */ | ||
162 | protected AudioFileFormat getAudioFileFormat(InputStream bitStream, int mediaLength, int totalms) throws UnsupportedAudioFileException, IOException | ||
163 | { | ||
164 | HashMap aff_properties = new HashMap(); | ||
165 | HashMap af_properties = new HashMap(); | ||
166 | if (totalms == AudioSystem.NOT_SPECIFIED) | ||
167 | { | ||
168 | totalms = 0; | ||
169 | } | ||
170 | if (totalms <= 0) | ||
171 | { | ||
172 | totalms = 0; | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | aff_properties.put("duration",new Long(totalms*1000)); | ||
177 | } | ||
178 | oggBitStream_ = bitStream; | ||
179 | init_jorbis(); | ||
180 | index = 0; | ||
181 | try | ||
182 | { | ||
183 | readHeaders(aff_properties, af_properties); | ||
184 | } | ||
185 | catch (IOException ioe) | ||
186 | { | ||
187 | if (TDebug.TraceAudioFileReader) | ||
188 | { | ||
189 | TDebug.out(ioe.getMessage()); | ||
190 | } | ||
191 | throw new UnsupportedAudioFileException(ioe.getMessage()); | ||
192 | } | ||
193 | |||
194 | String dmp = vorbisInfo.toString(); | ||
195 | if (TDebug.TraceAudioFileReader) | ||
196 | { | ||
197 | TDebug.out(dmp); | ||
198 | } | ||
199 | int ind = dmp.lastIndexOf("bitrate:"); | ||
200 | int minbitrate = -1; | ||
201 | int nominalbitrate = -1; | ||
202 | int maxbitrate = -1; | ||
203 | if (ind != -1) | ||
204 | { | ||
205 | dmp = dmp.substring(ind + 8, dmp.length()); | ||
206 | StringTokenizer st = new StringTokenizer(dmp, ","); | ||
207 | if (st.hasMoreTokens()) | ||
208 | { | ||
209 | minbitrate = Integer.parseInt(st.nextToken()); | ||
210 | } | ||
211 | if (st.hasMoreTokens()) | ||
212 | { | ||
213 | nominalbitrate = Integer.parseInt(st.nextToken()); | ||
214 | } | ||
215 | if (st.hasMoreTokens()) | ||
216 | { | ||
217 | maxbitrate = Integer.parseInt(st.nextToken()); | ||
218 | } | ||
219 | } | ||
220 | if (nominalbitrate > 0) af_properties.put("bitrate",new Integer(nominalbitrate)); | ||
221 | af_properties.put("vbr",new Boolean(true)); | ||
222 | |||
223 | if (minbitrate > 0) aff_properties.put("ogg.bitrate.min.bps",new Integer(minbitrate)); | ||
224 | if (maxbitrate > 0) aff_properties.put("ogg.bitrate.max.bps",new Integer(maxbitrate)); | ||
225 | if (nominalbitrate > 0) aff_properties.put("ogg.bitrate.nominal.bps",new Integer(nominalbitrate)); | ||
226 | if (vorbisInfo.channels > 0) aff_properties.put("ogg.channels",new Integer(vorbisInfo.channels)); | ||
227 | if (vorbisInfo.rate > 0) aff_properties.put("ogg.frequency.hz",new Integer(vorbisInfo.rate)); | ||
228 | if (mediaLength > 0) aff_properties.put("ogg.length.bytes",new Integer(mediaLength)); | ||
229 | aff_properties.put("ogg.version",new Integer(vorbisInfo.version)); | ||
230 | |||
231 | AudioFormat.Encoding encoding = VorbisEncoding.VORBISENC; | ||
232 | AudioFormat format = new VorbisAudioFormat(encoding, vorbisInfo.rate, AudioSystem.NOT_SPECIFIED, vorbisInfo.channels, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, true,af_properties); | ||
233 | AudioFileFormat.Type type = VorbisFileFormatType.OGG; | ||
234 | return new VorbisAudioFileFormat(VorbisFileFormatType.OGG, format, AudioSystem.NOT_SPECIFIED, mediaLength,aff_properties); | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * Return the AudioInputStream from the given InputStream. | ||
239 | */ | ||
240 | public AudioInputStream getAudioInputStream(InputStream inputStream) throws UnsupportedAudioFileException, IOException | ||
241 | { | ||
242 | if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(InputStream inputStream)"); | ||
243 | return getAudioInputStream(inputStream, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED); | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | * Return the AudioInputStream from the given InputStream. | ||
248 | */ | ||
249 | public AudioInputStream getAudioInputStream(InputStream inputStream, int medialength, int totalms) throws UnsupportedAudioFileException, IOException | ||
250 | { | ||
251 | if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(InputStream inputStreamint medialength, int totalms)"); | ||
252 | try | ||
253 | { | ||
254 | if (!inputStream.markSupported()) inputStream = new BufferedInputStream(inputStream); | ||
255 | inputStream.mark(MARK_LIMIT); | ||
256 | AudioFileFormat audioFileFormat = getAudioFileFormat(inputStream, medialength, totalms); | ||
257 | inputStream.reset(); | ||
258 | return new AudioInputStream(inputStream, audioFileFormat.getFormat(), audioFileFormat.getFrameLength()); | ||
259 | } | ||
260 | catch (UnsupportedAudioFileException e) | ||
261 | { | ||
262 | inputStream.reset(); | ||
263 | throw e; | ||
264 | } | ||
265 | catch (IOException e) | ||
266 | { | ||
267 | inputStream.reset(); | ||
268 | throw e; | ||
269 | } | ||
270 | } | ||
271 | |||
272 | /** | ||
273 | * Return the AudioInputStream from the given File. | ||
274 | */ | ||
275 | public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException | ||
276 | { | ||
277 | if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(File file)"); | ||
278 | InputStream inputStream = new FileInputStream(file); | ||
279 | try | ||
280 | { | ||
281 | return getAudioInputStream(inputStream); | ||
282 | } | ||
283 | catch (UnsupportedAudioFileException e) | ||
284 | { | ||
285 | if (inputStream != null) inputStream.close(); | ||
286 | throw e; | ||
287 | } | ||
288 | catch (IOException e) | ||
289 | { | ||
290 | if (inputStream != null) inputStream.close(); | ||
291 | throw e; | ||
292 | } | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * Return the AudioInputStream from the given URL. | ||
297 | */ | ||
298 | public AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException | ||
299 | { | ||
300 | if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(URL url)"); | ||
301 | InputStream inputStream = url.openStream(); | ||
302 | try | ||
303 | { | ||
304 | return getAudioInputStream(inputStream); | ||
305 | } | ||
306 | catch (UnsupportedAudioFileException e) | ||
307 | { | ||
308 | if (inputStream != null) inputStream.close(); | ||
309 | throw e; | ||
310 | } | ||
311 | catch (IOException e) | ||
312 | { | ||
313 | if (inputStream != null) inputStream.close(); | ||
314 | throw e; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | /** | ||
319 | * Reads headers and comments. | ||
320 | */ | ||
321 | private void readHeaders(HashMap aff_properties, HashMap af_properties) throws IOException | ||
322 | { | ||
323 | if(TDebug.TraceAudioConverter) TDebug.out("readHeaders("); | ||
324 | index = oggSyncState_.buffer(bufferSize_); | ||
325 | buffer = oggSyncState_.data; | ||
326 | bytes = readFromStream(buffer, index, bufferSize_); | ||
327 | if(bytes == -1) | ||
328 | { | ||
329 | if(TDebug.TraceAudioConverter) TDebug.out("Cannot get any data from selected Ogg bitstream."); | ||
330 | throw new IOException("Cannot get any data from selected Ogg bitstream."); | ||
331 | } | ||
332 | oggSyncState_.wrote(bytes); | ||
333 | if(oggSyncState_.pageout(oggPage_) != 1) | ||
334 | { | ||
335 | if(bytes < bufferSize_) | ||
336 | { | ||
337 | throw new IOException("EOF"); | ||
338 | } | ||
339 | if(TDebug.TraceAudioConverter) TDebug.out("Input does not appear to be an Ogg bitstream."); | ||
340 | throw new IOException("Input does not appear to be an Ogg bitstream."); | ||
341 | } | ||
342 | oggStreamState_.init(oggPage_.serialno()); | ||
343 | vorbisInfo.init(); | ||
344 | vorbisComment.init(); | ||
345 | aff_properties.put("ogg.serial",new Integer(oggPage_.serialno())); | ||
346 | if(oggStreamState_.pagein(oggPage_) < 0) | ||
347 | { | ||
348 | // error; stream version mismatch perhaps | ||
349 | if(TDebug.TraceAudioConverter) TDebug.out("Error reading first page of Ogg bitstream data."); | ||
350 | throw new IOException("Error reading first page of Ogg bitstream data."); | ||
351 | } | ||
352 | if(oggStreamState_.packetout(oggPacket_) != 1) | ||
353 | { | ||
354 | // no page? must not be vorbis | ||
355 | if(TDebug.TraceAudioConverter) TDebug.out("Error reading initial header packet."); | ||
356 | throw new IOException("Error reading initial header packet."); | ||
357 | } | ||
358 | if(vorbisInfo.synthesis_headerin(vorbisComment, oggPacket_) < 0) | ||
359 | { | ||
360 | // error case; not a vorbis header | ||
361 | if(TDebug.TraceAudioConverter) TDebug.out("This Ogg bitstream does not contain Vorbis audio data."); | ||
362 | throw new IOException("This Ogg bitstream does not contain Vorbis audio data."); | ||
363 | } | ||
364 | int i = 0; | ||
365 | while(i < 2) | ||
366 | { | ||
367 | while(i < 2) | ||
368 | { | ||
369 | int result = oggSyncState_.pageout(oggPage_); | ||
370 | if(result == 0) | ||
371 | { | ||
372 | break; | ||
373 | } // Need more data | ||
374 | if(result == 1) | ||
375 | { | ||
376 | oggStreamState_.pagein(oggPage_); | ||
377 | while(i < 2) | ||
378 | { | ||
379 | result = oggStreamState_.packetout(oggPacket_); | ||
380 | if(result == 0) | ||
381 | { | ||
382 | break; | ||
383 | } | ||
384 | if(result == -1) | ||
385 | { | ||
386 | if(TDebug.TraceAudioConverter) TDebug.out("Corrupt secondary header. Exiting."); | ||
387 | throw new IOException("Corrupt secondary header. Exiting."); | ||
388 | } | ||
389 | vorbisInfo.synthesis_headerin(vorbisComment, oggPacket_); | ||
390 | i++; | ||
391 | } | ||
392 | } | ||
393 | } | ||
394 | index = oggSyncState_.buffer(bufferSize_); | ||
395 | buffer = oggSyncState_.data; | ||
396 | bytes = readFromStream(buffer, index, bufferSize_); | ||
397 | if(bytes == -1) | ||
398 | { | ||
399 | break; | ||
400 | } | ||
401 | if(bytes == 0 && i < 2) | ||
402 | { | ||
403 | if(TDebug.TraceAudioConverter) TDebug.out("End of file before finding all Vorbis headers!"); | ||
404 | throw new IOException("End of file before finding all Vorbis headers!"); | ||
405 | } | ||
406 | oggSyncState_.wrote(bytes); | ||
407 | } | ||
408 | // Read Ogg Vorbis comments. | ||
409 | byte[][] ptr = vorbisComment.user_comments; | ||
410 | String currComment = ""; | ||
411 | int c = 0; | ||
412 | for(int j = 0; j < ptr.length; j++) | ||
413 | { | ||
414 | if(ptr[j] == null) | ||
415 | { | ||
416 | break; | ||
417 | } | ||
418 | currComment = (new String(ptr[j], 0, ptr[j].length - 1)).trim(); | ||
419 | if(TDebug.TraceAudioConverter) TDebug.out(currComment); | ||
420 | if (currComment.toLowerCase().startsWith("artist")) | ||
421 | { | ||
422 | aff_properties.put("author",currComment.substring(7)); | ||
423 | } | ||
424 | else if (currComment.toLowerCase().startsWith("title")) | ||
425 | { | ||
426 | aff_properties.put("title",currComment.substring(6)); | ||
427 | } | ||
428 | else if (currComment.toLowerCase().startsWith("album")) | ||
429 | { | ||
430 | aff_properties.put("album",currComment.substring(6)); | ||
431 | } | ||
432 | else if (currComment.toLowerCase().startsWith("date")) | ||
433 | { | ||
434 | aff_properties.put("date",currComment.substring(5)); | ||
435 | } | ||
436 | else if (currComment.toLowerCase().startsWith("copyright")) | ||
437 | { | ||
438 | aff_properties.put("copyright",currComment.substring(10)); | ||
439 | } | ||
440 | else if (currComment.toLowerCase().startsWith("comment")) | ||
441 | { | ||
442 | aff_properties.put("comment",currComment.substring(8)); | ||
443 | } | ||
444 | else if (currComment.toLowerCase().startsWith("genre")) | ||
445 | { | ||
446 | aff_properties.put("ogg.comment.genre",currComment.substring(6)); | ||
447 | } | ||
448 | else if (currComment.toLowerCase().startsWith("tracknumber")) | ||
449 | { | ||
450 | aff_properties.put("ogg.comment.track",currComment.substring(12)); | ||
451 | } | ||
452 | else | ||
453 | { | ||
454 | c++; | ||
455 | aff_properties.put("ogg.comment.ext."+c,currComment); | ||
456 | } | ||
457 | aff_properties.put("ogg.comment.encodedby",new String(vorbisComment.vendor, 0, vorbisComment.vendor.length - 1)); | ||
458 | } | ||
459 | } | ||
460 | |||
461 | /** | ||
462 | * Reads from the oggBitStream_ a specified number of Bytes(bufferSize_) worth | ||
463 | * starting at index and puts them in the specified buffer[]. | ||
464 | * | ||
465 | * @return the number of bytes read or -1 if error. | ||
466 | */ | ||
467 | private int readFromStream(byte[] buffer, int index, int bufferSize_) | ||
468 | { | ||
469 | int bytes = 0; | ||
470 | try | ||
471 | { | ||
472 | bytes = oggBitStream_.read(buffer, index, bufferSize_); | ||
473 | } | ||
474 | catch (Exception e) | ||
475 | { | ||
476 | if (TDebug.TraceAudioFileReader) | ||
477 | { | ||
478 | TDebug.out("Cannot Read Selected Song"); | ||
479 | } | ||
480 | bytes = -1; | ||
481 | } | ||
482 | return bytes; | ||
483 | } | ||
484 | |||
485 | /** | ||
486 | * Initializes all the jOrbis and jOgg vars that are used for song playback. | ||
487 | */ | ||
488 | private void init_jorbis() | ||
489 | { | ||
490 | oggSyncState_ = new SyncState(); | ||
491 | oggStreamState_ = new StreamState(); | ||
492 | oggPage_ = new Page(); | ||
493 | oggPacket_ = new Packet(); | ||
494 | vorbisInfo = new Info(); | ||
495 | vorbisComment = new Comment(); | ||
496 | vorbisDspState = new DspState(); | ||
497 | vorbisBlock = new Block(vorbisDspState); | ||
498 | buffer = null; | ||
499 | bytes = 0; | ||
500 | oggSyncState_.init(); | ||
501 | } | ||
502 | } | ||
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFormat.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFormat.java deleted file mode 100644 index 829ab2f8cd..0000000000 --- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFormat.java +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | /* | ||
2 | * VorbisAudioFormat. | ||
3 | * | ||
4 | * JavaZOOM : vorbisspi@javazoom.net | ||
5 | * http://www.javazoom.net | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU Library General Public License as published | ||
9 | * by the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU Library General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Library General Public | ||
18 | * License along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | package javazoom.spi.vorbis.sampled.file; | ||
24 | |||
25 | import java.util.Map; | ||
26 | |||
27 | import javax.sound.sampled.AudioFormat; | ||
28 | |||
29 | import org.tritonus.share.sampled.TAudioFormat; | ||
30 | |||
31 | /** | ||
32 | * @author JavaZOOM | ||
33 | */ | ||
34 | public class VorbisAudioFormat extends TAudioFormat | ||
35 | { | ||
36 | /** | ||
37 | * Constructor. | ||
38 | * @param encoding | ||
39 | * @param nFrequency | ||
40 | * @param SampleSizeInBits | ||
41 | * @param nChannels | ||
42 | * @param FrameSize | ||
43 | * @param FrameRate | ||
44 | * @param isBigEndian | ||
45 | * @param properties | ||
46 | */ | ||
47 | public VorbisAudioFormat(AudioFormat.Encoding encoding, float nFrequency, int SampleSizeInBits, int nChannels, int FrameSize, float FrameRate, boolean isBigEndian, Map properties) | ||
48 | { | ||
49 | super(encoding, nFrequency, SampleSizeInBits, nChannels, FrameSize, FrameRate, isBigEndian, properties); | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * Ogg Vorbis audio format parameters. | ||
54 | * Some parameters might be unavailable. So availability test is required before reading any parameter. | ||
55 | * | ||
56 | * <br>AudioFormat parameters. | ||
57 | * <ul> | ||
58 | * <li><b>bitrate</b> [Integer], bitrate in bits per seconds, average bitrate for VBR enabled stream. | ||
59 | * <li><b>vbr</b> [Boolean], VBR flag. | ||
60 | * </ul> | ||
61 | */ | ||
62 | public Map properties() | ||
63 | { | ||
64 | return super.properties(); | ||
65 | } | ||
66 | } | ||
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisEncoding.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisEncoding.java deleted file mode 100644 index 7800f1556d..0000000000 --- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisEncoding.java +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* | ||
2 | * VorbisEncoding. | ||
3 | * | ||
4 | * JavaZOOM : vorbisspi@javazoom.net | ||
5 | * http://www.javazoom.net | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU Library General Public License as published | ||
9 | * by the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU Library General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Library General Public | ||
18 | * License along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | package javazoom.spi.vorbis.sampled.file; | ||
24 | |||
25 | import javax.sound.sampled.AudioFormat; | ||
26 | |||
27 | /** | ||
28 | * Encodings used by the VORBIS audio decoder. | ||
29 | */ | ||
30 | public class VorbisEncoding extends AudioFormat.Encoding | ||
31 | { | ||
32 | public static final AudioFormat.Encoding VORBISENC = new VorbisEncoding("VORBISENC"); | ||
33 | |||
34 | /** | ||
35 | * Constructors. | ||
36 | */ | ||
37 | public VorbisEncoding(String name) | ||
38 | { | ||
39 | super(name); | ||
40 | } | ||
41 | } | ||
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisFileFormatType.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisFileFormatType.java deleted file mode 100644 index f006bbfe1d..0000000000 --- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisFileFormatType.java +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* | ||
2 | * VorbisFileFormatType. | ||
3 | * | ||
4 | * JavaZOOM : vorbisspi@javazoom.net | ||
5 | * http://www.javazoom.net | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU Library General Public License as published | ||
9 | * by the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU Library General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Library General Public | ||
18 | * License along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | package javazoom.spi.vorbis.sampled.file; | ||
24 | |||
25 | import javax.sound.sampled.AudioFileFormat; | ||
26 | |||
27 | /** | ||
28 | * FileFormatTypes used by the VORBIS audio decoder. | ||
29 | */ | ||
30 | public class VorbisFileFormatType extends AudioFileFormat.Type | ||
31 | { | ||
32 | public static final AudioFileFormat.Type VORBIS = new VorbisFileFormatType("VORBIS", "ogg"); | ||
33 | public static final AudioFileFormat.Type OGG = new VorbisFileFormatType("OGG", "ogg"); | ||
34 | /** | ||
35 | * Constructor. | ||
36 | */ | ||
37 | public VorbisFileFormatType(String name, String extension) | ||
38 | { | ||
39 | super(name, extension); | ||
40 | } | ||
41 | } | ||