Vivoe Lite 0.5.0
Lightweight GVA like HMI for military displays.
Loading...
Searching...
No Matches
sample.h
Go to the documentation of this file.
1//
2// Copyright (c) 2023, DefenceX PTY LTD
3//
4// This file is part of the VivoeX project developed by DefenceX.
5//
6// Licensed under the Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
7// License. See the LICENSE file in the project root for full license details.
8//
12
13#ifndef HMICORE_HARDWARE_SAMPLE_H_
14#define HMICORE_HARDWARE_SAMPLE_H_
15
16#include <sndfile.h>
17
18#include <string_view>
19#include <vector>
20
21namespace gva {
22
28 public:
33 virtual ~AudioSampleBase() = default;
34
42 virtual int32_t ReadBytes(uint8_t* buffer, const uint32_t bytes) = 0;
43
49 virtual int32_t GetChannels() const = 0;
50
56 virtual void Seek(uint32_t bytes) = 0;
57
63 virtual int32_t GetSamplingRate() const = 0;
64};
65
71 public:
76 struct CallbackData {
78 SNDFILE* file;
80 SF_INFO info;
81 };
82
88 explicit AudioSample(const std::string_view filename);
89
97 int32_t ReadBytes(uint8_t* buffer, const uint32_t bytes) final;
98
104 int32_t GetChannels() const final;
105
111 int32_t GetSamplingRate() const final;
112
118 void Seek(uint32_t bytes) final;
119
120 private:
121 uint32_t total_ = 0;
122 uint32_t seek_ = 0;
123 CallbackData fileinfo_;
124 std::vector<float> data_;
125};
126
127} // namespace gva
128
129#endif // HMICORE_HARDWARE_SAMPLE_H_
The Audio Sample Base class.
Definition sample.h:27
virtual int32_t GetSamplingRate() const =0
Get the Sampling Rate attribute.
virtual ~AudioSampleBase()=default
Destroy the Audio Sample Base object.
virtual void Seek(uint32_t bytes)=0
Get the Sampling Rate attribute.
virtual int32_t GetChannels() const =0
Get the Channels attribute.
virtual int32_t ReadBytes(uint8_t *buffer, const uint32_t bytes)=0
Destroy the Audio Sample Base object.
The Audio Sample class.
Definition sample.h:70
int32_t ReadBytes(uint8_t *buffer, const uint32_t bytes) final
Destroy the Audio Sample object.
Definition sample.cc:47
int32_t GetSamplingRate() const final
Get the Sampling Rate attribute.
Definition sample.cc:65
void Seek(uint32_t bytes) final
Get the Total Samples attribute.
Definition sample.cc:67
SNDFILE * file
The audio sample file.
Definition sample.h:78
int32_t GetChannels() const final
Get the Channels attribute.
Definition sample.cc:63
SF_INFO info
The audio sample info.
Definition sample.h:80
Construct a new Audio Sample object.
Definition sample.h:76