diff --git a/include/ReMixer/AudioFormat.hpp b/include/ReMixer/AudioFormat.hpp new file mode 100644 index 0000000..c6eab84 --- /dev/null +++ b/include/ReMixer/AudioFormat.hpp @@ -0,0 +1,28 @@ +#pragma once +#include + +namespace ReMixer { + enum class SampleFormat { + Unknown, + Float16, + Float32, + Int16, + Int32, + }; + + + + struct AudioFormat { + uint32_t sample_rate; + uint16_t channels; + SampleFormat format; + + static AudioFormat StereoFloat(uint32_t rate) { + return {rate, 2, SampleFormat::Float16}; + } + + static AudioFormat StereoFloat48kHz() { + return StereoFloat(48_kHz); + } + }; +} diff --git a/include/ReMixer/Frequency.hpp b/include/ReMixer/Frequency.hpp new file mode 100644 index 0000000..5673393 --- /dev/null +++ b/include/ReMixer/Frequency.hpp @@ -0,0 +1,17 @@ +#pragma once + +namespace ReMixer { + namespace FrequencyLiterals { + unsigned operator ""_Hz(long double frequency); + unsigned operator ""_Hz(unsigned long long int frequency); + unsigned operator ""_kHz(long double frequency); + unsigned operator ""_kHz(unsigned long long int frequency); + unsigned operator ""_MHz(long double frequency); + unsigned operator ""_MHz(unsigned long long int frequency); + unsigned operator ""_GHz(long double frequency); + unsigned operator ""_GHz(unsigned long long int frequency); + } + + + using namespace FrequencyLiterals; +} \ No newline at end of file diff --git a/include/ReMixer/IAudioDevice.hpp b/include/ReMixer/IAudioDevice.hpp new file mode 100644 index 0000000..1f633b9 --- /dev/null +++ b/include/ReMixer/IAudioDevice.hpp @@ -0,0 +1,30 @@ +#pragma once +#include "ReMixer.h" + +namespace ReMixer { + + enum class DeviceType { + Unknown, Output, Input, Duplex + }; + + struct AudioDeviceInfo { + std::string id; + std::string name; + DeviceType type; + bool is_default; + std::set supported_formats; + }; + + class IAudioDevice { + public: + virtual ~IAudioDevice() = default; + + virtual bool Initialize(const AudioFormat& requestedFormat, uint32_t bufferSizeFrames) = 0; + virtual void Shutdown() = 0; + virtual bool Start() = 0; + virtual bool Stop() = 0; + virtual bool IsRunning() const = 0; + + + }; +} diff --git a/include/ReMixer/ReMixer.h b/include/ReMixer/ReMixer.h index 9ea2f01..6db57f3 100644 --- a/include/ReMixer/ReMixer.h +++ b/include/ReMixer/ReMixer.h @@ -30,80 +30,20 @@ namespace ReMixer { /// Allow users to discover available audio input and output devices. /// - enum class SampleFormat { - Unknown, - Float16, - Float32, - Int16, - Int32, - }; - unsigned operator ""_Hz(unsigned long long int frequency); - unsigned operator ""_kHz(long double frequency); - unsigned operator ""_kHz(unsigned long long int frequency); - struct AudioFormat { - uint32_t sample_rate; - uint16_t channels; - SampleFormat format; - static AudioFormat StereoFloat(uint32_t rate) { - return {rate, 2, SampleFormat::Float16}; - } - static AudioFormat StereoFloat48kHz() { - return StereoFloat(48_kHz); - } - }; - enum class StreamDirection { - PLAYBACK, - RECORD, - }; - /// We do not plan to support specifications such as 7.1 Surround. - /// 3D Positional Audio will be implemented later in software. - enum class StreamMode : bool { - MONO = false, - STEREO = true - }; - - enum class DeviceType { - Unknown, Output, Input, Duplex - }; - - struct AudioDeviceInfo { - std::string id; - std::string name; - DeviceType type; - bool is_default; - std::set supported_formats; - }; + class Sound; class Stream; class SoundSubsystem; class PulseAudioSubsystem; class PulseStream; - class SoundHandle { - public: - protected: - SoundHandle(const Sound& sound); - private: - }; - class IAudioDevice { - public: - virtual ~IAudioDevice() = default; - - virtual bool Initialize(const AudioFormat& requestedFormat, uint32_t bufferSizeFrames) = 0; - virtual void Shutdown() = 0; - virtual bool Start() = 0; - virtual bool Stop() = 0; - virtual bool IsRunning() const = 0; - - - }; void Init(); diff --git a/include/ReMixer/SoundHandle.hpp b/include/ReMixer/SoundHandle.hpp new file mode 100644 index 0000000..326dbac --- /dev/null +++ b/include/ReMixer/SoundHandle.hpp @@ -0,0 +1,13 @@ +#pragma once +#include "sound.h" + +namespace ReMixer { + class SoundHandle { + public: + protected: + SoundHandle(const Sound& sound); + private: + }; + + +} diff --git a/include/ReMixer/stream.h b/include/ReMixer/stream.h index e4cd61a..23f50a4 100644 --- a/include/ReMixer/stream.h +++ b/include/ReMixer/stream.h @@ -17,9 +17,21 @@ #include #include #include -#include namespace ReMixer { + + enum class StreamDirection { + PLAYBACK, + RECORD, + }; + + /// We do not plan to support specifications such as 7.1 Surround. + /// 3D Positional Audio will be implemented later in software. + enum class StreamMode : bool { + MONO = false, + STEREO = true + }; + /// The stream class is an abstract class that represents distinct output / input channels on an audio system. /// Each audio system implements their concept of streams as a derivation of this class. class Stream { diff --git a/src/linux/ReMixer.cpp b/src/linux/ReMixer.cpp index 21ae153..a9bb69f 100644 --- a/src/linux/ReMixer.cpp +++ b/src/linux/ReMixer.cpp @@ -1,14 +1,4 @@ #include -unsigned ReMixer::operator ""_Hz(unsigned long long int frequency) { - return frequency; -} -unsigned ReMixer::operator ""_kHz(long double frequency) { - return frequency * 1000; -} - -unsigned ReMixer::operator ""_kHz(unsigned long long int frequency) { - return operator ""_kHz((long double)frequency); -} diff --git a/src/shared/Frequency.cpp b/src/shared/Frequency.cpp new file mode 100644 index 0000000..7b10fac --- /dev/null +++ b/src/shared/Frequency.cpp @@ -0,0 +1,36 @@ +#include +namespace ReMixer::FrequencyLiterals { + unsigned operator ""_Hz(long double frequency) { + return frequency; + } + + unsigned operator ""_MHz(long double frequency) { + return frequency * 1000 * 1000; + } + + unsigned operator ""_MHz(unsigned long long int frequency) { + return frequency * 1000 * 1000; + } + + unsigned operator ""_GHz(long double frequency) { + return frequency * 1000 * 1000 * 1000; + } + + unsigned operator ""_GHz(unsigned long long int frequency) { + return frequency * 1000 * 1000 * 1000; + } + + + +} +unsigned ReMixer::FrequencyLiterals::operator ""_Hz(unsigned long long int frequency) { + return frequency; +} + +unsigned ReMixer::FrequencyLiterals::operator ""_kHz(long double frequency) { + return frequency * 1000; +} + +unsigned ReMixer::FrequencyLiterals::operator ""_kHz(unsigned long long int frequency) { + return operator ""_kHz((long double)frequency); +} \ No newline at end of file