diff options
Diffstat (limited to 'songdbj/org/tritonus/share/sampled/TAudioFormat.java')
-rw-r--r-- | songdbj/org/tritonus/share/sampled/TAudioFormat.java | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/songdbj/org/tritonus/share/sampled/TAudioFormat.java b/songdbj/org/tritonus/share/sampled/TAudioFormat.java new file mode 100644 index 0000000000..7911d5e005 --- /dev/null +++ b/songdbj/org/tritonus/share/sampled/TAudioFormat.java | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | * TAudioFormat.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; | ||
30 | |||
31 | import java.util.Collections; | ||
32 | import java.util.HashMap; | ||
33 | import java.util.Map; | ||
34 | |||
35 | import javax.sound.sampled.AudioFormat; | ||
36 | |||
37 | |||
38 | |||
39 | public class TAudioFormat | ||
40 | extends AudioFormat | ||
41 | { | ||
42 | private Map<String, Object> m_properties; | ||
43 | private Map<String, Object> m_unmodifiableProperties; | ||
44 | |||
45 | |||
46 | public TAudioFormat(AudioFormat.Encoding encoding, | ||
47 | float sampleRate, | ||
48 | int sampleSizeInBits, | ||
49 | int channels, | ||
50 | int frameSize, | ||
51 | float frameRate, | ||
52 | boolean bigEndian, | ||
53 | Map<String, Object> properties) | ||
54 | { | ||
55 | super(encoding, | ||
56 | sampleRate, | ||
57 | sampleSizeInBits, | ||
58 | channels, | ||
59 | frameSize, | ||
60 | frameRate, | ||
61 | bigEndian); | ||
62 | initMaps(properties); | ||
63 | } | ||
64 | |||
65 | |||
66 | public TAudioFormat(float sampleRate, | ||
67 | int sampleSizeInBits, | ||
68 | int channels, | ||
69 | boolean signed, | ||
70 | boolean bigEndian, | ||
71 | Map<String, Object> properties) | ||
72 | { | ||
73 | super(sampleRate, | ||
74 | sampleSizeInBits, | ||
75 | channels, | ||
76 | signed, | ||
77 | bigEndian); | ||
78 | initMaps(properties); | ||
79 | } | ||
80 | |||
81 | |||
82 | |||
83 | private void initMaps(Map<String, Object> properties) | ||
84 | { | ||
85 | /* Here, we make a shallow copy of the map. It's unclear if this | ||
86 | is sufficient (or if a deep copy should be made). | ||
87 | */ | ||
88 | m_properties = new HashMap<String, Object>(); | ||
89 | m_properties.putAll(properties); | ||
90 | m_unmodifiableProperties = Collections.unmodifiableMap(m_properties); | ||
91 | } | ||
92 | |||
93 | |||
94 | |||
95 | public Map<String, Object> properties() | ||
96 | { | ||
97 | return m_unmodifiableProperties; | ||
98 | } | ||
99 | |||
100 | |||
101 | |||
102 | protected void setProperty(String key, Object value) | ||
103 | { | ||
104 | m_properties.put(key, value); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | |||
109 | |||
110 | /*** TAudioFormat.java ***/ | ||