summaryrefslogtreecommitdiff
path: root/songdbj/org/tritonus/file/AiffTool.java
diff options
context:
space:
mode:
authorMichiel Van Der Kolk <not.valid@email.address>2005-07-11 15:42:37 +0000
committerMichiel Van Der Kolk <not.valid@email.address>2005-07-11 15:42:37 +0000
commit9fee0ec4ca0c5b7a334cc29dbb58e76c7a4c736e (patch)
tree4c304cd4151020bd5494d279ee68a105ae3a5a3a /songdbj/org/tritonus/file/AiffTool.java
parentdfa8ecbe609ca8ea194d08560a44fb9a92e94b4b (diff)
downloadrockbox-9fee0ec4ca0c5b7a334cc29dbb58e76c7a4c736e.tar.gz
rockbox-9fee0ec4ca0c5b7a334cc29dbb58e76c7a4c736e.zip
Songdb java version, source. only 1.5 compatible
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7101 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'songdbj/org/tritonus/file/AiffTool.java')
-rw-r--r--songdbj/org/tritonus/file/AiffTool.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/songdbj/org/tritonus/file/AiffTool.java b/songdbj/org/tritonus/file/AiffTool.java
new file mode 100644
index 0000000000..39cdbf0878
--- /dev/null
+++ b/songdbj/org/tritonus/file/AiffTool.java
@@ -0,0 +1,82 @@
1/*
2 * AiffTool.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 javax.sound.sampled.AudioFormat;
34import javax.sound.sampled.AudioFileFormat;
35import javax.sound.sampled.AudioSystem;
36
37
38/**
39 * Common constants and methods for handling aiff and aiff-c files.
40 *
41 * @author Florian Bomers
42 */
43
44public class AiffTool {
45
46 public static final int AIFF_FORM_MAGIC = 0x464F524D;
47 public static final int AIFF_AIFF_MAGIC = 0x41494646;
48 public static final int AIFF_AIFC_MAGIC = 0x41494643;
49 public static final int AIFF_COMM_MAGIC = 0x434F4D4D;
50 public static final int AIFF_SSND_MAGIC = 0x53534E44;
51 public static final int AIFF_FVER_MAGIC = 0x46564552;
52 public static final int AIFF_COMM_UNSPECIFIED = 0x00000000; // "0000"
53 public static final int AIFF_COMM_PCM = 0x4E4F4E45; // "NONE"
54 public static final int AIFF_COMM_ULAW = 0x756C6177; // "ulaw"
55 public static final int AIFF_COMM_IMA_ADPCM = 0x696D6134; // "ima4"
56 public static final int AIFF_FVER_TIME_STAMP = 0xA2805140; // May 23, 1990, 2:40pm
57
58 public static int getFormatCode(AudioFormat format) {
59 AudioFormat.Encoding encoding = format.getEncoding();
60 int nSampleSize = format.getSampleSizeInBits();
61 boolean bigEndian = format.isBigEndian();
62 // $$fb 2000-08-16: check the frame size, too.
63 boolean frameSizeOK=format.getFrameSize()==AudioSystem.NOT_SPECIFIED
64 || format.getChannels()!=AudioSystem.NOT_SPECIFIED
65 || format.getFrameSize()==nSampleSize/8*format.getChannels();
66
67 if ((encoding.equals(AudioFormat.Encoding.PCM_SIGNED))
68 && ((bigEndian && nSampleSize>=16 && nSampleSize<=32) || (nSampleSize==8))
69 && frameSizeOK) {
70 return AIFF_COMM_PCM;
71 } else if (encoding.equals(AudioFormat.Encoding.ULAW) && nSampleSize == 8 && frameSizeOK) {
72 return AIFF_COMM_ULAW;
73 } else if (encoding.equals(new AudioFormat.Encoding("IMA_ADPCM")) && nSampleSize == 4) {
74 return AIFF_COMM_IMA_ADPCM;
75 } else {
76 return AIFF_COMM_UNSPECIFIED;
77 }
78 }
79
80}
81
82/*** AiffTool.java ***/