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