diff options
Diffstat (limited to 'songdbj/org/tritonus/share/sampled/convert/TAudioInputStream.java')
-rw-r--r-- | songdbj/org/tritonus/share/sampled/convert/TAudioInputStream.java | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/songdbj/org/tritonus/share/sampled/convert/TAudioInputStream.java b/songdbj/org/tritonus/share/sampled/convert/TAudioInputStream.java new file mode 100644 index 0000000000..d84530e115 --- /dev/null +++ b/songdbj/org/tritonus/share/sampled/convert/TAudioInputStream.java | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | * TAudioInputStream.java | ||
3 | * | ||
4 | * This file is part of Tritonus: http://www.tritonus.org/ | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * Copyright (c) 2003 by Matthias Pfisterer | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU Library General Public License as published | ||
12 | * by the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU Library General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU Library General Public | ||
21 | * License along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | /* | ||
26 | |<--- this code is formatted to fit into 80 columns --->| | ||
27 | */ | ||
28 | |||
29 | package org.tritonus.share.sampled.convert; | ||
30 | |||
31 | import java.io.InputStream; | ||
32 | |||
33 | import java.util.Collections; | ||
34 | import java.util.HashMap; | ||
35 | import java.util.Map; | ||
36 | |||
37 | import javax.sound.sampled.AudioFormat; | ||
38 | import javax.sound.sampled.AudioInputStream; | ||
39 | |||
40 | |||
41 | /** AudioInputStream base class. This class implements "dynamic" | ||
42 | properties. "Dynamic" properties are properties that may change | ||
43 | during the life time of the objects. This is typically used to | ||
44 | pass information like the current frame number, volume of subbands | ||
45 | and similar values. "Dynamic" properties are different from | ||
46 | properties in AudioFormat and AudioFileFormat, which are | ||
47 | considered "static", as they aren't allowed to change after | ||
48 | creating of the object, thereby maintaining the immutable | ||
49 | character of these classes. | ||
50 | */ | ||
51 | |||
52 | public class TAudioInputStream | ||
53 | extends AudioInputStream | ||
54 | { | ||
55 | private Map<String, Object> m_properties; | ||
56 | private Map<String, Object> m_unmodifiableProperties; | ||
57 | |||
58 | |||
59 | /** Constructor without properties. | ||
60 | Creates an empty properties map. | ||
61 | */ | ||
62 | public TAudioInputStream(InputStream inputStream, | ||
63 | AudioFormat audioFormat, | ||
64 | long lLengthInFrames) | ||
65 | { | ||
66 | super(inputStream, audioFormat, lLengthInFrames); | ||
67 | initMaps(new HashMap<String, Object>()); | ||
68 | } | ||
69 | |||
70 | |||
71 | /** Constructor with properties. | ||
72 | The passed properties map is not copied. This allows subclasses | ||
73 | to change values in the map after creation, and the changes are | ||
74 | reflected in the map the application program can obtain. | ||
75 | */ | ||
76 | public TAudioInputStream(InputStream inputStream, | ||
77 | AudioFormat audioFormat, | ||
78 | long lLengthInFrames, | ||
79 | Map<String, Object> properties) | ||
80 | { | ||
81 | super(inputStream, audioFormat, lLengthInFrames); | ||
82 | initMaps(properties); | ||
83 | } | ||
84 | |||
85 | |||
86 | private void initMaps(Map<String, Object> properties) | ||
87 | { | ||
88 | /* Here, we make a shallow copy of the map. It's unclear if this | ||
89 | is sufficient (of if a deep copy should be made). | ||
90 | */ | ||
91 | m_properties = properties; | ||
92 | m_unmodifiableProperties = Collections.unmodifiableMap(m_properties); | ||
93 | } | ||
94 | |||
95 | |||
96 | /** Obtain a Map containing the properties. This method returns a | ||
97 | Map that cannot be modified by the application program, but | ||
98 | reflects changes to the map made by the implementation. | ||
99 | |||
100 | @return a map containing the properties. | ||
101 | */ | ||
102 | public Map<String, Object> properties() | ||
103 | { | ||
104 | return m_unmodifiableProperties; | ||
105 | } | ||
106 | |||
107 | |||
108 | /** Set a property. Unlike in AudioFormat and AudioFileFormat, | ||
109 | this method may be used anywhere by subclasses - it is not | ||
110 | restricted to be used in the constructor. | ||
111 | */ | ||
112 | protected void setProperty(String key, Object value) | ||
113 | { | ||
114 | m_properties.put(key, value); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | |||
119 | |||
120 | /*** TAudioInputStream.java ***/ | ||