diff --git a/include/Metadata.h b/include/Metadata.h index cc04db4..a888a85 100644 --- a/include/Metadata.h +++ b/include/Metadata.h @@ -17,3 +17,7 @@ struct Metadata { unsigned int sampleRate; unsigned int bitRate; }; + +struct Track { + +}; diff --git a/include/Player.h b/include/Player.h new file mode 100644 index 0000000..c30c014 --- /dev/null +++ b/include/Player.h @@ -0,0 +1,63 @@ +#pragma once + +#include "../include/Metadata.h" +#include "../include/miniaudio.h" + +#include +#include +#include + +using Queue = std::vector; + +class Player { + public: + virtual ~Player() = delete; + + virtual void initPlayer(); + void loadFile() const; + + // Transport Control + virtual void play() const; + virtual void stop() const; + virtual void pause() const; + virtual void previous() const; + virtual void next() const; + + virtual void getPlayheadPosition() const; + virtual void setPlayheadPosition() const; + + // get Metadat + virtual std::string& getArtist() const; + virtual std::string& getTitle() const; + virtual std::string& getAlbum() const; + virtual unsigned int getTrackNr() const; + + // Player Queue + Queue getQueue() const; + Queue clearQueue(); + Queue addToQueue( Track& track ); + Queue rempveFromQueue( Track& track ); + Queue shuffleQueue(); + + private: + std::string artist_; + std::string title_; + std::string album_; + std::string trackNr_; + std::string filePath_; + Queue queue_; + + unsigned int samplerate_ = 48000; + unsigned int channels_ = 2; + + +}; + +class PlayerLocal : public Player { + public: + virtual void initPlayer() override; + virtual ma_engine_config configureEngine() override; + + const virtual unsigned int getSamplerate() const; + +}; diff --git a/include/PlayerEngine.h b/include/PlayerEngine.h new file mode 100644 index 0000000..473b123 --- /dev/null +++ b/include/PlayerEngine.h @@ -0,0 +1,27 @@ +#pragma once + +#include "miniaudio.h" + +class PlayerEngine { + private: + ma_engine engine_; + ma_engine_config engineConfig_; + ma_device device_; + ma_device_config deviceConfig_; + unsigned int sampleRate_; + unsigned int channels_ = 2; + ma_format format_ = ma_format_unknown; + + public: + PlayerEngine(); + PlayerEngine( unsigned int sampleRate, unsigned int channels, ma_format format ); + ma_device getDevice() const; + unsigned int getChannels() const; + unsigned int getSampleRate() const; + ma_format getFormat() const; + + void setDevice( ma_device device ); + void setSampleRate( unsigned int sampleRate ); + void setChannels( unsigned int channels ); + void setFormat( ma_format format ); +}; diff --git a/src/Player.cpp b/src/Player.cpp new file mode 100644 index 0000000..493a421 --- /dev/null +++ b/src/Player.cpp @@ -0,0 +1,3 @@ +#include "../include/Player.h" + +//#include "../include/miniaudio.h" diff --git a/src/PlayerEngine.cpp b/src/PlayerEngine.cpp new file mode 100644 index 0000000..3f144d8 --- /dev/null +++ b/src/PlayerEngine.cpp @@ -0,0 +1,18 @@ +#include "../include/PlayerEngine.h" + +using pe = PlayerEngine; + +// Constructor + pe::PlayerEngine( unsigned int sampleRate, unsigned int channels, ma_format format ) : sampleRate_{ sampleRate }, channels_{ channels }, format_( format ) {} + + // Getters + ma_device pe::getDevice() const { return device_; } + ma_format pe::getFormat() const { return format_; } + unsigned int pe::getSampleRate() const { return sampleRate_; } + unsigned int pe::getChannels() const { return channels_; } + + // Setters + void pe::setDevice( ma_device device ) { device_ = device; } + void pe::setSampleRate ( unsigned int sampleRate ) { sampleRate_ = sampleRate; } + void pe::setChannels( unsigned int channels ) { channels_ = channels; } + void pe::setFormat( ma_format format ) { format_ = format; }