1 /***************************************************************************
2 copyright : (C) 2006 by Lukáš Lalinský
3 email : lalinsky@gmail.com
5 copyright : (C) 2004 by Allan Sandfeld Jensen
6 email : kde@carewolf.org
7 (original MPC implementation)
8 ***************************************************************************/
10 /***************************************************************************
11 * This library is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU Lesser General Public License version *
13 * 2.1 as published by the Free Software Foundation. *
15 * This library is distributed in the hope that it will be useful, but *
16 * WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
18 * Lesser General Public License for more details. *
20 * You should have received a copy of the GNU Lesser General Public *
21 * License along with this library; if not, write to the Free Software *
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
25 * Alternatively, this file is available under the Mozilla Public *
26 * License Version 1.1. You may obtain a copy of the License at *
27 * http://www.mozilla.org/MPL/ *
28 ***************************************************************************/
34 #include "trueaudioproperties.h"
35 #include "trueaudiofile.h"
37 using namespace TagLib;
39 class TrueAudio::Properties::PropertiesPrivate
42 PropertiesPrivate(const ByteVector &d, long length, ReadStyle s) :
64 ////////////////////////////////////////////////////////////////////////////////
66 ////////////////////////////////////////////////////////////////////////////////
68 TrueAudio::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) : AudioProperties(style)
70 d = new PropertiesPrivate(data, streamLength, style);
74 TrueAudio::Properties::~Properties()
79 int TrueAudio::Properties::length() const
84 int TrueAudio::Properties::bitrate() const
89 int TrueAudio::Properties::sampleRate() const
94 int TrueAudio::Properties::bitsPerSample() const
96 return d->bitsPerSample;
99 int TrueAudio::Properties::channels() const
104 int TrueAudio::Properties::ttaVersion() const
109 ////////////////////////////////////////////////////////////////////////////////
111 ////////////////////////////////////////////////////////////////////////////////
113 void TrueAudio::Properties::read()
115 if(!d->data.startsWith("TTA"))
120 d->version = d->data[pos] - '0';
123 d->channels = d->data.mid(pos, 2).toShort(false);
126 d->bitsPerSample = d->data.mid(pos, 2).toShort(false);
129 d->sampleRate = d->data.mid(pos, 4).toUInt(false);
132 unsigned long samples = d->data.mid(pos, 4).toUInt(false);
133 d->length = samples / d->sampleRate;
135 d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;