HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
AudioPlaylist.h
Go to the documentation of this file.
1#pragma once
2#include "HephAudioShared.h"
3#include "AudioStream.h"
7#include "EventArgs.h"
8#include "EventResult.h"
9#include <string>
10#include <vector>
11
18#define HEPHAUDIO_PLAYLIST_EVENT_USER_ARG_KEY "audio_playlist"
19
20namespace HephAudio
21{
28 {
29 public:
34 enum TransitionEffect : uint8_t
35 {
36 None,
37 Delay,
38 Fade,
39 FadeIn,
40 FadeOut
41 };
42
43 private:
44 AudioStream stream;
45 std::vector<std::filesystem::path> files;
46 bool isPaused;
47 bool applyFadeInOrDelay;
48 TransitionEffect transitionEffect;
49 double transitionDuration_s;
50
51 public:
64
71 AudioPlaylist(Native::NativeAudio* pNativeAudio, const std::vector<std::filesystem::path>& files);
72
79 AudioPlaylist(Audio& audio, const std::vector<std::filesystem::path>& files);
80
88 AudioPlaylist(Native::NativeAudio* pNativeAudio, TransitionEffect transitionEffect, double transitionDuration_s);
89
97 AudioPlaylist(Audio& audio, TransitionEffect transitionEffect, double transitionDuration_s);
98
107 AudioPlaylist(Native::NativeAudio* pNativeAudio, TransitionEffect transitionEffect, double transitionDuration_s, const std::vector<std::filesystem::path>& files);
108
117 AudioPlaylist(Audio& audio, TransitionEffect transitionEffect, double transitionDuration_s, const std::vector<std::filesystem::path>& files);
118
119 AudioPlaylist(const AudioPlaylist&) = delete;
120
123
124 AudioPlaylist& operator=(const AudioPlaylist&) = delete;
125 AudioPlaylist& operator=(const std::filesystem::path& rhs);
126 AudioPlaylist& operator=(const std::vector<std::filesystem::path>& rhs);
127 AudioPlaylist& operator=(AudioPlaylist&& rhs) noexcept;
128
133 size_t Size() const;
134
140
146
151 void SetTransitionEffect(TransitionEffect transitionEffect);
152
157 double GetTransitionDuration() const;
158
163 void SetTransitionDuration(double transitionDuration_s);
164
169 void Start();
170
175 void Stop();
176
182 bool IsPaused() const;
183
189 void Add(const std::filesystem::path& filePath);
190
196 void Add(const std::vector<std::filesystem::path>& files);
197
204 void Insert(const std::filesystem::path& filePath, size_t index);
205
212 void Insert(const std::vector<std::filesystem::path>& files, size_t index);
213
219 void Remove(size_t index);
220
227 void Remove(size_t index, size_t count);
228
233 void Remove(const std::filesystem::path& filePath);
234
239 void Skip();
240
246 void Skip(size_t n);
247
252 void Clear();
253
254 private:
255 void ChangeFile();
256 static void OnFinishedPlaying(const Heph::EventParams& eventParams);
257 static void ApplyTransitionEffect(const Heph::EventParams& eventParams);
258 static void Transition_Delay(AudioPlaylist* pPlaylist, AudioRenderEventArgs* pRenderArgs, AudioRenderEventResult* pRenderResult);
259 static void Transition_FadeIn(AudioPlaylist* pPlaylist, AudioRenderEventArgs* pRenderArgs, AudioRenderEventResult* pRenderResult);
260 static void Transition_FadeOut(AudioPlaylist* pPlaylist, AudioRenderEventArgs* pRenderArgs, AudioRenderEventResult* pRenderResult);
261 };
262}
#define HEPH_API
Definition HephShared.h:132
class for creating playlists. Uses AudioStream internally to play the files.
Definition AudioPlaylist.h:28
void Remove(size_t index, size_t count)
void SetTransitionEffect(TransitionEffect transitionEffect)
void Insert(const std::vector< std::filesystem::path > &files, size_t index)
void Remove(const std::filesystem::path &filePath)
AudioPlaylist(Native::NativeAudio *pNativeAudio)
AudioPlaylist(Audio &audio)
Native::NativeAudio * GetNativeAudio() const
void Add(const std::filesystem::path &filePath)
AudioPlaylist(Audio &audio, TransitionEffect transitionEffect, double transitionDuration_s, const std::vector< std::filesystem::path > &files)
AudioPlaylist(Native::NativeAudio *pNativeAudio, TransitionEffect transitionEffect, double transitionDuration_s)
void Remove(size_t index)
void SetTransitionDuration(double transitionDuration_s)
TransitionEffect GetTransitionEffect() const
AudioPlaylist(Audio &audio, TransitionEffect transitionEffect, double transitionDuration_s)
AudioPlaylist(Native::NativeAudio *pNativeAudio, const std::vector< std::filesystem::path > &files)
AudioPlaylist(Native::NativeAudio *pNativeAudio, TransitionEffect transitionEffect, double transitionDuration_s, const std::vector< std::filesystem::path > &files)
void Add(const std::vector< std::filesystem::path > &files)
TransitionEffect
Definition AudioPlaylist.h:35
AudioPlaylist(AudioPlaylist &&rhs) noexcept
AudioPlaylist(Audio &audio, const std::vector< std::filesystem::path > &files)
void Insert(const std::filesystem::path &filePath, size_t index)
double GetTransitionDuration() const
Class for playing audio files without loading them into memory. Reads the portion of audio data from ...
Definition AudioStream.h:23
manages the native audio classes.
Definition Audio.h:39
base class for the classes that interact with the native audio APIs.
Definition NativeAudio.h:28
struct for storing the arguments for the audio render events.
Definition AudioRenderEventArgs.h:16
struct for storing the results of the audio render events.
Definition AudioRenderEventResult.h:15
stores the information required to handle an event.
Definition EventParams.h:16