WavPack: AudioProperties improvements

Add lengthInSeconds(), lengthInMilliseconds() properties. (#503)
Add isLossless() property.
Support multi channel. (#92)
Remove some data members which are not needed to carry.
Add some tests for audio properties.
Add some supplementary comments.
This commit is contained in:
Tsuda Kageyu
2015-05-21 18:41:22 +09:00
parent 447a4739c5
commit 22f250eaa4
5 changed files with 158 additions and 69 deletions

BIN
tests/data/four_channels.wv Normal file

Binary file not shown.

View File

@ -12,27 +12,43 @@ using namespace TagLib;
class TestWavPack : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestWavPack);
CPPUNIT_TEST(testBasic);
CPPUNIT_TEST(testLengthScan);
CPPUNIT_TEST(testNoLengthProperties);
CPPUNIT_TEST(testMultiChannelProperties);
CPPUNIT_TEST(testFuzzedFile);
CPPUNIT_TEST_SUITE_END();
public:
void testBasic()
void testNoLengthProperties()
{
WavPack::File f(TEST_FILE_PATH_C("no_length.wv"));
WavPack::Properties *props = f.audioProperties();
CPPUNIT_ASSERT_EQUAL(44100, props->sampleRate());
CPPUNIT_ASSERT_EQUAL(2, props->channels());
CPPUNIT_ASSERT_EQUAL(1, props->bitrate());
CPPUNIT_ASSERT_EQUAL(0x407, props->version());
CPPUNIT_ASSERT(f.audioProperties());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(3705, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(16, f.audioProperties()->bitsPerSample());
CPPUNIT_ASSERT_EQUAL(true, f.audioProperties()->isLossless());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(163392U, f.audioProperties()->sampleFrames());
CPPUNIT_ASSERT_EQUAL(1031, f.audioProperties()->version());
}
void testLengthScan()
void testMultiChannelProperties()
{
WavPack::File f(TEST_FILE_PATH_C("no_length.wv"));
WavPack::Properties *props = f.audioProperties();
CPPUNIT_ASSERT_EQUAL(4, props->length());
WavPack::File f(TEST_FILE_PATH_C("four_channels.wv"));
CPPUNIT_ASSERT(f.audioProperties());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(3833, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(112, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(4, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(16, f.audioProperties()->bitsPerSample());
CPPUNIT_ASSERT_EQUAL(false, f.audioProperties()->isLossless());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(169031U, f.audioProperties()->sampleFrames());
CPPUNIT_ASSERT_EQUAL(1031, f.audioProperties()->version());
}
void testFuzzedFile()