HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
audio_block.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "../hires_utc_clock.hpp"
8#include "../required.hpp"
9#include "../assert.hpp"
10#include <span>
11
12namespace tt {
13
27 static constexpr ssize_t samples_per_vector = 16;
28
32
36 [[nodiscard]] ssize_t number_of_samples() const noexcept
37 {
39 }
40
44
53 std::span<float> samples;
54
61 [[nodiscard]] std::span<float> samples_for_channel(ssize_t index) noexcept
62 {
63 tt_axiom(index >= 0 && index < number_of_channels);
64 if (samples.empty()) {
65 return {};
66 } else {
67 tt_axiom(ssize(samples) == number_of_channels * number_of_samples());
68 return samples.subspan(index * number_of_samples(), number_of_samples());
69 }
70 }
71
76
84
90
94
104
109 bool silent;
110};
111
112
113}
A block of audio data.
Definition audio_block.hpp:24
ssize_t number_of_channels
Number of channels in this audio block.
Definition audio_block.hpp:43
double word_clock_sample_rate
Sample rate of the word clock attached to the audio interface For example in some situation on film s...
Definition audio_block.hpp:89
double device_sample_rate
Sample rate to what the audio device is configured to.
Definition audio_block.hpp:93
hires_utc_clock::time_point timestamp
Timestamp when the sample first sample in this block was captured at the audio device input or when t...
Definition audio_block.hpp:83
bool silent
This block of audio is silent.
Definition audio_block.hpp:109
ssize_t number_of_samples() const noexcept
Number of samples in this audio block.
Definition audio_block.hpp:36
ssize_t number_of_vectors
Number of vector of samples in this audio block.
Definition audio_block.hpp:31
static constexpr ssize_t samples_per_vector
The number of samples in a vector.
Definition audio_block.hpp:27
std::span< float > samples
Sample data.
Definition audio_block.hpp:53
std::span< float > samples_for_channel(ssize_t index) noexcept
Sample data for a channel.
Definition audio_block.hpp:61
bool corrupt
The sample data in this block was corrupted Examples of how corruption could happen:
Definition audio_block.hpp:103
uint64_t sample_position
The sample position of the first sample in this block since the start of the capture/render session.
Definition audio_block.hpp:75