[DEV] set basic sound set system
This commit is contained in:
parent
b45894a4f1
commit
af8f953867
@ -9,23 +9,23 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/thread/tools.h>
|
||||
#include <ewolsa/debug.h>
|
||||
#include <ewolsa/LoadedFile.h>
|
||||
#include <ewolsa/decWav.h>
|
||||
#include <ewolsa/decOgg.h>
|
||||
#include <audio/ess/debug.h>
|
||||
#include <audio/ess/LoadedFile.h>
|
||||
#include <audio/ess/decWav.h>
|
||||
#include <audio/ess/decOgg.h>
|
||||
|
||||
static void threadCallback2(void* _userData) {
|
||||
etk::thread::setName("ewolSA decoder");
|
||||
ewolsa::LoadedFile* decodeFile = reinterpret_cast<ewolsa::LoadedFile*>(_userData);
|
||||
audio::ess::LoadedFile* decodeFile = reinterpret_cast<audio::ess::LoadedFile*>(_userData);
|
||||
decodeFile->decode();
|
||||
}
|
||||
|
||||
void ewolsa::LoadedFile::decode() {
|
||||
m_data = ewolsa::ogg::loadAudioFile(m_file, m_nbChanRequested);
|
||||
void audio::ess::LoadedFile::decode() {
|
||||
m_data = audio::ess::ogg::loadAudioFile(m_file, m_nbChanRequested);
|
||||
m_nbSamples = m_data.size();
|
||||
}
|
||||
|
||||
ewolsa::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanRequested) :
|
||||
audio::ess::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanRequested) :
|
||||
m_thread(nullptr),
|
||||
m_file(_fileName),
|
||||
m_nbSamples(0),
|
||||
@ -34,7 +34,7 @@ ewolsa::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanReque
|
||||
std::string tmpName = etk::tolower(m_file);
|
||||
// select the corect Loader :
|
||||
if (etk::end_with(tmpName, ".wav") == true) {
|
||||
m_data = ewolsa::wav::loadAudioFile(m_file, m_nbChanRequested);
|
||||
m_data = audio::ess::wav::loadAudioFile(m_file, m_nbChanRequested);
|
||||
m_nbSamples = m_data.size();
|
||||
} else if (etk::end_with(tmpName, ".ogg") == true) {
|
||||
EWOLSA_DEBUG("create thread");
|
||||
@ -55,7 +55,7 @@ ewolsa::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanReque
|
||||
}
|
||||
|
||||
|
||||
ewolsa::LoadedFile::~LoadedFile() {
|
||||
audio::ess::LoadedFile::~LoadedFile() {
|
||||
if (m_thread != nullptr) {
|
||||
delete m_thread;
|
||||
}
|
40
audio/ess/LoadedFile.h
Normal file
40
audio/ess/LoadedFile.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __EWOLSA_LOADED_FILE_H__
|
||||
#define __EWOLSA_LOADED_FILE_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <thread>
|
||||
#include <pthread.h>
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
class LoadedFile {
|
||||
private:
|
||||
std::thread* m_thread;
|
||||
public:
|
||||
LoadedFile(const std::string& _fileName, int8_t _nbChanRequested=1);
|
||||
~LoadedFile();
|
||||
std::string m_file;
|
||||
int32_t m_nbSamples;
|
||||
int32_t m_nbChanRequested;
|
||||
int32_t m_requestedTime;
|
||||
std::vector<int16_t> m_data;
|
||||
public:
|
||||
const std::string& getName() {
|
||||
return m_file;
|
||||
};
|
||||
void decode();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -6,9 +6,9 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewolsa/debug.h>
|
||||
#include <audio/ess/debug.h>
|
||||
|
||||
int32_t ewolsa::getLogId() {
|
||||
static int32_t g_val = etk::log::registerInstance("ewol-sa");
|
||||
int32_t audio::ess::getLogId() {
|
||||
static int32_t g_val = etk::log::registerInstance("audio-ess");
|
||||
return g_val;
|
||||
}
|
@ -11,10 +11,13 @@
|
||||
|
||||
#include <etk/log.h>
|
||||
|
||||
namespace ewolsa {
|
||||
int32_t getLogId();
|
||||
};
|
||||
#define EWOLSA_BASE(info,data) TK_LOG_BASE(ewolsa::getLogId(),info,data)
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
int32_t getLogId();
|
||||
}
|
||||
}
|
||||
#define EWOLSA_BASE(info,data) TK_LOG_BASE(audio::ess::getLogId(),info,data)
|
||||
|
||||
#define EWOLSA_CRITICAL(data) EWOLSA_BASE(1, data)
|
||||
#define EWOLSA_ERROR(data) EWOLSA_BASE(2, data)
|
@ -8,8 +8,8 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <ewolsa/debug.h>
|
||||
#include <ewolsa/decOgg.h>
|
||||
#include <audio/ess/debug.h>
|
||||
#include <audio/ess/decOgg.h>
|
||||
#include <tremor/ivorbiscodec.h>
|
||||
#include <tremor/ivorbisfile.h>
|
||||
#include <memory>
|
||||
@ -48,7 +48,7 @@ static long localTellFunc(void *datasource) {
|
||||
return file->fileTell();
|
||||
}
|
||||
|
||||
std::vector<int16_t> ewolsa::ogg::loadAudioFile(const std::string& _filename, int8_t _nbChan) {
|
||||
std::vector<int16_t> audio::ess::ogg::loadAudioFile(const std::string& _filename, int8_t _nbChan) {
|
||||
OggVorbis_File vf;
|
||||
int32_t eof=0;
|
||||
int32_t current_section;
|
@ -11,11 +11,14 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace ewolsa {
|
||||
namespace ogg {
|
||||
std::vector<int16_t> loadAudioFile(const std::string& _filename, int8_t _nbChan);
|
||||
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
namespace ogg {
|
||||
std::vector<int16_t> loadAudioFile(const std::string& _filename, int8_t _nbChan);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -8,8 +8,8 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <ewolsa/debug.h>
|
||||
#include <ewolsa/decWav.h>
|
||||
#include <audio/ess/debug.h>
|
||||
#include <audio/ess/decWav.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
@ -59,7 +59,7 @@ typedef struct {
|
||||
#define COMPR_G721 (64)
|
||||
#define COMPR_MPEG (80)
|
||||
|
||||
std::vector<int16_t> ewolsa::wav::loadAudioFile(const std::string& _filename, int8_t _nbChan) {
|
||||
std::vector<int16_t> audio::ess::wav::loadAudioFile(const std::string& _filename, int8_t _nbChan) {
|
||||
waveHeader myHeader;
|
||||
memset(&myHeader, 0, sizeof(waveHeader));
|
||||
etk::FSNode fileAccess(_filename);
|
@ -11,11 +11,14 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace ewolsa {
|
||||
namespace wav {
|
||||
std::vector<int16_t> loadAudioFile(const std::string& _filename, int8_t _nbChan);
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
namespace wav {
|
||||
std::vector<int16_t> loadAudioFile(const std::string& _filename, int8_t _nbChan);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -9,11 +9,11 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#include <ewolsa/debug.h>
|
||||
#include <ewolsa/effects.h>
|
||||
#include <ewolsa/decWav.h>
|
||||
#include <audio/ess/debug.h>
|
||||
#include <audio/ess/effects.h>
|
||||
#include <audio/ess/decWav.h>
|
||||
#include <math.h>
|
||||
#include <ewolsa/LoadedFile.h>
|
||||
#include <audio/ess/LoadedFile.h>
|
||||
#include <mutex>
|
||||
|
||||
static std::mutex localMutex;
|
||||
@ -29,16 +29,16 @@ static int32_t effectsVolumeApply = 1<<16;
|
||||
class RequestPlay {
|
||||
private:
|
||||
bool m_freeSlot;
|
||||
ewolsa::LoadedFile* m_effect; // reference to the effects
|
||||
audio::ess::LoadedFile* m_effect; // reference to the effects
|
||||
int32_t m_playTime; // position in sample playing in the audio effects
|
||||
public :
|
||||
RequestPlay(ewolsa::LoadedFile * _effect) :
|
||||
RequestPlay(audio::ess::LoadedFile * _effect) :
|
||||
m_freeSlot(false),
|
||||
m_effect(_effect),
|
||||
m_playTime(0) {
|
||||
|
||||
};
|
||||
void reset(ewolsa::LoadedFile * _effect) {
|
||||
void reset(audio::ess::LoadedFile * _effect) {
|
||||
m_effect=_effect;
|
||||
m_playTime=0;
|
||||
m_freeSlot=false;
|
||||
@ -78,20 +78,20 @@ class RequestPlay {
|
||||
};
|
||||
|
||||
#include <vector>
|
||||
std::vector<ewolsa::LoadedFile*> ListEffects;
|
||||
std::vector<audio::ess::LoadedFile*> ListEffects;
|
||||
std::vector<RequestPlay*> ListEffectsPlaying;
|
||||
|
||||
void ewolsa::effects::init() {
|
||||
ewolsa::effects::volumeSet(0);
|
||||
ewolsa::effects::muteSet(false);
|
||||
void audio::ess::effects::init() {
|
||||
audio::ess::effects::volumeSet(0);
|
||||
audio::ess::effects::muteSet(false);
|
||||
}
|
||||
|
||||
void ewolsa::effects::unInit() {
|
||||
ewolsa::effects::volumeSet(-1000);
|
||||
ewolsa::effects::muteSet(true);
|
||||
void audio::ess::effects::unInit() {
|
||||
audio::ess::effects::volumeSet(-1000);
|
||||
audio::ess::effects::muteSet(true);
|
||||
}
|
||||
|
||||
int32_t ewolsa::effects::add(const std::string& _file) {
|
||||
int32_t audio::ess::effects::add(const std::string& _file) {
|
||||
for (size_t iii=0; iii<ListEffects.size(); iii++) {
|
||||
if (ListEffects[iii] == nullptr) {
|
||||
continue;
|
||||
@ -102,7 +102,7 @@ int32_t ewolsa::effects::add(const std::string& _file) {
|
||||
}
|
||||
}
|
||||
// effect does not exist ... create a new one ...
|
||||
ewolsa::LoadedFile * tmpEffect = new ewolsa::LoadedFile(_file);
|
||||
audio::ess::LoadedFile * tmpEffect = new audio::ess::LoadedFile(_file);
|
||||
if (nullptr == tmpEffect) {
|
||||
EWOLSA_ERROR("Error to load the effects : \"" << _file << "\"");
|
||||
return -1;
|
||||
@ -111,7 +111,7 @@ int32_t ewolsa::effects::add(const std::string& _file) {
|
||||
return ListEffects.size()-1;
|
||||
}
|
||||
|
||||
void ewolsa::effects::rm(int32_t _effectId) {
|
||||
void audio::ess::effects::rm(int32_t _effectId) {
|
||||
// find element ...
|
||||
if (_effectId <0 || _effectId >= (int64_t)ListEffects.size()) {
|
||||
EWOLSA_ERROR("Wrong effect ID : " << _effectId << " != [0.." << ListEffects.size()-1 << "] == > can not remove it ...");
|
||||
@ -132,7 +132,7 @@ void ewolsa::effects::rm(int32_t _effectId) {
|
||||
}
|
||||
|
||||
|
||||
void ewolsa::effects::play(int32_t _effectId, float _xxx, float _yyy) {
|
||||
void audio::ess::effects::play(int32_t _effectId, float _xxx, float _yyy) {
|
||||
if (_effectId <0 || _effectId >= (int64_t)ListEffects.size()) {
|
||||
EWOLSA_ERROR("Wrong effect ID : " << _effectId << " != [0.." << ListEffects.size()-1 << "] == > can not play it ...");
|
||||
return;
|
||||
@ -158,7 +158,7 @@ void ewolsa::effects::play(int32_t _effectId, float _xxx, float _yyy) {
|
||||
}
|
||||
|
||||
|
||||
float ewolsa::effects::volumeGet() {
|
||||
float audio::ess::effects::volumeGet() {
|
||||
return effectsVolume;
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ static void uptateEffectVolume() {
|
||||
}
|
||||
}
|
||||
|
||||
void ewolsa::effects::volumeSet(float _newVolume) {
|
||||
void audio::ess::effects::volumeSet(float _newVolume) {
|
||||
effectsVolume = _newVolume;
|
||||
effectsVolume = std::avg(-100.0f, effectsVolume, 20.0f);
|
||||
EWOLSA_INFO("Set music Volume at " << _newVolume << "dB == > " << effectsVolume << "dB");
|
||||
@ -182,12 +182,12 @@ void ewolsa::effects::volumeSet(float _newVolume) {
|
||||
}
|
||||
|
||||
|
||||
bool ewolsa::effects::muteGet() {
|
||||
bool audio::ess::effects::muteGet() {
|
||||
return effectsMute;
|
||||
}
|
||||
|
||||
|
||||
void ewolsa::effects::muteSet(bool _newMute) {
|
||||
void audio::ess::effects::muteSet(bool _newMute) {
|
||||
effectsMute = _newMute;
|
||||
EWOLSA_INFO("Set effects Mute at " << _newMute);
|
||||
uptateEffectVolume();
|
||||
@ -195,7 +195,7 @@ void ewolsa::effects::muteSet(bool _newMute) {
|
||||
|
||||
|
||||
|
||||
void ewolsa::effects::getData(int16_t* _bufferInterlace, int32_t _nbSample, int32_t _nbChannels) {
|
||||
void audio::ess::effects::getData(int16_t* _bufferInterlace, int32_t _nbSample, int32_t _nbChannels) {
|
||||
for (size_t iii = 0; iii < ListEffectsPlaying.size(); ++iii) {
|
||||
if (ListEffectsPlaying[iii]!= nullptr) {
|
||||
ListEffectsPlaying[iii]->play(_bufferInterlace, _nbSample, _nbChannels);
|
37
audio/ess/effects.h
Normal file
37
audio/ess/effects.h
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __EWOLSA_EFFECTS_H__
|
||||
#define __EWOLSA_EFFECTS_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
// note effect is loaded in memory (then don't create long effect) and unload only when requested
|
||||
namespace effects {
|
||||
void init();
|
||||
void unInit();
|
||||
// note : support file (Mono, 16bit, 48kHz) : .raw or .wav (no encodage) or .ogg (decoded with tremor lib)
|
||||
int32_t add(const std::string& _file);
|
||||
void rm(int32_t _effectId);
|
||||
void play(int32_t _effectId, float _xxx=0, float _yyy=0);
|
||||
// in db
|
||||
float volumeGet();
|
||||
void volumeSet(float _newVolume);
|
||||
bool muteGet();
|
||||
void muteSet(bool _newMute);
|
||||
void getData(int16_t* _bufferInterlace, int32_t _nbSample, int32_t _nbChannels);
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -9,19 +9,19 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#include <river/Interface.h>
|
||||
#include <river/Manager.h>
|
||||
#include <ewolsa/ewolsa.h>
|
||||
#include <ewolsa/debug.h>
|
||||
#include <audio/river/Interface.h>
|
||||
#include <audio/river/Manager.h>
|
||||
#include <audio/ess/ess.h>
|
||||
#include <audio/ess/debug.h>
|
||||
|
||||
|
||||
class OutputInterface {
|
||||
private:
|
||||
std::shared_ptr<river::Manager> m_manager;
|
||||
std::shared_ptr<river::Interface> m_interface;
|
||||
std::shared_ptr<audio::river::Manager> m_manager;
|
||||
std::shared_ptr<audio::river::Interface> m_interface;
|
||||
public:
|
||||
OutputInterface() {
|
||||
m_manager = river::Manager::create("testApplication");
|
||||
m_manager = audio::river::Manager::create("testApplication");
|
||||
//Set stereo output:
|
||||
std::vector<audio::channel> channelMap;
|
||||
channelMap.push_back(audio::channel_frontLeft);
|
||||
@ -30,7 +30,7 @@ class OutputInterface {
|
||||
channelMap,
|
||||
audio::format_int16,
|
||||
"speaker",
|
||||
"ewolsa::basicOutput");
|
||||
"audio::ess::basicOutput");
|
||||
if (m_interface == nullptr) {
|
||||
EWOLSA_ERROR("can not allocate output interface ... ");
|
||||
return;
|
||||
@ -64,18 +64,18 @@ class OutputInterface {
|
||||
EWOLSA_ERROR("call wrong type ... (need int16_t)");
|
||||
}
|
||||
// call music
|
||||
ewolsa::music::getData(static_cast<int16_t*>(_data), _nbChunk, _map.size());
|
||||
audio::ess::music::getData(static_cast<int16_t*>(_data), _nbChunk, _map.size());
|
||||
// call Effects
|
||||
//ewolsa::effects::getData(static_cast<int16_t*>(_data), _nbChunk, _map.size());
|
||||
//audio::ess::effects::getData(static_cast<int16_t*>(_data), _nbChunk, _map.size());
|
||||
}
|
||||
};
|
||||
std::shared_ptr<OutputInterface> g_ioInterface;
|
||||
|
||||
void ewolsa::init() {
|
||||
void audio::ess::init() {
|
||||
g_ioInterface = std::make_shared<OutputInterface>();
|
||||
}
|
||||
|
||||
void ewolsa::unInit() {
|
||||
void audio::ess::unInit() {
|
||||
g_ioInterface.reset();
|
||||
}
|
||||
|
@ -11,13 +11,15 @@
|
||||
#define __EWOLSA_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewolsa/effects.h>
|
||||
#include <ewolsa/music.h>
|
||||
#include <audio/ess/effects.h>
|
||||
#include <audio/ess/music.h>
|
||||
|
||||
namespace ewolsa {
|
||||
void init();
|
||||
void unInit();
|
||||
};
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
void init();
|
||||
void unInit();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#include <ewolsa/music.h>
|
||||
#include <ewolsa/debug.h>
|
||||
#include <ewolsa/LoadedFile.h>
|
||||
#include <audio/ess/music.h>
|
||||
#include <audio/ess/debug.h>
|
||||
#include <audio/ess/LoadedFile.h>
|
||||
#include <math.h>
|
||||
#include <mutex>
|
||||
|
||||
@ -22,13 +22,13 @@ static float musicVolume = 0;
|
||||
static int32_t musicVolumeApply = 1<<16;
|
||||
static int32_t musicFadingTime = 0;
|
||||
static int32_t musicPositionReading = 0;
|
||||
static std::vector<ewolsa::LoadedFile*> musicListRead;
|
||||
static std::vector<audio::ess::LoadedFile*> musicListRead;
|
||||
static int32_t musicCurrentRead = -1;
|
||||
static int32_t musicNextRead = -1;
|
||||
|
||||
void ewolsa::music::init() {
|
||||
ewolsa::music::volumeSet(0);
|
||||
ewolsa::music::muteSet(false);
|
||||
void audio::ess::music::init() {
|
||||
audio::ess::music::volumeSet(0);
|
||||
audio::ess::music::muteSet(false);
|
||||
std::unique_lock<std::mutex> lck(localMutex);
|
||||
musicCurrentRead = -1;
|
||||
musicNextRead = -1;
|
||||
@ -43,9 +43,9 @@ void ewolsa::music::init() {
|
||||
musicListRead.clear();
|
||||
}
|
||||
|
||||
void ewolsa::music::unInit() {
|
||||
ewolsa::music::volumeSet(-1000);
|
||||
ewolsa::music::muteSet(true);
|
||||
void audio::ess::music::unInit() {
|
||||
audio::ess::music::volumeSet(-1000);
|
||||
audio::ess::music::muteSet(true);
|
||||
std::unique_lock<std::mutex> lck(localMutex);
|
||||
musicCurrentRead = -1;
|
||||
musicNextRead = -1;
|
||||
@ -61,14 +61,14 @@ void ewolsa::music::unInit() {
|
||||
}
|
||||
|
||||
|
||||
void ewolsa::music::fading(int32_t _timeMs) {
|
||||
void audio::ess::music::fading(int32_t _timeMs) {
|
||||
musicFadingTime = _timeMs;
|
||||
musicFadingTime = std::avg(-100, musicFadingTime, 20);
|
||||
EWOLSA_INFO("Set music fading time at " << _timeMs << "ms == > " << musicFadingTime << "ms");
|
||||
}
|
||||
|
||||
|
||||
void ewolsa::music::preLoad(const std::string& _file) {
|
||||
void audio::ess::music::preLoad(const std::string& _file) {
|
||||
// check if music already existed ...
|
||||
for (size_t iii=0; iii<musicListRead.size(); ++iii) {
|
||||
if (musicListRead[iii] == nullptr) {
|
||||
@ -78,7 +78,7 @@ void ewolsa::music::preLoad(const std::string& _file) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
ewolsa::LoadedFile* tmp = new ewolsa::LoadedFile(_file, 2);
|
||||
audio::ess::LoadedFile* tmp = new audio::ess::LoadedFile(_file, 2);
|
||||
if (tmp != nullptr) {
|
||||
/*
|
||||
if (tmp->m_data == nullptr) {
|
||||
@ -94,7 +94,7 @@ void ewolsa::music::preLoad(const std::string& _file) {
|
||||
}
|
||||
|
||||
|
||||
bool ewolsa::music::play(const std::string& _file) {
|
||||
bool audio::ess::music::play(const std::string& _file) {
|
||||
preLoad(_file);
|
||||
// in all case we stop the current playing music ...
|
||||
stop();
|
||||
@ -119,7 +119,7 @@ bool ewolsa::music::play(const std::string& _file) {
|
||||
}
|
||||
|
||||
|
||||
bool ewolsa::music::stop() {
|
||||
bool audio::ess::music::stop() {
|
||||
if (musicCurrentRead == -1) {
|
||||
EWOLSA_INFO("No current audio is playing");
|
||||
return false;
|
||||
@ -131,7 +131,7 @@ bool ewolsa::music::stop() {
|
||||
|
||||
|
||||
|
||||
float ewolsa::music::volumeGet() {
|
||||
float audio::ess::music::volumeGet() {
|
||||
return musicVolume;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ static void uptateMusicVolume() {
|
||||
}
|
||||
}
|
||||
|
||||
void ewolsa::music::volumeSet(float _newVolume) {
|
||||
void audio::ess::music::volumeSet(float _newVolume) {
|
||||
musicVolume = _newVolume;
|
||||
musicVolume = std::avg(-1000.0f, musicVolume, 40.0f);
|
||||
EWOLSA_INFO("Set music Volume at " << _newVolume << "dB == > " << musicVolume << "dB");
|
||||
@ -156,19 +156,19 @@ void ewolsa::music::volumeSet(float _newVolume) {
|
||||
}
|
||||
|
||||
|
||||
bool ewolsa::music::muteGet() {
|
||||
bool audio::ess::music::muteGet() {
|
||||
return musicMute;
|
||||
}
|
||||
|
||||
|
||||
void ewolsa::music::muteSet(bool _newMute) {
|
||||
void audio::ess::music::muteSet(bool _newMute) {
|
||||
musicMute = _newMute;
|
||||
EWOLSA_INFO("Set music Mute at " << _newMute);
|
||||
uptateMusicVolume();
|
||||
}
|
||||
|
||||
|
||||
void ewolsa::music::getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels) {
|
||||
void audio::ess::music::getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels) {
|
||||
EWOLSA_VERBOSE("Music !!! " << musicCurrentRead << " ... " << musicNextRead << " pos: " << musicPositionReading);
|
||||
std::unique_lock<std::mutex> lck(localMutex);
|
||||
if (musicCurrentRead != musicNextRead) {
|
37
audio/ess/music.h
Normal file
37
audio/ess/music.h
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __EWOLSA_MUSIC_H__
|
||||
#define __EWOLSA_MUSIC_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
namespace music {
|
||||
void init();
|
||||
void unInit();
|
||||
void fading(int32_t _timeMs);
|
||||
|
||||
void preLoad(const std::string& _file);
|
||||
bool play(const std::string& _file);
|
||||
bool stop();
|
||||
|
||||
// in db
|
||||
float volumeGet();
|
||||
void volumeSet(float _newVolume);
|
||||
bool muteGet();
|
||||
void muteSet(bool _newMute);
|
||||
void getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,38 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __EWOLSA_LOADED_FILE_H__
|
||||
#define __EWOLSA_LOADED_FILE_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <thread>
|
||||
#include <pthread.h>
|
||||
|
||||
namespace ewolsa {
|
||||
class LoadedFile {
|
||||
private:
|
||||
std::thread* m_thread;
|
||||
public:
|
||||
LoadedFile(const std::string& _fileName, int8_t _nbChanRequested=1);
|
||||
~LoadedFile();
|
||||
std::string m_file;
|
||||
int32_t m_nbSamples;
|
||||
int32_t m_nbChanRequested;
|
||||
int32_t m_requestedTime;
|
||||
std::vector<int16_t> m_data;
|
||||
public:
|
||||
const std::string& getName() {
|
||||
return m_file;
|
||||
};
|
||||
void decode();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __EWOLSA_EFFECTS_H__
|
||||
#define __EWOLSA_EFFECTS_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace ewolsa {
|
||||
// note effect is loaded in memory (then don't create long effect) and unload only when requested
|
||||
namespace effects {
|
||||
void init();
|
||||
void unInit();
|
||||
// note : support file (Mono, 16bit, 48kHz) : .raw or .wav (no encodage) or .ogg (decoded with tremor lib)
|
||||
int32_t add(const std::string& _file);
|
||||
void rm(int32_t _effectId);
|
||||
void play(int32_t _effectId, float _xxx=0, float _yyy=0);
|
||||
// in db
|
||||
float volumeGet();
|
||||
void volumeSet(float _newVolume);
|
||||
bool muteGet();
|
||||
void muteSet(bool _newMute);
|
||||
void getData(int16_t* _bufferInterlace, int32_t _nbSample, int32_t _nbChannels);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,36 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __EWOLSA_MUSIC_H__
|
||||
#define __EWOLSA_MUSIC_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace ewolsa {
|
||||
namespace music {
|
||||
void init();
|
||||
void unInit();
|
||||
void fading(int32_t _timeMs);
|
||||
|
||||
void preLoad(const std::string& _file);
|
||||
bool play(const std::string& _file);
|
||||
bool stop();
|
||||
|
||||
// in db
|
||||
float volumeGet();
|
||||
void volumeSet(float _newVolume);
|
||||
bool muteGet();
|
||||
void muteSet(bool _newMute);
|
||||
void getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -4,25 +4,26 @@ import lutinTools as tools
|
||||
import lutinDebug as debug
|
||||
|
||||
def get_desc():
|
||||
return "ewolsa : ewol simple audio interface for 'small game' audio effects"
|
||||
return "audio_ess : ewol sound set interface for 'small game' audio effects"
|
||||
|
||||
|
||||
def create(target):
|
||||
myModule = module.Module(__file__, 'ewolsa', 'LIBRARY')
|
||||
myModule = module.Module(__file__, 'audio_ess', 'LIBRARY')
|
||||
# System core
|
||||
myModule.add_src_file([
|
||||
'ewolsa/debug.cpp',
|
||||
'ewolsa/decWav.cpp',
|
||||
'ewolsa/decOgg.cpp',
|
||||
'ewolsa/effects.cpp',
|
||||
'ewolsa/ewolsa.cpp',
|
||||
'ewolsa/music.cpp',
|
||||
'ewolsa/LoadedFile.cpp'
|
||||
'audio/ess/debug.cpp',
|
||||
'audio/ess/decWav.cpp',
|
||||
'audio/ess/decOgg.cpp',
|
||||
'audio/ess/effects.cpp',
|
||||
'audio/ess/ess.cpp',
|
||||
'audio/ess/music.cpp',
|
||||
'audio/ess/LoadedFile.cpp'
|
||||
])
|
||||
|
||||
# name of the dependency
|
||||
myModule.add_module_depend(['etk', 'river', 'ogg'])
|
||||
myModule.add_module_depend(['etk', 'audio_river', 'ogg'])
|
||||
if target.name=="Android":
|
||||
# TODO : Change this ...
|
||||
myModule.add_export_flag_CC("-pthread -frtti -fexceptions")
|
||||
|
||||
myModule.add_export_path(tools.get_current_path(__file__))
|
Loading…
x
Reference in New Issue
Block a user