Class Clip

Class Documentation

class Clip

Declaration: final

Immutable, owned interleaved float PCM.

Frames contain one sample per channel. Samples must be finite; [-1, 1] is the nominal range, without implicit clamping. Copies share storage. Moving also preserves the source’s valid snapshot. Neither construction nor access requires an audio system or native device.

Public Functions

Clip(const Clip&) = default

Share immutable PCM storage; neither a device nor the source Clip lifetime is retained.

Clip &operator=(const Clip&) = default

Replace this handle with shared immutable source storage.

Assignment does not alter PCM already retained by voices.

::CE::Audio::Format format() const noexcept

Declaration: [[nodiscard]]

Return a copied channel/sample-rate format.

std::uint64_t frame_count() const noexcept

Declaration: [[nodiscard]]

Return complete PCM frame count: samples().size()/format().channels.

std::chrono::duration<double> duration() const noexcept

Declaration: [[nodiscard]]

Return clip duration in seconds, frame_count()/sample_rate.

std::span<const float> samples() const noexcept

Declaration: [[nodiscard]]

Borrow immutable channel-interleaved float samples.

Retain a Clip copy while using the view; it does not borrow the original input vector.

Public Static Functions

static Clip from_samples(::CE::Audio::Format format, std::vector<float> samples)

Declaration: [[nodiscard]]

Consume/copy owned float PCM at the supplied format.

Reject empty data, incomplete interleaved frames, unsupported format and nonfinite samples with invalid_args. Nominal amplitude is[-1,1], without implicit clamping. Allocation failures propagate; no audio system/device is opened.