neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
audio_bitstream.hpp
Go to the documentation of this file.
1// audio_waveform.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2021 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#include <neogfx/neogfx.hpp>
23
24#pragma once
25
26namespace neogfx
27{
28 template <typename Interface>
29 class audio_bitstream : public reference_counted<Interface>
30 {
31 public:
32 audio_bitstream(audio_sample_rate aSampleRate, float aAmplitude = 1.0f);
33 audio_bitstream(i_audio_device const& aDevice, float aAmplitude = 1.0f);
34 public:
36 public:
37 audio_sample_rate sample_rate() const final;
38 void set_sample_rate(audio_sample_rate aSampleRate) override;
39 public:
40 float amplitude() const final;
41 void set_amplitude(float aAmplitude) final;
42 bool has_envelope() const final;
43 adsr_envelope const& envelope() const final;
44 void clear_envelope() final;
45 void set_envelope(adsr_envelope const& aEnvelope) final;
46 protected:
47 float apply_envelope(audio_sample_index aIndex, audio_sample_count aLength) const;
48 private:
49 audio_sample_rate iSampleRate;
50 float iAmplitude;
51 std::optional<adsr_envelope> iEnvelope;
52 };
53}
float amplitude() const final
audio_sample_rate sample_rate() const final
adsr_envelope const & envelope() const final
void set_amplitude(float aAmplitude) final
float apply_envelope(audio_sample_index aIndex, audio_sample_count aLength) const
bool has_envelope() const final
void set_envelope(adsr_envelope const &aEnvelope) final
void set_sample_rate(audio_sample_rate aSampleRate) override
std::uint64_t audio_sample_count
std::uint64_t audio_sample_index
std::uint64_t audio_sample_rate