diff options
Diffstat (limited to 'songdbj/org/tritonus/file/AuAudioFileWriter.java')
-rw-r--r-- | songdbj/org/tritonus/file/AuAudioFileWriter.java | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/songdbj/org/tritonus/file/AuAudioFileWriter.java b/songdbj/org/tritonus/file/AuAudioFileWriter.java new file mode 100644 index 0000000000..5ac80a8c8a --- /dev/null +++ b/songdbj/org/tritonus/file/AuAudioFileWriter.java | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * AuAudioFileWriter.java | ||
3 | * | ||
4 | * This file is part of Tritonus: http://www.tritonus.org/ | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * Copyright (c) 1999,2000,2001 by Florian Bomers <http://www.bomers.de> | ||
9 | * Copyright (c) 1999 by Matthias Pfisterer | ||
10 | * | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU Library General Public License as published | ||
14 | * by the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU Library General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU Library General Public | ||
23 | * License along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | /* | ||
29 | |<--- this code is formatted to fit into 80 columns --->| | ||
30 | */ | ||
31 | |||
32 | package org.tritonus.sampled.file; | ||
33 | |||
34 | import java.io.IOException; | ||
35 | import java.util.Arrays; | ||
36 | |||
37 | import javax.sound.sampled.AudioFileFormat; | ||
38 | import javax.sound.sampled.AudioFormat; | ||
39 | import javax.sound.sampled.AudioInputStream; | ||
40 | import javax.sound.sampled.AudioSystem; | ||
41 | |||
42 | import org.tritonus.share.TDebug; | ||
43 | import org.tritonus.share.sampled.file.AudioOutputStream; | ||
44 | import org.tritonus.share.sampled.file.TAudioFileWriter; | ||
45 | import org.tritonus.share.sampled.file.TDataOutputStream; | ||
46 | |||
47 | |||
48 | /** | ||
49 | * AudioFileWriter for Sun/Next AU files. | ||
50 | * | ||
51 | * @author Florian Bomers | ||
52 | * @author Matthias Pfisterer | ||
53 | */ | ||
54 | public class AuAudioFileWriter extends TAudioFileWriter { | ||
55 | |||
56 | private static final AudioFileFormat.Type[] FILE_TYPES = | ||
57 | { | ||
58 | AudioFileFormat.Type.AU | ||
59 | }; | ||
60 | |||
61 | private static final int ALL=AudioSystem.NOT_SPECIFIED; | ||
62 | |||
63 | // IMPORTANT: this array depends on the AudioFormat.match() algorithm which takes | ||
64 | // AudioSystem.NOT_SPECIFIED into account ! | ||
65 | private static final AudioFormat[] AUDIO_FORMATS = | ||
66 | { | ||
67 | new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 8, ALL, ALL, ALL, true), | ||
68 | new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 8, ALL, ALL, ALL, false), | ||
69 | |||
70 | new AudioFormat(AudioFormat.Encoding.ULAW, ALL, 8, ALL, ALL, ALL, false), | ||
71 | new AudioFormat(AudioFormat.Encoding.ULAW, ALL, 8, ALL, ALL, ALL, true), | ||
72 | |||
73 | new AudioFormat(AudioFormat.Encoding.ALAW, ALL, 8, ALL, ALL, ALL, false), | ||
74 | new AudioFormat(AudioFormat.Encoding.ALAW, ALL, 8, ALL, ALL, ALL, true), | ||
75 | |||
76 | new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 16, ALL, ALL, ALL, true), | ||
77 | |||
78 | new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 24, ALL, ALL, ALL, true), | ||
79 | |||
80 | new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 32, ALL, ALL, ALL, true), | ||
81 | }; | ||
82 | |||
83 | public AuAudioFileWriter() { | ||
84 | super(Arrays.asList(FILE_TYPES), | ||
85 | Arrays.asList(AUDIO_FORMATS)); | ||
86 | } | ||
87 | |||
88 | |||
89 | protected boolean isAudioFormatSupportedImpl(AudioFormat format, | ||
90 | AudioFileFormat.Type fileType) { | ||
91 | return AuTool.getFormatCode(format)!=AuTool.SND_FORMAT_UNSPECIFIED; | ||
92 | } | ||
93 | protected AudioOutputStream getAudioOutputStream(AudioFormat audioFormat, | ||
94 | long lLengthInBytes, | ||
95 | AudioFileFormat.Type fileType, | ||
96 | TDataOutputStream dataOutputStream) throws IOException { | ||
97 | return new AuAudioOutputStream(audioFormat, | ||
98 | lLengthInBytes, | ||
99 | dataOutputStream); | ||
100 | } | ||
101 | |||
102 | } | ||
103 | |||
104 | /*** AuAudioFileWriter.java ***/ | ||