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/org/tritonus/file/AiffTool.java | |
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/org/tritonus/file/AiffTool.java')
-rw-r--r-- | songdbj/org/tritonus/file/AiffTool.java | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/songdbj/org/tritonus/file/AiffTool.java b/songdbj/org/tritonus/file/AiffTool.java deleted file mode 100644 index 39cdbf0878..0000000000 --- a/songdbj/org/tritonus/file/AiffTool.java +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
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 | |||
31 | package org.tritonus.sampled.file; | ||
32 | |||
33 | import javax.sound.sampled.AudioFormat; | ||
34 | import javax.sound.sampled.AudioFileFormat; | ||
35 | import 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 | |||
44 | public 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 ***/ | ||