AccurateRip Checksum Calculation module

Calculate checksums of audio tracks.

AccurateRip checksums are calculated from a sequence of input sample sequences. The caller is responsible for determining an Algorithm and providing the entire sequence of audio sample sequences to a Calculation instance. The result is provided in a Checksums instance.

An Algorithm specifies a method to calculate Checksums over a sequence of audio samples. AccurateRip specifies two distinct algorithms for calculating a checksum, v1 and v2. A v1 checksum can be materialized as a subtotal when calculating a v2 checksum. Therefore a calculation of a v2 value can also provide the v1 value for the input. Hence there are three variants of the Algorith available: V1, V2 and V1and2. The latter provides v1 as well as v2.

Class Settings provides an interface for configuring an Algorithm or the calculation process.

As part of the Settings there exists a Context in which the Calculation is performed. The Algorithm is aware of the Context. The Context indicates if either FIRST_TRACK, LAST_TRACK, or both have to be treated specially when calculating. This is a requirement of the AccurateRip algorithms.

A Calculation represents the technical process of calculating Checksums by an Algorithm. It has to be parametized with an Algorithm, initialized with the offsets and the leadout of the audio image and then subsequently be updated with portions of samples in their correct order. A Calculation works fine with the default settings, but can be finetuned by providing custom Settings.

Updating a Calculation with an actual sequence of samples is done by providing a sequence of samples represented by two instances of SampleInputIterator. Those instances represent start and stop of the update. SampleInputIterator is a wrapper iterator for any iterator with a value_type of sample_t, which is the declared type for PCM 32 bit samples. Using a SampleSequence may be of convenience for establishing compatibility of the sample input format.

Its result can be provided as soon as a Calculation is complete(). The resulting Checksums represent the result for all requested checksum types and all tracks of the audio input. It is an aggregation of the ChecksumSet for each track of an respective audio input. Depending on the input, it can represent either an entire album or a single track.

ChecksumSet is a set of Checksums of different checksum::types of the same track.

A Checksum refers to a particular track and a particular checksum::type. Checksums are calculated by updating a Calculation with a sequence of sample sequences.

Namespaces

namespace arcstk::v_1_0_0::AccurateRip
AccurateRip checksum calculation algorithms.
namespace arcstk::v_1_0_0::checksum
Operations on checksum types and their names.

Classes

class arcstk::Algorithm
Interface: Checksum calculation algorithm.
class arcstk::Calculation
Perform checksums calculation.
class arcstk::Checksum
An AccurateRip checksum for a single file or track.
class arcstk::ChecksumSet
A set of Checksum instances of different types for a single track.
class arcstk::SampleInputIterator
Type erasing interface for iterators over PCM 32 bit samples.
template<typename T, bool is_planar>
class arcstk::SampleSequence
A sequence of samples represented by 16 or 32 bit integral types.
class arcstk::Settings
Settings for a Calculation.

Enums

enum class Context: unsigned { TRACK = 0, FIRST_TRACK = 1, LAST_TRACK = 2, ALBUM = 3 }
Indicate the track context.

Typedefs

using Checksums = std::vector<ChecksumSet>
A list of ChecksumSets.
using ChecksumtypeSet = std::unordered_set<checksum::type>
Set of Checksum types.
template<typename T>
using InterleavedSamples = SampleSequence<T, false>
Interleaved sample sequence with samples of type T.
template<typename T>
using PlanarSamples = SampleSequence<T, true>
Planar sample sequence with samples of type T.
using Points = std::vector<AudioSize>
List of split points within a range of samples.
using sample_t = uint32_t
Represent a 32 bit wide PCM stereo sample.

Functions

auto any(const Context& c) -> bool noexcept
Returns TRUE iff c is not equivalent to Context::TRACK.
auto make_calculation(std::unique_ptr<Algorithm> algorithm, const ToC& toc) -> std::unique_ptr<Calculation>
Create a Calculation from an Algorithm and a ToC.
auto name(const Context& c) -> std::string noexcept
Name of the specified Context.
void swap(Context& lhs, Context& rhs) noexcept
Swap two Context instances.
auto to_string(const Context& c) -> std::string noexcept
String representation of a Context.

Variables

const Checksum EmptyChecksum
Global instance of an empty Checksum.
const Checksums EmptyChecksums
Global instance of empty Checksums.
const ChecksumSet EmptyChecksumSet
Global instance of an empty ChecksumSet.

Enum documentation

enum class Context: unsigned

Indicate the track context.

AccurateRip algorithms imply different restrictions for calculating the checksums of the the first and last track of an album. Context represents this information.

Enumerators
TRACK

Single track that is neither first or last track.

FIRST_TRACK

First track is first track of an album.

LAST_TRACK

Last track is last track of an album.

ALBUM

Entire album, hence first as well as last track.

Typedef documentation

using Checksums = std::vector<ChecksumSet>

A list of ChecksumSets.

Each ChecksumSet represents a track. The order of the ChecksumSets follows the order of tracks on the original compact disc.

using ChecksumtypeSet = std::unordered_set<checksum::type>

Set of Checksum types.

Guaranteed to be iterable and duplicate-free.

#include <samples.hpp>
template<typename T>
using InterleavedSamples = SampleSequence<T, false>

Interleaved sample sequence with samples of type T.

An interleaved sequence has one input buffer, in which the samples for each channel occurr in order.

T can only be some signed or unsigned integral type of either 16 or 32 bit width.

#include <samples.hpp>
template<typename T>
using PlanarSamples = SampleSequence<T, true>

Planar sample sequence with samples of type T.

A planar sequence has two separated input buffers, one for each channel.

T can only be some signed or unsigned integral type of either 16 or 32 bit width.

using Points = std::vector<AudioSize>

List of split points within a range of samples.

Guaranteed to be forward iterable and have operator [].

using sample_t = uint32_t

Represent a 32 bit wide PCM stereo sample.

An unsigned integer of exact 32 bit length.

The type is not intended to do arithmetic operations on it.

Bitwise operators are guaranteed to work as on unsigned types.

Function documentation

bool any(const Context& c) noexcept

Returns TRUE iff c is not equivalent to Context::TRACK.

Parameters
in Context to evaluate
Returns TRUE iff c is not equivalent to Context::TRACK

Equivalent to c != Context::TRACK.

std::unique_ptr<Calculation> make_calculation(std::unique_ptr<Algorithm> algorithm, const ToC& toc)

Create a Calculation from an Algorithm and a ToC.

Parameters
algorithm in The algorithm to use for calculating
toc in Complete ToC to perform calculation for
Returns Calculation object using algorithm and toc.

If the ToC is not complete, the Calculation must be updated with the correct total number of input samples before calling Calculation::update().

std::string name(const Context& c) noexcept

Name of the specified Context.

Parameters
in Context to provide name of
Returns Name of context

void swap(Context& lhs, Context& rhs) noexcept

Swap two Context instances.

Parameters
lhs in Left hand side to swap
rhs in Right hand side to swap

std::string to_string(const Context& c) noexcept

String representation of a Context.

Parameters
in Context to transform to a string
Returns String representation of context

This will return the name of the context. It is equivalent to name().

Variable documentation

const Checksum EmptyChecksum

Global instance of an empty Checksum.

Avoid the creation of empty instances whenever possible.

const Checksums EmptyChecksums

Global instance of empty Checksums.

Avoid the creation of empty instances whenever possible.

const ChecksumSet EmptyChecksumSet

Global instance of an empty ChecksumSet.

Avoid the creation of empty instances whenever possible.