HephAudio v3.1.0
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
AudioStream.h
Go to the documentation of this file.
1#pragma once
2#include "HephAudioShared.h"
3#include "Audio.h"
4#include "AudioBuffer.h"
5#include <filesystem>
6
13#define HEPHAUDIO_STREAM_EVENT_USER_ARG_KEY "audio_stream"
14
15namespace HephAudio
16{
23 {
24 private:
25 std::shared_ptr<Native::NativeAudio> pNativeAudio;
26 std::shared_ptr<IAudioDecoder> pAudioDecoder;
27 AudioFormatInfo formatInfo;
28 size_t frameCount;
29 AudioObject* pAudioObject;
30 AudioBuffer decodedBuffer;
31
32 public:
38 AudioStream(std::shared_ptr<Native::NativeAudio> pNativeAudio);
39
46
53 AudioStream(std::shared_ptr<Native::NativeAudio> pNativeAudio, const std::filesystem::path& filePath);
54
61 AudioStream(Audio& audio, const std::filesystem::path& filePath);
62
63 AudioStream(const AudioStream&) = delete;
64
66 AudioStream(AudioStream&& rhs) noexcept;
67
70
71 AudioStream& operator=(const AudioStream&) = delete;
72 AudioStream& operator=(AudioStream&& rhs) noexcept;
73
78 std::shared_ptr<Native::NativeAudio> GetNativeAudio() const;
79
84 std::shared_ptr<IAudioDecoder> GetAudioDecoder() const;
85
91 void SetAudioDecoder(std::shared_ptr<IAudioDecoder> pNewDecoder);
92
98
104
109 size_t GetFrameCount() const;
110
115 void ChangeFile(const std::filesystem::path& newFilePath);
116
121 void CloseFile();
122
127 void Start();
128
133 void Stop();
134
139 double GetPosition() const;
140
145 void SetPosition(double position);
146
147 private:
148 void Release();
149 static void OnRender(const Heph::EventParams& eventParams);
150 static void OnFinishedPlaying(const Heph::EventParams& eventParams);
151 };
152}
#define HEPH_API
Definition HephShared.h:124
class for storing the audio samples in internal format.
Definition AudioBuffer.h:16
Class for playing audio files without loading them into memory. Reads the portion of audio data from ...
Definition AudioStream.h:23
const AudioFormatInfo & GetAudioFormatInfo() const
AudioStream(Audio &audio, const std::filesystem::path &filePath)
AudioStream(std::shared_ptr< Native::NativeAudio > pNativeAudio)
void SetPosition(double position)
AudioObject * GetAudioObject() const
AudioStream(Audio &audio)
double GetPosition() const
AudioStream(std::shared_ptr< Native::NativeAudio > pNativeAudio, const std::filesystem::path &filePath)
std::shared_ptr< IAudioDecoder > GetAudioDecoder() const
size_t GetFrameCount() const
void SetAudioDecoder(std::shared_ptr< IAudioDecoder > pNewDecoder)
AudioStream(AudioStream &&rhs) noexcept
std::shared_ptr< Native::NativeAudio > GetNativeAudio() const
void ChangeFile(const std::filesystem::path &newFilePath)
manages the native audio classes.
Definition Audio.h:47
stores the properties of the audio signals
Definition AudioFormatInfo.h:20
stores information that's necessary to play audio.
Definition AudioObject.h:33
stores the information required to handle an event.
Definition EventParams.h:16