@@ -66,7 +66,7 @@ public struct StreamHeader : IAudioCodec, ILosslessAudioCodec
66
66
/// </summary>
67
67
/// <remarks>
68
68
/// This value is stored in bytes (17-26).
69
- /// the sample rate at which the sound is to be played back,
69
+ /// the sample rate at which the sound is to be played back,
70
70
/// in sample frames per second
71
71
/// </remarks>
72
72
readonly ulong sample_rate ;
@@ -120,7 +120,7 @@ public struct StreamHeader : IAudioCodec, ILosslessAudioCodec
120
120
/// </exception>
121
121
/// <exception cref="CorruptFileException">
122
122
/// <paramref name="data" /> does not begin with <see
123
- /// cref="FileIdentifier" />
123
+ /// cref="FileIdentifier" />
124
124
/// </exception>
125
125
public StreamHeader ( ByteVector data , long streamLength )
126
126
{
@@ -138,54 +138,7 @@ public StreamHeader (ByteVector data, long streamLength)
138
138
channels = data . Mid ( 8 , 2 ) . ToUShort ( true ) ;
139
139
total_frames = data . Mid ( 10 , 4 ) . ToULong ( true ) ;
140
140
bits_per_sample = data . Mid ( 14 , 2 ) . ToUShort ( true ) ;
141
-
142
- ByteVector sample_rate_indicator = data . Mid ( 17 , 1 ) ;
143
- ulong sample_rate_tmp = data . Mid ( 18 , 2 ) . ToULong ( true ) ;
144
- sample_rate = 44100 ; // Set 44100 as default sample rate
145
-
146
- // The following are combinations that iTunes 8 encodes to.
147
- // There may be other combinations in the field, but i couldn't test them.
148
- switch ( sample_rate_tmp ) {
149
- case 44100 :
150
- if ( sample_rate_indicator == 0x0E ) {
151
- sample_rate = 44100 ;
152
- } else if ( sample_rate_indicator == 0x0D ) {
153
- sample_rate = 22050 ;
154
- } else if ( sample_rate_indicator == 0x0C ) {
155
- sample_rate = 11025 ;
156
- }
157
- break ;
158
-
159
- case 48000 :
160
- if ( sample_rate_indicator == 0x0E ) {
161
- sample_rate = 48000 ;
162
- } else if ( sample_rate_indicator == 0x0D ) {
163
- sample_rate = 24000 ;
164
- }
165
- break ;
166
-
167
- case 64000 :
168
- if ( sample_rate_indicator == 0x0D ) {
169
- sample_rate = 32000 ;
170
- } else if ( sample_rate_indicator == 0x0C ) {
171
- sample_rate = 16000 ;
172
- } else if ( sample_rate_indicator == 0x0B ) {
173
- sample_rate = 8000 ;
174
- }
175
- break ;
176
-
177
- case 44510 :
178
- if ( sample_rate_indicator == 0x0D ) {
179
- sample_rate = 22255 ;
180
- }
181
- break ;
182
-
183
- case 44508 :
184
- if ( sample_rate_indicator == 0x0C ) {
185
- sample_rate = 11127 ;
186
- }
187
- break ;
188
- }
141
+ sample_rate = ( ulong ) data . Mid ( 16 , 10 ) . ToExtendedPrecision ( ) ;
189
142
}
190
143
191
144
#endregion
0 commit comments