2 * Sonitus - StreamInfo.java - Copyright © 2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sonitus.io.flac;
21 * Parser for a {@link BlockType#STREAMINFO} metadata block.
23 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
25 public class StreamInfo extends Data {
28 * Creates a new STREAMINFO block from the given buffer.
31 * The contents of the metadata block
33 public StreamInfo(byte[] content) {
42 * Returns the minimum block size.
44 * @return The minimum block size (in samples)
46 public int minimumBlockSize() {
47 return (int) parseBits(0, 0, 16);
51 * Returns the maximum block size.
53 * @return The maximum block size (in samples)
55 public int maximumBlockSize() {
56 return (int) parseBits(2, 0, 16);
60 * Returns the minimum frame size.
62 * @return The minimum frame size (in bytes)
64 public int minimumFrameSize() {
65 return (int) parseBits(4, 0, 24);
69 * Returns the maximum frame size.
71 * @return The maximum frame size (in bytes)
73 public int maximumFrameSize() {
74 return (int) parseBits(7, 0, 24);
78 * Returns the sample rate.
80 * @return The sample rate (in Hertz)
82 public int sampleRate() {
83 return (int) parseBits(10, 0, 20);
87 * Returns the number of channels.
89 * @return The number of channels
91 public int numberOfChannels() {
92 return (int) (parseBits(12, 4, 3) + 1);
96 * Returns the number of bits per sample.
98 * @return The number of bits per sample
100 public int bitsPerSample() {
101 return (int) (parseBits(12, 7, 5) + 1);
105 * Returns the total number of samples.
107 * @return The total number of samples
109 public long totalSamples() {
110 return parseBits(13, 4, 36);