diff options
author | Michiel Van Der Kolk <not.valid@email.address> | 2005-07-11 15:42:37 +0000 |
---|---|---|
committer | Michiel Van Der Kolk <not.valid@email.address> | 2005-07-11 15:42:37 +0000 |
commit | 9fee0ec4ca0c5b7a334cc29dbb58e76c7a4c736e (patch) | |
tree | 4c304cd4151020bd5494d279ee68a105ae3a5a3a /songdbj/net/shredzone/ifish/ltr/LTRmp3.java | |
parent | dfa8ecbe609ca8ea194d08560a44fb9a92e94b4b (diff) | |
download | rockbox-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/net/shredzone/ifish/ltr/LTRmp3.java')
-rw-r--r-- | songdbj/net/shredzone/ifish/ltr/LTRmp3.java | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/songdbj/net/shredzone/ifish/ltr/LTRmp3.java b/songdbj/net/shredzone/ifish/ltr/LTRmp3.java new file mode 100644 index 0000000000..1b31c405ba --- /dev/null +++ b/songdbj/net/shredzone/ifish/ltr/LTRmp3.java | |||
@@ -0,0 +1,165 @@ | |||
1 | /* | ||
2 | * iFish -- An iRiver iHP jukebox database creation tool | ||
3 | * | ||
4 | * Copyright (c) 2004 Richard "Shred" Körber | ||
5 | * http://www.shredzone.net/go/ifish | ||
6 | * | ||
7 | *----------------------------------------------------------------------- | ||
8 | * ***** BEGIN LICENSE BLOCK ***** | ||
9 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
10 | * | ||
11 | * The contents of this file are subject to the Mozilla Public License Version | ||
12 | * 1.1 (the "License"); you may not use this file except in compliance with | ||
13 | * the License. You may obtain a copy of the License at | ||
14 | * http://www.mozilla.org/MPL/ | ||
15 | * | ||
16 | * Software distributed under the License is distributed on an "AS IS" basis, | ||
17 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
18 | * for the specific language governing rights and limitations under the | ||
19 | * License. | ||
20 | * | ||
21 | * The Original Code is IFISH. | ||
22 | * | ||
23 | * The Initial Developer of the Original Code is | ||
24 | * Richard "Shred" Körber. | ||
25 | * Portions created by the Initial Developer are Copyright (C) 2004 | ||
26 | * the Initial Developer. All Rights Reserved. | ||
27 | * | ||
28 | * Contributor(s): | ||
29 | * | ||
30 | * Alternatively, the contents of this file may be used under the terms of | ||
31 | * either the GNU General Public License Version 2 or later (the "GPL"), or | ||
32 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
33 | * in which case the provisions of the GPL or the LGPL are applicable instead | ||
34 | * of those above. If you wish to allow use of your version of this file only | ||
35 | * under the terms of either the GPL or the LGPL, and not to allow others to | ||
36 | * use your version of this file under the terms of the MPL, indicate your | ||
37 | * decision by deleting the provisions above and replace them with the notice | ||
38 | * and other provisions required by the GPL or the LGPL. If you do not delete | ||
39 | * the provisions above, a recipient may use your version of this file under | ||
40 | * the terms of any one of the MPL, the GPL or the LGPL. | ||
41 | * | ||
42 | * ***** END LICENSE BLOCK ***** | ||
43 | */ | ||
44 | |||
45 | package net.shredzone.ifish.ltr; | ||
46 | |||
47 | import java.io.*; | ||
48 | |||
49 | /** | ||
50 | * The Base Class for mp3 decoding of the Lightweight Tag Reader. | ||
51 | * | ||
52 | * @author Richard Körber <dev@shredzone.de> | ||
53 | * @version $Id$ | ||
54 | */ | ||
55 | public abstract class LTRmp3 extends LTR { | ||
56 | |||
57 | private final static String[] genres = { | ||
58 | //--- Genres as specified in ID3v1 --- | ||
59 | "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", | ||
60 | "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", | ||
61 | "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial", | ||
62 | "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", | ||
63 | "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", | ||
64 | "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", | ||
65 | "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass", | ||
66 | "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", | ||
67 | "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", | ||
68 | "Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream", | ||
69 | "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", | ||
70 | "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", | ||
71 | "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", | ||
72 | "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", | ||
73 | "Rock & Roll", "Hard Rock", | ||
74 | |||
75 | //--- This are WinAmp extensions --- | ||
76 | "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebop", | ||
77 | "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", | ||
78 | "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", | ||
79 | "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", | ||
80 | "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", | ||
81 | "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", | ||
82 | "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", | ||
83 | "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall", | ||
84 | }; | ||
85 | |||
86 | protected final String charsetV1 = "ISO-8859-1"; | ||
87 | protected final String charsetV2 = "ISO-8859-1"; | ||
88 | |||
89 | /** | ||
90 | * Constructor for the LTRmp3 object | ||
91 | * | ||
92 | * @param in File to be used | ||
93 | * @throws FormatDecodeException Could not decode file | ||
94 | */ | ||
95 | public LTRmp3( RandomAccessFile in ) | ||
96 | throws FormatDecodeException { | ||
97 | super( in ); | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * Decode the mp3 numerical Genre code and convert it to a human | ||
102 | * readable string. The genre is decoded according to the | ||
103 | * specifications found at <a href="http://www.id3.org">www.id3.org</a>, | ||
104 | * as well as the WinAmp extensions. | ||
105 | * | ||
106 | * @param id Genre ID | ||
107 | * @return ID String, null if the genre ID was unknown | ||
108 | */ | ||
109 | protected String decodeGenre( int id ) { | ||
110 | if( id>=genres.length ) return null; | ||
111 | return genres[id]; | ||
112 | } | ||
113 | |||
114 | /** | ||
115 | * Read an ID3v2 integer. This is a 4 byte big endian value, which is | ||
116 | * always not syncsafe. | ||
117 | * | ||
118 | * @return The integer read. | ||
119 | * @throws IOException If there were not enough bytes in the file. | ||
120 | */ | ||
121 | protected int readInt() | ||
122 | throws IOException { | ||
123 | int val = 0; | ||
124 | for( int cnt = 4; cnt > 0; cnt-- ) { | ||
125 | val <<= 8; | ||
126 | val |= ( in.readByte() & 0xFF ); | ||
127 | } | ||
128 | return val; | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * Read an ID3v2 syncsafe integer. This is a 4 byte big endian value | ||
133 | * with the bit 7 of each byte always being 0. | ||
134 | * | ||
135 | * @return The syncsafe integer read. | ||
136 | * @throws IOException If there were not enough bytes in the file. | ||
137 | */ | ||
138 | protected int readSyncsafeInt() | ||
139 | throws IOException { | ||
140 | int val = 0; | ||
141 | for( int cnt = 4; cnt > 0; cnt-- ) { | ||
142 | val <<= 7; | ||
143 | val |= ( readSyncsafe() & 0x7F ); | ||
144 | } | ||
145 | return val; | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * Read a syncsafe byte. It is made sure that a byte is available in | ||
150 | * the file, and that bit 7 is 0. An IOException is thrown otherwise. | ||
151 | * | ||
152 | * @return The byte read. | ||
153 | * @throws IOException If premature EOF was reached or byte was not | ||
154 | * syncsafe. | ||
155 | */ | ||
156 | protected byte readSyncsafe() | ||
157 | throws IOException { | ||
158 | byte read = in.readByte(); | ||
159 | if(( read & 0x80 ) != 0 ) { | ||
160 | throw new IOException( "not syncsafe" ); | ||
161 | } | ||
162 | return read; | ||
163 | } | ||
164 | |||
165 | } | ||