summaryrefslogtreecommitdiff
path: root/songdbj/org/tritonus/file/AuTool.java
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2007-01-08 23:53:00 +0000
committerBjörn Stenberg <bjorn@haxx.se>2007-01-08 23:53:00 +0000
commit7039a05147b8bbfc829babea1c65bd436450b505 (patch)
tree4ba555eb84ed97b72b0575034d5b0530a393713e /songdbj/org/tritonus/file/AuTool.java
parent6d4c19707ef95942e323cbdc89fbbfdbe45e7cc5 (diff)
downloadrockbox-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/org/tritonus/file/AuTool.java')
-rw-r--r--songdbj/org/tritonus/file/AuTool.java95
1 files changed, 0 insertions, 95 deletions
diff --git a/songdbj/org/tritonus/file/AuTool.java b/songdbj/org/tritonus/file/AuTool.java
deleted file mode 100644
index bcdc62f86c..0000000000
--- a/songdbj/org/tritonus/file/AuTool.java
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * AuTool.java
3 *
4 * This file is part of Tritonus: http://www.tritonus.org/
5 */
6
7/*
8 * Copyright (c) 2000,2001 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 javax.sound.sampled.AudioFormat;
34import javax.sound.sampled.AudioFileFormat;
35import javax.sound.sampled.AudioSystem;
36
37
38/** Common constants and methods for handling au files.
39 *
40 * @author Florian Bomers
41 */
42
43public class AuTool {
44
45 public static final int AU_HEADER_MAGIC = 0x2e736e64;
46 public static final int AUDIO_UNKNOWN_SIZE = -1;
47
48 // length of header in bytes
49 public static final int DATA_OFFSET = 24;
50
51 public static final int SND_FORMAT_UNSPECIFIED = 0;
52 public static final int SND_FORMAT_MULAW_8 = 1;
53 public static final int SND_FORMAT_LINEAR_8 = 2;
54 public static final int SND_FORMAT_LINEAR_16 = 3;
55 public static final int SND_FORMAT_LINEAR_24 = 4;
56 public static final int SND_FORMAT_LINEAR_32 = 5;
57 public static final int SND_FORMAT_FLOAT = 6;
58 public static final int SND_FORMAT_DOUBLE = 7;
59 public static final int SND_FORMAT_ADPCM_G721 = 23;
60 public static final int SND_FORMAT_ADPCM_G722 = 24;
61 public static final int SND_FORMAT_ADPCM_G723_3 = 25;
62 public static final int SND_FORMAT_ADPCM_G723_5 = 26;
63 public static final int SND_FORMAT_ALAW_8 = 27;
64
65 public static int getFormatCode(AudioFormat format) {
66 AudioFormat.Encoding encoding = format.getEncoding();
67 int nSampleSize = format.getSampleSizeInBits();
68 // must be big endian for >8 bit formats
69 boolean bigEndian = format.isBigEndian();
70 // $$fb 2000-08-16: check the frame size, too.
71 boolean frameSizeOK=(
72 format.getFrameSize()==AudioSystem.NOT_SPECIFIED
73 || format.getChannels()!=AudioSystem.NOT_SPECIFIED
74 || format.getFrameSize()==nSampleSize/8*format.getChannels());
75
76 if (encoding.equals(AudioFormat.Encoding.ULAW) && nSampleSize == 8 && frameSizeOK) {
77 return SND_FORMAT_MULAW_8;
78 } else if (encoding.equals(AudioFormat.Encoding.PCM_SIGNED) && frameSizeOK) {
79 if (nSampleSize == 8) {
80 return SND_FORMAT_LINEAR_8;
81 } else if (nSampleSize == 16 && bigEndian) {
82 return SND_FORMAT_LINEAR_16;
83 } else if (nSampleSize == 24 && bigEndian) {
84 return SND_FORMAT_LINEAR_24;
85 } else if (nSampleSize == 32 && bigEndian) {
86 return SND_FORMAT_LINEAR_32;
87 }
88 } else if (encoding.equals(AudioFormat.Encoding.ALAW) && nSampleSize == 8 && frameSizeOK) {
89 return SND_FORMAT_ALAW_8;
90 }
91 return SND_FORMAT_UNSPECIFIED;
92 }
93}
94
95/*** AuTool.java ***/