NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
saudio.hpp
Go to the documentation of this file.
1
12#pragma once
13
14#include <filesystem>
15
17#include "NNL/common/io.hpp"
18
19namespace nnl {
38struct SAudio {
39 std::string name;
40
42
44
45 std::vector<i16> pcm;
46
54 [[nodiscard]] static SAudio Import(const std::filesystem::path& path);
55
63 [[nodiscard]] static SAudio Import(BufferView buffer);
64
72 void ExportWAV(const std::filesystem::path& path) const;
73
79 [[nodiscard]] Buffer ExportWAV() const;
80
86 void ToMono();
87};
88
89} // namespace nnl
Contains macros and definitions for fixed-width types.
std::uint16_t u16
16-bit unsigned integer
Definition fixed_type.hpp:62
std::uint32_t u32
32-bit unsigned integer
Definition fixed_type.hpp:60
Reader implementation for read-only memory buffers.
Definition io.hpp:598
std::vector< u8 > Buffer
A type alias for std::vector<u8> that denotes a raw, contiguous memory region that may be interpreted...
Definition io.hpp:40
static SAudio Import(BufferView buffer)
Constructs an audio asset from a WAV file in the buffer.
void ToMono()
Converts stereo audio to mono.
std::vector< i16 > pcm
The PCM audio data stored as 16-bit samples.
Definition saudio.hpp:45
static SAudio Import(const std::filesystem::path &path)
Constructs an audio asset from a WAV file located at the specified file path.
Buffer ExportWAV() const
Exports the audio data to a WAV file.
u32 sample_rate
The sample rate of the audio (per second)
Definition saudio.hpp:41
u16 num_channels
The number of audio channels (1 for mono, 2 for stereo).
Definition saudio.hpp:43
void ExportWAV(const std::filesystem::path &path) const
Exports the audio data to a WAV file.
std::string name
An optional name of the audio asset.
Definition saudio.hpp:39
Represents a simple audio asset.
Definition saudio.hpp:38
Provides classes for reading and writing binary data to and from various sources.
Definition exception.hpp:56