2018-09-02 01:39:02 +02:00
|
|
|
/***************************************************************************
|
|
|
|
copyright : (C) 2016 by Damien Plisson, Audirvana
|
|
|
|
email : damien78@audirvana.com
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* This library is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser General Public License version *
|
|
|
|
* 2.1 as published by the Free Software Foundation. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, but *
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
|
|
* Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this library; if not, write to the Free Software *
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
|
|
|
* 02110-1301 USA *
|
|
|
|
* *
|
|
|
|
* Alternatively, this file is available under the Mozilla Public *
|
|
|
|
* License Version 1.1. You may obtain a copy of the License at *
|
|
|
|
* http://www.mozilla.org/MPL/ *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include <tstring.h>
|
|
|
|
#include <tdebug.h>
|
|
|
|
|
|
|
|
#include "dsdiffproperties.h"
|
|
|
|
|
2019-04-25 23:00:25 +02:00
|
|
|
using namespace Strawberry_TagLib::TagLib;
|
2018-09-02 01:39:02 +02:00
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
class DSDIFF::AudioProperties::AudioPropertiesPrivate {
|
2020-06-13 19:02:42 +02:00
|
|
|
public:
|
2020-06-22 00:49:25 +02:00
|
|
|
AudioPropertiesPrivate() : length(0),
|
2020-06-13 19:02:42 +02:00
|
|
|
bitrate(0),
|
|
|
|
sampleRate(0),
|
|
|
|
channels(0),
|
|
|
|
sampleWidth(0),
|
|
|
|
sampleCount(0) {
|
2018-09-02 01:39:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int length;
|
|
|
|
int bitrate;
|
|
|
|
int sampleRate;
|
|
|
|
int channels;
|
|
|
|
int sampleWidth;
|
|
|
|
unsigned long long sampleCount;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// public members
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
DSDIFF::AudioProperties::AudioProperties(const unsigned int sampleRate, const unsigned short channels, const unsigned long long samplesCount, const int bitrate, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style) {
|
2020-06-14 17:01:05 +02:00
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
d = new AudioPropertiesPrivate;
|
2018-09-02 01:39:02 +02:00
|
|
|
|
2020-06-13 19:02:42 +02:00
|
|
|
d->channels = channels;
|
2018-09-02 01:39:02 +02:00
|
|
|
d->sampleCount = samplesCount;
|
|
|
|
d->sampleWidth = 1;
|
2020-06-13 19:02:42 +02:00
|
|
|
d->sampleRate = sampleRate;
|
|
|
|
d->bitrate = bitrate;
|
|
|
|
d->length = d->sampleRate > 0 ? static_cast<int>((d->sampleCount * 1000.0) / d->sampleRate + 0.5) : 0;
|
2020-06-14 17:01:05 +02:00
|
|
|
|
2018-09-02 01:39:02 +02:00
|
|
|
}
|
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
DSDIFF::AudioProperties::~AudioProperties() {
|
2018-09-02 01:39:02 +02:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
int DSDIFF::AudioProperties::lengthInSeconds() const {
|
2018-09-02 01:39:02 +02:00
|
|
|
return d->length / 1000;
|
|
|
|
}
|
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
int DSDIFF::AudioProperties::lengthInMilliseconds() const {
|
2018-09-02 01:39:02 +02:00
|
|
|
return d->length;
|
|
|
|
}
|
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
int DSDIFF::AudioProperties::bitrate() const {
|
2018-09-02 01:39:02 +02:00
|
|
|
return d->bitrate;
|
|
|
|
}
|
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
int DSDIFF::AudioProperties::sampleRate() const {
|
2018-09-02 01:39:02 +02:00
|
|
|
return d->sampleRate;
|
|
|
|
}
|
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
int DSDIFF::AudioProperties::channels() const {
|
2018-09-02 01:39:02 +02:00
|
|
|
return d->channels;
|
|
|
|
}
|
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
int DSDIFF::AudioProperties::bitsPerSample() const {
|
2018-09-02 01:39:02 +02:00
|
|
|
return d->sampleWidth;
|
|
|
|
}
|
|
|
|
|
2020-06-22 00:49:25 +02:00
|
|
|
long long DSDIFF::AudioProperties::sampleCount() const {
|
2018-09-02 01:39:02 +02:00
|
|
|
return d->sampleCount;
|
|
|
|
}
|