[DEV] update new AirTAudio
This commit is contained in:
parent
d274d793ba
commit
baf70033f3
@ -62,7 +62,7 @@ int32_t eaudiofx::GeneratorFile::init(void) {
|
|||||||
EAUDIOFX_ERROR("Can not open the input file ...");
|
EAUDIOFX_ERROR("Can not open the input file ...");
|
||||||
return eaudiofx::ERR_FAIL;
|
return eaudiofx::ERR_FAIL;
|
||||||
}
|
}
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ int32_t eaudiofx::GeneratorFile::unInit(void) {
|
|||||||
EAUDIOFX_ERROR("Can not close the input file ...");
|
EAUDIOFX_ERROR("Can not close the input file ...");
|
||||||
return eaudiofx::ERR_FAIL;
|
return eaudiofx::ERR_FAIL;
|
||||||
}
|
}
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <eaudiofx/base/GeneratorRtAudio.h>
|
#include <eaudiofx/base/GeneratorRtAudio.h>
|
||||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
#include <eaudiofx/core/BufferAudioRaw.h>
|
||||||
#include <rtaudio/RtAudio.h>
|
#include <airtaudio/Interface.h>
|
||||||
|
|
||||||
eaudiofx::GeneratorRtAudio::GeneratorRtAudio(void) {
|
eaudiofx::GeneratorRtAudio::GeneratorRtAudio(void) {
|
||||||
setLive(true);
|
setLive(true);
|
||||||
|
@ -9,13 +9,13 @@
|
|||||||
#include <eaudiofx/base/ReceiverRtAudio.h>
|
#include <eaudiofx/base/ReceiverRtAudio.h>
|
||||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
#include <eaudiofx/core/BufferAudioRaw.h>
|
||||||
#include <eaudiofx/debug.h>
|
#include <eaudiofx/debug.h>
|
||||||
#include <rtaudio/RtAudio.h>
|
#include <airtaudio/Interface.h>
|
||||||
|
|
||||||
int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
|
int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
|
||||||
void *_inputBuffer,
|
void *_inputBuffer,
|
||||||
unsigned int _nBufferFrames,
|
unsigned int _nBufferFrames,
|
||||||
double _streamTime,
|
double _streamTime,
|
||||||
RtAudioStreamStatus _status,
|
airtaudio::streamStatus _status,
|
||||||
void* _userData) {
|
void* _userData) {
|
||||||
if (_userData == NULL) {
|
if (_userData == NULL) {
|
||||||
EAUDIOFX_ERROR("Null class pointer");
|
EAUDIOFX_ERROR("Null class pointer");
|
||||||
@ -37,7 +37,7 @@ int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
|
|||||||
int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer,
|
int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer,
|
||||||
size_t _nBufferFrames,
|
size_t _nBufferFrames,
|
||||||
double _streamTime,
|
double _streamTime,
|
||||||
RtAudioStreamStatus _status) {
|
airtaudio::streamStatus _status) {
|
||||||
// Request block input:
|
// Request block input:
|
||||||
int32_t ret = eaudiofx::Block::pull(_streamTime, _nBufferFrames, (float)_nBufferFrames/48000.0f);
|
int32_t ret = eaudiofx::Block::pull(_streamTime, _nBufferFrames, (float)_nBufferFrames/48000.0f);
|
||||||
if (ret != eaudiofx::ERR_NONE) {
|
if (ret != eaudiofx::ERR_NONE) {
|
||||||
@ -85,40 +85,35 @@ eaudiofx::ReceiverRtAudio::ReceiverRtAudio(void) {
|
|||||||
|
|
||||||
|
|
||||||
int32_t eaudiofx::ReceiverRtAudio::init(void) {
|
int32_t eaudiofx::ReceiverRtAudio::init(void) {
|
||||||
|
m_dac.instanciate();
|
||||||
EAUDIOFX_DEBUG("Create RTAudio generator ...");
|
EAUDIOFX_DEBUG("Create RTAudio generator ...");
|
||||||
if ( m_dac.getDeviceCount() < 1 ) {
|
if ( m_dac.getDeviceCount() < 1 ) {
|
||||||
EAUDIOFX_ERROR("No audio devices found!");
|
EAUDIOFX_ERROR("No audio devices found!");
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
}
|
}
|
||||||
EAUDIOFX_DEBUG("nb devices :" << m_dac.getDeviceCount() << " default device ID : " << m_dac.getDefaultOutputDevice());
|
EAUDIOFX_DEBUG("nb devices :" << m_dac.getDeviceCount() << " default device ID : " << m_dac.getDefaultOutputDevice());
|
||||||
RtAudio::StreamParameters parameters;
|
|
||||||
m_parameters.deviceId = m_dac.getDefaultOutputDevice();
|
m_parameters.deviceId = m_dac.getDefaultOutputDevice();
|
||||||
m_parameters.nChannels = 2;
|
m_parameters.nChannels = 2;
|
||||||
m_parameters.firstChannel = 0;
|
m_parameters.firstChannel = 0;
|
||||||
unsigned int bufferFrames = 256;
|
unsigned int bufferFrames = 256;
|
||||||
try {
|
EAUDIOFX_DEBUG("OPEN Stream ...");
|
||||||
EAUDIOFX_DEBUG("OPEN Stream ...");
|
// TODO : Check return error
|
||||||
m_dac.openStream(&m_parameters, NULL, RTAUDIO_FLOAT32, 48000, &bufferFrames, &rtAudioCallBack, (void *)this);
|
m_dac.openStream(&m_parameters, NULL, airtaudio::FLOAT32, 48000, &bufferFrames, &rtAudioCallBack, (void *)this);
|
||||||
m_dac.startStream();
|
// TODO : Check return error
|
||||||
}catch ( RtError& e ) {
|
m_dac.startStream();
|
||||||
e.printMessage();
|
|
||||||
exit( 0 );
|
|
||||||
}
|
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t eaudiofx::ReceiverRtAudio::unInit(void) {
|
int32_t eaudiofx::ReceiverRtAudio::unInit(void) {
|
||||||
try {
|
EAUDIOFX_DEBUG("STOP Stream ...");
|
||||||
EAUDIOFX_DEBUG("STOP Stream ...");
|
// Stop the stream
|
||||||
// Stop the stream
|
m_dac.stopStream();
|
||||||
m_dac.stopStream();
|
// TODO : Check return error
|
||||||
} catch (RtError& e) {
|
|
||||||
e.printMessage();
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
if ( m_dac.isStreamOpen() ) {
|
if ( m_dac.isStreamOpen() ) {
|
||||||
m_dac.closeStream();
|
m_dac.closeStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define __EAUDIOFX_RECEIVER_RTAUDIO_H__
|
#define __EAUDIOFX_RECEIVER_RTAUDIO_H__
|
||||||
|
|
||||||
#include <eaudiofx/core/BlockReceiver.h>
|
#include <eaudiofx/core/BlockReceiver.h>
|
||||||
#include <rtaudio/RtAudio.h>
|
#include <airtaudio/Interface.h>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class ReceiverRtAudio : public eaudiofx::BlockReceiver {
|
class ReceiverRtAudio : public eaudiofx::BlockReceiver {
|
||||||
@ -19,13 +19,13 @@ namespace eaudiofx {
|
|||||||
void *_inputBuffer,
|
void *_inputBuffer,
|
||||||
unsigned int _nBufferFrames,
|
unsigned int _nBufferFrames,
|
||||||
double _streamTime,
|
double _streamTime,
|
||||||
RtAudioStreamStatus _status,
|
airtaudio::streamStatus _status,
|
||||||
void* _userData);
|
void* _userData);
|
||||||
// class callback
|
// class callback
|
||||||
int32_t needData(float* _outputBuffer,
|
int32_t needData(float* _outputBuffer,
|
||||||
size_t _nBufferFrames,
|
size_t _nBufferFrames,
|
||||||
double _streamTime,
|
double _streamTime,
|
||||||
RtAudioStreamStatus _status);
|
airtaudio::streamStatus _status);
|
||||||
public:
|
public:
|
||||||
ReceiverRtAudio(void);
|
ReceiverRtAudio(void);
|
||||||
virtual ~ReceiverRtAudio(void) {};
|
virtual ~ReceiverRtAudio(void) {};
|
||||||
@ -33,8 +33,8 @@ namespace eaudiofx {
|
|||||||
virtual int32_t init(void);
|
virtual int32_t init(void);
|
||||||
virtual int32_t unInit(void);
|
virtual int32_t unInit(void);
|
||||||
protected:
|
protected:
|
||||||
RtAudio m_dac;
|
airtaudio::Interface m_dac;
|
||||||
RtAudio::StreamParameters m_parameters;
|
airtaudio::StreamParameters m_parameters;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -102,6 +102,7 @@ int32_t eaudiofx::Block::unLinkBuffer(const eaudiofx::Buffer* _buffer) {
|
|||||||
it.second.m_buffer = NULL;
|
it.second.m_buffer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t eaudiofx::Block::unLinkBuffer(const std::string& _name) {
|
int32_t eaudiofx::Block::unLinkBuffer(const std::string& _name) {
|
||||||
|
@ -125,11 +125,13 @@ int32_t eaudiofx::BlockDecoder::pull(double _currentTime, int32_t _request, floa
|
|||||||
|
|
||||||
int32_t eaudiofx::BlockDecoder::init(void) {
|
int32_t eaudiofx::BlockDecoder::init(void) {
|
||||||
|
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t eaudiofx::BlockDecoder::unInit(void) {
|
int32_t eaudiofx::BlockDecoder::unInit(void) {
|
||||||
|
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ def create(target):
|
|||||||
])
|
])
|
||||||
|
|
||||||
# name of the dependency
|
# name of the dependency
|
||||||
myModule.add_module_depend(['ewol', 'rtaudio'])
|
myModule.add_module_depend(['ewol', 'airtaudio'])
|
||||||
|
|
||||||
myModule.add_export_path(tools.get_current_path(__file__))
|
myModule.add_export_path(tools.get_current_path(__file__))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user