audio-drain/audio/drain/Volume.hpp

101 lines
2.7 KiB
C++
Raw Normal View History

2015-04-10 23:00:13 +02:00
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
2015-04-10 23:00:13 +02:00
*/
#pragma once
2015-04-10 23:00:13 +02:00
2016-10-02 21:41:55 +02:00
#include <audio/drain/Algo.hpp>
2015-04-10 23:00:13 +02:00
#ifdef HAVE_SPEEX_DSP_RESAMPLE
#include <speex/speex_resampler.h>
2015-04-10 23:00:13 +02:00
#endif
2016-10-02 21:41:55 +02:00
#include <ememory/memory.hpp>
2015-04-10 23:00:13 +02:00
namespace audio {
namespace drain {
// data structure.
class VolumeElement {
public:
VolumeElement(const std::string& _name="ERROR-VOLUME-NAME", float _volumedB=0.0f) :
m_name(_name),
2015-07-02 21:17:24 +02:00
m_volumedB(_volumedB),
m_mute(false) {
2015-04-10 23:00:13 +02:00
}
private:
std::string m_name;
public:
std::string getName() const {
return m_name;
}
private:
float m_volumedB;
public:
float getVolume() const {
return m_volumedB;
}
void setVolume(float _volumedB) {
m_volumedB = _volumedB;
}
2015-07-02 21:17:24 +02:00
private:
bool m_mute;
public:
bool getMute() const {
return m_mute;
}
void setMute(bool _mute) {
m_mute = _mute;
}
2015-04-10 23:00:13 +02:00
};
// TODO: Optimisation
// TODO: Zero crossing
// TODO: Continuous update volume
// TODO: Manage multiple volume
// TODO: Manage set volume
class Volume : public audio::drain::Algo {
private:
2016-07-19 21:43:58 +02:00
std::vector<ememory::SharedPtr<drain::VolumeElement> > m_volumeList;
2015-04-10 23:00:13 +02:00
// for float input :
float m_volumeAppli;
// for integer input :
int32_t m_volumeDecalage; // Volume to apply is simple as : X * m_coef >> m_coef
int32_t m_volumeCoef;
// convertion function:
void (*m_functionConvert)(void* _input, void* _output, size_t _nbSample, int32_t _volumeCoef, int32_t _volumeDecalage, float _volumeAppli);
protected:
/**
* @brief Constructor
*/
Volume();
void init();
public:
2016-07-19 21:43:58 +02:00
static ememory::SharedPtr<Volume> create();
2015-04-10 23:00:13 +02:00
/**
* @brief Destructor
*/
virtual ~Volume();
protected:
virtual void configurationChange();
public:
2015-04-13 21:49:48 +02:00
virtual bool process(audio::Time& _time,
2015-04-10 23:00:13 +02:00
void* _input,
size_t _inputNbChunk,
void*& _output,
size_t& _outputNbChunk);
public:
virtual std::vector<audio::format> getFormatSupportedInput();
virtual std::vector<audio::format> getFormatSupportedOutput();
public:
2016-07-19 21:43:58 +02:00
virtual void addVolumeStage(const ememory::SharedPtr<drain::VolumeElement>& _volume);
2015-04-10 23:00:13 +02:00
virtual bool setParameter(const std::string& _parameter, const std::string& _value);
virtual std::string getParameter(const std::string& _parameter) const;
virtual std::string getParameterProperty(const std::string& _parameter) const;
public:
void volumeChange();
public:
virtual std::string getDotDesc();
2015-04-10 23:00:13 +02:00
};
}
}