class
#include <include/calculate.hpp>
v_1_0_0::CalcContext Interface for information about the current audio input.
CalcContext provides the metadata that is required to perform the Calculation correctly.
The CalcContext determines whether the input is single- or multitrack and whether it has to skip samples on the beginning of the first or the end of the last track.
CalcContext also provides service methods for identifying the first and last sample of a track relevant for Calculation or to get the track for a given sample.
CalcContext offers also access to its underlying TOC data.
CalcContext instances are created exclusively via the variants of make_
A CalcContext is intended as a "read-only" object, it should never be required to modify the CalcContext of an audio input. The only exception is notify_
Constructors, destructors, conversion operators
- ~CalcContext() pure virtual noexcept
- Virtual default destructor.
Public functions
- auto audio_size() const -> const AudioSize& noexcept
- Return the size of the referenced audio file.
- auto clone() const -> std::unique_ptr<CalcContext> noexcept
- Clone this CalcContext object.
- auto filename() const -> std::string noexcept
- Name of current audio file.
-
auto first_relevant_sample() const -> sample_
count_ t noexcept - Get 0-based index of the first relevant sample of the current audio input.
-
auto first_relevant_sample(const TrackNo track) const -> sample_
count_ t noexcept - Get 0-based index of the first relevant sample of the specified 1-based track.
- auto id() const -> ARId noexcept
- Return the ARId of the current medium, if known.
- auto is_multi_track() const -> bool noexcept
- Returns
TRUE
if this instances indicates a processing for multiple tracks on a single input file. -
auto last_relevant_sample() const -> sample_
count_ t noexcept - Get 0-based index of the last relevant sample of the current audio input.
-
auto last_relevant_sample(const TrackNo track) const -> sample_
count_ t noexcept - Get 0-based index of the last relevant sample of the specified 1-based track.
-
auto length(const int track) const -> lba_
count_ t noexcept - Return the normalized length of the specified 0-based track.
-
void notify_skips(const sample_
count_ t num_skip_front, const sample_ count_ t num_skip_back) noexcept - Notifies the instance about configured skipping amounts at the beginning of the first track and the end of the last track.
-
auto num_skip_back() const -> sample_
count_ t noexcept - Returns the amount of samples to skip at the end of the last track.
-
auto num_skip_front() const -> sample_
count_ t noexcept - Returns the amount of samples to skip at the beginning of the first track.
-
auto offset(const int track) const -> lba_
count_ t noexcept - Return the offset of the specified 0-based track from the TOC.
- void set_audio_size(const AudioSize& audio_size)
- Inform about the AudioSize of the current file.
- void set_filename(const std::string& filename) noexcept
- Set the name of the current audio file.
- auto skips_back() const -> bool noexcept
- Returns
TRUE
iff this context will skip the last 2940 samples (5 LBA frames) of the last track. - auto skips_front() const -> bool noexcept
- Returns
TRUE
iff this context will skip the first 2939 samples of the first track. - auto total_tracks() const -> int noexcept
- Convenience method: Total number of tracks.
-
auto track(const sample_
count_ t smpl) const -> int noexcept - Returns 1-based track number of the track containing the specified 0-based sample.
Private functions
- auto do_audio_size() const -> const AudioSize& pure virtual noexcept
- Implements audio_
size() const. - auto do_clone() const -> std::unique_ptr<CalcContext> pure virtual noexcept
- Implements clone() const.
- auto do_filename() const -> std::string pure virtual noexcept
- Implements filename() const.
-
auto do_first_relevant_sample(const TrackNo track) const -> sample_
count_ t pure virtual noexcept - Implements first_
relevant_ sample(const TrackNo track) const. -
auto do_first_relevant_sample_no_parms() const -> sample_
count_ t pure virtual noexcept - Implements first_
relevant_ sample() const. - auto do_id() const -> ARId pure virtual noexcept
- Implements id() const.
- auto do_is_multi_track() const -> bool pure virtual noexcept
- Implements is_
multi_ track() const. -
auto do_last_relevant_sample(const TrackNo track) const -> sample_
count_ t pure virtual noexcept - Implements last_
relevant_ sample(const TrackNo track) const. -
auto do_last_relevant_sample_no_parms() const -> sample_
count_ t pure virtual noexcept - Implements last_
relevant_ sample() const. -
auto do_length(const int track) const -> lba_
count_ t pure virtual noexcept - Implements length(const int track) const.
-
void do_notify_skips(const sample_
count_ t num_skip_front, const sample_ count_ t num_skip_back) pure virtual noexcept - Implements notify_
skips(const sample_ count_ t num_ skip_ front, const sample_ count_ t num_ skip_ back). -
auto do_num_skip_back() const -> sample_
count_ t pure virtual noexcept - Implements num_
skip_ back() const. -
auto do_num_skip_front() const -> sample_
count_ t pure virtual noexcept - Implements num_
skip_ front() const. -
auto do_offset(const int track) const -> lba_
count_ t pure virtual noexcept - Implements offset(const int track) const.
- void do_set_audio_size(const AudioSize& audio_size) pure virtual
- Implements set_
audio_ size(const AudioSize &audio_ size). - void do_set_filename(const std::string& filename) pure virtual noexcept
- Implements set_filename(const std::
string &filename). - auto do_skips_back() const -> bool pure virtual noexcept
- Implements skips_
back() const. - auto do_skips_front() const -> bool pure virtual noexcept
- Implements skips_
front() const. - auto do_total_tracks() const -> int pure virtual noexcept
- Implements total_
tracks() const. -
auto do_track(const sample_
count_ t smpl) const -> int pure virtual noexcept - Implements track(const sample_
count_ t smpl) const.
Function documentation
const AudioSize& arcstk:: v_1_0_0:: CalcContext:: audio_size() const noexcept
Return the size of the referenced audio file.
Returns | The size of the referenced audio file |
---|
std::unique_ptr<CalcContext> arcstk:: v_1_0_0:: CalcContext:: clone() const noexcept
Clone this CalcContext object.
Returns | A clone of this instance |
---|
A clone is a deep copy, i.e. the result of the cloning will be a different object with the exact same state.
std::string arcstk:: v_1_0_0:: CalcContext:: filename() const noexcept
Name of current audio file.
Returns | Name of the audio file that is currently processed |
---|
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: first_relevant_sample() const noexcept
Get 0-based index of the first relevant sample of the current audio input.
Returns | Index of the first sample contributing to the first track's ARCS |
---|
Which sample is actually the first relevant one depends on
- the offset of the first track and
- whether samples in the beginning of the first track are to be skipped.
Always equivalent with first_
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: first_relevant_sample(const TrackNo track) const noexcept
Get 0-based index of the first relevant sample of the specified 1-based track.
Parameters | |
---|---|
track in | The 1-based track number |
Returns | Index of the first sample contributing to the track's ARCS |
Note that parameter track
is 1-based, which means that first_relevant_sample(2)
returns the first 0-based sample of the actual track 2 (and not track 3).
ARId arcstk:: v_1_0_0:: CalcContext:: id() const noexcept
Return the ARId of the current medium, if known.
Returns | The ARId of the current medium |
---|
The value returned will only be significant iff non-empty offsets and non-zero total PCM byte count are available. Otherwise the ARId returned will be empty()
.
bool arcstk:: v_1_0_0:: CalcContext:: is_multi_track() const noexcept
Returns TRUE
if this instances indicates a processing for multiple tracks on a single input file.
Returns | TRUE if this context specifies multitrack mode, otherwise FALSE |
---|
If this is FALSE
, no chunks will be available. Multitrack mode is activated by setting a TOC.
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: last_relevant_sample() const noexcept
Get 0-based index of the last relevant sample of the current audio input.
Returns | Index of the last sample contributing to the last track's ARCS |
---|
Which sample is actually the last relevant one depends on whether samples in the end of the last track are to be skipped.
Always equivalent with last_
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: last_relevant_sample(const TrackNo track) const noexcept
Get 0-based index of the last relevant sample of the specified 1-based track.
Parameters | |
---|---|
track in | 1-based track number, accepts 0 as offset of track 1 |
Returns | Index of last sample contributing to the specified track's ARCS |
Note that parameter track
is 1-based, which means that last_relevant_sample(2) returns the last 0-based sample of the actual track 2 (and not track 3).
If no offsets are set, the output will always be identical to last_
For track == 0
, the last sample of the offset before track 1 is returned. This may of course be 0 iff the offset of track 1 is 0.
lba_ count_ t arcstk:: v_1_0_0:: CalcContext:: length(const int track) const noexcept
Return the normalized length of the specified 0-based track.
Parameters | |
---|---|
track in | The 0-based track to get the length for |
Returns | The length for the specified 0-based track |
Note that length(i) == offset(i+2) - offset(i+1)
for all i: 0 <= i < toc().total_
.
For the last track t = toc().total_
, the value of length(t)
may be 0
if the TOC is incomplete and the instance is not yet updated with the concrete AudioSize, otherwise it is length(t) == leadout_frame() - offset(t+1)
.
void arcstk:: v_1_0_0:: CalcContext:: notify_skips(const sample_ count_ t num_skip_front,
const sample_ count_ t num_skip_back) noexcept
Notifies the instance about configured skipping amounts at the beginning of the first track and the end of the last track.
Parameters | |
---|---|
num_skip_front in | Actual amount of skipped samples at the beginning |
num_skip_back in | Actual amount of skipped samples at the end |
Whether actual skipping takes place can be determined by skips_
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: num_skip_back() const noexcept
Returns the amount of samples to skip at the end of the last track.
Returns | The number of samples to skip at the end of the last track |
---|
If the audio input contains only one track, this track is the last track.
The value is either 2940 or 0.
The skipping is already active if this instance skips_
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: num_skip_front() const noexcept
Returns the amount of samples to skip at the beginning of the first track.
Returns | The number of samples to skip at the beginning of the first track |
---|
If the audio input contains only one track, this track is the first track.
The value is either 2939 or 0.
The skipping is already active if this instance skips_
lba_ count_ t arcstk:: v_1_0_0:: CalcContext:: offset(const int track) const noexcept
Return the offset of the specified 0-based track from the TOC.
Parameters | |
---|---|
track in | The 0-based track to get the offset for |
Returns | The offset for the specified 0-based track |
Note that offset(i) == toc().offset(i+1)
for all i: 0 <= i < toc().total_
.
void arcstk:: v_1_0_0:: CalcContext:: set_audio_size(const AudioSize& audio_size)
Inform about the AudioSize of the current file.
Parameters | |
---|---|
audio_size in | AudioSize |
This contains the information about the leadout frame. This information must be known before Calculation::
void arcstk:: v_1_0_0:: CalcContext:: set_filename(const std::string& filename) noexcept
Set the name of the current audio file.
Parameters | |
---|---|
filename in | Name of the audio file that is to be processed |
bool arcstk:: v_1_0_0:: CalcContext:: skips_back() const noexcept
Returns TRUE
iff this context will skip the last 2940 samples (5 LBA frames) of the last track.
Returns | TRUE iff context will signal to skip the last samples. |
---|
bool arcstk:: v_1_0_0:: CalcContext:: skips_front() const noexcept
Returns TRUE
iff this context will skip the first 2939 samples of the first track.
Returns | TRUE iff context will signal to skip the first samples. |
---|
int arcstk:: v_1_0_0:: CalcContext:: total_tracks() const noexcept
Convenience method: Total number of tracks.
Returns | The number of tracks represented in this file |
---|
This number will aways be a non-negative integer up to 99
.
Since the track count should be accessed in a uniform way, regardless whether we actually have multiple tracks or only one.
int arcstk:: v_1_0_0:: CalcContext:: track(const sample_ count_ t smpl) const noexcept
Returns 1-based track number of the track containing the specified 0-based sample.
Parameters | |
---|---|
smpl in | The sample to get the track for |
Returns | Track number of the track containing sample smpl |
If total_samples() is 0, the method will return 0 regardless of the actual value of smpl
.
If smpl
is bigger than total_samples() - 1
, the method will return an invalid high track number ("infinite").
The user has therefore to check for the validity of the result by checking whether 0 < result <= CDDA::
.
const AudioSize& arcstk:: v_1_0_0:: CalcContext:: do_audio_size() const pure virtual private noexcept
Implements audio_
Returns | The total number of bytes of the PCM samples |
---|
std::unique_ptr<CalcContext> arcstk:: v_1_0_0:: CalcContext:: do_clone() const pure virtual private noexcept
Implements clone() const.
Returns | A clone of this instance |
---|
std::string arcstk:: v_1_0_0:: CalcContext:: do_filename() const pure virtual private noexcept
Implements filename() const.
Returns | Name of the audio file that is currently processed |
---|
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: do_first_relevant_sample(const TrackNo track) const pure virtual private noexcept
Implements first_
Parameters | |
---|---|
track in | The 1-based track number |
Returns | Index of the first sample contributing to the track's ARCS |
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: do_first_relevant_sample_no_parms() const pure virtual private noexcept
Implements first_
Returns | Index of the first sample contributing to the first track's ARCS |
---|
ARId arcstk:: v_1_0_0:: CalcContext:: do_id() const pure virtual private noexcept
Implements id() const.
Returns | The ARId of the current medium |
---|
bool arcstk:: v_1_0_0:: CalcContext:: do_is_multi_track() const pure virtual private noexcept
Implements is_
Returns | TRUE if this context specifies multitrack mode, otherwise FALSE |
---|
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: do_last_relevant_sample(const TrackNo track) const pure virtual private noexcept
Implements last_
Parameters | |
---|---|
track in | 1-based track number, accepts 0 as offset of track 1 |
Returns | Index of last sample contributing to the specified track's ARCS |
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: do_last_relevant_sample_no_parms() const pure virtual private noexcept
Implements last_
Returns | Index of the last sample contributing to the last track's ARCS |
---|
lba_ count_ t arcstk:: v_1_0_0:: CalcContext:: do_length(const int track) const pure virtual private noexcept
Implements length(const int track) const.
Parameters | |
---|---|
track in | The 0-based track to get the length for |
Returns | The length for the specified 0-based track |
void arcstk:: v_1_0_0:: CalcContext:: do_notify_skips(const sample_ count_ t num_skip_front,
const sample_ count_ t num_skip_back) pure virtual private noexcept
Implements notify_
Parameters | |
---|---|
num_skip_front in | Actual amount of skipped samples at the beginning |
num_skip_back in | Actual amount of skipped samples at the end |
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: do_num_skip_back() const pure virtual private noexcept
Implements num_
Returns | The number of samples to skip at the end of the last track |
---|
sample_ count_ t arcstk:: v_1_0_0:: CalcContext:: do_num_skip_front() const pure virtual private noexcept
Implements num_
Returns | The number of samples to skip at the beginning of the first track |
---|
lba_ count_ t arcstk:: v_1_0_0:: CalcContext:: do_offset(const int track) const pure virtual private noexcept
Implements offset(const int track) const.
Parameters | |
---|---|
track in | The 0-based track to get the offset for |
Returns | The offset for the specified 0-based track |
void arcstk:: v_1_0_0:: CalcContext:: do_set_audio_size(const AudioSize& audio_size) pure virtual private
Implements set_
Parameters | |
---|---|
audio_size in | AudioSize |
void arcstk:: v_1_0_0:: CalcContext:: do_set_filename(const std::string& filename) pure virtual private noexcept
Implements set_filename(const std::
Parameters | |
---|---|
filename in | Name of the audio file that is to be processed |
bool arcstk:: v_1_0_0:: CalcContext:: do_skips_back() const pure virtual private noexcept
Implements skips_
Returns | TRUE iff context will signal to skip the last samples. |
---|
bool arcstk:: v_1_0_0:: CalcContext:: do_skips_front() const pure virtual private noexcept
Implements skips_
Returns | TRUE iff context will signal to skip the first samples. |
---|
int arcstk:: v_1_0_0:: CalcContext:: do_total_tracks() const pure virtual private noexcept
Implements total_
Returns | The number of tracks represented in this file |
---|
int arcstk:: v_1_0_0:: CalcContext:: do_track(const sample_ count_ t smpl) const pure virtual private noexcept
Implements track(const sample_
Parameters | |
---|---|
smpl in | The sample to get the track for |
Returns | Track number of the track containing sample smpl |