Compare commits
41 Commits
Author | SHA1 | Date | |
---|---|---|---|
b114de5f1d | |||
d13298acf9 | |||
a5ca43b7dd | |||
abc2ce6a49 | |||
6a2e12c2ad | |||
7d38eb190d | |||
bc47714cff | |||
6ecf73bb11 | |||
417845abc2 | |||
5acf1ead90 | |||
e80670fd0c | |||
77241b828d | |||
d0bc917536 | |||
4fcde8de4f | |||
d20753518c | |||
2ffe31a3e9 | |||
f91dc09ac1 | |||
2566843a66 | |||
9a37b437c6 | |||
e83ac7620d | |||
434c8097d0 | |||
07a56e29ae | |||
aa5df52e14 | |||
c9bb77e8d6 | |||
ef0bda6405 | |||
e7d5b421c3 | |||
dd2e5240e3 | |||
f1643a1231 | |||
569d59e05a | |||
88c8178a72 | |||
dbd66a0157 | |||
5cab7f39eb | |||
9323412a44 | |||
58ceff9371 | |||
c329af6863 | |||
3ce856c1c6 | |||
0692b6f8bc | |||
f791cb3613 | |||
972bbf60bc | |||
2ed71b8c7a | |||
10820f0c86 |
110
.travis.yml
110
.travis.yml
@@ -1,42 +1,96 @@
|
|||||||
language: cpp
|
language: cpp
|
||||||
|
|
||||||
compiler:
|
sudo: required
|
||||||
- clang
|
dist: trusty
|
||||||
- gcc
|
|
||||||
|
|
||||||
os:
|
branches:
|
||||||
- linux
|
only:
|
||||||
- osx
|
- master
|
||||||
|
- dev
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- g++-4.9
|
||||||
|
- expect
|
||||||
|
- binutils-mingw-w64-x86-64 # 64bit MinGW
|
||||||
|
- gcc-mingw-w64-x86-64
|
||||||
|
- g++-mingw-w64-x86-64
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: linux
|
||||||
|
env: CONF=release BUILDER=gcc TARGET=Linux TAG=Linux COMPILATOR_OPTION="--compilator-version=4.9" GCOV=--gcov
|
||||||
|
compiler: gcc
|
||||||
|
- os: linux
|
||||||
|
env: CONF=debug BUILDER=clang TARGET=Linux
|
||||||
|
compiler: clang
|
||||||
|
- os: linux
|
||||||
|
env: CONF=release BUILDER=gcc TARGET=Windows TAG=Mingw
|
||||||
|
compiler: x86_64-w64-mingw32-gcc
|
||||||
|
- os: linux
|
||||||
|
env: CONF=release BUILDER=gcc TARGET=Android TAG=Android DISABLE_PACKAGE=-p
|
||||||
|
compiler: gcc
|
||||||
|
- os: osx
|
||||||
|
env: CONF=release BUILDER=clang TARGET=MacOs TAG=MacOs
|
||||||
|
compiler: clang
|
||||||
|
- os: osx
|
||||||
|
env: CONF=release BUILDER=clang TARGET=IOs TAG=IOs
|
||||||
|
compiler: clang
|
||||||
|
|
||||||
|
|
||||||
|
install:
|
||||||
|
- cd ..
|
||||||
|
- pip install --user lutin
|
||||||
|
- if [ "$TAG" == "Android" ]; then
|
||||||
|
git clone --depth 1 --branch master https://github.com/HeeroYui/android-download-tool;
|
||||||
|
./android-download-tool/dl-android.sh;
|
||||||
|
fi
|
||||||
|
- git clone --depth 1 --branch master https://github.com/atria-soft/ci.git
|
||||||
|
- cd -
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- cd ..
|
- cd ..
|
||||||
- git clone https://github.com/generic-library/gtest-lutin.git --recurse-submodules
|
- git clone https://github.com/atria-soft/etk.git -b $TRAVIS_BRANCH
|
||||||
- git clone https://github.com/generic-library/speex-dsp-lutin.git --recurse-submodules
|
- git clone https://github.com/atria-soft/elog.git -b $TRAVIS_BRANCH
|
||||||
- git clone https://github.com/generic-library/z-lutin.git --recurse-submodules
|
- git clone https://github.com/atria-soft/ememory.git -b $TRAVIS_BRANCH
|
||||||
- git clone https://github.com/generic-library/portaudio-lutin.git --recurse-submodules
|
- git clone https://github.com/atria-soft/echrono.git -b $TRAVIS_BRANCH
|
||||||
- git clone https://github.com/atria-soft/etk.git
|
- git clone https://github.com/atria-soft/ethread.git -b $TRAVIS_BRANCH
|
||||||
- git clone https://github.com/atria-soft/ejson.git
|
- git clone https://github.com/atria-soft/ejson.git -b $TRAVIS_BRANCH
|
||||||
- git clone https://github.com/musicdsp/audio.git
|
- git clone https://github.com/atria-soft/jvm-basics.git -b $TRAVIS_BRANCH
|
||||||
- git clone https://github.com/musicdsp/audio-algo-drain.git
|
- git clone https://github.com/musicdsp/audio.git -b $TRAVIS_BRANCH
|
||||||
- git clone https://github.com/musicdsp/audio-drain.git
|
- git clone https://github.com/musicdsp/audio-algo-drain.git -b $TRAVIS_BRANCH
|
||||||
- git clone https://github.com/musicdsp/audio-orchestra.git
|
- git clone https://github.com/musicdsp/audio-algo-river.git -b $TRAVIS_BRANCH
|
||||||
|
- git clone https://github.com/musicdsp/audio-algo-speex.git -b $TRAVIS_BRANCH
|
||||||
|
- git clone https://github.com/musicdsp/audio-drain.git -b $TRAVIS_BRANCH
|
||||||
|
- git clone https://github.com/musicdsp/audio-orchestra.git -b $TRAVIS_BRANCH
|
||||||
|
- git clone https://github.com/generic-library/gtest-lutin.git --recursive
|
||||||
|
- git clone https://github.com/generic-library/z-lutin.git --recursive
|
||||||
|
- git clone https://github.com/generic-library/speex-dsp-lutin.git --recursive
|
||||||
- pwd
|
- pwd
|
||||||
- ls -l
|
- ls -l
|
||||||
- if [ "$CXX" == "clang++" ]; then BUILDER=clang; else BUILDER=gcc; fi
|
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||||
|
export PATH=$PATH:/Users/travis/Library/Python/2.7/bin/;
|
||||||
|
fi
|
||||||
|
- ./ci/build_send.py --tag=$TAG --status=START;
|
||||||
|
|
||||||
install:
|
|
||||||
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
|
||||||
- sudo apt-get update -qq
|
|
||||||
- sudo apt-get install -qq g++-4.9
|
|
||||||
- sudo apt-get install -qq libstdc++-4.9-dev
|
|
||||||
- sudo rm /usr/bin/gcc /usr/bin/g++
|
|
||||||
- sudo ln -s /usr/bin/gcc-4.9 /usr/bin/gcc
|
|
||||||
- sudo ln -s /usr/bin/g++-4.9 /usr/bin/g++
|
|
||||||
- sudo pip install lutin
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- lutin -C -P -c$BUILDER -mdebug -p audio-river-test
|
- lutin -w -j4 -C -P -t$TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE audio-river-test*; STATUS=$?
|
||||||
- ./out/Linux_x86_64/debug/staging/$BUILDER/audio-river-test/usr/bin/audio-river-test -l6
|
- ./ci/build_send.py --tag=$TAG --status="$STATUS";
|
||||||
|
|
||||||
|
after_script:
|
||||||
|
- if [ "$GCOV" != "" ]; then
|
||||||
|
./ci/warning_send.py --find-path ./out/Linux_x86_64/$CONF/build/$BUILDER/audio-river/;
|
||||||
|
fi
|
||||||
|
#- lutin -w -j4 -C -P -t$TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE audio-river-test?run:--elog-level=3 | tee out_test.txt
|
||||||
|
#- if [ "$GCOV" != "" ]; then
|
||||||
|
# ./ci/test_send.py --file=out_test.txt;
|
||||||
|
# lutin -C -P -t $TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF -p audio-river?gcov;
|
||||||
|
# ./ci/coverage_send.py --json=out/Linux_x86_64/$CONF/build/$BUILDER/audio-river/audio-river_coverage.json;
|
||||||
|
# fi
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
|
88
README.md
Normal file
88
README.md
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
audio-river
|
||||||
|
=====
|
||||||
|
|
||||||
|
`audio-river` is a High level hardware audio interface that connect to orchestra (multi-platform backend)
|
||||||
|
|
||||||
|
Release (master)
|
||||||
|
----------------
|
||||||
|
|
||||||
|
[](https://travis-ci.org/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
|
||||||
|
Developement (dev)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
[](https://travis-ci.org/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
[](http://musicdsp.com/ci/musicdsp/audio-river)
|
||||||
|
|
||||||
|
|
||||||
|
Instructions
|
||||||
|
============
|
||||||
|
|
||||||
|
download Build system:
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
sudo pip install lutin
|
||||||
|
sudo pip install pillow
|
||||||
|
|
||||||
|
download the software:
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
mkdir WORKING_DIRECTORY
|
||||||
|
cd WORKING_DIRECTORY
|
||||||
|
git clone https://github.com/atria-soft/etk.git
|
||||||
|
git clone https://github.com/atria-soft/elog.git
|
||||||
|
git clone https://github.com/atria-soft/ememory.git
|
||||||
|
git clone https://github.com/atria-soft/ethread.git
|
||||||
|
git clone https://github.com/atria-soft/ejson.git
|
||||||
|
git clone https://github.com/musicdsp/audio.git
|
||||||
|
git clone https://github.com/musicdsp/audio-algo-drain.git
|
||||||
|
git clone https://github.com/musicdsp/audio-algo-river.git
|
||||||
|
git clone https://github.com/musicdsp/audio-algo-speex.git
|
||||||
|
git clone https://github.com/musicdsp/audio-drain.git
|
||||||
|
git clone https://github.com/musicdsp/audio-orchestra.git
|
||||||
|
git clone https://github.com/musicdsp/audio-river.git
|
||||||
|
git clone https://github.com/generic-library/gtest-lutin.git --recursive
|
||||||
|
git clone https://github.com/generic-library/z-lutin.git --recursive
|
||||||
|
git clone https://github.com/generic-library/speex-dsp-lutin.git --recursive
|
||||||
|
|
||||||
|
Compile software:
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
cd WORKING_DIRECTORY
|
||||||
|
lutin -C -P audio-river-test?build?run
|
||||||
|
|
||||||
|
License (APACHE v2.0)
|
||||||
|
=====================
|
||||||
|
Copyright audio-river Edouard DUPIN
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
@@ -4,17 +4,13 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.hpp"
|
||||||
#include "Interface.h"
|
#include "Interface.hpp"
|
||||||
#include "io/Node.h"
|
#include "io/Node.hpp"
|
||||||
#include <audio/drain/EndPointCallback.h>
|
#include <audio/drain/EndPointCallback.hpp>
|
||||||
#include <audio/drain/EndPointWrite.h>
|
#include <audio/drain/EndPointWrite.hpp>
|
||||||
#include <audio/drain/EndPointRead.h>
|
#include <audio/drain/EndPointRead.hpp>
|
||||||
#include <audio/drain/Volume.h>
|
#include <audio/drain/Volume.hpp>
|
||||||
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "Interface"
|
|
||||||
|
|
||||||
audio::river::Interface::Interface(void) :
|
audio::river::Interface::Interface(void) :
|
||||||
m_node(),
|
m_node(),
|
||||||
@@ -27,13 +23,13 @@ audio::river::Interface::Interface(void) :
|
|||||||
bool audio::river::Interface::init(float _freq,
|
bool audio::river::Interface::init(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std11::shared_ptr<audio::river::io::Node>& _node,
|
ememory::SharedPtr<audio::river::io::Node> _node,
|
||||||
const std11::shared_ptr<const ejson::Object>& _config) {
|
const ejson::Object& _config) {
|
||||||
std::vector<audio::channel> map(_map);
|
std::vector<audio::channel> map(_map);
|
||||||
m_node = _node;
|
m_node = _node;
|
||||||
m_config = _config;
|
m_config = _config;
|
||||||
m_mode = audio::river::modeInterface_unknow;
|
m_mode = audio::river::modeInterface_unknow;
|
||||||
std::string type = m_config->getStringValue("io", "error");
|
std::string type = m_config["io"].toString().get("error");
|
||||||
static int32_t uid=0;
|
static int32_t uid=0;
|
||||||
m_name = _node->getName() + "__" + (_node->isInput()==true?"input":"output") + "__" + type + "__" + etk::to_string(uid++);
|
m_name = _node->getName() + "__" + (_node->isInput()==true?"input":"output") + "__" + type + "__" + etk::to_string(uid++);
|
||||||
if (type == "output") {
|
if (type == "output") {
|
||||||
@@ -44,7 +40,7 @@ bool audio::river::Interface::init(float _freq,
|
|||||||
m_mode = audio::river::modeInterface_feedback;
|
m_mode = audio::river::modeInterface_feedback;
|
||||||
}
|
}
|
||||||
// register interface to be notify from the volume change.
|
// register interface to be notify from the volume change.
|
||||||
m_node->registerAsRemote(shared_from_this());
|
m_node->registerAsRemote(sharedFromThis());
|
||||||
|
|
||||||
if (map.size() == 0) {
|
if (map.size() == 0) {
|
||||||
RIVER_INFO("Select auto map system ...");
|
RIVER_INFO("Select auto map system ...");
|
||||||
@@ -57,10 +53,10 @@ bool audio::river::Interface::init(float _freq,
|
|||||||
&& m_mode == audio::river::modeInterface_input) {
|
&& m_mode == audio::river::modeInterface_input) {
|
||||||
m_process.setInputConfig(m_node->getInterfaceFormat());
|
m_process.setInputConfig(m_node->getInterfaceFormat());
|
||||||
// Add volume only if the Low level has a volume (otherwise it will be added by the application)
|
// Add volume only if the Low level has a volume (otherwise it will be added by the application)
|
||||||
std11::shared_ptr<audio::drain::VolumeElement> tmpVolume = m_node->getVolume();
|
ememory::SharedPtr<audio::drain::VolumeElement> tmpVolume = m_node->getVolume();
|
||||||
if (tmpVolume != nullptr) {
|
if (tmpVolume != nullptr) {
|
||||||
// add all time the volume stage :
|
// add all time the volume stage :
|
||||||
std11::shared_ptr<audio::drain::Volume> algo = audio::drain::Volume::create();
|
ememory::SharedPtr<audio::drain::Volume> algo = audio::drain::Volume::create();
|
||||||
//algo->setInputFormat(m_node->getInterfaceFormat());
|
//algo->setInputFormat(m_node->getInterfaceFormat());
|
||||||
algo->setName("volume");
|
algo->setName("volume");
|
||||||
m_process.pushBack(algo);
|
m_process.pushBack(algo);
|
||||||
@@ -72,10 +68,10 @@ bool audio::river::Interface::init(float _freq,
|
|||||||
&& m_mode == audio::river::modeInterface_output) {
|
&& m_mode == audio::river::modeInterface_output) {
|
||||||
m_process.setInputConfig(audio::drain::IOFormatInterface(map, _format, _freq));
|
m_process.setInputConfig(audio::drain::IOFormatInterface(map, _format, _freq));
|
||||||
// Add volume only if the Low level has a volume (otherwise it will be added by the application)
|
// Add volume only if the Low level has a volume (otherwise it will be added by the application)
|
||||||
std11::shared_ptr<audio::drain::VolumeElement> tmpVolume = m_node->getVolume();
|
ememory::SharedPtr<audio::drain::VolumeElement> tmpVolume = m_node->getVolume();
|
||||||
if (tmpVolume != nullptr) {
|
if (tmpVolume != nullptr) {
|
||||||
// add all time the volume stage :
|
// add all time the volume stage :
|
||||||
std11::shared_ptr<audio::drain::Volume> algo = audio::drain::Volume::create();
|
ememory::SharedPtr<audio::drain::Volume> algo = audio::drain::Volume::create();
|
||||||
//algo->setOutputFormat(m_node->getInterfaceFormat());
|
//algo->setOutputFormat(m_node->getInterfaceFormat());
|
||||||
algo->setName("volume");
|
algo->setName("volume");
|
||||||
m_process.pushBack(algo);
|
m_process.pushBack(algo);
|
||||||
@@ -95,20 +91,20 @@ bool audio::river::Interface::init(float _freq,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::Interface> audio::river::Interface::create(float _freq,
|
ememory::SharedPtr<audio::river::Interface> audio::river::Interface::create(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std11::shared_ptr<audio::river::io::Node>& _node,
|
const ememory::SharedPtr<audio::river::io::Node>& _node,
|
||||||
const std11::shared_ptr<const ejson::Object>& _config) {
|
const ejson::Object& _config) {
|
||||||
std11::shared_ptr<audio::river::Interface> out = std11::shared_ptr<audio::river::Interface>(new audio::river::Interface());
|
ememory::SharedPtr<audio::river::Interface> out = ememory::SharedPtr<audio::river::Interface>(new audio::river::Interface());
|
||||||
out->init(_freq, _map, _format, _node, _config);
|
out->init(_freq, _map, _format, _node, _config);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio::river::Interface::~Interface() {
|
audio::river::Interface::~Interface() {
|
||||||
//stop(true, true);
|
//stop(true, true);
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
//m_node->interfaceRemove(shared_from_this());
|
//m_node->interfaceRemove(sharedFromThis());
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
bool audio::river::Interface::hasEndPoint() {
|
bool audio::river::Interface::hasEndPoint() {
|
||||||
@@ -116,7 +112,7 @@ bool audio::river::Interface::hasEndPoint() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void audio::river::Interface::setReadwrite() {
|
void audio::river::Interface::setReadwrite() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_process.removeAlgoDynamic();
|
m_process.removeAlgoDynamic();
|
||||||
if (m_process.hasType<audio::drain::EndPoint>() ) {
|
if (m_process.hasType<audio::drain::EndPoint>() ) {
|
||||||
RIVER_ERROR("Endpoint is already present ==> can not change");
|
RIVER_ERROR("Endpoint is already present ==> can not change");
|
||||||
@@ -124,47 +120,47 @@ void audio::river::Interface::setReadwrite() {
|
|||||||
}
|
}
|
||||||
if (m_node->isInput() == true) {
|
if (m_node->isInput() == true) {
|
||||||
m_process.removeIfLast<audio::drain::EndPoint>();
|
m_process.removeIfLast<audio::drain::EndPoint>();
|
||||||
std11::shared_ptr<audio::drain::EndPointRead> algo = audio::drain::EndPointRead::create();
|
ememory::SharedPtr<audio::drain::EndPointRead> algo = audio::drain::EndPointRead::create();
|
||||||
m_process.pushBack(algo);
|
m_process.pushBack(algo);
|
||||||
} else {
|
} else {
|
||||||
m_process.removeIfFirst<audio::drain::EndPoint>();
|
m_process.removeIfFirst<audio::drain::EndPoint>();
|
||||||
std11::shared_ptr<audio::drain::EndPointWrite> algo = audio::drain::EndPointWrite::create();
|
ememory::SharedPtr<audio::drain::EndPointWrite> algo = audio::drain::EndPointWrite::create();
|
||||||
m_process.pushFront(algo);
|
m_process.pushFront(algo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::setOutputCallback(audio::drain::playbackFunction _function) {
|
void audio::river::Interface::setOutputCallback(audio::drain::playbackFunction _function) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_mode != audio::river::modeInterface_output) {
|
if (m_mode != audio::river::modeInterface_output) {
|
||||||
RIVER_ERROR("Can not set output endpoint on other than a output IO");
|
RIVER_ERROR("Can not set output endpoint on other than a output IO");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_process.removeAlgoDynamic();
|
m_process.removeAlgoDynamic();
|
||||||
m_process.removeIfFirst<audio::drain::EndPoint>();
|
m_process.removeIfFirst<audio::drain::EndPoint>();
|
||||||
std11::shared_ptr<audio::drain::Algo> algo = audio::drain::EndPointCallback::create(_function);
|
ememory::SharedPtr<audio::drain::Algo> algo = audio::drain::EndPointCallback::create(_function);
|
||||||
m_process.pushFront(algo);
|
m_process.pushFront(algo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::setInputCallback(audio::drain::recordFunction _function) {
|
void audio::river::Interface::setInputCallback(audio::drain::recordFunction _function) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_mode == audio::river::modeInterface_output) {
|
if (m_mode == audio::river::modeInterface_output) {
|
||||||
RIVER_ERROR("Can not set output endpoint on other than a input or feedback IO");
|
RIVER_ERROR("Can not set output endpoint on other than a input or feedback IO");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_process.removeAlgoDynamic();
|
m_process.removeAlgoDynamic();
|
||||||
m_process.removeIfLast<audio::drain::EndPoint>();
|
m_process.removeIfLast<audio::drain::EndPoint>();
|
||||||
std11::shared_ptr<audio::drain::Algo> algo = audio::drain::EndPointCallback::create(_function);
|
ememory::SharedPtr<audio::drain::Algo> algo = audio::drain::EndPointCallback::create(_function);
|
||||||
m_process.pushBack(algo);
|
m_process.pushBack(algo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::setWriteCallback(audio::drain::playbackFunctionWrite _function) {
|
void audio::river::Interface::setWriteCallback(audio::drain::playbackFunctionWrite _function) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_mode != audio::river::modeInterface_output) {
|
if (m_mode != audio::river::modeInterface_output) {
|
||||||
RIVER_ERROR("Can not set output endpoint on other than a output IO");
|
RIVER_ERROR("Can not set output endpoint on other than a output IO");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_process.removeAlgoDynamic();
|
m_process.removeAlgoDynamic();
|
||||||
std11::shared_ptr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
ememory::SharedPtr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -172,22 +168,22 @@ void audio::river::Interface::setWriteCallback(audio::drain::playbackFunctionWri
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::start(const audio::Time& _time) {
|
void audio::river::Interface::start(const audio::Time& _time) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
RIVER_DEBUG("start [BEGIN]");
|
RIVER_DEBUG("start [BEGIN]");
|
||||||
m_process.updateInterAlgo();
|
m_process.updateInterAlgo();
|
||||||
m_node->interfaceAdd(shared_from_this());
|
m_node->interfaceAdd(sharedFromThis());
|
||||||
RIVER_DEBUG("start [ END ]");
|
RIVER_DEBUG("start [ END ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::stop(bool _fast, bool _abort) {
|
void audio::river::Interface::stop(bool _fast, bool _abort) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
RIVER_DEBUG("stop [BEGIN]");
|
RIVER_DEBUG("stop [BEGIN]");
|
||||||
m_node->interfaceRemove(shared_from_this());
|
m_node->interfaceRemove(sharedFromThis());
|
||||||
RIVER_DEBUG("stop [ END]");
|
RIVER_DEBUG("stop [ END]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::abort() {
|
void audio::river::Interface::abort() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
RIVER_DEBUG("abort [BEGIN]");
|
RIVER_DEBUG("abort [BEGIN]");
|
||||||
// TODO :...
|
// TODO :...
|
||||||
RIVER_DEBUG("abort [ END ]");
|
RIVER_DEBUG("abort [ END ]");
|
||||||
@@ -201,7 +197,7 @@ bool audio::river::Interface::setParameter(const std::string& _filter, const std
|
|||||||
RIVER_ERROR("Interface is not allowed to modify '" << _parameter << "' Volume just allowed to modify 'FLOW' volume");
|
RIVER_ERROR("Interface is not allowed to modify '" << _parameter << "' Volume just allowed to modify 'FLOW' volume");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::drain::Algo> algo = m_process.get<audio::drain::Algo>(_filter);
|
ememory::SharedPtr<audio::drain::Algo> algo = m_process.get<audio::drain::Algo>(_filter);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
|
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
|
||||||
return false;
|
return false;
|
||||||
@@ -213,7 +209,7 @@ bool audio::river::Interface::setParameter(const std::string& _filter, const std
|
|||||||
std::string audio::river::Interface::getParameter(const std::string& _filter, const std::string& _parameter) const {
|
std::string audio::river::Interface::getParameter(const std::string& _filter, const std::string& _parameter) const {
|
||||||
RIVER_DEBUG("getParameter [BEGIN] : '" << _filter << "':'" << _parameter << "'");
|
RIVER_DEBUG("getParameter [BEGIN] : '" << _filter << "':'" << _parameter << "'");
|
||||||
std::string out;
|
std::string out;
|
||||||
std11::shared_ptr<const audio::drain::Algo> algo = m_process.get<const audio::drain::Algo>(_filter);
|
ememory::SharedPtr<const audio::drain::Algo> algo = m_process.get<const audio::drain::Algo>(_filter);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
|
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
|
||||||
return "[ERROR]";
|
return "[ERROR]";
|
||||||
@@ -225,7 +221,7 @@ std::string audio::river::Interface::getParameter(const std::string& _filter, co
|
|||||||
std::string audio::river::Interface::getParameterProperty(const std::string& _filter, const std::string& _parameter) const {
|
std::string audio::river::Interface::getParameterProperty(const std::string& _filter, const std::string& _parameter) const {
|
||||||
RIVER_DEBUG("getParameterProperty [BEGIN] : '" << _filter << "':'" << _parameter << "'");
|
RIVER_DEBUG("getParameterProperty [BEGIN] : '" << _filter << "':'" << _parameter << "'");
|
||||||
std::string out;
|
std::string out;
|
||||||
std11::shared_ptr<const audio::drain::Algo> algo = m_process.get<const audio::drain::Algo>(_filter);
|
ememory::SharedPtr<const audio::drain::Algo> algo = m_process.get<const audio::drain::Algo>(_filter);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
|
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
|
||||||
return "[ERROR]";
|
return "[ERROR]";
|
||||||
@@ -236,9 +232,9 @@ std::string audio::river::Interface::getParameterProperty(const std::string& _fi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::write(const void* _value, size_t _nbChunk) {
|
void audio::river::Interface::write(const void* _value, size_t _nbChunk) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_process.updateInterAlgo();
|
m_process.updateInterAlgo();
|
||||||
std11::shared_ptr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
ememory::SharedPtr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -256,7 +252,7 @@ std::vector<int16_t> audio::river::Interface::read(size_t _nbChunk) {
|
|||||||
int32_t nbChunkBuffer = m_circularBuffer.size() / m_map.size();
|
int32_t nbChunkBuffer = m_circularBuffer.size() / m_map.size();
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
while (nbChunkBuffer < _nbChunk) {
|
while (nbChunkBuffer < _nbChunk) {
|
||||||
usleep(1000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
nbChunkBuffer = m_circularBuffer.size() / m_map.size();
|
nbChunkBuffer = m_circularBuffer.size() / m_map.size();
|
||||||
}
|
}
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
@@ -271,14 +267,14 @@ std::vector<int16_t> audio::river::Interface::read(size_t _nbChunk) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void audio::river::Interface::read(void* _value, size_t _nbChunk) {
|
void audio::river::Interface::read(void* _value, size_t _nbChunk) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_process.updateInterAlgo();
|
m_process.updateInterAlgo();
|
||||||
// TODO :...
|
// TODO :...
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t audio::river::Interface::size() const {
|
size_t audio::river::Interface::size() const {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
// TODO :...
|
// TODO :...
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -288,9 +284,9 @@ size_t audio::river::Interface::size() const {
|
|||||||
|
|
||||||
|
|
||||||
void audio::river::Interface::setBufferSize(size_t _nbChunk) {
|
void audio::river::Interface::setBufferSize(size_t _nbChunk) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_node->isInput() == true) {
|
if (m_node->isInput() == true) {
|
||||||
std11::shared_ptr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
ememory::SharedPtr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request set buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request set buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return;
|
return;
|
||||||
@@ -298,7 +294,7 @@ void audio::river::Interface::setBufferSize(size_t _nbChunk) {
|
|||||||
algo->setBufferSize(_nbChunk);
|
algo->setBufferSize(_nbChunk);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
ememory::SharedPtr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request set buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request set buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return;
|
return;
|
||||||
@@ -306,10 +302,10 @@ void audio::river::Interface::setBufferSize(size_t _nbChunk) {
|
|||||||
algo->setBufferSize(_nbChunk);
|
algo->setBufferSize(_nbChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::setBufferSize(const std11::chrono::microseconds& _time) {
|
void audio::river::Interface::setBufferSize(const std::chrono::microseconds& _time) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_node->isInput() == true) {
|
if (m_node->isInput() == true) {
|
||||||
std11::shared_ptr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
ememory::SharedPtr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request set buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request set buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return;
|
return;
|
||||||
@@ -317,7 +313,7 @@ void audio::river::Interface::setBufferSize(const std11::chrono::microseconds& _
|
|||||||
algo->setBufferSize(_time);
|
algo->setBufferSize(_time);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
ememory::SharedPtr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request set buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request set buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return;
|
return;
|
||||||
@@ -326,16 +322,16 @@ void audio::river::Interface::setBufferSize(const std11::chrono::microseconds& _
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t audio::river::Interface::getBufferSize() {
|
size_t audio::river::Interface::getBufferSize() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_node->isInput() == true) {
|
if (m_node->isInput() == true) {
|
||||||
std11::shared_ptr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
ememory::SharedPtr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return algo->getBufferSize();
|
return algo->getBufferSize();
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
ememory::SharedPtr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -343,35 +339,35 @@ size_t audio::river::Interface::getBufferSize() {
|
|||||||
return algo->getBufferSize();
|
return algo->getBufferSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::chrono::microseconds audio::river::Interface::getBufferSizeMicrosecond() {
|
std::chrono::microseconds audio::river::Interface::getBufferSizeMicrosecond() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_node->isInput() == true) {
|
if (m_node->isInput() == true) {
|
||||||
std11::shared_ptr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
ememory::SharedPtr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return std11::chrono::microseconds(0);
|
return std::chrono::microseconds(0);
|
||||||
}
|
}
|
||||||
return algo->getBufferSizeMicrosecond();
|
return algo->getBufferSizeMicrosecond();
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
ememory::SharedPtr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return std11::chrono::microseconds(0);
|
return std::chrono::microseconds(0);
|
||||||
}
|
}
|
||||||
return algo->getBufferSizeMicrosecond();
|
return algo->getBufferSizeMicrosecond();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t audio::river::Interface::getBufferFillSize() {
|
size_t audio::river::Interface::getBufferFillSize() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_node->isInput() == true) {
|
if (m_node->isInput() == true) {
|
||||||
std11::shared_ptr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
ememory::SharedPtr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return algo->getBufferFillSize();
|
return algo->getBufferFillSize();
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
ememory::SharedPtr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -380,20 +376,20 @@ size_t audio::river::Interface::getBufferFillSize() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::chrono::microseconds audio::river::Interface::getBufferFillSizeMicrosecond() {
|
std::chrono::microseconds audio::river::Interface::getBufferFillSizeMicrosecond() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_node->isInput() == true) {
|
if (m_node->isInput() == true) {
|
||||||
std11::shared_ptr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
ememory::SharedPtr<audio::drain::EndPointRead> algo = m_process.get<audio::drain::EndPointRead>(m_process.size()-1);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return std11::chrono::microseconds(0);
|
return std::chrono::microseconds(0);
|
||||||
}
|
}
|
||||||
return algo->getBufferFillSizeMicrosecond();
|
return algo->getBufferFillSizeMicrosecond();
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
ememory::SharedPtr<audio::drain::EndPointWrite> algo = m_process.get<audio::drain::EndPointWrite>(0);
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
RIVER_ERROR("Request get buffer size for Interface that is not READ or WRITE mode ...");
|
||||||
return std11::chrono::microseconds(0);
|
return std::chrono::microseconds(0);
|
||||||
}
|
}
|
||||||
return algo->getBufferFillSizeMicrosecond();
|
return algo->getBufferFillSizeMicrosecond();
|
||||||
}
|
}
|
||||||
@@ -401,23 +397,23 @@ std11::chrono::microseconds audio::river::Interface::getBufferFillSizeMicrosecon
|
|||||||
|
|
||||||
|
|
||||||
void audio::river::Interface::clearInternalBuffer() {
|
void audio::river::Interface::clearInternalBuffer() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_process.updateInterAlgo();
|
m_process.updateInterAlgo();
|
||||||
// TODO :...
|
// TODO :...
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
audio::Time audio::river::Interface::getCurrentTime() const {
|
audio::Time audio::river::Interface::getCurrentTime() const {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
// TODO :...
|
// TODO :...
|
||||||
return audio::Time();
|
return audio::Time();
|
||||||
return audio::Time::now();
|
return audio::Time::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::addVolumeGroup(const std::string& _name) {
|
void audio::river::Interface::addVolumeGroup(const std::string& _name) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
RIVER_DEBUG("addVolumeGroup(" << _name << ")");
|
RIVER_DEBUG("addVolumeGroup(" << _name << ")");
|
||||||
std11::shared_ptr<audio::drain::Volume> algo = m_process.get<audio::drain::Volume>("volume");
|
ememory::SharedPtr<audio::drain::Volume> algo = m_process.get<audio::drain::Volume>("volume");
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
m_process.removeAlgoDynamic();
|
m_process.removeAlgoDynamic();
|
||||||
// add all time the volume stage :
|
// add all time the volume stage :
|
||||||
@@ -431,29 +427,29 @@ void audio::river::Interface::addVolumeGroup(const std::string& _name) {
|
|||||||
}
|
}
|
||||||
if (_name == "FLOW") {
|
if (_name == "FLOW") {
|
||||||
// Local volume name
|
// Local volume name
|
||||||
algo->addVolumeStage(std11::make_shared<audio::drain::VolumeElement>(_name));
|
algo->addVolumeStage(ememory::makeShared<audio::drain::VolumeElement>(_name));
|
||||||
} else {
|
} else {
|
||||||
// get manager unique instance:
|
// get manager unique instance:
|
||||||
std11::shared_ptr<audio::river::io::Manager> mng = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> mng = audio::river::io::Manager::getInstance();
|
||||||
algo->addVolumeStage(mng->getVolumeGroup(_name));
|
algo->addVolumeStage(mng->getVolumeGroup(_name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::systemNewInputData(audio::Time _time, const void* _data, size_t _nbChunk) {
|
void audio::river::Interface::systemNewInputData(audio::Time _time, const void* _data, size_t _nbChunk) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lockProcess(m_mutex);
|
std::unique_lock<std::recursive_mutex> lockProcess(m_mutex);
|
||||||
void * tmpData = const_cast<void*>(_data);
|
void * tmpData = const_cast<void*>(_data);
|
||||||
m_process.push(_time, tmpData, _nbChunk);
|
m_process.push(_time, tmpData, _nbChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::systemNeedOutputData(audio::Time _time, void* _data, size_t _nbChunk, size_t _chunkSize) {
|
void audio::river::Interface::systemNeedOutputData(audio::Time _time, void* _data, size_t _nbChunk, size_t _chunkSize) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lockProcess(m_mutex);
|
std::unique_lock<std::recursive_mutex> lockProcess(m_mutex);
|
||||||
//RIVER_INFO("time : " << _time);
|
//RIVER_INFO("time : " << _time);
|
||||||
m_process.pull(_time, _data, _nbChunk, _chunkSize);
|
m_process.pull(_time, _data, _nbChunk, _chunkSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::Interface::systemVolumeChange() {
|
void audio::river::Interface::systemVolumeChange() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lockProcess(m_mutex);
|
std::unique_lock<std::recursive_mutex> lockProcess(m_mutex);
|
||||||
std11::shared_ptr<audio::drain::Volume> algo = m_process.get<audio::drain::Volume>("volume");
|
ememory::SharedPtr<audio::drain::Volume> algo = m_process.get<audio::drain::Volume>("volume");
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -3,25 +3,23 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __AUDIO_RIVER_INTERFACE_H__
|
|
||||||
#define __AUDIO_RIVER_INTERFACE_H__
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <etk/mutex.h>
|
#include <mutex>
|
||||||
#include <etk/chrono.h>
|
#include <chrono>
|
||||||
#include <etk/functional.h>
|
#include <functional>
|
||||||
#include <etk/memory.h>
|
#include <ememory/memory.hpp>
|
||||||
#include <audio/format.h>
|
#include <audio/format.hpp>
|
||||||
#include <audio/channel.h>
|
#include <audio/channel.hpp>
|
||||||
#include <audio/drain/Process.h>
|
#include <audio/drain/Process.hpp>
|
||||||
#include <audio/drain/EndPointCallback.h>
|
#include <audio/drain/EndPointCallback.hpp>
|
||||||
#include <audio/drain/EndPointWrite.h>
|
#include <audio/drain/EndPointWrite.hpp>
|
||||||
#include <ejson/ejson.h>
|
#include <ejson/ejson.hpp>
|
||||||
#include <etk/os/FSNode.h>
|
#include <etk/os/FSNode.hpp>
|
||||||
#include <audio/Time.h>
|
#include <audio/Time.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
@@ -41,7 +39,7 @@ namespace audio {
|
|||||||
* @brief Interface is the basic handle to manage the input output stream
|
* @brief Interface is the basic handle to manage the input output stream
|
||||||
* @note To create this class see @ref audio::river::Manager class
|
* @note To create this class see @ref audio::river::Manager class
|
||||||
*/
|
*/
|
||||||
class Interface : public std11::enable_shared_from_this<Interface> {
|
class Interface : public ememory::EnableSharedFromThis<Interface> {
|
||||||
friend class io::Node;
|
friend class io::Node;
|
||||||
friend class io::NodeAirTAudio;
|
friend class io::NodeAirTAudio;
|
||||||
friend class io::NodeAEC;
|
friend class io::NodeAEC;
|
||||||
@@ -67,8 +65,8 @@ namespace audio {
|
|||||||
bool init(float _freq,
|
bool init(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std11::shared_ptr<audio::river::io::Node>& _node,
|
ememory::SharedPtr<audio::river::io::Node> _node,
|
||||||
const std11::shared_ptr<const ejson::Object>& _config);
|
const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Factory of this interface (called by class audio::river::Manager)
|
* @brief Factory of this interface (called by class audio::river::Manager)
|
||||||
* @param[in] _freq Frequency.
|
* @param[in] _freq Frequency.
|
||||||
@@ -79,19 +77,19 @@ namespace audio {
|
|||||||
* @return nullptr The configuration does not work.
|
* @return nullptr The configuration does not work.
|
||||||
* @return pointer The interface has been corectly created.
|
* @return pointer The interface has been corectly created.
|
||||||
*/
|
*/
|
||||||
static std11::shared_ptr<Interface> create(float _freq,
|
static ememory::SharedPtr<Interface> create(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std11::shared_ptr<audio::river::io::Node>& _node,
|
const ememory::SharedPtr<audio::river::io::Node>& _node,
|
||||||
const std11::shared_ptr<const ejson::Object>& _config);
|
const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~Interface();
|
virtual ~Interface();
|
||||||
protected:
|
protected:
|
||||||
mutable std11::recursive_mutex m_mutex; //!< Local mutex to protect data
|
mutable std::recursive_mutex m_mutex; //!< Local mutex to protect data
|
||||||
std11::shared_ptr<const ejson::Object> m_config; //!< configuration set by the user.
|
ejson::Object m_config; //!< configuration set by the user.
|
||||||
protected:
|
protected:
|
||||||
enum modeInterface m_mode; //!< interface type (input/output/feedback)
|
enum modeInterface m_mode; //!< interface type (input/output/feedback)
|
||||||
public:
|
public:
|
||||||
@@ -118,7 +116,7 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
std11::shared_ptr<audio::river::io::Node> m_node; //!< Hardware interface to/from stream audio flow.
|
ememory::SharedPtr<audio::river::io::Node> m_node; //!< Hardware interface to/from stream audio flow.
|
||||||
protected:
|
protected:
|
||||||
std::string m_name; //!< Name of the interface.
|
std::string m_name; //!< Name of the interface.
|
||||||
public:
|
public:
|
||||||
@@ -247,7 +245,7 @@ namespace audio {
|
|||||||
* @brief Set buffer size size of the buffer with the stored time in µs
|
* @brief Set buffer size size of the buffer with the stored time in µs
|
||||||
* @param[in] _time Time in microsecond of the buffer
|
* @param[in] _time Time in microsecond of the buffer
|
||||||
*/
|
*/
|
||||||
virtual void setBufferSize(const std11::chrono::microseconds& _time);
|
virtual void setBufferSize(const std::chrono::microseconds& _time);
|
||||||
/**
|
/**
|
||||||
* @brief get buffer size in chunk number
|
* @brief get buffer size in chunk number
|
||||||
* @return Number of chunk that can be written in the buffer
|
* @return Number of chunk that can be written in the buffer
|
||||||
@@ -257,7 +255,7 @@ namespace audio {
|
|||||||
* @brief Set buffer size size of the buffer with the stored time in µs
|
* @brief Set buffer size size of the buffer with the stored time in µs
|
||||||
* @return Time in microsecond that can be written in the buffer
|
* @return Time in microsecond that can be written in the buffer
|
||||||
*/
|
*/
|
||||||
virtual std11::chrono::microseconds getBufferSizeMicrosecond();
|
virtual std::chrono::microseconds getBufferSizeMicrosecond();
|
||||||
/**
|
/**
|
||||||
* @brief Get buffer size filled in chunk number
|
* @brief Get buffer size filled in chunk number
|
||||||
* @return Number of chunk in the buffer (that might be read/write)
|
* @return Number of chunk in the buffer (that might be read/write)
|
||||||
@@ -267,7 +265,7 @@ namespace audio {
|
|||||||
* @brief Set buffer size size of the buffer with the stored time in µs
|
* @brief Set buffer size size of the buffer with the stored time in µs
|
||||||
* @return Time in microsecond of the buffer (that might be read/write)
|
* @return Time in microsecond of the buffer (that might be read/write)
|
||||||
*/
|
*/
|
||||||
virtual std11::chrono::microseconds getBufferFillSizeMicrosecond();
|
virtual std::chrono::microseconds getBufferFillSizeMicrosecond();
|
||||||
/**
|
/**
|
||||||
* @brief Remove internal Buffer
|
* @brief Remove internal Buffer
|
||||||
*/
|
*/
|
||||||
@@ -330,6 +328,3 @@ namespace audio {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -4,24 +4,22 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Manager.h"
|
#include "Manager.hpp"
|
||||||
#include "Interface.h"
|
#include "Interface.hpp"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "io/Manager.h"
|
#include "io/Manager.hpp"
|
||||||
#include "io/Node.h"
|
#include "io/Node.hpp"
|
||||||
#include "debug.h"
|
#include "debug.hpp"
|
||||||
#include <ejson/ejson.h>
|
#include <ejson/ejson.hpp>
|
||||||
|
|
||||||
#undef __class__
|
static std::mutex g_mutex;
|
||||||
#define __class__ "Manager"
|
static std::vector<ememory::WeakPtr<audio::river::Manager> > g_listOfAllManager;
|
||||||
static std11::mutex g_mutex;
|
|
||||||
static std::vector<std11::weak_ptr<audio::river::Manager> > g_listOfAllManager;
|
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::Manager> audio::river::Manager::create(const std::string& _applicationUniqueId) {
|
ememory::SharedPtr<audio::river::Manager> audio::river::Manager::create(const std::string& _applicationUniqueId) {
|
||||||
std11::unique_lock<std11::mutex> lock(g_mutex);
|
std::unique_lock<std::mutex> lock(g_mutex);
|
||||||
for (size_t iii=0; iii<g_listOfAllManager.size() ; ++iii) {
|
for (size_t iii=0; iii<g_listOfAllManager.size() ; ++iii) {
|
||||||
std11::shared_ptr<audio::river::Manager> tmp = g_listOfAllManager[iii].lock();
|
ememory::SharedPtr<audio::river::Manager> tmp = g_listOfAllManager[iii].lock();
|
||||||
if (tmp == nullptr) {
|
if (tmp == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -30,7 +28,7 @@ std11::shared_ptr<audio::river::Manager> audio::river::Manager::create(const std
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create a new one:
|
// create a new one:
|
||||||
std11::shared_ptr<audio::river::Manager> out = std11::shared_ptr<audio::river::Manager>(new audio::river::Manager(_applicationUniqueId));
|
ememory::SharedPtr<audio::river::Manager> out = ememory::SharedPtr<audio::river::Manager>(new audio::river::Manager(_applicationUniqueId));
|
||||||
// add it at the list:
|
// add it at the list:
|
||||||
for (size_t iii=0; iii<g_listOfAllManager.size() ; ++iii) {
|
for (size_t iii=0; iii<g_listOfAllManager.size() ; ++iii) {
|
||||||
if (g_listOfAllManager[iii].expired() == true) {
|
if (g_listOfAllManager[iii].expired() == true) {
|
||||||
@@ -55,7 +53,7 @@ audio::river::Manager::~Manager() {
|
|||||||
|
|
||||||
std::vector<std::string> audio::river::Manager::getListStreamInput() {
|
std::vector<std::string> audio::river::Manager::getListStreamInput() {
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
} else {
|
} else {
|
||||||
@@ -66,7 +64,7 @@ std::vector<std::string> audio::river::Manager::getListStreamInput() {
|
|||||||
|
|
||||||
std::vector<std::string> audio::river::Manager::getListStreamOutput() {
|
std::vector<std::string> audio::river::Manager::getListStreamOutput() {
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
} else {
|
} else {
|
||||||
@@ -77,7 +75,7 @@ std::vector<std::string> audio::river::Manager::getListStreamOutput() {
|
|||||||
|
|
||||||
std::vector<std::string> audio::river::Manager::getListStreamVirtual() {
|
std::vector<std::string> audio::river::Manager::getListStreamVirtual() {
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
} else {
|
} else {
|
||||||
@@ -88,7 +86,7 @@ std::vector<std::string> audio::river::Manager::getListStreamVirtual() {
|
|||||||
|
|
||||||
std::vector<std::string> audio::river::Manager::getListStream() {
|
std::vector<std::string> audio::river::Manager::getListStream() {
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
} else {
|
} else {
|
||||||
@@ -98,7 +96,7 @@ std::vector<std::string> audio::river::Manager::getListStream() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool audio::river::Manager::setVolume(const std::string& _volumeName, float _valuedB) {
|
bool audio::river::Manager::setVolume(const std::string& _volumeName, float _valuedB) {
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
return false;
|
return false;
|
||||||
@@ -107,7 +105,7 @@ bool audio::river::Manager::setVolume(const std::string& _volumeName, float _val
|
|||||||
}
|
}
|
||||||
|
|
||||||
float audio::river::Manager::getVolume(const std::string& _volumeName) const {
|
float audio::river::Manager::getVolume(const std::string& _volumeName) const {
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
return false;
|
return false;
|
||||||
@@ -116,7 +114,7 @@ float audio::river::Manager::getVolume(const std::string& _volumeName) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<float,float> audio::river::Manager::getVolumeRange(const std::string& _volumeName) const {
|
std::pair<float,float> audio::river::Manager::getVolumeRange(const std::string& _volumeName) const {
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
return std::make_pair<float,float>(0.0f,0.0f);
|
return std::make_pair<float,float>(0.0f,0.0f);
|
||||||
@@ -124,62 +122,80 @@ std::pair<float,float> audio::river::Manager::getVolumeRange(const std::string&
|
|||||||
return manager->getVolumeRange(_volumeName);
|
return manager->getVolumeRange(_volumeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::Interface> audio::river::Manager::createOutput(float _freq,
|
void audio::river::Manager::setMute(const std::string& _volumeName, bool _mute) {
|
||||||
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
|
if (manager == nullptr) {
|
||||||
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
manager->setMute(_volumeName, _mute);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool audio::river::Manager::getMute(const std::string& _volumeName) const {
|
||||||
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
|
if (manager == nullptr) {
|
||||||
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return manager->getMute(_volumeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
ememory::SharedPtr<audio::river::Interface> audio::river::Manager::createOutput(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::string& _streamName,
|
const std::string& _streamName,
|
||||||
const std::string& _options) {
|
const std::string& _options) {
|
||||||
// get global hardware interface:
|
// get global hardware interface:
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
// get the output or input channel :
|
// get the output or input channel :
|
||||||
std11::shared_ptr<audio::river::io::Node> node = manager->getNode(_streamName);
|
ememory::SharedPtr<audio::river::io::Node> node = manager->getNode(_streamName);
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
RIVER_ERROR("Can not get the Requested stream '" << _streamName << "' ==> not listed in : " << manager->getListStream());
|
RIVER_ERROR("Can not get the Requested stream '" << _streamName << "' ==> not listed in : " << manager->getListStream());
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
if (node->isOutput() != true) {
|
if (node->isOutput() != true) {
|
||||||
RIVER_ERROR("Can not Connect output on other thing than output ... for stream '" << _streamName << "'");;
|
RIVER_ERROR("Can not Connect output on other thing than output ... for stream '" << _streamName << "'");;
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std11::shared_ptr<audio::river::Interface> interface;
|
ememory::SharedPtr<audio::river::Interface> interface;
|
||||||
std11::shared_ptr<ejson::Object> tmpOption = ejson::Object::create(_options);
|
ejson::Object tmpOption = ejson::Object(_options);
|
||||||
tmpOption->addString("io", "output");
|
tmpOption.add("io", ejson::String("output"));
|
||||||
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
||||||
// store it in a list (needed to apply some parameters).
|
// store it in a list (needed to apply some parameters).
|
||||||
m_listOpenInterface.push_back(interface);
|
m_listOpenInterface.push_back(interface);
|
||||||
return interface;
|
return interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::Interface> audio::river::Manager::createInput(float _freq,
|
ememory::SharedPtr<audio::river::Interface> audio::river::Manager::createInput(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::string& _streamName,
|
const std::string& _streamName,
|
||||||
const std::string& _options) {
|
const std::string& _options) {
|
||||||
// get global hardware interface:
|
// get global hardware interface:
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
// get the output or input channel :
|
// get the output or input channel :
|
||||||
std11::shared_ptr<audio::river::io::Node> node = manager->getNode(_streamName);
|
ememory::SharedPtr<audio::river::io::Node> node = manager->getNode(_streamName);
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
RIVER_ERROR("Can not get the Requested stream '" << _streamName << "' ==> not listed in : " << manager->getListStream());
|
RIVER_ERROR("Can not get the Requested stream '" << _streamName << "' ==> not listed in : " << manager->getListStream());
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
if (node->isInput() != true) {
|
if (node->isInput() != true) {
|
||||||
RIVER_ERROR("Can not Connect input on other thing than input ... for stream '" << _streamName << "'");;
|
RIVER_ERROR("Can not Connect input on other thing than input ... for stream '" << _streamName << "'");;
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std11::shared_ptr<audio::river::Interface> interface;
|
ememory::SharedPtr<audio::river::Interface> interface;
|
||||||
std11::shared_ptr<ejson::Object> tmpOption = ejson::Object::create(_options);
|
ejson::Object tmpOption = ejson::Object(_options);
|
||||||
tmpOption->addString("io", "input");
|
tmpOption.add("io", ejson::String("input"));
|
||||||
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
||||||
// store it in a list (needed to apply some parameters).
|
// store it in a list (needed to apply some parameters).
|
||||||
m_listOpenInterface.push_back(interface);
|
m_listOpenInterface.push_back(interface);
|
||||||
@@ -187,31 +203,31 @@ std11::shared_ptr<audio::river::Interface> audio::river::Manager::createInput(fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::Interface> audio::river::Manager::createFeedback(float _freq,
|
ememory::SharedPtr<audio::river::Interface> audio::river::Manager::createFeedback(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::string& _streamName,
|
const std::string& _streamName,
|
||||||
const std::string& _options) {
|
const std::string& _options) {
|
||||||
// get global hardware interface:
|
// get global hardware interface:
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Unable to load harware IO manager ... ");
|
RIVER_ERROR("Unable to load harware IO manager ... ");
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
// get the output or input channel :
|
// get the output or input channel :
|
||||||
std11::shared_ptr<audio::river::io::Node> node = manager->getNode(_streamName);
|
ememory::SharedPtr<audio::river::io::Node> node = manager->getNode(_streamName);
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
RIVER_ERROR("Can not get the Requested stream '" << _streamName << "' ==> not listed in : " << manager->getListStream());
|
RIVER_ERROR("Can not get the Requested stream '" << _streamName << "' ==> not listed in : " << manager->getListStream());
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
if (node->isOutput() != true) {
|
if (node->isOutput() != true) {
|
||||||
RIVER_ERROR("Can not Connect feedback on other thing than output ... for stream '" << _streamName << "'");;
|
RIVER_ERROR("Can not Connect feedback on other thing than output ... for stream '" << _streamName << "'");;
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std11::shared_ptr<audio::river::Interface> interface;
|
ememory::SharedPtr<audio::river::Interface> interface;
|
||||||
std11::shared_ptr<ejson::Object> tmpOption = ejson::Object::create(_options);
|
ejson::Object tmpOption = ejson::Object(_options);
|
||||||
tmpOption->addString("io", "feedback");
|
tmpOption.add("io", ejson::String("feedback"));
|
||||||
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
||||||
// store it in a list (needed to apply some parameters).
|
// store it in a list (needed to apply some parameters).
|
||||||
m_listOpenInterface.push_back(interface);
|
m_listOpenInterface.push_back(interface);
|
||||||
@@ -220,7 +236,7 @@ std11::shared_ptr<audio::river::Interface> audio::river::Manager::createFeedback
|
|||||||
|
|
||||||
void audio::river::Manager::generateDotAll(const std::string& _filename) {
|
void audio::river::Manager::generateDotAll(const std::string& _filename) {
|
||||||
// get global hardware interface:
|
// get global hardware interface:
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
RIVER_ERROR("Can not get the harware manager");
|
RIVER_ERROR("Can not get the harware manager");
|
||||||
return;
|
return;
|
||||||
|
@@ -3,27 +3,25 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __AUDIO_RIVER_MANAGER_H__
|
|
||||||
#define __AUDIO_RIVER_MANAGER_H__
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <etk/memory.h>
|
#include <ememory/memory.hpp>
|
||||||
#include <audio/river/Interface.h>
|
#include <audio/river/Interface.hpp>
|
||||||
#include <audio/format.h>
|
#include <audio/format.hpp>
|
||||||
#include <audio/channel.h>
|
#include <audio/channel.hpp>
|
||||||
#include <ejson/ejson.h>
|
#include <ejson/ejson.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
/**
|
/**
|
||||||
* @brief Audio interface manager : Single interface for every application that want to access on the Audio input/output
|
* @brief Audio interface manager : Single interface for every application that want to access on the Audio input/output
|
||||||
*/
|
*/
|
||||||
class Manager : public std11::enable_shared_from_this<Manager> {
|
class Manager : public ememory::EnableSharedFromThis<Manager> {
|
||||||
private:
|
private:
|
||||||
const std::string& m_applicationUniqueId; //!< name of the application that open the Audio Interface.
|
const std::string& m_applicationUniqueId; //!< name of the application that open the Audio Interface.
|
||||||
std::vector<std11::weak_ptr<audio::river::Interface> > m_listOpenInterface; //!< List of all open Stream.
|
std::vector<ememory::WeakPtr<audio::river::Interface> > m_listOpenInterface; //!< List of all open Stream.
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@@ -35,7 +33,7 @@ namespace audio {
|
|||||||
* @param[in] _applicationUniqueId Unique name of the application
|
* @param[in] _applicationUniqueId Unique name of the application
|
||||||
* @return Pointer on the manager or nullptr if an error occured
|
* @return Pointer on the manager or nullptr if an error occured
|
||||||
*/
|
*/
|
||||||
static std11::shared_ptr<audio::river::Manager> create(const std::string& _applicationUniqueId);
|
static ememory::SharedPtr<audio::river::Manager> create(const std::string& _applicationUniqueId);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@@ -78,6 +76,7 @@ namespace audio {
|
|||||||
* @example ret = getVolume("MASTER"); can return something like ret = -3.0f
|
* @example ret = getVolume("MASTER"); can return something like ret = -3.0f
|
||||||
*/
|
*/
|
||||||
virtual float getVolume(const std::string& _volumeName) const;
|
virtual float getVolume(const std::string& _volumeName) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a parameter value
|
* @brief Get a parameter value
|
||||||
* @param[in] _volumeName Name of the volume (MASTER, MATER_BT ...)
|
* @param[in] _volumeName Name of the volume (MASTER, MATER_BT ...)
|
||||||
@@ -85,6 +84,18 @@ namespace audio {
|
|||||||
* @example ret = getVolumeRange("MASTER"); can return something like ret=(-120.0f,0.0f)
|
* @example ret = getVolumeRange("MASTER"); can return something like ret=(-120.0f,0.0f)
|
||||||
*/
|
*/
|
||||||
virtual std::pair<float,float> getVolumeRange(const std::string& _volumeName) const;
|
virtual std::pair<float,float> getVolumeRange(const std::string& _volumeName) const;
|
||||||
|
/**
|
||||||
|
* @brief Set a Mute for a specific volume group
|
||||||
|
* @param[in] _volumeName Name of the volume (MASTER, MATER_BT ...)
|
||||||
|
* @param[in] _mute Mute enable or disable.
|
||||||
|
*/
|
||||||
|
virtual void setMute(const std::string& _volumeName, bool _mute);
|
||||||
|
/**
|
||||||
|
* @brief Get a volume value
|
||||||
|
* @param[in] _volumeName Name of the volume (MASTER, MATER_BT ...)
|
||||||
|
* @return The Mute of the volume volume.
|
||||||
|
*/
|
||||||
|
virtual bool getMute(const std::string& _volumeName) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create output Interface
|
* @brief Create output Interface
|
||||||
@@ -95,7 +106,7 @@ namespace audio {
|
|||||||
* @param[in] _options Json option to configure default resampling and many other things.
|
* @param[in] _options Json option to configure default resampling and many other things.
|
||||||
* @return a pointer on the interface
|
* @return a pointer on the interface
|
||||||
*/
|
*/
|
||||||
virtual std11::shared_ptr<Interface> createOutput(float _freq = 48000,
|
virtual ememory::SharedPtr<Interface> createOutput(float _freq = 48000,
|
||||||
const std::vector<audio::channel>& _map = std::vector<audio::channel>(),
|
const std::vector<audio::channel>& _map = std::vector<audio::channel>(),
|
||||||
audio::format _format = audio::format_int16,
|
audio::format _format = audio::format_int16,
|
||||||
const std::string& _streamName = "",
|
const std::string& _streamName = "",
|
||||||
@@ -109,7 +120,7 @@ namespace audio {
|
|||||||
* @param[in] _options Json option to configure default resampling and many other things.
|
* @param[in] _options Json option to configure default resampling and many other things.
|
||||||
* @return a pointer on the interface
|
* @return a pointer on the interface
|
||||||
*/
|
*/
|
||||||
virtual std11::shared_ptr<Interface> createInput(float _freq = 48000,
|
virtual ememory::SharedPtr<Interface> createInput(float _freq = 48000,
|
||||||
const std::vector<audio::channel>& _map = std::vector<audio::channel>(),
|
const std::vector<audio::channel>& _map = std::vector<audio::channel>(),
|
||||||
audio::format _format = audio::format_int16,
|
audio::format _format = audio::format_int16,
|
||||||
const std::string& _streamName = "",
|
const std::string& _streamName = "",
|
||||||
@@ -123,7 +134,7 @@ namespace audio {
|
|||||||
* @param[in] _options Json option to configure default resampling and many other things.
|
* @param[in] _options Json option to configure default resampling and many other things.
|
||||||
* @return a pointer on the interface
|
* @return a pointer on the interface
|
||||||
*/
|
*/
|
||||||
virtual std11::shared_ptr<Interface> createFeedback(float _freq = 48000,
|
virtual ememory::SharedPtr<Interface> createFeedback(float _freq = 48000,
|
||||||
const std::vector<audio::channel>& _map = std::vector<audio::channel>(),
|
const std::vector<audio::channel>& _map = std::vector<audio::channel>(),
|
||||||
audio::format _format = audio::format_int16,
|
audio::format _format = audio::format_int16,
|
||||||
const std::string& _streamName = "",
|
const std::string& _streamName = "",
|
||||||
@@ -137,4 +148,3 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
@@ -4,10 +4,10 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <audio/river/debug.h>
|
#include <audio/river/debug.hpp>
|
||||||
|
|
||||||
|
|
||||||
int32_t audio::river::getLogId() {
|
int32_t audio::river::getLogId() {
|
||||||
static int32_t g_val = etk::log::registerInstance("river");
|
static int32_t g_val = elog::registerInstance("river");
|
||||||
return g_val;
|
return g_val;
|
||||||
}
|
}
|
||||||
|
@@ -3,20 +3,18 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <elog/log.hpp>
|
||||||
#ifndef __AUDIO_RIVER_DEBUG_H__
|
|
||||||
#define __AUDIO_RIVER_DEBUG_H__
|
|
||||||
|
|
||||||
#include <etk/log.h>
|
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
int32_t getLogId();
|
int32_t getLogId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define RIVER_BASE(info,data) TK_LOG_BASE(audio::river::getLogId(),info,data)
|
#define RIVER_BASE(info,data) ELOG_BASE(audio::river::getLogId(),info,data)
|
||||||
|
|
||||||
|
#define RIVER_PRINT(data) RIVER_BASE(-1, data)
|
||||||
#define RIVER_CRITICAL(data) RIVER_BASE(1, data)
|
#define RIVER_CRITICAL(data) RIVER_BASE(1, data)
|
||||||
#define RIVER_ERROR(data) RIVER_BASE(2, data)
|
#define RIVER_ERROR(data) RIVER_BASE(2, data)
|
||||||
#define RIVER_WARNING(data) RIVER_BASE(3, data)
|
#define RIVER_WARNING(data) RIVER_BASE(3, data)
|
||||||
@@ -60,6 +58,3 @@ namespace audio {
|
|||||||
} \
|
} \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -3,9 +3,7 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifdef __AUDIO_RIVER_DEBUG_H__
|
|
||||||
#undef __AUDIO_RIVER_DEBUG_H__
|
|
||||||
|
|
||||||
#undef RIVER_BASE
|
#undef RIVER_BASE
|
||||||
#undef RIVER_CRITICAL
|
#undef RIVER_CRITICAL
|
||||||
@@ -17,5 +15,3 @@
|
|||||||
#undef RIVER_TODO
|
#undef RIVER_TODO
|
||||||
#undef RIVER_ASSERT
|
#undef RIVER_ASSERT
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -4,42 +4,39 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <audio/river/io/Group.h>
|
#include <audio/river/io/Group.hpp>
|
||||||
#include <audio/river/debug.h>
|
#include <audio/river/debug.hpp>
|
||||||
#include "Node.h"
|
#include "Node.hpp"
|
||||||
#include "NodeAEC.h"
|
#include "NodeAEC.hpp"
|
||||||
#include "NodeOrchestra.h"
|
#include "NodeOrchestra.hpp"
|
||||||
#include "NodePortAudio.h"
|
#include "NodePortAudio.hpp"
|
||||||
#include "Node.h"
|
#include "Node.hpp"
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "io::Group"
|
|
||||||
|
|
||||||
void audio::river::io::Group::createFrom(const ejson::Document& _obj, const std::string& _name) {
|
void audio::river::io::Group::createFrom(const ejson::Document& _obj, const std::string& _name) {
|
||||||
RIVER_INFO("Create Group[" << _name << "] (START) ___________________________");
|
RIVER_INFO("Create Group[" << _name << "] (START) ___________________________");
|
||||||
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
||||||
const std11::shared_ptr<const ejson::Object> tmpObject = _obj.getObject(_obj.getKey(iii));
|
const ejson::Object tmpObject = _obj[iii].toObject();
|
||||||
if (tmpObject == nullptr) {
|
if (tmpObject.exist() == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::string groupName = tmpObject->getStringValue("group", "");
|
std::string groupName = tmpObject["group"].toString().get();
|
||||||
if (groupName == _name) {
|
if (groupName == _name) {
|
||||||
RIVER_INFO("Add element in Group[" << _name << "]: " << _obj.getKey(iii));
|
RIVER_INFO("Add element in Group[" << _name << "]: " << _obj.getKey(iii));
|
||||||
// get type : io
|
// get type : io
|
||||||
std::string ioType = tmpObject->getStringValue("io", "error");
|
std::string ioType = tmpObject["io"].toString().get("error");
|
||||||
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
||||||
if ( ioType == "input"
|
if ( ioType == "input"
|
||||||
|| ioType == "output") {
|
|| ioType == "output") {
|
||||||
std11::shared_ptr<audio::river::io::Node> tmp = audio::river::io::NodeOrchestra::create(_obj.getKey(iii), tmpObject);
|
ememory::SharedPtr<audio::river::io::Node> tmp = audio::river::io::NodeOrchestra::create(_obj.getKey(iii), tmpObject);
|
||||||
tmp->setGroup(shared_from_this());
|
tmp->setGroup(sharedFromThis());
|
||||||
m_list.push_back(tmp);
|
m_list.push_back(tmp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
||||||
if ( ioType == "PAinput"
|
if ( ioType == "PAinput"
|
||||||
|| ioType == "PAoutput") {
|
|| ioType == "PAoutput") {
|
||||||
std11::shared_ptr<audio::river::io::Node> tmp = audio::river::io::NodePortAudio::create(_obj.getKey(iii), tmpObject);
|
ememory::SharedPtr<audio::river::io::Node> tmp = audio::river::io::NodePortAudio::create(_obj.getKey(iii), tmpObject);
|
||||||
tmp->setGroup(shared_from_this());
|
tmp->setGroup(sharedFromThis());
|
||||||
m_list.push_back(tmp);
|
m_list.push_back(tmp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -49,10 +46,10 @@ void audio::river::io::Group::createFrom(const ejson::Document& _obj, const std:
|
|||||||
// Note : The interlink work only for alsa (NOW) and with AirTAudio...
|
// Note : The interlink work only for alsa (NOW) and with AirTAudio...
|
||||||
if(m_list.size() > 1) {
|
if(m_list.size() > 1) {
|
||||||
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
||||||
std11::shared_ptr<audio::river::io::NodeOrchestra> linkRef = std11::dynamic_pointer_cast<audio::river::io::NodeOrchestra>(m_list[0]);
|
ememory::SharedPtr<audio::river::io::NodeOrchestra> linkRef = ememory::dynamicPointerCast<audio::river::io::NodeOrchestra>(m_list[0]);
|
||||||
for (size_t iii=1; iii<m_list.size(); ++iii) {
|
for (size_t iii=1; iii<m_list.size(); ++iii) {
|
||||||
if (m_list[iii] != nullptr) {
|
if (m_list[iii] != nullptr) {
|
||||||
std11::shared_ptr<audio::river::io::NodeOrchestra> link = std11::dynamic_pointer_cast<audio::river::io::NodeOrchestra>(m_list[iii]);
|
ememory::SharedPtr<audio::river::io::NodeOrchestra> link = ememory::dynamicPointerCast<audio::river::io::NodeOrchestra>(m_list[iii]);
|
||||||
linkRef->m_interface.isMasterOf(link->m_interface);
|
linkRef->m_interface.isMasterOf(link->m_interface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,7 +59,7 @@ void audio::river::io::Group::createFrom(const ejson::Document& _obj, const std:
|
|||||||
// manage Link Between Nodes :
|
// manage Link Between Nodes :
|
||||||
if (m_link != nullptr) {
|
if (m_link != nullptr) {
|
||||||
RIVER_INFO("******** START LINK ************");
|
RIVER_INFO("******** START LINK ************");
|
||||||
std11::shared_ptr<audio::river::io::NodeOrchestra> link = std11::dynamic_pointer_cast<audio::river::io::NodeOrchestra>(m_link);
|
ememory::SharedPtr<audio::river::io::NodeOrchestra> link = ememory::dynamicPointerCast<audio::river::io::NodeOrchestra>(m_link);
|
||||||
if (link == nullptr) {
|
if (link == nullptr) {
|
||||||
RIVER_ERROR("Can not link 2 Interface with not the same type (reserved for HW interface)");
|
RIVER_ERROR("Can not link 2 Interface with not the same type (reserved for HW interface)");
|
||||||
return;
|
return;
|
||||||
@@ -82,7 +79,7 @@ void audio::river::io::Group::createFrom(const ejson::Document& _obj, const std:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::io::Node> audio::river::io::Group::getNode(const std::string& _name) {
|
ememory::SharedPtr<audio::river::io::Node> audio::river::io::Group::getNode(const std::string& _name) {
|
||||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||||
if (m_list[iii] != nullptr) {
|
if (m_list[iii] != nullptr) {
|
||||||
if (m_list[iii]->getName() == _name) {
|
if (m_list[iii]->getName() == _name) {
|
||||||
@@ -90,7 +87,7 @@ std11::shared_ptr<audio::river::io::Node> audio::river::io::Group::getNode(const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std11::shared_ptr<audio::river::io::Node>();
|
return ememory::SharedPtr<audio::river::io::Node>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::Group::start() {
|
void audio::river::io::Group::start() {
|
||||||
|
@@ -4,13 +4,12 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __AUDIO_RIVER_IO_GROUP_H__
|
#pragma once
|
||||||
#define __AUDIO_RIVER_IO_GROUP_H__
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <ejson/ejson.h>
|
#include <ejson/ejson.hpp>
|
||||||
#include <etk/os/FSNode.h>
|
#include <etk/os/FSNode.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
@@ -24,7 +23,7 @@ namespace audio {
|
|||||||
* is stopped.
|
* is stopped.
|
||||||
* @note For the Alsa interface a low level link is availlable with AirTAudio for Alsa (One thread)
|
* @note For the Alsa interface a low level link is availlable with AirTAudio for Alsa (One thread)
|
||||||
*/
|
*/
|
||||||
class Group : public std11::enable_shared_from_this<Group> {
|
class Group : public ememory::EnableSharedFromThis<Group> {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Contructor. No special thing to do.
|
* @brief Contructor. No special thing to do.
|
||||||
@@ -37,7 +36,7 @@ namespace audio {
|
|||||||
// TODO : ...
|
// TODO : ...
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::vector< std11::shared_ptr<Node> > m_list; //!< List of all node in the group
|
std::vector< ememory::SharedPtr<Node> > m_list; //!< List of all node in the group
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Create a group with all node needed to syncronize together
|
* @brief Create a group with all node needed to syncronize together
|
||||||
@@ -51,7 +50,7 @@ namespace audio {
|
|||||||
* @return nullptr The node named _name was not found.
|
* @return nullptr The node named _name was not found.
|
||||||
* @return pointer The node was find in this group.
|
* @return pointer The node was find in this group.
|
||||||
*/
|
*/
|
||||||
std11::shared_ptr<audio::river::io::Node> getNode(const std::string& _name);
|
ememory::SharedPtr<audio::river::io::Node> getNode(const std::string& _name);
|
||||||
/**
|
/**
|
||||||
* @brief Start the group.
|
* @brief Start the group.
|
||||||
* @note all sub-node will be started.
|
* @note all sub-node will be started.
|
||||||
@@ -74,5 +73,3 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -4,24 +4,21 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <audio/river/io/Manager.h>
|
#include <audio/river/io/Manager.hpp>
|
||||||
#include <audio/river/debug.h>
|
#include <audio/river/debug.hpp>
|
||||||
#include <audio/river/river.h>
|
#include <audio/river/river.hpp>
|
||||||
#include <audio/river/io/Node.h>
|
#include <audio/river/io/Node.hpp>
|
||||||
#include <audio/river/io/NodeAEC.h>
|
#include <audio/river/io/NodeAEC.hpp>
|
||||||
#include <audio/river/io/NodeMuxer.h>
|
#include <audio/river/io/NodeMuxer.hpp>
|
||||||
#include <audio/river/io/NodeOrchestra.h>
|
#include <audio/river/io/NodeOrchestra.hpp>
|
||||||
#include <audio/river/io/NodePortAudio.h>
|
#include <audio/river/io/NodePortAudio.hpp>
|
||||||
#include <etk/os/FSNode.h>
|
#include <etk/os/FSNode.hpp>
|
||||||
#include <etk/memory.h>
|
#include <ememory/memory.hpp>
|
||||||
#include <etk/types.h>
|
#include <etk/types.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "io::Manager"
|
|
||||||
|
|
||||||
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
||||||
#include <portaudio.h>
|
#include <portaudio/portaudio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static std::string basicAutoConfig =
|
static std::string basicAutoConfig =
|
||||||
@@ -37,7 +34,8 @@ static std::string basicAutoConfig =
|
|||||||
" 'front-left', 'front-right'\n"
|
" 'front-left', 'front-right'\n"
|
||||||
" ],\n"
|
" ],\n"
|
||||||
" type:'auto',\n"
|
" type:'auto',\n"
|
||||||
" nb-chunk:1024\n"
|
" nb-chunk:1024,\n"
|
||||||
|
" mux-demux-type:'float'\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" speaker:{\n"
|
" speaker:{\n"
|
||||||
" io:'output',\n"
|
" io:'output',\n"
|
||||||
@@ -51,7 +49,8 @@ static std::string basicAutoConfig =
|
|||||||
" ],\n"
|
" ],\n"
|
||||||
" type:'auto',\n"
|
" type:'auto',\n"
|
||||||
" nb-chunk:1024,\n"
|
" nb-chunk:1024,\n"
|
||||||
" volume-name:'MASTER'\n"
|
" volume-name:'MASTER',\n"
|
||||||
|
" mux-demux-type:'float'\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
@@ -67,7 +66,7 @@ audio::river::io::Manager::Manager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::Manager::init(const std::string& _filename) {
|
void audio::river::io::Manager::init(const std::string& _filename) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (_filename == "") {
|
if (_filename == "") {
|
||||||
RIVER_INFO("Load default config");
|
RIVER_INFO("Load default config");
|
||||||
m_config.parse(basicAutoConfig);
|
m_config.parse(basicAutoConfig);
|
||||||
@@ -77,12 +76,12 @@ void audio::river::io::Manager::init(const std::string& _filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::Manager::initString(const std::string& _data) {
|
void audio::river::io::Manager::initString(const std::string& _data) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_config.parse(_data);
|
m_config.parse(_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::Manager::unInit() {
|
void audio::river::io::Manager::unInit() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
// TODO : ...
|
// TODO : ...
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,26 +94,26 @@ audio::river::io::Manager::~Manager() {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::io::Manager> audio::river::io::Manager::getInstance() {
|
ememory::SharedPtr<audio::river::io::Manager> audio::river::io::Manager::getInstance() {
|
||||||
if (audio::river::isInit() == false) {
|
if (audio::river::isInit() == false) {
|
||||||
return std11::shared_ptr<audio::river::io::Manager>();
|
return ememory::SharedPtr<audio::river::io::Manager>();
|
||||||
}
|
}
|
||||||
static std11::shared_ptr<audio::river::io::Manager> manager(new Manager());
|
static ememory::SharedPtr<audio::river::io::Manager> manager(new Manager());
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> audio::river::io::Manager::getListStreamInput() {
|
std::vector<std::string> audio::river::io::Manager::getListStreamInput() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std::vector<std::string> keys = m_config.getKeys();
|
std::vector<std::string> keys = m_config.getKeys();
|
||||||
for (size_t iii=0; iii<keys.size(); ++iii) {
|
for (auto &it : keys) {
|
||||||
const std11::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
|
const ejson::Object tmppp = m_config[it].toObject();
|
||||||
if (tmppp != nullptr) {
|
if (tmppp.exist() == true) {
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp["io"].toString().get("error");
|
||||||
if ( type == "input"
|
if ( type == "input"
|
||||||
|| type == "PAinput") {
|
|| type == "PAinput") {
|
||||||
output.push_back(keys[iii]);
|
output.push_back(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,16 +121,16 @@ std::vector<std::string> audio::river::io::Manager::getListStreamInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> audio::river::io::Manager::getListStreamOutput() {
|
std::vector<std::string> audio::river::io::Manager::getListStreamOutput() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std::vector<std::string> keys = m_config.getKeys();
|
std::vector<std::string> keys = m_config.getKeys();
|
||||||
for (size_t iii=0; iii<keys.size(); ++iii) {
|
for (auto &it : keys) {
|
||||||
const std11::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
|
const ejson::Object tmppp = m_config[it].toObject();
|
||||||
if (tmppp != nullptr) {
|
if (tmppp.exist() == true) {
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp["io"].toString().get("error");
|
||||||
if ( type == "output"
|
if ( type == "output"
|
||||||
|| type == "PAoutput") {
|
|| type == "PAoutput") {
|
||||||
output.push_back(keys[iii]);
|
output.push_back(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,19 +138,19 @@ std::vector<std::string> audio::river::io::Manager::getListStreamOutput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> audio::river::io::Manager::getListStreamVirtual() {
|
std::vector<std::string> audio::river::io::Manager::getListStreamVirtual() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std::vector<std::string> keys = m_config.getKeys();
|
std::vector<std::string> keys = m_config.getKeys();
|
||||||
for (size_t iii=0; iii<keys.size(); ++iii) {
|
for (auto &it : keys) {
|
||||||
const std11::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
|
const ejson::Object tmppp = m_config[it].toObject();
|
||||||
if (tmppp != nullptr) {
|
if (tmppp.exist() == true) {
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp["io"].toString().get("error");
|
||||||
if ( type != "input"
|
if ( type != "input"
|
||||||
&& type != "PAinput"
|
&& type != "PAinput"
|
||||||
&& type != "output"
|
&& type != "output"
|
||||||
&& type != "PAoutput"
|
&& type != "PAoutput"
|
||||||
&& type != "error") {
|
&& type != "error") {
|
||||||
output.push_back(keys[iii]);
|
output.push_back(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,27 +158,27 @@ std::vector<std::string> audio::river::io::Manager::getListStreamVirtual() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> audio::river::io::Manager::getListStream() {
|
std::vector<std::string> audio::river::io::Manager::getListStream() {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std::vector<std::string> keys = m_config.getKeys();
|
std::vector<std::string> keys = m_config.getKeys();
|
||||||
for (size_t iii=0; iii<keys.size(); ++iii) {
|
for (auto &it : keys) {
|
||||||
const std11::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
|
const ejson::Object tmppp = m_config[it].toObject();
|
||||||
if (tmppp != nullptr) {
|
if (tmppp.exist() == true) {
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp["io"].toString().get("error");
|
||||||
if (type != "error") {
|
if (type != "error") {
|
||||||
output.push_back(keys[iii]);
|
output.push_back(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::io::Node> audio::river::io::Manager::getNode(const std::string& _name) {
|
ememory::SharedPtr<audio::river::io::Node> audio::river::io::Manager::getNode(const std::string& _name) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
RIVER_WARNING("Get node : " << _name);
|
RIVER_WARNING("Get node : " << _name);
|
||||||
// search in the standalone list :
|
// search in the standalone list :
|
||||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||||
std11::shared_ptr<audio::river::io::Node> tmppp = m_list[iii].lock();
|
ememory::SharedPtr<audio::river::io::Node> tmppp = m_list[iii].lock();
|
||||||
if ( tmppp != nullptr
|
if ( tmppp != nullptr
|
||||||
&& _name == tmppp->getName()) {
|
&& _name == tmppp->getName()) {
|
||||||
RIVER_WARNING(" find it ... in standalone");
|
RIVER_WARNING(" find it ... in standalone");
|
||||||
@@ -188,11 +187,11 @@ std11::shared_ptr<audio::river::io::Node> audio::river::io::Manager::getNode(con
|
|||||||
}
|
}
|
||||||
// search in the group list:
|
// search in the group list:
|
||||||
{
|
{
|
||||||
for (std::map<std::string, std11::shared_ptr<audio::river::io::Group> >::iterator it(m_listGroup.begin());
|
for (std::map<std::string, ememory::SharedPtr<audio::river::io::Group> >::iterator it(m_listGroup.begin());
|
||||||
it != m_listGroup.end();
|
it != m_listGroup.end();
|
||||||
++it) {
|
++it) {
|
||||||
if (it->second != nullptr) {
|
if (it->second != nullptr) {
|
||||||
std11::shared_ptr<audio::river::io::Node> node = it->second->getNode(_name);
|
ememory::SharedPtr<audio::river::io::Node> node = it->second->getNode(_name);
|
||||||
if (node != nullptr) {
|
if (node != nullptr) {
|
||||||
RIVER_WARNING(" find it ... in group: " << it->first);
|
RIVER_WARNING(" find it ... in group: " << it->first);
|
||||||
return node;
|
return node;
|
||||||
@@ -202,21 +201,21 @@ std11::shared_ptr<audio::river::io::Node> audio::river::io::Manager::getNode(con
|
|||||||
}
|
}
|
||||||
RIVER_WARNING("Try create a new one : " << _name);
|
RIVER_WARNING("Try create a new one : " << _name);
|
||||||
// check if the node can be open :
|
// check if the node can be open :
|
||||||
const std11::shared_ptr<const ejson::Object> tmpObject = m_config.getObject(_name);
|
const ejson::Object tmpObject = m_config[_name].toObject();
|
||||||
if (tmpObject != nullptr) {
|
if (tmpObject.exist() == true) {
|
||||||
//Check if it is in a group:
|
//Check if it is in a group:
|
||||||
std::string groupName = tmpObject->getStringValue("group", "");
|
std::string groupName = tmpObject["group"].toString().get();
|
||||||
// get type : io
|
// get type : io
|
||||||
std::string ioType = tmpObject->getStringValue("io", "error");
|
std::string ioType = tmpObject["io"].toString().get("error");
|
||||||
if ( groupName != ""
|
if ( groupName != ""
|
||||||
&& ( ioType == "input"
|
&& ( ioType == "input"
|
||||||
|| ioType == "output"
|
|| ioType == "output"
|
||||||
|| ioType == "PAinput"
|
|| ioType == "PAinput"
|
||||||
|| ioType == "PAoutput") ) {
|
|| ioType == "PAoutput") ) {
|
||||||
std11::shared_ptr<audio::river::io::Group> tmpGroup = getGroup(groupName);
|
ememory::SharedPtr<audio::river::io::Group> tmpGroup = getGroup(groupName);
|
||||||
if (tmpGroup == nullptr) {
|
if (tmpGroup == nullptr) {
|
||||||
RIVER_WARNING("Can not get group ... '" << groupName << "'");
|
RIVER_WARNING("Can not get group ... '" << groupName << "'");
|
||||||
return std11::shared_ptr<audio::river::io::Node>();
|
return ememory::SharedPtr<audio::river::io::Node>();
|
||||||
}
|
}
|
||||||
return tmpGroup->getNode(_name);
|
return tmpGroup->getNode(_name);
|
||||||
} else {
|
} else {
|
||||||
@@ -228,7 +227,7 @@ std11::shared_ptr<audio::river::io::Node> audio::river::io::Manager::getNode(con
|
|||||||
if ( ioType == "input"
|
if ( ioType == "input"
|
||||||
|| ioType == "output") {
|
|| ioType == "output") {
|
||||||
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
||||||
std11::shared_ptr<audio::river::io::Node> tmp = audio::river::io::NodeOrchestra::create(_name, tmpObject);
|
ememory::SharedPtr<audio::river::io::Node> tmp = audio::river::io::NodeOrchestra::create(_name, tmpObject);
|
||||||
m_list.push_back(tmp);
|
m_list.push_back(tmp);
|
||||||
return tmp;
|
return tmp;
|
||||||
#else
|
#else
|
||||||
@@ -238,7 +237,7 @@ std11::shared_ptr<audio::river::io::Node> audio::river::io::Manager::getNode(con
|
|||||||
if ( ioType == "PAinput"
|
if ( ioType == "PAinput"
|
||||||
|| ioType == "PAoutput") {
|
|| ioType == "PAoutput") {
|
||||||
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
||||||
std11::shared_ptr<audio::river::io::Node> tmp = audio::river::io::NodePortAudio::create(_name, tmpObject);
|
ememory::SharedPtr<audio::river::io::Node> tmp = audio::river::io::NodePortAudio::create(_name, tmpObject);
|
||||||
m_list.push_back(tmp);
|
m_list.push_back(tmp);
|
||||||
return tmp;
|
return tmp;
|
||||||
#else
|
#else
|
||||||
@@ -246,26 +245,26 @@ std11::shared_ptr<audio::river::io::Node> audio::river::io::Manager::getNode(con
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (ioType == "aec") {
|
if (ioType == "aec") {
|
||||||
std11::shared_ptr<audio::river::io::Node> tmp = audio::river::io::NodeAEC::create(_name, tmpObject);
|
ememory::SharedPtr<audio::river::io::Node> tmp = audio::river::io::NodeAEC::create(_name, tmpObject);
|
||||||
m_list.push_back(tmp);
|
m_list.push_back(tmp);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
if (ioType == "muxer") {
|
if (ioType == "muxer") {
|
||||||
std11::shared_ptr<audio::river::io::Node> tmp = audio::river::io::NodeMuxer::create(_name, tmpObject);
|
ememory::SharedPtr<audio::river::io::Node> tmp = audio::river::io::NodeMuxer::create(_name, tmpObject);
|
||||||
m_list.push_back(tmp);
|
m_list.push_back(tmp);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RIVER_ERROR("Can not create the interface : '" << _name << "' the node is not DEFINED in the configuration file availlable : " << m_config.getKeys());
|
RIVER_ERROR("Can not create the interface : '" << _name << "' the node is not DEFINED in the configuration file availlable : " << m_config.getKeys());
|
||||||
return std11::shared_ptr<audio::river::io::Node>();
|
return ememory::SharedPtr<audio::river::io::Node>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::shared_ptr<audio::drain::VolumeElement> audio::river::io::Manager::getVolumeGroup(const std::string& _name) {
|
ememory::SharedPtr<audio::drain::VolumeElement> audio::river::io::Manager::getVolumeGroup(const std::string& _name) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (_name == "") {
|
if (_name == "") {
|
||||||
RIVER_ERROR("Try to create an audio group with no name ...");
|
RIVER_ERROR("Try to create an audio group with no name ...");
|
||||||
return std11::shared_ptr<audio::drain::VolumeElement>();
|
return ememory::SharedPtr<audio::drain::VolumeElement>();
|
||||||
}
|
}
|
||||||
for (size_t iii=0; iii<m_volumeGroup.size(); ++iii) {
|
for (size_t iii=0; iii<m_volumeGroup.size(); ++iii) {
|
||||||
if (m_volumeGroup[iii] == nullptr) {
|
if (m_volumeGroup[iii] == nullptr) {
|
||||||
@@ -276,14 +275,14 @@ std11::shared_ptr<audio::drain::VolumeElement> audio::river::io::Manager::getVol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
RIVER_DEBUG("Add a new volume group : '" << _name << "'");
|
RIVER_DEBUG("Add a new volume group : '" << _name << "'");
|
||||||
std11::shared_ptr<audio::drain::VolumeElement> tmpVolume = std11::make_shared<audio::drain::VolumeElement>(_name);
|
ememory::SharedPtr<audio::drain::VolumeElement> tmpVolume = ememory::makeShared<audio::drain::VolumeElement>(_name);
|
||||||
m_volumeGroup.push_back(tmpVolume);
|
m_volumeGroup.push_back(tmpVolume);
|
||||||
return tmpVolume;
|
return tmpVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool audio::river::io::Manager::setVolume(const std::string& _volumeName, float _valuedB) {
|
bool audio::river::io::Manager::setVolume(const std::string& _volumeName, float _valuedB) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std11::shared_ptr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
ememory::SharedPtr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||||
if (volume == nullptr) {
|
if (volume == nullptr) {
|
||||||
RIVER_ERROR("Can not set volume ... : '" << _volumeName << "'");
|
RIVER_ERROR("Can not set volume ... : '" << _volumeName << "'");
|
||||||
return false;
|
return false;
|
||||||
@@ -295,7 +294,7 @@ bool audio::river::io::Manager::setVolume(const std::string& _volumeName, float
|
|||||||
}
|
}
|
||||||
volume->setVolume(_valuedB);
|
volume->setVolume(_valuedB);
|
||||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||||
std11::shared_ptr<audio::river::io::Node> val = m_list[iii].lock();
|
ememory::SharedPtr<audio::river::io::Node> val = m_list[iii].lock();
|
||||||
if (val != nullptr) {
|
if (val != nullptr) {
|
||||||
val->volumeChange();
|
val->volumeChange();
|
||||||
}
|
}
|
||||||
@@ -304,8 +303,8 @@ bool audio::river::io::Manager::setVolume(const std::string& _volumeName, float
|
|||||||
}
|
}
|
||||||
|
|
||||||
float audio::river::io::Manager::getVolume(const std::string& _volumeName) {
|
float audio::river::io::Manager::getVolume(const std::string& _volumeName) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std11::shared_ptr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
ememory::SharedPtr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||||
if (volume == nullptr) {
|
if (volume == nullptr) {
|
||||||
RIVER_ERROR("Can not get volume ... : '" << _volumeName << "'");
|
RIVER_ERROR("Can not get volume ... : '" << _volumeName << "'");
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@@ -317,8 +316,34 @@ std::pair<float,float> audio::river::io::Manager::getVolumeRange(const std::stri
|
|||||||
return std::make_pair<float,float>(-300, 300);
|
return std::make_pair<float,float>(-300, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void audio::river::io::Manager::setMute(const std::string& _volumeName, bool _mute) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
|
ememory::SharedPtr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||||
|
if (volume == nullptr) {
|
||||||
|
RIVER_ERROR("Can not set volume ... : '" << _volumeName << "'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
volume->setMute(_mute);
|
||||||
|
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||||
|
ememory::SharedPtr<audio::river::io::Node> val = m_list[iii].lock();
|
||||||
|
if (val != nullptr) {
|
||||||
|
val->volumeChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool audio::river::io::Manager::getMute(const std::string& _volumeName) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
|
ememory::SharedPtr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||||
|
if (volume == nullptr) {
|
||||||
|
RIVER_ERROR("Can not get volume ... : '" << _volumeName << "'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return volume->getMute();
|
||||||
|
}
|
||||||
|
|
||||||
void audio::river::io::Manager::generateDot(const std::string& _filename) {
|
void audio::river::io::Manager::generateDot(const std::string& _filename) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
etk::FSNode node(_filename);
|
etk::FSNode node(_filename);
|
||||||
RIVER_INFO("Generate the DOT files: " << node);
|
RIVER_INFO("Generate the DOT files: " << node);
|
||||||
if (node.fileOpenWrite() == false) {
|
if (node.fileOpenWrite() == false) {
|
||||||
@@ -331,14 +356,14 @@ void audio::river::io::Manager::generateDot(const std::string& _filename) {
|
|||||||
{
|
{
|
||||||
// standalone
|
// standalone
|
||||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||||
std11::shared_ptr<audio::river::io::Node> val = m_list[iii].lock();
|
ememory::SharedPtr<audio::river::io::Node> val = m_list[iii].lock();
|
||||||
if (val != nullptr) {
|
if (val != nullptr) {
|
||||||
if (val->isHarwareNode() == true) {
|
if (val->isHarwareNode() == true) {
|
||||||
val->generateDot(node);
|
val->generateDot(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (std::map<std::string, std11::shared_ptr<audio::river::io::Group> >::iterator it(m_listGroup.begin());
|
for (std::map<std::string, ememory::SharedPtr<audio::river::io::Group> >::iterator it(m_listGroup.begin());
|
||||||
it != m_listGroup.end();
|
it != m_listGroup.end();
|
||||||
++it) {
|
++it) {
|
||||||
if (it->second != nullptr) {
|
if (it->second != nullptr) {
|
||||||
@@ -350,14 +375,14 @@ void audio::river::io::Manager::generateDot(const std::string& _filename) {
|
|||||||
{
|
{
|
||||||
// standalone
|
// standalone
|
||||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||||
std11::shared_ptr<audio::river::io::Node> val = m_list[iii].lock();
|
ememory::SharedPtr<audio::river::io::Node> val = m_list[iii].lock();
|
||||||
if (val != nullptr) {
|
if (val != nullptr) {
|
||||||
if (val->isHarwareNode() == false) {
|
if (val->isHarwareNode() == false) {
|
||||||
val->generateDot(node);
|
val->generateDot(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (std::map<std::string, std11::shared_ptr<audio::river::io::Group> >::iterator it(m_listGroup.begin());
|
for (std::map<std::string, ememory::SharedPtr<audio::river::io::Group> >::iterator it(m_listGroup.begin());
|
||||||
it != m_listGroup.end();
|
it != m_listGroup.end();
|
||||||
++it) {
|
++it) {
|
||||||
if (it->second != nullptr) {
|
if (it->second != nullptr) {
|
||||||
@@ -371,16 +396,16 @@ void audio::river::io::Manager::generateDot(const std::string& _filename) {
|
|||||||
RIVER_INFO("Generate the DOT files: " << node << " (DONE)");
|
RIVER_INFO("Generate the DOT files: " << node << " (DONE)");
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::io::Group> audio::river::io::Manager::getGroup(const std::string& _name) {
|
ememory::SharedPtr<audio::river::io::Group> audio::river::io::Manager::getGroup(const std::string& _name) {
|
||||||
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std11::shared_ptr<audio::river::io::Group> out;
|
ememory::SharedPtr<audio::river::io::Group> out;
|
||||||
std::map<std::string, std11::shared_ptr<audio::river::io::Group> >::iterator it = m_listGroup.find(_name);
|
std::map<std::string, ememory::SharedPtr<audio::river::io::Group> >::iterator it = m_listGroup.find(_name);
|
||||||
if (it == m_listGroup.end()) {
|
if (it == m_listGroup.end()) {
|
||||||
RIVER_INFO("Create a new group: " << _name << " (START)");
|
RIVER_INFO("Create a new group: " << _name << " (START)");
|
||||||
out = std11::make_shared<audio::river::io::Group>();
|
out = ememory::makeShared<audio::river::io::Group>();
|
||||||
if (out != nullptr) {
|
if (out != nullptr) {
|
||||||
out->createFrom(m_config, _name);
|
out->createFrom(m_config, _name);
|
||||||
std::pair<std::string, std11::shared_ptr<audio::river::io::Group> > plop(std::string(_name), out);
|
std::pair<std::string, ememory::SharedPtr<audio::river::io::Group> > plop(std::string(_name), out);
|
||||||
m_listGroup.insert(plop);
|
m_listGroup.insert(plop);
|
||||||
RIVER_INFO("Create a new group: " << _name << " ( END )");
|
RIVER_INFO("Create a new group: " << _name << " ( END )");
|
||||||
} else {
|
} else {
|
||||||
|
@@ -3,24 +3,22 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __AUDIO_RIVER_IO_MANAGER_H__
|
|
||||||
#define __AUDIO_RIVER_IO_MANAGER_H__
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <etk/mutex.h>
|
#include <mutex>
|
||||||
#include <etk/chrono.h>
|
#include <chrono>
|
||||||
#include <etk/functional.h>
|
#include <functional>
|
||||||
#include <etk/memory.h>
|
#include <ememory/memory.hpp>
|
||||||
#include <audio/format.h>
|
#include <audio/format.hpp>
|
||||||
#include <audio/channel.h>
|
#include <audio/channel.hpp>
|
||||||
#include <ejson/ejson.h>
|
#include <ejson/ejson.hpp>
|
||||||
#include <audio/drain/Volume.h>
|
#include <audio/drain/Volume.hpp>
|
||||||
#include <audio/river/io/Group.h>
|
#include <audio/river/io/Group.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
@@ -30,16 +28,16 @@ namespace audio {
|
|||||||
* @brief Internal sigleton of all Flow hadware and virtuals.
|
* @brief Internal sigleton of all Flow hadware and virtuals.
|
||||||
* @note this class will be initialize by the audio::river::init() function at the start of the application.
|
* @note this class will be initialize by the audio::river::init() function at the start of the application.
|
||||||
*/
|
*/
|
||||||
class Manager : public std11::enable_shared_from_this<Manager> {
|
class Manager : public ememory::EnableSharedFromThis<Manager> {
|
||||||
private:
|
private:
|
||||||
mutable std11::recursive_mutex m_mutex; //!< prevent multiple access
|
mutable std::recursive_mutex m_mutex; //!< prevent multiple access
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
Manager();
|
Manager();
|
||||||
public:
|
public:
|
||||||
static std11::shared_ptr<Manager> getInstance();
|
static ememory::SharedPtr<Manager> getInstance();
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@@ -60,24 +58,24 @@ namespace audio {
|
|||||||
void unInit();
|
void unInit();
|
||||||
private:
|
private:
|
||||||
ejson::Document m_config; //!< harware configuration
|
ejson::Document m_config; //!< harware configuration
|
||||||
std::vector<std11::shared_ptr<audio::river::io::Node> > m_listKeepAlive; //!< list of all Node that might be keep alive sone/all time
|
std::vector<ememory::SharedPtr<audio::river::io::Node> > m_listKeepAlive; //!< list of all Node that might be keep alive sone/all time
|
||||||
std::vector<std11::weak_ptr<audio::river::io::Node> > m_list; //!< List of all IO node
|
std::vector<ememory::WeakPtr<audio::river::io::Node> > m_list; //!< List of all IO node
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Get a node with his name (the name is set in the description file.
|
* @brief Get a node with his name (the name is set in the description file.
|
||||||
* @param[in] _name Name of the node
|
* @param[in] _name Name of the node
|
||||||
* @return Pointer on the noe or a nullptr if the node does not exist in the file or an error occured.
|
* @return Pointer on the noe or a nullptr if the node does not exist in the file or an error occured.
|
||||||
*/
|
*/
|
||||||
std11::shared_ptr<audio::river::io::Node> getNode(const std::string& _name);
|
ememory::SharedPtr<audio::river::io::Node> getNode(const std::string& _name);
|
||||||
private:
|
private:
|
||||||
std::vector<std11::shared_ptr<audio::drain::VolumeElement> > m_volumeGroup; //!< List of All global volume in the Low level interface.
|
std::vector<ememory::SharedPtr<audio::drain::VolumeElement> > m_volumeGroup; //!< List of All global volume in the Low level interface.
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Get a volume in the global list of vilume
|
* @brief Get a volume in the global list of vilume
|
||||||
* @param[in] _name Name of the volume.
|
* @param[in] _name Name of the volume.
|
||||||
* @return pointer on the requested volume (create it if does not exist). nullptr if the name is empty.
|
* @return pointer on the requested volume (create it if does not exist). nullptr if the name is empty.
|
||||||
*/
|
*/
|
||||||
std11::shared_ptr<audio::drain::VolumeElement> getVolumeGroup(const std::string& _name);
|
ememory::SharedPtr<audio::drain::VolumeElement> getVolumeGroup(const std::string& _name);
|
||||||
/**
|
/**
|
||||||
* @brief Get all input audio stream.
|
* @brief Get all input audio stream.
|
||||||
* @return a list of all availlables input stream name
|
* @return a list of all availlables input stream name
|
||||||
@@ -122,24 +120,34 @@ namespace audio {
|
|||||||
* @example ret = getVolumeRange("MASTER"); can return something like ret=(-120.0f,0.0f)
|
* @example ret = getVolumeRange("MASTER"); can return something like ret=(-120.0f,0.0f)
|
||||||
*/
|
*/
|
||||||
std::pair<float,float> getVolumeRange(const std::string& _volumeName) const;
|
std::pair<float,float> getVolumeRange(const std::string& _volumeName) const;
|
||||||
|
/**
|
||||||
|
* @brief Set a Mute for a specific volume group
|
||||||
|
* @param[in] _volumeName Name of the volume (MASTER, MATER_BT ...)
|
||||||
|
* @param[in] _mute Mute enable or disable.
|
||||||
|
*/
|
||||||
|
void setMute(const std::string& _volumeName, bool _mute);
|
||||||
|
/**
|
||||||
|
* @brief Get a volume value
|
||||||
|
* @param[in] _volumeName Name of the volume (MASTER, MATER_BT ...)
|
||||||
|
* @return The Mute of the volume volume.
|
||||||
|
*/
|
||||||
|
bool getMute(const std::string& _volumeName);
|
||||||
/**
|
/**
|
||||||
* @brief Generate the dot file corresponding at the actif nodes.
|
* @brief Generate the dot file corresponding at the actif nodes.
|
||||||
* @param[in] _filename Name of the file to write data.
|
* @param[in] _filename Name of the file to write data.
|
||||||
*/
|
*/
|
||||||
void generateDot(const std::string& _filename);
|
void generateDot(const std::string& _filename);
|
||||||
private:
|
private:
|
||||||
std::map<std::string, std11::shared_ptr<audio::river::io::Group> > m_listGroup; //!< List of all groups
|
std::map<std::string, ememory::SharedPtr<audio::river::io::Group> > m_listGroup; //!< List of all groups
|
||||||
/**
|
/**
|
||||||
* @brief get a low level interface group.
|
* @brief get a low level interface group.
|
||||||
* @param[in] _name Name of the group.
|
* @param[in] _name Name of the group.
|
||||||
* @return Pointer on the requested group or nullptr if the group does not existed.
|
* @return Pointer on the requested group or nullptr if the group does not existed.
|
||||||
*/
|
*/
|
||||||
std11::shared_ptr<audio::river::io::Group> getGroup(const std::string& _name);
|
ememory::SharedPtr<audio::river::io::Group> getGroup(const std::string& _name);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -4,14 +4,10 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Node.h"
|
#include "Node.hpp"
|
||||||
#include <audio/river/debug.h>
|
#include <audio/river/debug.hpp>
|
||||||
|
|
||||||
#undef __class__
|
audio::river::io::Node::Node(const std::string& _name, const ejson::Object& _config) :
|
||||||
#define __class__ "io::Node"
|
|
||||||
|
|
||||||
|
|
||||||
audio::river::io::Node::Node(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) :
|
|
||||||
m_config(_config),
|
m_config(_config),
|
||||||
m_name(_name),
|
m_name(_name),
|
||||||
m_isInput(false) {
|
m_isInput(false) {
|
||||||
@@ -34,7 +30,7 @@ audio::river::io::Node::Node(const std::string& _name, const std11::shared_ptr<c
|
|||||||
# muxer/demuxer format type (int8-on-int16, int16-on-int32, int24-on-int32, int32-on-int64, float)
|
# muxer/demuxer format type (int8-on-int16, int16-on-int32, int24-on-int32, int32-on-int64, float)
|
||||||
mux-demux-type:"int16_on_int32",
|
mux-demux-type:"int16_on_int32",
|
||||||
*/
|
*/
|
||||||
std::string interfaceType = m_config->getStringValue("io");
|
std::string interfaceType = m_config["io"].toString().get();
|
||||||
RIVER_INFO("interfaceType=" << interfaceType);
|
RIVER_INFO("interfaceType=" << interfaceType);
|
||||||
if ( interfaceType == "input"
|
if ( interfaceType == "input"
|
||||||
|| interfaceType == "PAinput"
|
|| interfaceType == "PAinput"
|
||||||
@@ -45,12 +41,12 @@ audio::river::io::Node::Node(const std::string& _name, const std11::shared_ptr<c
|
|||||||
m_isInput = false;
|
m_isInput = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t frequency = m_config->getNumberValue("frequency", 1);
|
int32_t frequency = m_config["frequency"].toNumber().get(1);
|
||||||
// Get audio format type:
|
// Get audio format type:
|
||||||
std::string type = m_config->getStringValue("type", "int16");
|
std::string type = m_config["type"].toString().get("int16");
|
||||||
enum audio::format formatType = audio::getFormatFromString(type);
|
enum audio::format formatType = audio::getFormatFromString(type);
|
||||||
// Get volume stage :
|
// Get volume stage :
|
||||||
std::string volumeName = m_config->getStringValue("volume-name", "");
|
std::string volumeName = m_config["volume-name"].toString().get();
|
||||||
if (volumeName != "") {
|
if (volumeName != "") {
|
||||||
RIVER_INFO("add node volume stage : '" << volumeName << "'");
|
RIVER_INFO("add node volume stage : '" << volumeName << "'");
|
||||||
// use global manager for volume ...
|
// use global manager for volume ...
|
||||||
@@ -58,15 +54,15 @@ audio::river::io::Node::Node(const std::string& _name, const std11::shared_ptr<c
|
|||||||
}
|
}
|
||||||
// Get map type :
|
// Get map type :
|
||||||
std::vector<audio::channel> map;
|
std::vector<audio::channel> map;
|
||||||
const std11::shared_ptr<const ejson::Array> listChannelMap = m_config->getArray("channel-map");
|
const ejson::Array listChannelMap = m_config["channel-map"].toArray();
|
||||||
if ( listChannelMap == nullptr
|
if ( listChannelMap.exist() == false
|
||||||
|| listChannelMap->size() == 0) {
|
|| listChannelMap.size() == 0) {
|
||||||
// set default channel property:
|
// set default channel property:
|
||||||
map.push_back(audio::channel_frontLeft);
|
map.push_back(audio::channel_frontLeft);
|
||||||
map.push_back(audio::channel_frontRight);
|
map.push_back(audio::channel_frontRight);
|
||||||
} else {
|
} else {
|
||||||
for (size_t iii=0; iii<listChannelMap->size(); ++iii) {
|
for (auto it : listChannelMap) {
|
||||||
std::string value = listChannelMap->getStringValue(iii);
|
std::string value = it.toString().get();
|
||||||
map.push_back(audio::getChannelFromString(value));
|
map.push_back(audio::getChannelFromString(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,17 +71,20 @@ audio::river::io::Node::Node(const std::string& _name, const std11::shared_ptr<c
|
|||||||
|
|
||||||
std::string muxerDemuxerConfig;
|
std::string muxerDemuxerConfig;
|
||||||
if (m_isInput == true) {
|
if (m_isInput == true) {
|
||||||
muxerDemuxerConfig = m_config->getStringValue("mux-demux-type", "int16");
|
muxerDemuxerConfig = m_config["mux-demux-type"].toString().get("int16");
|
||||||
} else {
|
} else {
|
||||||
muxerDemuxerConfig = m_config->getStringValue("mux-demux-type", "int16-on-int32");
|
muxerDemuxerConfig = m_config["mux-demux-type"].toString().get("int16-on-int32");
|
||||||
}
|
}
|
||||||
enum audio::format muxerFormatType = audio::getFormatFromString(muxerDemuxerConfig);
|
enum audio::format muxerFormatType = audio::getFormatFromString(muxerDemuxerConfig);
|
||||||
if (m_isInput == true) {
|
if (m_isInput == true) {
|
||||||
if (muxerFormatType != audio::format_int16) {
|
// Support all ...
|
||||||
RIVER_CRITICAL("not supported demuxer type ... " << muxerFormatType << " for INPUT set in file:" << muxerDemuxerConfig);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (muxerFormatType != audio::format_int16_on_int32) {
|
if ( muxerFormatType != audio::format_int8_on_int16
|
||||||
|
&& muxerFormatType != audio::format_int16_on_int32
|
||||||
|
&& muxerFormatType != audio::format_int24_on_int32
|
||||||
|
&& muxerFormatType != audio::format_int32_on_int64
|
||||||
|
&& muxerFormatType != audio::format_float
|
||||||
|
&& muxerFormatType != audio::format_double) {
|
||||||
RIVER_CRITICAL("not supported demuxer type ... " << muxerFormatType << " for OUTPUT set in file:" << muxerDemuxerConfig);
|
RIVER_CRITICAL("not supported demuxer type ... " << muxerFormatType << " for OUTPUT set in file:" << muxerDemuxerConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +122,7 @@ size_t audio::river::io::Node::getNumberOfInterface(enum audio::river::modeInter
|
|||||||
size_t audio::river::io::Node::getNumberOfInterfaceAvaillable(enum audio::river::modeInterface _interfaceType) {
|
size_t audio::river::io::Node::getNumberOfInterfaceAvaillable(enum audio::river::modeInterface _interfaceType) {
|
||||||
size_t out = 0;
|
size_t out = 0;
|
||||||
for (size_t iii=0; iii<m_listAvaillable.size(); ++iii) {
|
for (size_t iii=0; iii<m_listAvaillable.size(); ++iii) {
|
||||||
std11::shared_ptr<audio::river::Interface> element = m_listAvaillable[iii].lock();
|
ememory::SharedPtr<audio::river::Interface> element = m_listAvaillable[iii].lock();
|
||||||
if (element == nullptr) {
|
if (element == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -134,8 +133,8 @@ size_t audio::river::io::Node::getNumberOfInterfaceAvaillable(enum audio::river:
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::Node::registerAsRemote(const std11::shared_ptr<audio::river::Interface>& _interface) {
|
void audio::river::io::Node::registerAsRemote(const ememory::SharedPtr<audio::river::Interface>& _interface) {
|
||||||
std::vector<std11::weak_ptr<audio::river::Interface> >::iterator it = m_listAvaillable.begin();
|
std::vector<ememory::WeakPtr<audio::river::Interface> >::iterator it = m_listAvaillable.begin();
|
||||||
while (it != m_listAvaillable.end()) {
|
while (it != m_listAvaillable.end()) {
|
||||||
if (it->expired() == true) {
|
if (it->expired() == true) {
|
||||||
it = m_listAvaillable.erase(it);
|
it = m_listAvaillable.erase(it);
|
||||||
@@ -146,9 +145,9 @@ void audio::river::io::Node::registerAsRemote(const std11::shared_ptr<audio::riv
|
|||||||
m_listAvaillable.push_back(_interface);
|
m_listAvaillable.push_back(_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::Node::interfaceAdd(const std11::shared_ptr<audio::river::Interface>& _interface) {
|
void audio::river::io::Node::interfaceAdd(const ememory::SharedPtr<audio::river::Interface>& _interface) {
|
||||||
{
|
{
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||||
if (_interface == m_list[iii]) {
|
if (_interface == m_list[iii]) {
|
||||||
return;
|
return;
|
||||||
@@ -162,9 +161,9 @@ void audio::river::io::Node::interfaceAdd(const std11::shared_ptr<audio::river::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::Node::interfaceRemove(const std11::shared_ptr<audio::river::Interface>& _interface) {
|
void audio::river::io::Node::interfaceRemove(const ememory::SharedPtr<audio::river::Interface>& _interface) {
|
||||||
{
|
{
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
||||||
if (_interface == m_list[iii]) {
|
if (_interface == m_list[iii]) {
|
||||||
m_list.erase(m_list.begin()+iii);
|
m_list.erase(m_list.begin()+iii);
|
||||||
@@ -182,7 +181,7 @@ void audio::river::io::Node::interfaceRemove(const std11::shared_ptr<audio::rive
|
|||||||
|
|
||||||
void audio::river::io::Node::volumeChange() {
|
void audio::river::io::Node::volumeChange() {
|
||||||
for (size_t iii=0; iii< m_listAvaillable.size(); ++iii) {
|
for (size_t iii=0; iii< m_listAvaillable.size(); ++iii) {
|
||||||
std11::shared_ptr<audio::river::Interface> node = m_listAvaillable[iii].lock();
|
ememory::SharedPtr<audio::river::Interface> node = m_listAvaillable[iii].lock();
|
||||||
if (node != nullptr) {
|
if (node != nullptr) {
|
||||||
node->systemVolumeChange();
|
node->systemVolumeChange();
|
||||||
}
|
}
|
||||||
@@ -195,7 +194,6 @@ void audio::river::io::Node::newInput(const void* _inputBuffer,
|
|||||||
if (_inputBuffer == nullptr) {
|
if (_inputBuffer == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const int16_t* inputBuffer = static_cast<const int16_t *>(_inputBuffer);
|
|
||||||
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
||||||
if (m_list[iii] == nullptr) {
|
if (m_list[iii] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
@@ -204,7 +202,7 @@ void audio::river::io::Node::newInput(const void* _inputBuffer,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RIVER_VERBOSE(" IO name="<< m_list[iii]->getName());
|
RIVER_VERBOSE(" IO name="<< m_list[iii]->getName());
|
||||||
m_list[iii]->systemNewInputData(_time, inputBuffer, _nbChunk);
|
m_list[iii]->systemNewInputData(_time, _inputBuffer, _nbChunk);
|
||||||
}
|
}
|
||||||
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [ END ]");
|
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [ END ]");
|
||||||
return;
|
return;
|
||||||
@@ -216,15 +214,22 @@ void audio::river::io::Node::newOutput(void* _outputBuffer,
|
|||||||
if (_outputBuffer == nullptr) {
|
if (_outputBuffer == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::vector<int32_t> output;
|
enum audio::format muxerFormatType = m_process.getInputConfig().getFormat();
|
||||||
|
std::vector<uint8_t> outputTmp2;
|
||||||
|
uint32_t nbByteTmpBuffer = audio::getFormatBytes(muxerFormatType)*m_process.getInputConfig().getMap().size()*_nbChunk;
|
||||||
|
RIVER_VERBOSE("resize=" << nbByteTmpBuffer);
|
||||||
|
outputTmp2.resize(nbByteTmpBuffer);
|
||||||
|
|
||||||
|
if (muxerFormatType == audio::format_int8_on_int16) {
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// process 16 bits
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// $$$$ change the int16
|
||||||
|
std::vector<int16_t> output;
|
||||||
RIVER_VERBOSE("resize=" << _nbChunk*m_process.getInputConfig().getMap().size());
|
RIVER_VERBOSE("resize=" << _nbChunk*m_process.getInputConfig().getMap().size());
|
||||||
output.resize(_nbChunk*m_process.getInputConfig().getMap().size(), 0);
|
output.resize(_nbChunk*m_process.getInputConfig().getMap().size(), 0);
|
||||||
// TODO : set here the mixer selection ...
|
// $$$$ change the int16
|
||||||
if (true) {
|
const int16_t* outputTmp = nullptr;
|
||||||
const int32_t* outputTmp = nullptr;
|
|
||||||
std::vector<uint8_t> outputTmp2;
|
|
||||||
RIVER_VERBOSE("resize=" << sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk);
|
|
||||||
outputTmp2.resize(sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk, 0);
|
|
||||||
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
||||||
if (m_list[iii] == nullptr) {
|
if (m_list[iii] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
@@ -234,19 +239,144 @@ void audio::river::io::Node::newOutput(void* _outputBuffer,
|
|||||||
}
|
}
|
||||||
RIVER_VERBOSE(" IO name="<< m_list[iii]->getName() << " " << iii);
|
RIVER_VERBOSE(" IO name="<< m_list[iii]->getName() << " " << iii);
|
||||||
// clear datas ...
|
// clear datas ...
|
||||||
memset(&outputTmp2[0], 0, sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk);
|
memset(&outputTmp2[0], 0, nbByteTmpBuffer);
|
||||||
RIVER_VERBOSE(" request Data="<< _nbChunk << " time=" << _time);
|
RIVER_VERBOSE(" request Data="<< _nbChunk << " time=" << _time);
|
||||||
m_list[iii]->systemNeedOutputData(_time, &outputTmp2[0], _nbChunk, sizeof(int32_t)*m_process.getInputConfig().getMap().size());
|
m_list[iii]->systemNeedOutputData(_time, &outputTmp2[0], _nbChunk, audio::getFormatBytes(muxerFormatType)*m_process.getInputConfig().getMap().size());
|
||||||
|
// $$$$ change the int16
|
||||||
|
outputTmp = reinterpret_cast<const int16_t*>(&outputTmp2[0]);
|
||||||
|
RIVER_VERBOSE(" Mix it ...");
|
||||||
|
// Add data to the output tmp buffer:
|
||||||
|
for (size_t kkk=0; kkk<output.size(); ++kkk) {
|
||||||
|
output[kkk] += outputTmp[kkk];
|
||||||
|
}
|
||||||
|
// TODO : if a signal is upper than 256* the maximum of 1 it can create a real problem ...
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" End stack process data ...");
|
||||||
|
m_process.processIn(&output[0], _nbChunk, _outputBuffer, _nbChunk);
|
||||||
|
} else if ( muxerFormatType == audio::format_int16_on_int32
|
||||||
|
|| muxerFormatType == audio::format_int24_on_int32) {
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// process 32 bits
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::vector<int32_t> output;
|
||||||
|
RIVER_VERBOSE("resize=" << _nbChunk*m_process.getInputConfig().getMap().size());
|
||||||
|
output.resize(_nbChunk*m_process.getInputConfig().getMap().size(), 0);
|
||||||
|
const int32_t* outputTmp = nullptr;
|
||||||
|
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
||||||
|
if (m_list[iii] == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m_list[iii]->getMode() != audio::river::modeInterface_output) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" IO name="<< m_list[iii]->getName() << " " << iii);
|
||||||
|
// clear datas ...
|
||||||
|
memset(&outputTmp2[0], 0, nbByteTmpBuffer);
|
||||||
|
RIVER_VERBOSE(" request Data="<< _nbChunk << " time=" << _time);
|
||||||
|
m_list[iii]->systemNeedOutputData(_time, &outputTmp2[0], _nbChunk, audio::getFormatBytes(muxerFormatType)*m_process.getInputConfig().getMap().size());
|
||||||
outputTmp = reinterpret_cast<const int32_t*>(&outputTmp2[0]);
|
outputTmp = reinterpret_cast<const int32_t*>(&outputTmp2[0]);
|
||||||
RIVER_VERBOSE(" Mix it ...");
|
RIVER_VERBOSE(" Mix it ...");
|
||||||
// Add data to the output tmp buffer:
|
// Add data to the output tmp buffer:
|
||||||
for (size_t kkk=0; kkk<output.size(); ++kkk) {
|
for (size_t kkk=0; kkk<output.size(); ++kkk) {
|
||||||
output[kkk] += outputTmp[kkk];
|
output[kkk] += outputTmp[kkk];
|
||||||
}
|
}
|
||||||
|
// TODO : if a signal is upper than 256* (for 24 bits) or 65335* (for 16 bits) the maximum of 1 it can create a real problem ...
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" End stack process data ...");
|
||||||
|
m_process.processIn(&output[0], _nbChunk, _outputBuffer, _nbChunk);
|
||||||
|
} else if (muxerFormatType == audio::format_int32_on_int64) {
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// process 64 bits
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::vector<int64_t> output;
|
||||||
|
RIVER_VERBOSE("resize=" << _nbChunk*m_process.getInputConfig().getMap().size());
|
||||||
|
output.resize(_nbChunk*m_process.getInputConfig().getMap().size(), 0);
|
||||||
|
const int64_t* outputTmp = nullptr;
|
||||||
|
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
||||||
|
if (m_list[iii] == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m_list[iii]->getMode() != audio::river::modeInterface_output) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" IO name="<< m_list[iii]->getName() << " " << iii);
|
||||||
|
// clear datas ...
|
||||||
|
memset(&outputTmp2[0], 0, nbByteTmpBuffer);
|
||||||
|
RIVER_VERBOSE(" request Data="<< _nbChunk << " time=" << _time);
|
||||||
|
m_list[iii]->systemNeedOutputData(_time, &outputTmp2[0], _nbChunk, audio::getFormatBytes(muxerFormatType)*m_process.getInputConfig().getMap().size());
|
||||||
|
outputTmp = reinterpret_cast<const int64_t*>(&outputTmp2[0]);
|
||||||
|
RIVER_VERBOSE(" Mix it ...");
|
||||||
|
// Add data to the output tmp buffer:
|
||||||
|
for (size_t kkk=0; kkk<output.size(); ++kkk) {
|
||||||
|
output[kkk] += outputTmp[kkk];
|
||||||
|
}
|
||||||
|
// TODO : if a signal is upper than 2000000000* the maximum of 1 it can create a real problem ...
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" End stack process data ...");
|
||||||
|
m_process.processIn(&output[0], _nbChunk, _outputBuffer, _nbChunk);
|
||||||
|
} else if (muxerFormatType == audio::format_float) {
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// process 32 bits FLOAT
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::vector<float> output;
|
||||||
|
RIVER_VERBOSE("resize=" << _nbChunk*m_process.getInputConfig().getMap().size());
|
||||||
|
output.resize(_nbChunk*m_process.getInputConfig().getMap().size(), 0);
|
||||||
|
const float* outputTmp = nullptr;
|
||||||
|
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
||||||
|
if (m_list[iii] == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m_list[iii]->getMode() != audio::river::modeInterface_output) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" IO name="<< m_list[iii]->getName() << " " << iii);
|
||||||
|
// clear datas ...
|
||||||
|
memset(&outputTmp2[0], 0, nbByteTmpBuffer);
|
||||||
|
RIVER_VERBOSE(" request Data="<< _nbChunk << " time=" << _time);
|
||||||
|
m_list[iii]->systemNeedOutputData(_time, &outputTmp2[0], _nbChunk, audio::getFormatBytes(muxerFormatType)*m_process.getInputConfig().getMap().size());
|
||||||
|
outputTmp = reinterpret_cast<const float*>(&outputTmp2[0]);
|
||||||
|
RIVER_VERBOSE(" Mix it ...");
|
||||||
|
// Add data to the output tmp buffer:
|
||||||
|
for (size_t kkk=0; kkk<output.size(); ++kkk) {
|
||||||
|
output[kkk] += outputTmp[kkk];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RIVER_VERBOSE(" End stack process data ...");
|
RIVER_VERBOSE(" End stack process data ...");
|
||||||
m_process.processIn(&output[0], _nbChunk, _outputBuffer, _nbChunk);
|
m_process.processIn(&output[0], _nbChunk, _outputBuffer, _nbChunk);
|
||||||
|
} else if (muxerFormatType == audio::format_double) {
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// process 64 bits FLOAT
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::vector<double> output;
|
||||||
|
RIVER_VERBOSE("resize=" << _nbChunk*m_process.getInputConfig().getMap().size());
|
||||||
|
output.resize(_nbChunk*m_process.getInputConfig().getMap().size(), 0);
|
||||||
|
const double* outputTmp = nullptr;
|
||||||
|
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
||||||
|
if (m_list[iii] == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m_list[iii]->getMode() != audio::river::modeInterface_output) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" IO name="<< m_list[iii]->getName() << " " << iii);
|
||||||
|
// clear datas ...
|
||||||
|
memset(&outputTmp2[0], 0, nbByteTmpBuffer);
|
||||||
|
RIVER_VERBOSE(" request Data="<< _nbChunk << " time=" << _time);
|
||||||
|
m_list[iii]->systemNeedOutputData(_time, &outputTmp2[0], _nbChunk, audio::getFormatBytes(muxerFormatType)*m_process.getInputConfig().getMap().size());
|
||||||
|
outputTmp = reinterpret_cast<const double*>(&outputTmp2[0]);
|
||||||
|
RIVER_VERBOSE(" Mix it ...");
|
||||||
|
// Add data to the output tmp buffer:
|
||||||
|
for (size_t kkk=0; kkk<output.size(); ++kkk) {
|
||||||
|
output[kkk] += outputTmp[kkk];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" End stack process data ...");
|
||||||
|
m_process.processIn(&output[0], _nbChunk, _outputBuffer, _nbChunk);
|
||||||
|
} else {
|
||||||
|
RIVER_ERROR("Wrong demuxer type: " << muxerFormatType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// The feedback get the real output data (after processing ...==> then no nneed to specify for each channels
|
||||||
RIVER_VERBOSE(" Feedback :");
|
RIVER_VERBOSE(" Feedback :");
|
||||||
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
||||||
if (m_list[iii] == nullptr) {
|
if (m_list[iii] == nullptr) {
|
||||||
@@ -324,7 +454,7 @@ void audio::river::io::Node::generateDot(etk::FSNode& _node) {
|
|||||||
if (m_listAvaillable[iii].expired() == true) {
|
if (m_listAvaillable[iii].expired() == true) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::river::Interface> element = m_listAvaillable[iii].lock();
|
ememory::SharedPtr<audio::river::Interface> element = m_listAvaillable[iii].lock();
|
||||||
if (element == nullptr) {
|
if (element == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -350,7 +480,7 @@ void audio::river::io::Node::generateDot(etk::FSNode& _node) {
|
|||||||
|
|
||||||
|
|
||||||
void audio::river::io::Node::startInGroup() {
|
void audio::river::io::Node::startInGroup() {
|
||||||
std11::shared_ptr<audio::river::io::Group> group = m_group.lock();
|
ememory::SharedPtr<audio::river::io::Group> group = m_group.lock();
|
||||||
if (group != nullptr) {
|
if (group != nullptr) {
|
||||||
group->start();
|
group->start();
|
||||||
} else {
|
} else {
|
||||||
@@ -359,7 +489,7 @@ void audio::river::io::Node::startInGroup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::Node::stopInGroup() {
|
void audio::river::io::Node::stopInGroup() {
|
||||||
std11::shared_ptr<audio::river::io::Group> group = m_group.lock();
|
ememory::SharedPtr<audio::river::io::Group> group = m_group.lock();
|
||||||
if (group != nullptr) {
|
if (group != nullptr) {
|
||||||
group->stop();
|
group->stop();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -3,24 +3,22 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __AUDIO_RIVER_IO_NODE_H__
|
|
||||||
#define __AUDIO_RIVER_IO_NODE_H__
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <etk/chrono.h>
|
#include <chrono>
|
||||||
#include <etk/functional.h>
|
#include <functional>
|
||||||
#include <etk/memory.h>
|
#include <ememory/memory.hpp>
|
||||||
#include <audio/format.h>
|
#include <audio/format.hpp>
|
||||||
#include <audio/channel.h>
|
#include <audio/channel.hpp>
|
||||||
#include "Manager.h"
|
#include "Manager.hpp"
|
||||||
#include <audio/river/Interface.h>
|
#include <audio/river/Interface.hpp>
|
||||||
#include <audio/drain/IOFormatInterface.h>
|
#include <audio/drain/IOFormatInterface.hpp>
|
||||||
#include <audio/drain/Volume.h>
|
#include <audio/drain/Volume.hpp>
|
||||||
#include <etk/os/FSNode.h>
|
#include <etk/os/FSNode.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
@@ -31,7 +29,7 @@ namespace audio {
|
|||||||
* @brief A node is the base for input/output interface. When a output id declared, we automaticly have a feedback associated.
|
* @brief A node is the base for input/output interface. When a output id declared, we automaticly have a feedback associated.
|
||||||
* this manage the muxing of data for output an the demuxing for input.
|
* this manage the muxing of data for output an the demuxing for input.
|
||||||
*/
|
*/
|
||||||
class Node : public std11::enable_shared_from_this<Node> {
|
class Node : public ememory::EnableSharedFromThis<Node> {
|
||||||
friend class audio::river::io::Group;
|
friend class audio::river::io::Group;
|
||||||
protected:
|
protected:
|
||||||
uint32_t m_uid; //!< uniqueNodeID use for debug an dot generation.
|
uint32_t m_uid; //!< uniqueNodeID use for debug an dot generation.
|
||||||
@@ -41,7 +39,7 @@ namespace audio {
|
|||||||
* @param[in] _name Name of the node.
|
* @param[in] _name Name of the node.
|
||||||
* @param[in] _config Configuration of the node.
|
* @param[in] _config Configuration of the node.
|
||||||
*/
|
*/
|
||||||
Node(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
|
Node(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
@@ -56,8 +54,8 @@ namespace audio {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
mutable std11::mutex m_mutex; //!< prevent open/close/write/read access that is multi-threaded.
|
mutable std::mutex m_mutex; //!< prevent open/close/write/read access that is multi-threaded.
|
||||||
std11::shared_ptr<const ejson::Object> m_config; //!< configuration description.
|
const ejson::Object m_config; //!< configuration description.
|
||||||
protected:
|
protected:
|
||||||
audio::drain::Process m_process; //!< Low level algorithms
|
audio::drain::Process m_process; //!< Low level algorithms
|
||||||
public:
|
public:
|
||||||
@@ -84,10 +82,10 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
std11::shared_ptr<audio::drain::VolumeElement> m_volume; //!< if a volume is set it is set here ... for hardware interface only.
|
ememory::SharedPtr<audio::drain::VolumeElement> m_volume; //!< if a volume is set it is set here ... for hardware interface only.
|
||||||
protected:
|
protected:
|
||||||
std::vector<std11::weak_ptr<audio::river::Interface> > m_listAvaillable; //!< List of all interface that exist on this Node
|
std::vector<ememory::WeakPtr<audio::river::Interface> > m_listAvaillable; //!< List of all interface that exist on this Node
|
||||||
std::vector<std11::shared_ptr<audio::river::Interface> > m_list; //!< List of all connected interface at this node.
|
std::vector<ememory::SharedPtr<audio::river::Interface> > m_list; //!< List of all connected interface at this node.
|
||||||
/**
|
/**
|
||||||
* @brief Get the number of interface with a specific type.
|
* @brief Get the number of interface with a specific type.
|
||||||
* @param[in] _interfaceType Type of the interface.
|
* @param[in] _interfaceType Type of the interface.
|
||||||
@@ -111,20 +109,20 @@ namespace audio {
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Register an interface that can connect on it. (might be done in the Interface Init)
|
* @brief Register an interface that can connect on it. (might be done in the Interface Init)
|
||||||
* @note We keep a std::weak_ptr. this is the reason why we do not have a remove.
|
* @note We keep a ememory::WeakPtr. this is the reason why we do not have a remove.
|
||||||
* @param[in] _interface Pointer on the interface to register.
|
* @param[in] _interface Pointer on the interface to register.
|
||||||
*/
|
*/
|
||||||
void registerAsRemote(const std11::shared_ptr<audio::river::Interface>& _interface);
|
void registerAsRemote(const ememory::SharedPtr<audio::river::Interface>& _interface);
|
||||||
/**
|
/**
|
||||||
* @brief Request this interface might receve/send dat on the flow. (start/resume)
|
* @brief Request this interface might receve/send dat on the flow. (start/resume)
|
||||||
* @param[in] _interface Pointer on the interface to register.
|
* @param[in] _interface Pointer on the interface to register.
|
||||||
*/
|
*/
|
||||||
void interfaceAdd(const std11::shared_ptr<audio::river::Interface>& _interface);
|
void interfaceAdd(const ememory::SharedPtr<audio::river::Interface>& _interface);
|
||||||
/**
|
/**
|
||||||
* @brief Un-register the interface as an availlable read/write interface. (suspend/stop)
|
* @brief Un-register the interface as an availlable read/write interface. (suspend/stop)
|
||||||
* @param[in] _interface Pointer on the interface to register.
|
* @param[in] _interface Pointer on the interface to register.
|
||||||
*/
|
*/
|
||||||
void interfaceRemove(const std11::shared_ptr<audio::river::Interface>& _interface);
|
void interfaceRemove(const ememory::SharedPtr<audio::river::Interface>& _interface);
|
||||||
protected:
|
protected:
|
||||||
std::string m_name; //!< Name of the interface
|
std::string m_name; //!< Name of the interface
|
||||||
public:
|
public:
|
||||||
@@ -153,13 +151,13 @@ namespace audio {
|
|||||||
return !m_isInput;
|
return !m_isInput;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
std11::weak_ptr<audio::river::io::Group> m_group; //!< reference on the group. If available.
|
ememory::WeakPtr<audio::river::io::Group> m_group; //!< reference on the group. If available.
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Set this node in a low level group.
|
* @brief Set this node in a low level group.
|
||||||
* @param[in] _group Group reference.
|
* @param[in] _group Group reference.
|
||||||
*/
|
*/
|
||||||
void setGroup(std11::shared_ptr<audio::river::io::Group> _group) {
|
void setGroup(ememory::SharedPtr<audio::river::io::Group> _group) {
|
||||||
m_group = _group;
|
m_group = _group;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
@@ -184,7 +182,7 @@ namespace audio {
|
|||||||
* @brief If this iss an hardware interface we can have a resuest of the volume stage:
|
* @brief If this iss an hardware interface we can have a resuest of the volume stage:
|
||||||
* @return pointer on the requested volume.
|
* @return pointer on the requested volume.
|
||||||
*/
|
*/
|
||||||
const std11::shared_ptr<audio::drain::VolumeElement>& getVolume() {
|
const ememory::SharedPtr<audio::drain::VolumeElement>& getVolume() {
|
||||||
return m_volume;
|
return m_volume;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
@@ -222,5 +220,3 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -4,46 +4,43 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <audio/river/io/NodeAEC.h>
|
#include <audio/river/io/NodeAEC.hpp>
|
||||||
#include <audio/river/debug.h>
|
#include <audio/river/debug.hpp>
|
||||||
#include <etk/types.h>
|
#include <etk/types.hpp>
|
||||||
#include <etk/memory.h>
|
#include <ememory/memory.hpp>
|
||||||
#include <etk/functional.h>
|
#include <functional>
|
||||||
|
|
||||||
#undef __class__
|
ememory::SharedPtr<audio::river::io::NodeAEC> audio::river::io::NodeAEC::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
#define __class__ "io::NodeAEC"
|
return ememory::SharedPtr<audio::river::io::NodeAEC>(new audio::river::io::NodeAEC(_name, _config));
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::io::NodeAEC> audio::river::io::NodeAEC::create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) {
|
|
||||||
return std11::shared_ptr<audio::river::io::NodeAEC>(new audio::river::io::NodeAEC(_name, _config));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::Interface> audio::river::io::NodeAEC::createInput(float _freq,
|
ememory::SharedPtr<audio::river::Interface> audio::river::io::NodeAEC::createInput(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::string& _objectName,
|
const std::string& _objectName,
|
||||||
const std::string& _name) {
|
const std::string& _name) {
|
||||||
// check if the output exist
|
// check if the output exist
|
||||||
const std11::shared_ptr<const ejson::Object> tmppp = m_config->getObject(_objectName);
|
const ejson::Object tmppp = m_config[_objectName].toObject();
|
||||||
if (tmppp == nullptr) {
|
if (tmppp.exist() == false) {
|
||||||
RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config->getKeys());
|
RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config.getKeys());
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
std::string streamName = tmppp->getStringValue("map-on", "error");
|
std::string streamName = tmppp["map-on"].toString().get("error");
|
||||||
|
|
||||||
m_nbChunk = m_config->getNumberValue("nb-chunk", 1024);
|
m_nbChunk = m_config["nb-chunk"].toNumber().get(1024);
|
||||||
// check if it is an Output:
|
// check if it is an Output:
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp["io"].toString().get("error");
|
||||||
if ( type != "input"
|
if ( type != "input"
|
||||||
&& type != "feedback") {
|
&& type != "feedback") {
|
||||||
RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type);
|
RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type);
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
// get global hardware interface:
|
// get global hardware interface:
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
// get the output or input channel :
|
// get the output or input channel :
|
||||||
std11::shared_ptr<audio::river::io::Node> node = manager->getNode(streamName);
|
ememory::SharedPtr<audio::river::io::Node> node = manager->getNode(streamName);
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std11::shared_ptr<audio::river::Interface> interface;
|
ememory::SharedPtr<audio::river::Interface> interface;
|
||||||
interface = audio::river::Interface::create(_freq, _map, _format, node, tmppp);
|
interface = audio::river::Interface::create(_freq, _map, _format, node, tmppp);
|
||||||
if (interface != nullptr) {
|
if (interface != nullptr) {
|
||||||
interface->setName(_name);
|
interface->setName(_name);
|
||||||
@@ -52,7 +49,7 @@ std11::shared_ptr<audio::river::Interface> audio::river::io::NodeAEC::createInpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
audio::river::io::NodeAEC::NodeAEC(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::NodeAEC::NodeAEC(const std::string& _name, const ejson::Object& _config) :
|
||||||
Node(_name, _config),
|
Node(_name, _config),
|
||||||
m_P_attaqueTime(1),
|
m_P_attaqueTime(1),
|
||||||
m_P_releaseTime(100),
|
m_P_releaseTime(100),
|
||||||
@@ -106,28 +103,28 @@ audio::river::io::NodeAEC::NodeAEC(const std::string& _name, const std11::shared
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceFeedBack->setInputCallback(std11::bind(&audio::river::io::NodeAEC::onDataReceivedFeedBack,
|
m_interfaceFeedBack->setInputCallback(std::bind(&audio::river::io::NodeAEC::onDataReceivedFeedBack,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceMicrophone->setInputCallback(std11::bind(&audio::river::io::NodeAEC::onDataReceivedMicrophone,
|
m_interfaceMicrophone->setInputCallback(std::bind(&audio::river::io::NodeAEC::onDataReceivedMicrophone,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
|
|
||||||
m_bufferMicrophone.setCapacity(std11::chrono::milliseconds(1000),
|
m_bufferMicrophone.setCapacity(std::chrono::milliseconds(1000),
|
||||||
audio::getFormatBytes(hardwareFormat.getFormat())*hardwareFormat.getMap().size(),
|
audio::getFormatBytes(hardwareFormat.getFormat())*hardwareFormat.getMap().size(),
|
||||||
hardwareFormat.getFrequency());
|
hardwareFormat.getFrequency());
|
||||||
m_bufferFeedBack.setCapacity(std11::chrono::milliseconds(1000),
|
m_bufferFeedBack.setCapacity(std::chrono::milliseconds(1000),
|
||||||
audio::getFormatBytes(hardwareFormat.getFormat()), // only one channel ...
|
audio::getFormatBytes(hardwareFormat.getFormat()), // only one channel ...
|
||||||
hardwareFormat.getFrequency());
|
hardwareFormat.getFrequency());
|
||||||
|
|
||||||
@@ -142,7 +139,7 @@ audio::river::io::NodeAEC::~NodeAEC() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void audio::river::io::NodeAEC::start() {
|
void audio::river::io::NodeAEC::start() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
||||||
if (m_interfaceFeedBack != nullptr) {
|
if (m_interfaceFeedBack != nullptr) {
|
||||||
RIVER_INFO("Start FEEDBACK : ");
|
RIVER_INFO("Start FEEDBACK : ");
|
||||||
@@ -155,7 +152,7 @@ void audio::river::io::NodeAEC::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::NodeAEC::stop() {
|
void audio::river::io::NodeAEC::stop() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
if (m_interfaceFeedBack != nullptr) {
|
if (m_interfaceFeedBack != nullptr) {
|
||||||
m_interfaceFeedBack->stop();
|
m_interfaceFeedBack->stop();
|
||||||
}
|
}
|
||||||
@@ -177,7 +174,7 @@ void audio::river::io::NodeAEC::onDataReceivedMicrophone(const void* _data,
|
|||||||
RIVER_ERROR("call wrong type ... (need int16_t)");
|
RIVER_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
// push data synchronize
|
// push data synchronize
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
m_bufferMicrophone.write(_data, _nbChunk, _time);
|
m_bufferMicrophone.write(_data, _nbChunk, _time);
|
||||||
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_Microphone.raw", _data, _nbChunk*_map.size());
|
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_Microphone.raw", _data, _nbChunk*_map.size());
|
||||||
process();
|
process();
|
||||||
@@ -195,7 +192,7 @@ void audio::river::io::NodeAEC::onDataReceivedFeedBack(const void* _data,
|
|||||||
RIVER_ERROR("call wrong type ... (need int16_t)");
|
RIVER_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
// push data synchronize
|
// push data synchronize
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
m_bufferFeedBack.write(_data, _nbChunk, _time);
|
m_bufferFeedBack.write(_data, _nbChunk, _time);
|
||||||
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_FeedBack.raw", _data, _nbChunk*_map.size());
|
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_FeedBack.raw", _data, _nbChunk*_map.size());
|
||||||
process();
|
process();
|
||||||
@@ -346,7 +343,7 @@ void audio::river::io::NodeAEC::generateDot(etk::FSNode& _node) {
|
|||||||
if (m_listAvaillable[iii].expired() == true) {
|
if (m_listAvaillable[iii].expired() == true) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::river::Interface> element = m_listAvaillable[iii].lock();
|
ememory::SharedPtr<audio::river::Interface> element = m_listAvaillable[iii].lock();
|
||||||
if (element == nullptr) {
|
if (element == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -3,13 +3,11 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef __AUDIO_RIVER_IO_NODE_AEC_H__
|
#include <audio/river/io/Node.hpp>
|
||||||
#define __AUDIO_RIVER_IO_NODE_AEC_H__
|
#include <audio/river/Interface.hpp>
|
||||||
|
#include <audio/drain/CircularBuffer.hpp>
|
||||||
#include <audio/river/io/Node.h>
|
|
||||||
#include <audio/river/Interface.h>
|
|
||||||
#include <audio/drain/CircularBuffer.h>
|
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
@@ -20,14 +18,14 @@ namespace audio {
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NodeAEC(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
|
NodeAEC(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Factory of this Virtual Node.
|
* @brief Factory of this Virtual Node.
|
||||||
* @param[in] _name Name of the node.
|
* @param[in] _name Name of the node.
|
||||||
* @param[in] _config Configuration of the node.
|
* @param[in] _config Configuration of the node.
|
||||||
*/
|
*/
|
||||||
static std11::shared_ptr<NodeAEC> create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
|
static ememory::SharedPtr<NodeAEC> create(const std::string& _name, const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@@ -35,8 +33,8 @@ namespace audio {
|
|||||||
protected:
|
protected:
|
||||||
virtual void start();
|
virtual void start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceMicrophone; //!< Interface on the Microphone.
|
ememory::SharedPtr<audio::river::Interface> m_interfaceMicrophone; //!< Interface on the Microphone.
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceFeedBack; //!< Interface on the feedback of speaker.
|
ememory::SharedPtr<audio::river::Interface> m_interfaceFeedBack; //!< Interface on the feedback of speaker.
|
||||||
/**
|
/**
|
||||||
* @brief Internal: create an input with the specific parameter:
|
* @brief Internal: create an input with the specific parameter:
|
||||||
* @param[in] _freq Frequency.
|
* @param[in] _freq Frequency.
|
||||||
@@ -46,7 +44,7 @@ namespace audio {
|
|||||||
* @param[in] _name
|
* @param[in] _name
|
||||||
* @return Interfae Pointer.
|
* @return Interfae Pointer.
|
||||||
*/
|
*/
|
||||||
std11::shared_ptr<audio::river::Interface> createInput(float _freq,
|
ememory::SharedPtr<audio::river::Interface> createInput(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::string& _streamName,
|
const std::string& _streamName,
|
||||||
@@ -106,5 +104,3 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
269
audio/river/io/NodeFile.cpp
Normal file
269
audio/river/io/NodeFile.cpp
Normal file
@@ -0,0 +1,269 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef AUDIO_RIVER_BUILD_FILE
|
||||||
|
|
||||||
|
#include <audio/river/io/NodeFile.hpp>
|
||||||
|
#include <audio/river/debug.hpp>
|
||||||
|
#include <ememory/memory.hpp>
|
||||||
|
|
||||||
|
int32_t audio::river::io::NodeFile::recordCallback(const void* _inputBuffer,
|
||||||
|
const audio::Time& _timeInput,
|
||||||
|
uint32_t _nbChunk,
|
||||||
|
const std::vector<audio::orchestra::status>& _status) {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
// TODO : Manage status ...
|
||||||
|
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
|
||||||
|
newInput(_inputBuffer, _nbChunk, _timeInput);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t audio::river::io::NodeFile::playbackCallback(void* _outputBuffer,
|
||||||
|
const audio::Time& _timeOutput,
|
||||||
|
uint32_t _nbChunk,
|
||||||
|
const std::vector<audio::orchestra::status>& _status) {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
// TODO : Manage status ...
|
||||||
|
RIVER_VERBOSE("data Output size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
|
||||||
|
newOutput(_outputBuffer, _nbChunk, _timeOutput);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ememory::SharedPtr<audio::river::io::NodeFile> audio::river::io::NodeFile::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
|
return ememory::SharedPtr<audio::river::io::NodeFile>(new audio::river::io::NodeFile(_name, _config));
|
||||||
|
}
|
||||||
|
|
||||||
|
audio::river::io::NodeFile::NodeFile(const std::string& _name, const ejson::Object& _config) :
|
||||||
|
Node(_name, _config) {
|
||||||
|
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
||||||
|
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
||||||
|
/**
|
||||||
|
map-on:{ # select hardware interface and name
|
||||||
|
interface:"alsa", # interface : "alsa", "pulse", "core", ...
|
||||||
|
name:"default", # name of the interface
|
||||||
|
},
|
||||||
|
nb-chunk:1024 # number of chunk to open device (create the latency anf the frequency to call user)
|
||||||
|
*/
|
||||||
|
std::string typeInterface = audio::orchestra::type::undefined;
|
||||||
|
std::string streamName = "default";
|
||||||
|
const ejson::Object tmpObject = m_config["map-on"].toObject();
|
||||||
|
if (tmpObject.exist() == false) {
|
||||||
|
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
||||||
|
} else {
|
||||||
|
typeInterface = tmpObject.getStringValue("interface", audio::orchestra::type::undefined);
|
||||||
|
if (typeInterface == "auto") {
|
||||||
|
typeInterface = audio::orchestra::type::undefined;
|
||||||
|
}
|
||||||
|
streamName = tmpObject.getStringValue("name", "default");
|
||||||
|
}
|
||||||
|
int32_t nbChunk = m_config.getNumberValue("nb-chunk", 1024);
|
||||||
|
|
||||||
|
// intanciate specific API ...
|
||||||
|
m_interface.instanciate(typeInterface);
|
||||||
|
m_interface.setName(_name);
|
||||||
|
// TODO : Check return ...
|
||||||
|
std::string type = m_config.getStringValue("type", "int16");
|
||||||
|
if (streamName == "") {
|
||||||
|
streamName = "default";
|
||||||
|
}
|
||||||
|
|
||||||
|
// search device ID :
|
||||||
|
RIVER_INFO("Open :");
|
||||||
|
RIVER_INFO(" m_streamName=" << streamName);
|
||||||
|
RIVER_INFO(" m_freq=" << hardwareFormat.getFrequency());
|
||||||
|
RIVER_INFO(" m_map=" << hardwareFormat.getMap());
|
||||||
|
RIVER_INFO(" m_format=" << hardwareFormat.getFormat());
|
||||||
|
RIVER_INFO(" m_isInput=" << m_isInput);
|
||||||
|
int32_t deviceId = -1;
|
||||||
|
/*
|
||||||
|
// TODO : Remove this from here (create an extern interface ...)
|
||||||
|
RIVER_INFO("Device list:");
|
||||||
|
for (int32_t iii=0; iii<m_interface.getDeviceCount(); ++iii) {
|
||||||
|
m_info = m_interface.getDeviceInfo(iii);
|
||||||
|
RIVER_INFO(" " << iii << " name :" << m_info.name);
|
||||||
|
m_info.display(2);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
// special case for default IO:
|
||||||
|
if (streamName == "default") {
|
||||||
|
if (m_isInput == true) {
|
||||||
|
deviceId = m_interface.getDefaultInputDevice();
|
||||||
|
} else {
|
||||||
|
deviceId = m_interface.getDefaultOutputDevice();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int32_t iii=0; iii<m_interface.getDeviceCount(); ++iii) {
|
||||||
|
m_info = m_interface.getDeviceInfo(iii);
|
||||||
|
if (m_info.name == streamName) {
|
||||||
|
RIVER_INFO(" Select ... id =" << iii);
|
||||||
|
deviceId = iii;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO : Check if the devace with the specific name exist ...
|
||||||
|
/*
|
||||||
|
if (deviceId == -1) {
|
||||||
|
RIVER_ERROR("Can not find the " << streamName << " audio interface ... (use O default ...)");
|
||||||
|
deviceId = 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Open specific ID :
|
||||||
|
if (deviceId == -1) {
|
||||||
|
m_info = m_interface.getDeviceInfo(streamName);
|
||||||
|
} else {
|
||||||
|
m_info = m_interface.getDeviceInfo(deviceId);
|
||||||
|
}
|
||||||
|
// display property :
|
||||||
|
{
|
||||||
|
RIVER_INFO("Device " << deviceId << " - '" << streamName << "' property :");
|
||||||
|
m_info.display();
|
||||||
|
|
||||||
|
if (etk::isIn(hardwareFormat.getFormat(), m_info.nativeFormats) == false) {
|
||||||
|
if (type == "auto") {
|
||||||
|
if (etk::isIn(audio::format_int16, m_info.nativeFormats) == true) {
|
||||||
|
hardwareFormat.setFormat(audio::format_int16);
|
||||||
|
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||||
|
} else if (etk::isIn(audio::format_float, m_info.nativeFormats) == true) {
|
||||||
|
hardwareFormat.setFormat(audio::format_float);
|
||||||
|
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||||
|
} else if (etk::isIn(audio::format_int16_on_int32, m_info.nativeFormats) == true) {
|
||||||
|
hardwareFormat.setFormat(audio::format_int16_on_int32);
|
||||||
|
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||||
|
} else if (etk::isIn(audio::format_int24, m_info.nativeFormats) == true) {
|
||||||
|
hardwareFormat.setFormat(audio::format_int24);
|
||||||
|
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||||
|
} else if (m_info.nativeFormats.size() != 0) {
|
||||||
|
hardwareFormat.setFormat(m_info.nativeFormats[0]);
|
||||||
|
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||||
|
} else {
|
||||||
|
RIVER_CRITICAL("auto set format no element in the configuration: " << m_info.nativeFormats);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RIVER_CRITICAL("Can not manage input transforamtion: " << hardwareFormat.getFormat() << " not in " << m_info.nativeFormats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (etk::isIn(hardwareFormat.getFrequency(), m_info.sampleRates) == false) {
|
||||||
|
if (etk::isIn(48000, m_info.sampleRates) == true) {
|
||||||
|
hardwareFormat.setFrequency(48000);
|
||||||
|
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||||
|
} else if (etk::isIn(44100, m_info.sampleRates) == true) {
|
||||||
|
hardwareFormat.setFrequency(44100);
|
||||||
|
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||||
|
} else if (etk::isIn(32000, m_info.sampleRates) == true) {
|
||||||
|
hardwareFormat.setFrequency(32000);
|
||||||
|
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||||
|
} else if (etk::isIn(16000, m_info.sampleRates) == true) {
|
||||||
|
hardwareFormat.setFrequency(16000);
|
||||||
|
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||||
|
} else if (etk::isIn(8000, m_info.sampleRates) == true) {
|
||||||
|
hardwareFormat.setFrequency(8000);
|
||||||
|
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||||
|
} else if (etk::isIn(96000, m_info.sampleRates) == true) {
|
||||||
|
hardwareFormat.setFrequency(96000);
|
||||||
|
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||||
|
} else if (m_info.sampleRates.size() != 0) {
|
||||||
|
hardwareFormat.setFrequency(m_info.sampleRates[0]);
|
||||||
|
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency() << "(first element in list) in " << m_info.sampleRates);
|
||||||
|
} else {
|
||||||
|
RIVER_CRITICAL("Can not manage input transforamtion:" << hardwareFormat.getFrequency() << " not in " << m_info.sampleRates);
|
||||||
|
}
|
||||||
|
interfaceFormat.setFrequency(hardwareFormat.getFrequency());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// open Audio device:
|
||||||
|
audio::orchestra::StreamParameters params;
|
||||||
|
params.deviceId = deviceId;
|
||||||
|
params.deviceName = streamName;
|
||||||
|
params.nChannels = hardwareFormat.getMap().size();
|
||||||
|
if (m_info.channels.size() < params.nChannels) {
|
||||||
|
RIVER_CRITICAL("Can not open hardware device with more channel (" << params.nChannels << ") that is autorized by hardware (" << m_info.channels.size() << ").");
|
||||||
|
}
|
||||||
|
audio::orchestra::StreamOptions option;
|
||||||
|
etk::from_string(option.mode, tmpObject->getStringValue("timestamp-mode", "soft"));
|
||||||
|
|
||||||
|
RIVER_DEBUG("interfaceFormat=" << interfaceFormat);
|
||||||
|
RIVER_DEBUG("hardwareFormat=" << hardwareFormat);
|
||||||
|
|
||||||
|
m_rtaudioFrameSize = nbChunk;
|
||||||
|
RIVER_INFO("Open output stream nbChannels=" << params.nChannels);
|
||||||
|
enum audio::orchestra::error err = audio::orchestra::error_none;
|
||||||
|
if (m_isInput == true) {
|
||||||
|
m_process.setInputConfig(hardwareFormat);
|
||||||
|
m_process.setOutputConfig(interfaceFormat);
|
||||||
|
err = m_interface.openStream(nullptr, ¶ms,
|
||||||
|
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||||
|
std::bind(&audio::river::io::NodeFile::recordCallback,
|
||||||
|
this,
|
||||||
|
std::placeholders::_1,
|
||||||
|
std::placeholders::_2,
|
||||||
|
std::placeholders::_5,
|
||||||
|
std::placeholders::_6),
|
||||||
|
option
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
m_process.setInputConfig(interfaceFormat);
|
||||||
|
m_process.setOutputConfig(hardwareFormat);
|
||||||
|
err = m_interface.openStream(¶ms, nullptr,
|
||||||
|
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||||
|
std::bind(&audio::river::io::NodeFile::playbackCallback,
|
||||||
|
this,
|
||||||
|
std::placeholders::_3,
|
||||||
|
std::placeholders::_4,
|
||||||
|
std::placeholders::_5,
|
||||||
|
std::placeholders::_6),
|
||||||
|
option
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (err != audio::orchestra::error_none) {
|
||||||
|
RIVER_ERROR("Create stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") << " can not create stream " << err);
|
||||||
|
}
|
||||||
|
m_process.updateInterAlgo();
|
||||||
|
}
|
||||||
|
|
||||||
|
audio::river::io::NodeFile::~NodeFile() {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
RIVER_INFO("close input stream");
|
||||||
|
if (m_interface.isStreamOpen() ) {
|
||||||
|
m_interface.closeStream();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void audio::river::io::NodeFile::threadCallback() {
|
||||||
|
etk::thread::setName("RIVER file-IO");
|
||||||
|
// open the file
|
||||||
|
|
||||||
|
while (m_alive == true) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void audio::river::io::NodeFile::start() {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
if (m_thread != nullptr) {
|
||||||
|
RIVER_ERROR("Start stream : '" << m_name << "' mode=" << (m_isInput?"read":"write") << " ==> already started ..." );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_alive = true;
|
||||||
|
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"read":"write") );
|
||||||
|
m_thread = ememory::makeShared<std::thread>(&audio::river::io::NodeFile::threadCallback2, this);
|
||||||
|
m_time = audio::Time::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
void audio::river::io::NodeFile::stop() {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
m_alive = false;
|
||||||
|
RIVER_INFO("Stop stream : '" << m_name << "' mode=" << (m_isInput?"read":"write") );
|
||||||
|
// TODO : Need join ...
|
||||||
|
m_thread->join();
|
||||||
|
m_thread.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
54
audio/river/io/NodeFile.hpp
Normal file
54
audio/river/io/NodeFile.hpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef AUDIO_RIVER_BUILD_FILE
|
||||||
|
|
||||||
|
#include <audio/river/io/Node.hpp>
|
||||||
|
#include <audio/orchestra/Interface.hpp>
|
||||||
|
|
||||||
|
namespace audio {
|
||||||
|
namespace river {
|
||||||
|
namespace io {
|
||||||
|
class Manager;
|
||||||
|
class Group;
|
||||||
|
/**
|
||||||
|
* @brief Low level node that is manage on the interface with the extern lib airtaudio
|
||||||
|
*/
|
||||||
|
class NodeFile : public audio::river::io::Node {
|
||||||
|
friend class audio::river::io::Group;
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* @brief Constructor
|
||||||
|
*/
|
||||||
|
NodeFile(const std::string& _name, const ejson::Object& _config);
|
||||||
|
public:
|
||||||
|
static ememory::SharedPtr<NodeFile> create(const std::string& _name, const ejson::Object& _config);
|
||||||
|
/**
|
||||||
|
* @brief Destructor
|
||||||
|
*/
|
||||||
|
virtual ~NodeFile();
|
||||||
|
virtual bool isHarwareNode() {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
protected:
|
||||||
|
audio::Time m_time; //!< time of the flow
|
||||||
|
etk::FSNode m_file; //!< File interface
|
||||||
|
bool m_restartAtEnd; //!< The read is done in loop
|
||||||
|
uint32_t m_sampleRate; //!< Sample Rate of the Raw file
|
||||||
|
audio::format m_format; //!< Format of the file
|
||||||
|
std::vector<audio::channel> m_map; //!< Map of the file
|
||||||
|
ememory::SharedPtr<std::thread> m_thread; //!< playing thread of the flow
|
||||||
|
std::atomic<bool> m_alive; //!< thread is active
|
||||||
|
protected:
|
||||||
|
virtual void start();
|
||||||
|
virtual void stop();
|
||||||
|
virtual void threadCallback():
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@@ -4,46 +4,43 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <audio/river/io/NodeMuxer.h>
|
#include <audio/river/io/NodeMuxer.hpp>
|
||||||
#include <audio/river/debug.h>
|
#include <audio/river/debug.hpp>
|
||||||
#include <etk/types.h>
|
#include <etk/types.hpp>
|
||||||
#include <etk/memory.h>
|
#include <ememory/memory.hpp>
|
||||||
#include <etk/functional.h>
|
#include <functional>
|
||||||
|
|
||||||
#undef __class__
|
ememory::SharedPtr<audio::river::io::NodeMuxer> audio::river::io::NodeMuxer::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
#define __class__ "io::NodeMuxer"
|
return ememory::SharedPtr<audio::river::io::NodeMuxer>(new audio::river::io::NodeMuxer(_name, _config));
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::io::NodeMuxer> audio::river::io::NodeMuxer::create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) {
|
|
||||||
return std11::shared_ptr<audio::river::io::NodeMuxer>(new audio::river::io::NodeMuxer(_name, _config));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::Interface> audio::river::io::NodeMuxer::createInput(float _freq,
|
ememory::SharedPtr<audio::river::Interface> audio::river::io::NodeMuxer::createInput(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::string& _objectName,
|
const std::string& _objectName,
|
||||||
const std::string& _name) {
|
const std::string& _name) {
|
||||||
// check if the output exist
|
// check if the output exist
|
||||||
const std11::shared_ptr<const ejson::Object> tmppp = m_config->getObject(_objectName);
|
const ejson::Object tmppp = m_config[_objectName].toObject();
|
||||||
if (tmppp == nullptr) {
|
if (tmppp.exist() == false) {
|
||||||
RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config->getKeys());
|
RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config.getKeys());
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
std::string streamName = tmppp->getStringValue("map-on", "error");
|
std::string streamName = tmppp["map-on"].toString().get("error");
|
||||||
|
|
||||||
|
|
||||||
// check if it is an Output:
|
// check if it is an Output:
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp["io"].toString().get("error");
|
||||||
if ( type != "input"
|
if ( type != "input"
|
||||||
&& type != "feedback") {
|
&& type != "feedback") {
|
||||||
RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type);
|
RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type);
|
||||||
return std11::shared_ptr<audio::river::Interface>();
|
return ememory::SharedPtr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
// get global hardware interface:
|
// get global hardware interface:
|
||||||
std11::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
|
||||||
// get the output or input channel :
|
// get the output or input channel :
|
||||||
std11::shared_ptr<audio::river::io::Node> node = manager->getNode(streamName);
|
ememory::SharedPtr<audio::river::io::Node> node = manager->getNode(streamName);
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std11::shared_ptr<audio::river::Interface> interface;
|
ememory::SharedPtr<audio::river::Interface> interface;
|
||||||
interface = audio::river::Interface::create(_freq, _map, _format, node, tmppp);
|
interface = audio::river::Interface::create(_freq, _map, _format, node, tmppp);
|
||||||
if (interface != nullptr) {
|
if (interface != nullptr) {
|
||||||
interface->setName(_name);
|
interface->setName(_name);
|
||||||
@@ -52,7 +49,7 @@ std11::shared_ptr<audio::river::Interface> audio::river::io::NodeMuxer::createIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const ejson::Object& _config) :
|
||||||
Node(_name, _config) {
|
Node(_name, _config) {
|
||||||
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
||||||
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
||||||
@@ -88,14 +85,14 @@ audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std11::sh
|
|||||||
RIVER_ERROR("Can not opne virtual device ... map-on-input-1 in " << _name);
|
RIVER_ERROR("Can not opne virtual device ... map-on-input-1 in " << _name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std11::shared_ptr<const ejson::Array> listChannelMap = m_config->getArray("input-1-remap");
|
const ejson::Array listChannelMap = m_config["input-1-remap"].toArray();
|
||||||
if ( listChannelMap == nullptr
|
if ( listChannelMap.exist() == false
|
||||||
|| listChannelMap->size() == 0) {
|
|| listChannelMap.size() == 0) {
|
||||||
m_mapInput1 = m_interfaceInput1->getInterfaceFormat().getMap();
|
m_mapInput1 = m_interfaceInput1->getInterfaceFormat().getMap();
|
||||||
} else {
|
} else {
|
||||||
m_mapInput1.clear();
|
m_mapInput1.clear();
|
||||||
for (size_t iii=0; iii<listChannelMap->size(); ++iii) {
|
for (const auto it : listChannelMap) {
|
||||||
std::string value = listChannelMap->getStringValue(iii);
|
std::string value = it.toString().get();
|
||||||
m_mapInput1.push_back(audio::getChannelFromString(value));
|
m_mapInput1.push_back(audio::getChannelFromString(value));
|
||||||
}
|
}
|
||||||
if (m_mapInput1.size() != m_interfaceInput1->getInterfaceFormat().getMap().size()) {
|
if (m_mapInput1.size() != m_interfaceInput1->getInterfaceFormat().getMap().size()) {
|
||||||
@@ -114,14 +111,14 @@ audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std11::sh
|
|||||||
RIVER_ERROR("Can not opne virtual device ... map-on-input-2 in " << _name);
|
RIVER_ERROR("Can not opne virtual device ... map-on-input-2 in " << _name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
listChannelMap = m_config->getArray("input-2-remap");
|
const ejson::Array listChannelMap2 = m_config["input-2-remap"].toArray();
|
||||||
if ( listChannelMap == nullptr
|
if ( listChannelMap2.exist() == false
|
||||||
|| listChannelMap->size() == 0) {
|
|| listChannelMap2.size() == 0) {
|
||||||
m_mapInput2 = m_interfaceInput2->getInterfaceFormat().getMap();
|
m_mapInput2 = m_interfaceInput2->getInterfaceFormat().getMap();
|
||||||
} else {
|
} else {
|
||||||
m_mapInput2.clear();
|
m_mapInput2.clear();
|
||||||
for (size_t iii=0; iii<listChannelMap->size(); ++iii) {
|
for (const auto it : listChannelMap2) {
|
||||||
std::string value = listChannelMap->getStringValue(iii);
|
std::string value = it.toString().get();
|
||||||
m_mapInput2.push_back(audio::getChannelFromString(value));
|
m_mapInput2.push_back(audio::getChannelFromString(value));
|
||||||
}
|
}
|
||||||
if (m_mapInput2.size() != m_interfaceInput2->getInterfaceFormat().getMap().size()) {
|
if (m_mapInput2.size() != m_interfaceInput2->getInterfaceFormat().getMap().size()) {
|
||||||
@@ -131,28 +128,28 @@ audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std11::sh
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceInput1->setInputCallback(std11::bind(&audio::river::io::NodeMuxer::onDataReceivedInput1,
|
m_interfaceInput1->setInputCallback(std::bind(&audio::river::io::NodeMuxer::onDataReceivedInput1,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceInput2->setInputCallback(std11::bind(&audio::river::io::NodeMuxer::onDataReceivedInput2,
|
m_interfaceInput2->setInputCallback(std::bind(&audio::river::io::NodeMuxer::onDataReceivedInput2,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
|
|
||||||
m_bufferInput1.setCapacity(std11::chrono::milliseconds(1000),
|
m_bufferInput1.setCapacity(std::chrono::milliseconds(1000),
|
||||||
audio::getFormatBytes(hardwareFormat.getFormat())*m_mapInput1.size(),
|
audio::getFormatBytes(hardwareFormat.getFormat())*m_mapInput1.size(),
|
||||||
hardwareFormat.getFrequency());
|
hardwareFormat.getFrequency());
|
||||||
m_bufferInput2.setCapacity(std11::chrono::milliseconds(1000),
|
m_bufferInput2.setCapacity(std::chrono::milliseconds(1000),
|
||||||
audio::getFormatBytes(hardwareFormat.getFormat())*m_mapInput2.size(),
|
audio::getFormatBytes(hardwareFormat.getFormat())*m_mapInput2.size(),
|
||||||
hardwareFormat.getFrequency());
|
hardwareFormat.getFrequency());
|
||||||
|
|
||||||
@@ -167,7 +164,7 @@ audio::river::io::NodeMuxer::~NodeMuxer() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void audio::river::io::NodeMuxer::start() {
|
void audio::river::io::NodeMuxer::start() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
||||||
if (m_interfaceInput1 != nullptr) {
|
if (m_interfaceInput1 != nullptr) {
|
||||||
RIVER_INFO("Start FEEDBACK : ");
|
RIVER_INFO("Start FEEDBACK : ");
|
||||||
@@ -180,7 +177,7 @@ void audio::river::io::NodeMuxer::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::NodeMuxer::stop() {
|
void audio::river::io::NodeMuxer::stop() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
if (m_interfaceInput1 != nullptr) {
|
if (m_interfaceInput1 != nullptr) {
|
||||||
m_interfaceInput1->stop();
|
m_interfaceInput1->stop();
|
||||||
}
|
}
|
||||||
@@ -196,15 +193,17 @@ void audio::river::io::NodeMuxer::onDataReceivedInput1(const void* _data,
|
|||||||
enum audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
RIVER_DEBUG("Microphone Time=" << _time << " _nbChunk=" << _nbChunk << " _map=" << _map << " _format=" << _format << " freq=" << _frequency);
|
RIVER_PRINT("Input-1 Time=" << _time << " _nbChunk=" << _nbChunk << " _map=" << _map << " _format=" << _format << " freq=" << _frequency);
|
||||||
RIVER_DEBUG(" next=" << _time + audio::Duration(0, _nbChunk*1000000000LL/int64_t(_frequency)) );
|
RIVER_DEBUG(" next=" << _time + audio::Duration(0, _nbChunk*1000000000LL/int64_t(_frequency)) );
|
||||||
|
/*
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
RIVER_ERROR("call wrong type ... (need int16_t)");
|
RIVER_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// push data synchronize
|
// push data synchronize
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
m_bufferInput1.write(_data, _nbChunk, _time);
|
m_bufferInput1.write(_data, _nbChunk, _time);
|
||||||
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_Microphone.raw", _data, _nbChunk*_map.size());
|
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_muxer_input_1.raw", _data, _nbChunk*_map.size());
|
||||||
process();
|
process();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,15 +213,17 @@ void audio::river::io::NodeMuxer::onDataReceivedInput2(const void* _data,
|
|||||||
enum audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
RIVER_DEBUG("FeedBack Time=" << _time << " _nbChunk=" << _nbChunk << " _map=" << _map << " _format=" << _format << " freq=" << _frequency);
|
RIVER_PRINT("Input-2 Time=" << _time << " _nbChunk=" << _nbChunk << " _map=" << _map << " _format=" << _format << " freq=" << _frequency);
|
||||||
RIVER_DEBUG(" next=" << _time + audio::Duration(0, _nbChunk*1000000000LL/int64_t(_frequency)) );
|
RIVER_DEBUG(" next=" << _time + audio::Duration(0, _nbChunk*1000000000LL/int64_t(_frequency)) );
|
||||||
|
/*
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
RIVER_ERROR("call wrong type ... (need int16_t)");
|
RIVER_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// push data synchronize
|
// push data synchronize
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
m_bufferInput2.write(_data, _nbChunk, _time);
|
m_bufferInput2.write(_data, _nbChunk, _time);
|
||||||
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_FeedBack.raw", _data, _nbChunk*_map.size());
|
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_muxer_input_2.raw", _data, _nbChunk*_map.size());
|
||||||
process();
|
process();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +234,7 @@ void audio::river::io::NodeMuxer::process() {
|
|||||||
if (m_bufferInput2.getSize() <= 256) {
|
if (m_bufferInput2.getSize() <= 256) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RIVER_PRINT("process : s1=" << m_bufferInput1.getSize() << " s2=" << m_bufferInput2.getSize());
|
||||||
audio::Time in1Time = m_bufferInput1.getReadTimeStamp();
|
audio::Time in1Time = m_bufferInput1.getReadTimeStamp();
|
||||||
audio::Time in2Time = m_bufferInput2.getReadTimeStamp();
|
audio::Time in2Time = m_bufferInput2.getReadTimeStamp();
|
||||||
audio::Duration delta;
|
audio::Duration delta;
|
||||||
@@ -241,18 +243,17 @@ void audio::river::io::NodeMuxer::process() {
|
|||||||
} else {
|
} else {
|
||||||
delta = in1Time - in2Time;
|
delta = in1Time - in2Time;
|
||||||
}
|
}
|
||||||
|
RIVER_VERBOSE("check delta " << delta.count() << " > " << m_sampleTime.count());
|
||||||
RIVER_INFO("check delta " << delta.count() << " > " << m_sampleTime.count());
|
|
||||||
if (delta > m_sampleTime) {
|
if (delta > m_sampleTime) {
|
||||||
// Synchronize if possible
|
// Synchronize if possible
|
||||||
if (in1Time < in2Time) {
|
if (in1Time < in2Time) {
|
||||||
RIVER_INFO("in1Time < in2Time : Change Microphone time start " << in2Time);
|
RIVER_INFO("in1Time < in2Time : Change Input-1 time start " << in2Time);
|
||||||
RIVER_INFO(" old time stamp=" << m_bufferInput1.getReadTimeStamp());
|
RIVER_INFO(" old time stamp=" << m_bufferInput1.getReadTimeStamp());
|
||||||
m_bufferInput1.setReadPosition(in2Time);
|
m_bufferInput1.setReadPosition(in2Time);
|
||||||
RIVER_INFO(" new time stamp=" << m_bufferInput1.getReadTimeStamp());
|
RIVER_INFO(" new time stamp=" << m_bufferInput1.getReadTimeStamp());
|
||||||
}
|
}
|
||||||
if (in1Time > in2Time) {
|
if (in1Time > in2Time) {
|
||||||
RIVER_INFO("in1Time > in2Time : Change FeedBack time start " << in1Time);
|
RIVER_INFO("in1Time > in2Time : Change Input-2 time start " << in1Time);
|
||||||
RIVER_INFO(" old time stamp=" << m_bufferInput2.getReadTimeStamp());
|
RIVER_INFO(" old time stamp=" << m_bufferInput2.getReadTimeStamp());
|
||||||
m_bufferInput2.setReadPosition(in1Time);
|
m_bufferInput2.setReadPosition(in1Time);
|
||||||
RIVER_INFO(" new time stamp=" << m_bufferInput2.getReadTimeStamp());
|
RIVER_INFO(" new time stamp=" << m_bufferInput2.getReadTimeStamp());
|
||||||
@@ -275,17 +276,17 @@ void audio::river::io::NodeMuxer::process() {
|
|||||||
}
|
}
|
||||||
std::vector<uint8_t> dataIn1;
|
std::vector<uint8_t> dataIn1;
|
||||||
std::vector<uint8_t> dataIn2;
|
std::vector<uint8_t> dataIn2;
|
||||||
dataIn1.resize(256*sizeof(int16_t)*m_mapInput1.size(), 0);
|
dataIn1.resize(256*audio::getFormatBytes(getInterfaceFormat().getFormat())*m_mapInput1.size(), 0);
|
||||||
dataIn2.resize(256*sizeof(int16_t)*m_mapInput2.size(), 0);
|
dataIn2.resize(256*audio::getFormatBytes(getInterfaceFormat().getFormat())*m_mapInput2.size(), 0);
|
||||||
m_data.resize(256*sizeof(int16_t)*getInterfaceFormat().getMap().size(), 0);
|
m_data.resize(256*audio::getFormatBytes(getInterfaceFormat().getFormat())*getInterfaceFormat().getMap().size(), 0);
|
||||||
while (true) {
|
while (true) {
|
||||||
in1Time = m_bufferInput1.getReadTimeStamp();
|
in1Time = m_bufferInput1.getReadTimeStamp();
|
||||||
in2Time = m_bufferInput2.getReadTimeStamp();
|
in2Time = m_bufferInput2.getReadTimeStamp();
|
||||||
//RIVER_INFO(" process 256 samples ... in1Time=" << in1Time << " in2Time=" << in2Time << " delta = " << (in1Time-in2Time).count());
|
//RIVER_INFO(" process 256 samples ... in1Time=" << in1Time << " in2Time=" << in2Time << " delta = " << (in1Time-in2Time).count());
|
||||||
m_bufferInput1.read(&dataIn1[0], 256);
|
m_bufferInput1.read(&dataIn1[0], 256);
|
||||||
m_bufferInput2.read(&dataIn2[0], 256);
|
m_bufferInput2.read(&dataIn2[0], 256);
|
||||||
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_INPUT1.raw", &dataIn1[0], 256 * m_mapInput1.size());
|
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_muxer_output_1.raw", &dataIn1[0], 256 * m_mapInput1.size());
|
||||||
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_INPUT2.raw", &dataIn2[0], 256 * m_mapInput2.size());
|
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_muxer_output_2.raw", &dataIn2[0], 256 * m_mapInput2.size());
|
||||||
// if threaded : send event / otherwise, process ...
|
// if threaded : send event / otherwise, process ...
|
||||||
processMuxer(&dataIn1[0], &dataIn2[0], 256, in1Time);
|
processMuxer(&dataIn1[0], &dataIn2[0], 256, in1Time);
|
||||||
if ( m_bufferInput1.getSize() <= 256
|
if ( m_bufferInput1.getSize() <= 256
|
||||||
@@ -460,7 +461,7 @@ void audio::river::io::NodeMuxer::generateDot(etk::FSNode& _node) {
|
|||||||
if (m_listAvaillable[iii].expired() == true) {
|
if (m_listAvaillable[iii].expired() == true) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std11::shared_ptr<audio::river::Interface> element = m_listAvaillable[iii].lock();
|
ememory::SharedPtr<audio::river::Interface> element = m_listAvaillable[iii].lock();
|
||||||
if (element == nullptr) {
|
if (element == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -3,13 +3,11 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef __AUDIO_RIVER_IO_NODE_MUXER_H__
|
#include <audio/river/io/Node.hpp>
|
||||||
#define __AUDIO_RIVER_IO_NODE_MUXER_H__
|
#include <audio/river/Interface.hpp>
|
||||||
|
#include <audio/drain/CircularBuffer.hpp>
|
||||||
#include <audio/river/io/Node.h>
|
|
||||||
#include <audio/river/Interface.h>
|
|
||||||
#include <audio/drain/CircularBuffer.h>
|
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
@@ -20,9 +18,9 @@ namespace audio {
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NodeMuxer(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
|
NodeMuxer(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
static std11::shared_ptr<NodeMuxer> create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
|
static ememory::SharedPtr<NodeMuxer> create(const std::string& _name, const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@@ -30,9 +28,9 @@ namespace audio {
|
|||||||
protected:
|
protected:
|
||||||
virtual void start();
|
virtual void start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceInput1;
|
ememory::SharedPtr<audio::river::Interface> m_interfaceInput1;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceInput2;
|
ememory::SharedPtr<audio::river::Interface> m_interfaceInput2;
|
||||||
std11::shared_ptr<audio::river::Interface> createInput(float _freq,
|
ememory::SharedPtr<audio::river::Interface> createInput(float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::string& _streamName,
|
const std::string& _streamName,
|
||||||
@@ -66,5 +64,3 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -6,18 +6,15 @@
|
|||||||
|
|
||||||
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
||||||
|
|
||||||
#include <audio/river/io/NodeOrchestra.h>
|
#include <audio/river/io/NodeOrchestra.hpp>
|
||||||
#include <audio/river/debug.h>
|
#include <audio/river/debug.hpp>
|
||||||
#include <etk/memory.h>
|
#include <ememory/memory.hpp>
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "io::NodeOrchestra"
|
|
||||||
|
|
||||||
int32_t audio::river::io::NodeOrchestra::recordCallback(const void* _inputBuffer,
|
int32_t audio::river::io::NodeOrchestra::recordCallback(const void* _inputBuffer,
|
||||||
const audio::Time& _timeInput,
|
const audio::Time& _timeInput,
|
||||||
uint32_t _nbChunk,
|
uint32_t _nbChunk,
|
||||||
const std::vector<audio::orchestra::status>& _status) {
|
const std::vector<audio::orchestra::status>& _status) {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
// TODO : Manage status ...
|
// TODO : Manage status ...
|
||||||
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
|
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
|
||||||
newInput(_inputBuffer, _nbChunk, _timeInput);
|
newInput(_inputBuffer, _nbChunk, _timeInput);
|
||||||
@@ -28,20 +25,20 @@ int32_t audio::river::io::NodeOrchestra::playbackCallback(void* _outputBuffer,
|
|||||||
const audio::Time& _timeOutput,
|
const audio::Time& _timeOutput,
|
||||||
uint32_t _nbChunk,
|
uint32_t _nbChunk,
|
||||||
const std::vector<audio::orchestra::status>& _status) {
|
const std::vector<audio::orchestra::status>& _status) {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
// TODO : Manage status ...
|
// TODO : Manage status ...
|
||||||
RIVER_VERBOSE("data Output size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
|
RIVER_VERBOSE("data Output size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size() << " data=" << uint64_t(_outputBuffer));
|
||||||
newOutput(_outputBuffer, _nbChunk, _timeOutput);
|
newOutput(_outputBuffer, _nbChunk, _timeOutput);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::io::NodeOrchestra> audio::river::io::NodeOrchestra::create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) {
|
ememory::SharedPtr<audio::river::io::NodeOrchestra> audio::river::io::NodeOrchestra::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
return std11::shared_ptr<audio::river::io::NodeOrchestra>(new audio::river::io::NodeOrchestra(_name, _config));
|
return ememory::SharedPtr<audio::river::io::NodeOrchestra>(new audio::river::io::NodeOrchestra(_name, _config));
|
||||||
}
|
}
|
||||||
|
|
||||||
audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const ejson::Object& _config) :
|
||||||
Node(_name, _config) {
|
Node(_name, _config) {
|
||||||
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
||||||
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
||||||
@@ -52,25 +49,25 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s
|
|||||||
},
|
},
|
||||||
nb-chunk:1024 # number of chunk to open device (create the latency anf the frequency to call user)
|
nb-chunk:1024 # number of chunk to open device (create the latency anf the frequency to call user)
|
||||||
*/
|
*/
|
||||||
std::string typeInterface = audio::orchestra::type_undefined;
|
std::string typeInterface = audio::orchestra::typeUndefined;
|
||||||
std::string streamName = "default";
|
std::string streamName = "default";
|
||||||
const std11::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on");
|
const ejson::Object tmpObject = m_config["map-on"].toObject();
|
||||||
if (tmpObject == nullptr) {
|
if (tmpObject.exist() == false) {
|
||||||
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
||||||
} else {
|
} else {
|
||||||
typeInterface = tmpObject->getStringValue("interface", audio::orchestra::type_undefined);
|
typeInterface = tmpObject["interface"].toString().get(audio::orchestra::typeUndefined);
|
||||||
if (typeInterface == "auto") {
|
if (typeInterface == "auto") {
|
||||||
typeInterface = audio::orchestra::type_undefined;
|
typeInterface = audio::orchestra::typeUndefined;
|
||||||
}
|
}
|
||||||
streamName = tmpObject->getStringValue("name", "default");
|
streamName = tmpObject["name"].toString().get("default");
|
||||||
}
|
}
|
||||||
int32_t nbChunk = m_config->getNumberValue("nb-chunk", 1024);
|
int32_t nbChunk = m_config["nb-chunk"].toNumber().get(1024);
|
||||||
|
|
||||||
// intanciate specific API ...
|
// intanciate specific API ...
|
||||||
m_interface.instanciate(typeInterface);
|
m_interface.instanciate(typeInterface);
|
||||||
m_interface.setName(_name);
|
m_interface.setName(_name);
|
||||||
// TODO : Check return ...
|
// TODO : Check return ...
|
||||||
std::string type = m_config->getStringValue("type", "int16");
|
std::string type = m_config["type"].toString().get("int16");
|
||||||
if (streamName == "") {
|
if (streamName == "") {
|
||||||
streamName = "default";
|
streamName = "default";
|
||||||
}
|
}
|
||||||
@@ -148,7 +145,8 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s
|
|||||||
RIVER_CRITICAL("auto set format no element in the configuration: " << m_info.nativeFormats);
|
RIVER_CRITICAL("auto set format no element in the configuration: " << m_info.nativeFormats);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RIVER_CRITICAL("Can not manage input transforamtion: " << hardwareFormat.getFormat() << " not in " << m_info.nativeFormats);
|
RIVER_ERROR("Can not manage input transforamtion: " << hardwareFormat.getFormat() << " not in " << m_info.nativeFormats);
|
||||||
|
hardwareFormat.setFormat(hardwareFormat.getFormat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (etk::isIn(hardwareFormat.getFrequency(), m_info.sampleRates) == false) {
|
if (etk::isIn(hardwareFormat.getFrequency(), m_info.sampleRates) == false) {
|
||||||
@@ -174,7 +172,7 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s
|
|||||||
hardwareFormat.setFrequency(m_info.sampleRates[0]);
|
hardwareFormat.setFrequency(m_info.sampleRates[0]);
|
||||||
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency() << "(first element in list) in " << m_info.sampleRates);
|
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency() << "(first element in list) in " << m_info.sampleRates);
|
||||||
} else {
|
} else {
|
||||||
RIVER_CRITICAL("Can not manage input transforamtion:" << hardwareFormat.getFrequency() << " not in " << m_info.sampleRates);
|
RIVER_ERROR("Can not manage input transforamtion:" << hardwareFormat.getFrequency() << " not in " << m_info.sampleRates);
|
||||||
}
|
}
|
||||||
interfaceFormat.setFrequency(hardwareFormat.getFrequency());
|
interfaceFormat.setFrequency(hardwareFormat.getFrequency());
|
||||||
}
|
}
|
||||||
@@ -186,10 +184,10 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s
|
|||||||
params.deviceName = streamName;
|
params.deviceName = streamName;
|
||||||
params.nChannels = hardwareFormat.getMap().size();
|
params.nChannels = hardwareFormat.getMap().size();
|
||||||
if (m_info.channels.size() < params.nChannels) {
|
if (m_info.channels.size() < params.nChannels) {
|
||||||
RIVER_CRITICAL("Can not open hardware device with more channel (" << params.nChannels << ") that is autorized by hardware (" << m_info.channels.size() << ").");
|
RIVER_ERROR("Can not open hardware device with more channel (" << params.nChannels << ") that is autorized by hardware (" << m_info.channels.size() << ").");
|
||||||
}
|
}
|
||||||
audio::orchestra::StreamOptions option;
|
audio::orchestra::StreamOptions option;
|
||||||
etk::from_string(option.mode, tmpObject->getStringValue("timestamp-mode", "soft"));
|
etk::from_string(option.mode, tmpObject["timestamp-mode"].toString().get("soft"));
|
||||||
|
|
||||||
RIVER_DEBUG("interfaceFormat=" << interfaceFormat);
|
RIVER_DEBUG("interfaceFormat=" << interfaceFormat);
|
||||||
RIVER_DEBUG("hardwareFormat=" << hardwareFormat);
|
RIVER_DEBUG("hardwareFormat=" << hardwareFormat);
|
||||||
@@ -202,12 +200,12 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s
|
|||||||
m_process.setOutputConfig(interfaceFormat);
|
m_process.setOutputConfig(interfaceFormat);
|
||||||
err = m_interface.openStream(nullptr, ¶ms,
|
err = m_interface.openStream(nullptr, ¶ms,
|
||||||
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||||
std11::bind(&audio::river::io::NodeOrchestra::recordCallback,
|
std::bind(&audio::river::io::NodeOrchestra::recordCallback,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6),
|
std::placeholders::_6),
|
||||||
option
|
option
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -215,12 +213,12 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s
|
|||||||
m_process.setOutputConfig(hardwareFormat);
|
m_process.setOutputConfig(hardwareFormat);
|
||||||
err = m_interface.openStream(¶ms, nullptr,
|
err = m_interface.openStream(¶ms, nullptr,
|
||||||
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||||
std11::bind(&audio::river::io::NodeOrchestra::playbackCallback,
|
std::bind(&audio::river::io::NodeOrchestra::playbackCallback,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6),
|
std::placeholders::_6),
|
||||||
option
|
option
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -231,7 +229,7 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s
|
|||||||
}
|
}
|
||||||
|
|
||||||
audio::river::io::NodeOrchestra::~NodeOrchestra() {
|
audio::river::io::NodeOrchestra::~NodeOrchestra() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
RIVER_INFO("close input stream");
|
RIVER_INFO("close input stream");
|
||||||
if (m_interface.isStreamOpen() ) {
|
if (m_interface.isStreamOpen() ) {
|
||||||
m_interface.closeStream();
|
m_interface.closeStream();
|
||||||
@@ -239,7 +237,7 @@ audio::river::io::NodeOrchestra::~NodeOrchestra() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void audio::river::io::NodeOrchestra::start() {
|
void audio::river::io::NodeOrchestra::start() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
||||||
enum audio::orchestra::error err = m_interface.startStream();
|
enum audio::orchestra::error err = m_interface.startStream();
|
||||||
if (err != audio::orchestra::error_none) {
|
if (err != audio::orchestra::error_none) {
|
||||||
@@ -248,7 +246,7 @@ void audio::river::io::NodeOrchestra::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::NodeOrchestra::stop() {
|
void audio::river::io::NodeOrchestra::stop() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
RIVER_INFO("Stop stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
RIVER_INFO("Stop stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
||||||
enum audio::orchestra::error err = m_interface.stopStream();
|
enum audio::orchestra::error err = m_interface.stopStream();
|
||||||
if (err != audio::orchestra::error_none) {
|
if (err != audio::orchestra::error_none) {
|
||||||
|
@@ -3,14 +3,12 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __AUDIO_RIVER_IO_NODE_AIRTAUDIO_H__
|
|
||||||
#define __AUDIO_RIVER_IO_NODE_AIRTAUDIO_H__
|
|
||||||
|
|
||||||
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
||||||
|
|
||||||
#include <audio/river/io/Node.h>
|
#include <audio/river/io/Node.hpp>
|
||||||
#include <audio/orchestra/Interface.h>
|
#include <audio/orchestra/Interface.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
@@ -26,9 +24,9 @@ namespace audio {
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NodeOrchestra(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
|
NodeOrchestra(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
static std11::shared_ptr<NodeOrchestra> create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
|
static ememory::SharedPtr<NodeOrchestra> create(const std::string& _name, const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@@ -73,6 +71,3 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -6,14 +6,11 @@
|
|||||||
|
|
||||||
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
||||||
|
|
||||||
#include <audio/river/io/NodePortAudio.h>
|
#include <audio/river/io/NodePortAudio.hpp>
|
||||||
#include <audio/river/debug.h>
|
#include <audio/river/debug.hpp>
|
||||||
#include <etk/memory.h>
|
#include <ememory/memory.hpp>
|
||||||
#include <audio/Time.h>
|
#include <audio/Time.hpp>
|
||||||
#include <audio/Duration.h>
|
#include <audio/Duration.hpp>
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "io::NodePortAudio"
|
|
||||||
|
|
||||||
static int portAudioStreamCallback(const void *_input,
|
static int portAudioStreamCallback(const void *_input,
|
||||||
void *_output,
|
void *_output,
|
||||||
@@ -42,7 +39,7 @@ int32_t audio::river::io::NodePortAudio::duplexCallback(const void* _inputBuffer
|
|||||||
const audio::Time& _timeOutput,
|
const audio::Time& _timeOutput,
|
||||||
uint32_t _nbChunk,
|
uint32_t _nbChunk,
|
||||||
PaStreamCallbackFlags _status) {
|
PaStreamCallbackFlags _status) {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
// TODO : Manage status ...
|
// TODO : Manage status ...
|
||||||
if (_inputBuffer != nullptr) {
|
if (_inputBuffer != nullptr) {
|
||||||
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
|
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
|
||||||
@@ -56,11 +53,11 @@ int32_t audio::river::io::NodePortAudio::duplexCallback(const void* _inputBuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std11::shared_ptr<audio::river::io::NodePortAudio> audio::river::io::NodePortAudio::create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) {
|
ememory::SharedPtr<audio::river::io::NodePortAudio> audio::river::io::NodePortAudio::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
return std11::shared_ptr<audio::river::io::NodePortAudio>(new audio::river::io::NodePortAudio(_name, _config));
|
return ememory::SharedPtr<audio::river::io::NodePortAudio>(new audio::river::io::NodePortAudio(_name, _config));
|
||||||
}
|
}
|
||||||
|
|
||||||
audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const ejson::Object& _config) :
|
||||||
Node(_name, _config) {
|
Node(_name, _config) {
|
||||||
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
||||||
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
||||||
@@ -72,14 +69,14 @@ audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const s
|
|||||||
nb-chunk:1024 # number of chunk to open device (create the latency anf the frequency to call user)
|
nb-chunk:1024 # number of chunk to open device (create the latency anf the frequency to call user)
|
||||||
*/
|
*/
|
||||||
std::string streamName = "default";
|
std::string streamName = "default";
|
||||||
const std11::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on");
|
const ejson::Object tmpObject = m_config["map-on"].toObject();
|
||||||
if (tmpObject == nullptr) {
|
if (tmpObject.exist() == false) {
|
||||||
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
||||||
} else {
|
} else {
|
||||||
std::string value = tmpObject->getStringValue("interface", "default");
|
std::string value = tmpObject.getStringValue("interface", "default");
|
||||||
streamName = tmpObject->getStringValue("name", "default");
|
streamName = tmpObject.getStringValue("name", "default");
|
||||||
}
|
}
|
||||||
int32_t nbChunk = m_config->getNumberValue("nb-chunk", 1024);
|
int32_t nbChunk = m_config.getNumberValue("nb-chunk", 1024);
|
||||||
|
|
||||||
PaError err = 0;
|
PaError err = 0;
|
||||||
if (m_isInput == true) {
|
if (m_isInput == true) {
|
||||||
@@ -108,7 +105,7 @@ audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const s
|
|||||||
}
|
}
|
||||||
|
|
||||||
audio::river::io::NodePortAudio::~NodePortAudio() {
|
audio::river::io::NodePortAudio::~NodePortAudio() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
RIVER_INFO("close input stream");
|
RIVER_INFO("close input stream");
|
||||||
PaError err = Pa_CloseStream( m_stream );
|
PaError err = Pa_CloseStream( m_stream );
|
||||||
if( err != paNoError ) {
|
if( err != paNoError ) {
|
||||||
@@ -117,7 +114,7 @@ audio::river::io::NodePortAudio::~NodePortAudio() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void audio::river::io::NodePortAudio::start() {
|
void audio::river::io::NodePortAudio::start() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
||||||
PaError err = Pa_StartStream(m_stream);
|
PaError err = Pa_StartStream(m_stream);
|
||||||
if( err != paNoError ) {
|
if( err != paNoError ) {
|
||||||
@@ -126,7 +123,7 @@ void audio::river::io::NodePortAudio::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::river::io::NodePortAudio::stop() {
|
void audio::river::io::NodePortAudio::stop() {
|
||||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
RIVER_INFO("Stop stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
RIVER_INFO("Stop stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
|
||||||
PaError err = Pa_StopStream(m_stream);
|
PaError err = Pa_StopStream(m_stream);
|
||||||
if( err != paNoError ) {
|
if( err != paNoError ) {
|
||||||
|
@@ -3,29 +3,27 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __AUDIO_RIVER_IO_NODE_PORTAUDIO_H__
|
|
||||||
#define __AUDIO_RIVER_IO_NODE_PORTAUDIO_H__
|
|
||||||
|
|
||||||
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
||||||
|
|
||||||
#include <audio/river/Interface.h>
|
#include <audio/river/Interface.hpp>
|
||||||
#include <audio/river/io/Node.h>
|
#include <audio/river/io/Node.hpp>
|
||||||
#include <portaudio.h>
|
#include <portaudio/portaudio.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace river {
|
namespace river {
|
||||||
namespace io {
|
namespace io {
|
||||||
class Manager;
|
class Manager;
|
||||||
//! @not-in-doc
|
//! @not_in_doc
|
||||||
class NodePortAudio : public Node {
|
class NodePortAudio : public Node {
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NodePortAudio(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
|
NodePortAudio(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
static std11::shared_ptr<NodePortAudio> create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
|
static ememory::SharedPtr<NodePortAudio> create(const std::string& _name, const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@@ -51,5 +49,3 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -4,9 +4,9 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <audio/river/river.h>
|
#include <audio/river/river.hpp>
|
||||||
#include <audio/river/debug.h>
|
#include <audio/river/debug.hpp>
|
||||||
#include <audio/river/io/Manager.h>
|
#include <audio/river/io/Manager.hpp>
|
||||||
|
|
||||||
static bool river_isInit = false;
|
static bool river_isInit = false;
|
||||||
static std::string river_configFile = "";
|
static std::string river_configFile = "";
|
||||||
@@ -18,7 +18,7 @@ void audio::river::init(const std::string& _filename) {
|
|||||||
river_isInit = true;
|
river_isInit = true;
|
||||||
river_configFile = _filename;
|
river_configFile = _filename;
|
||||||
RIVER_DEBUG("init RIVER :" << river_configFile);
|
RIVER_DEBUG("init RIVER :" << river_configFile);
|
||||||
std11::shared_ptr<audio::river::io::Manager> mng = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> mng = audio::river::io::Manager::getInstance();
|
||||||
if (mng != nullptr) {
|
if (mng != nullptr) {
|
||||||
mng->init(river_configFile);
|
mng->init(river_configFile);
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ void audio::river::initString(const std::string& _config) {
|
|||||||
river_isInit = true;
|
river_isInit = true;
|
||||||
river_configFile = _config;
|
river_configFile = _config;
|
||||||
RIVER_DEBUG("init RIVER with config.");
|
RIVER_DEBUG("init RIVER with config.");
|
||||||
std11::shared_ptr<audio::river::io::Manager> mng = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> mng = audio::river::io::Manager::getInstance();
|
||||||
if (mng != nullptr) {
|
if (mng != nullptr) {
|
||||||
mng->initString(river_configFile);
|
mng->initString(river_configFile);
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ void audio::river::unInit() {
|
|||||||
if (river_isInit == true) {
|
if (river_isInit == true) {
|
||||||
river_isInit = false;
|
river_isInit = false;
|
||||||
RIVER_DEBUG("un-init RIVER.");
|
RIVER_DEBUG("un-init RIVER.");
|
||||||
std11::shared_ptr<audio::river::io::Manager> mng = audio::river::io::Manager::getInstance();
|
ememory::SharedPtr<audio::river::io::Manager> mng = audio::river::io::Manager::getInstance();
|
||||||
if (mng != nullptr) {
|
if (mng != nullptr) {
|
||||||
RIVER_ERROR("Can not get on the RIVER hardware manager !!!");
|
RIVER_ERROR("Can not get on the RIVER hardware manager !!!");
|
||||||
mng->unInit();
|
mng->unInit();
|
||||||
|
@@ -3,13 +3,16 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef __AUDIO_RIVER_H__
|
#include <etk/types.hpp>
|
||||||
#define __AUDIO_RIVER_H__
|
/**
|
||||||
|
* @brief Audio library namespace
|
||||||
#include <etk/types.h>
|
*/
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
|
/**
|
||||||
|
* @brief Audio-river library namespace
|
||||||
|
*/
|
||||||
namespace river {
|
namespace river {
|
||||||
/**
|
/**
|
||||||
* @brief Initialize the River Library
|
* @brief Initialize the River Library
|
||||||
@@ -36,5 +39,3 @@ namespace audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
1
authors.txt
Normal file
1
authors.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
MR Edouard DUPIN <yui.heero@gmail.com>
|
@@ -1,79 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.3)
|
|
||||||
project(audio_river)
|
|
||||||
|
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
||||||
|
|
||||||
## Find catkin macros and libraries
|
|
||||||
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
|
|
||||||
## is used, also find other catkin packages
|
|
||||||
find_package(catkin REQUIRED COMPONENTS
|
|
||||||
audio_drain
|
|
||||||
audio
|
|
||||||
audio_orchestra
|
|
||||||
ejson
|
|
||||||
)
|
|
||||||
|
|
||||||
###################################
|
|
||||||
## catkin specific configuration ##
|
|
||||||
###################################
|
|
||||||
## The catkin_package macro generates cmake config files for your package
|
|
||||||
## Declare things to be passed to dependent projects
|
|
||||||
## INCLUDE_DIRS: uncomment this if you package contains header files
|
|
||||||
## LIBRARIES: libraries you create in this project that dependent projects also need
|
|
||||||
## CATKIN_DEPENDS: catkin_packages dependent projects also need
|
|
||||||
## DEPENDS: system dependencies of this project that dependent projects also need
|
|
||||||
catkin_package(
|
|
||||||
INCLUDE_DIRS ../
|
|
||||||
LIBRARIES ${PROJECT_NAME}
|
|
||||||
CATKIN_DEPENDS audio_orchestra audio audio_drain ejson
|
|
||||||
DEPENDS system_lib
|
|
||||||
)
|
|
||||||
|
|
||||||
###########
|
|
||||||
## Build ##
|
|
||||||
###########
|
|
||||||
|
|
||||||
## Specify additional locations of header files
|
|
||||||
## Your package locations should be listed before other locations
|
|
||||||
include_directories(
|
|
||||||
..
|
|
||||||
${catkin_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
## Declare a cpp library
|
|
||||||
add_library(${PROJECT_NAME}
|
|
||||||
../audio/river/debug.cpp
|
|
||||||
../audio/river/river.cpp
|
|
||||||
../audio/river/Manager.cpp
|
|
||||||
../audio/river/Interface.cpp
|
|
||||||
../audio/river/io/Group.cpp
|
|
||||||
../audio/river/io/Node.cpp
|
|
||||||
../audio/river/io/NodeOrchestra.cpp
|
|
||||||
../audio/river/io/NodePortAudio.cpp
|
|
||||||
../audio/river/io/NodeAEC.cpp
|
|
||||||
../audio/river/io/NodeMuxer.cpp
|
|
||||||
../audio/river/io/Manager.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
add_definitions(-DAUDIO_RIVER_BUILD_ORCHESTRA)
|
|
||||||
|
|
||||||
## Specify libraries to link a library or executable target against
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
|
||||||
${catkin_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
||||||
#############
|
|
||||||
## Install ##
|
|
||||||
#############
|
|
||||||
|
|
||||||
## Mark executables and/or libraries for installation
|
|
||||||
install(TARGETS ${PROJECT_NAME}
|
|
||||||
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
|
||||||
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
|
||||||
)
|
|
||||||
|
|
||||||
## Mark cpp header files for installation
|
|
||||||
install(DIRECTORY ../audio/river/
|
|
||||||
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
|
||||||
FILES_MATCHING PATTERN "*.h"
|
|
||||||
)
|
|
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<package>
|
|
||||||
<name>audio_river</name>
|
|
||||||
<version>0.3.0</version>
|
|
||||||
<description>Ewol River Intrerface : Is to multiple acces on different format on Audio IO</description>
|
|
||||||
<maintainer email="yui.heero@gmail.com">Edouard DUPIN</maintainer>
|
|
||||||
<license>Apache-2.0</license>
|
|
||||||
<build_depend>ejson</build_depend>
|
|
||||||
<build_depend>audio</build_depend>
|
|
||||||
<build_depend>audio_orchestra</build_depend>
|
|
||||||
<build_depend>audio_drain</build_depend>
|
|
||||||
<buildtool_depend>catkin</buildtool_depend>
|
|
||||||
<run_depend>ejson</run_depend>
|
|
||||||
<run_depend>audio</run_depend>
|
|
||||||
<run_depend>audio_orchestra</run_depend>
|
|
||||||
<run_depend>audio_drain</run_depend>
|
|
||||||
</package>
|
|
@@ -1,41 +0,0 @@
|
|||||||
=?=RIVER: Bases =?=
|
|
||||||
__________________________________________________
|
|
||||||
[right][tutorial[000_Build | Next: Tutorals]][/right]
|
|
||||||
|
|
||||||
=== Overview:===
|
|
||||||
|
|
||||||
===User requires:===
|
|
||||||
To use ewol you need to know only C++ language. It could be usefull to know:
|
|
||||||
:** [b]Python[/b] for all build tool.
|
|
||||||
:** [b]git[/b] for all version management
|
|
||||||
:** [b]Audio[/b] Basic knowlege of audio streaming af data organisation.
|
|
||||||
|
|
||||||
=== Architecture:===
|
|
||||||
River has been designed to replace the pulseAudio basic asyncronous interface that create
|
|
||||||
more problem that it will solve. The second point is that is not enougth portable to be
|
|
||||||
embended in a proprietary software without distributing all the sources (Ios).
|
|
||||||
|
|
||||||
Start at this point we will have simple objectives :
|
|
||||||
:** manage multiple Low level interface: (done by the [lib[airtaudio | AirTAudio]] interface):
|
|
||||||
::** for linux
|
|
||||||
:::** Alsa
|
|
||||||
:::** Pulse
|
|
||||||
:::** Oss
|
|
||||||
::** for Mac-OsX
|
|
||||||
:::** CoreAudio
|
|
||||||
::** for IOs
|
|
||||||
:::** CoreAudio (embended version)
|
|
||||||
::** for Windows
|
|
||||||
:::** ASIO
|
|
||||||
::** For Android
|
|
||||||
:::** Java (JDK-6)
|
|
||||||
:** Synchronous interface ==> no delay and reduce latency
|
|
||||||
:** Manage the thread priority (need sometimes to be more reactive)
|
|
||||||
:** manage mixing of some flow (2 inputs stereo and the user want 1 input quad)
|
|
||||||
:** AEC Acoustic Echo Cancelation (TODO : in the current implementation we have a simple sound cutter)
|
|
||||||
:** Equalizer (done with [lib[drain | Drain])
|
|
||||||
:** Resmpling (done by the libspeexDSP)
|
|
||||||
:** Correct volume management (and configurable)
|
|
||||||
:** Fade-in and Fade-out (done with [lib[drain | Drain])
|
|
||||||
:** Channel reorganisation (done with [lib[drain | Drain])
|
|
||||||
:** A correct feedback interface
|
|
100
doc/build.md
Normal file
100
doc/build.md
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
Build lib & build sample {#audio_river_build}
|
||||||
|
========================
|
||||||
|
|
||||||
|
@tableofcontents
|
||||||
|
|
||||||
|
Download: {#audio_river_build_download}
|
||||||
|
=========
|
||||||
|
|
||||||
|
ege use some tools to manage source and build it:
|
||||||
|
|
||||||
|
need google repo: {#audio_river_build_download_repo}
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
see: http://source.android.com/source/downloading.html#installing-repo
|
||||||
|
|
||||||
|
On all platform:
|
||||||
|
```{.sh}
|
||||||
|
mkdir ~/.bin
|
||||||
|
PATH=~/.bin:$PATH
|
||||||
|
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
|
||||||
|
chmod a+x ~/.bin/repo
|
||||||
|
```
|
||||||
|
|
||||||
|
On ubuntu
|
||||||
|
```{.sh}
|
||||||
|
sudo apt-get install repo
|
||||||
|
```
|
||||||
|
|
||||||
|
On archlinux
|
||||||
|
```{.sh}
|
||||||
|
sudo pacman -S repo
|
||||||
|
```
|
||||||
|
|
||||||
|
lutin (build-system): {#audio_river_build_download_lutin}
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
```{.sh}
|
||||||
|
pip install lutin --user
|
||||||
|
# optionnal dependency of lutin (manage image changing size for application release)
|
||||||
|
pip install pillow --user
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
dependency: {#audio_river_build_download_dependency}
|
||||||
|
-----------
|
||||||
|
|
||||||
|
```{.sh}
|
||||||
|
mkdir -p WORKING_DIRECTORY/framework
|
||||||
|
cd WORKING_DIRECTORY/framework
|
||||||
|
repo init -u git://github.com/atria-soft/manifest.git
|
||||||
|
repo sync -j8
|
||||||
|
cd ../..
|
||||||
|
```
|
||||||
|
|
||||||
|
sources: {#audio_river_build_download_sources}
|
||||||
|
--------
|
||||||
|
|
||||||
|
They are already download in the repo manifest in:
|
||||||
|
|
||||||
|
```{.sh}
|
||||||
|
cd WORKING_DIRECTORY/framework/musicdsp/audio-river
|
||||||
|
```
|
||||||
|
|
||||||
|
Build: {#audio_river_build_build}
|
||||||
|
======
|
||||||
|
|
||||||
|
you must stay in zour working directory...
|
||||||
|
```{.sh}
|
||||||
|
cd WORKING_DIRECTORY
|
||||||
|
```
|
||||||
|
|
||||||
|
library: {#audio_river_build_build_library}
|
||||||
|
--------
|
||||||
|
|
||||||
|
```{.sh}
|
||||||
|
lutin -mdebug audio-river
|
||||||
|
```
|
||||||
|
|
||||||
|
Sample: {#audio_river_build_build_sample}
|
||||||
|
-------
|
||||||
|
|
||||||
|
```{.sh}
|
||||||
|
lutin -mdebug audio-river-sample-read?run
|
||||||
|
lutin -mdebug audio-river-sample-write?run
|
||||||
|
```
|
||||||
|
|
||||||
|
A fast way:
|
||||||
|
```{.sh}
|
||||||
|
lutin -mdebug audio-river-*
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Run sample: {#audio_river_build_run_sample}
|
||||||
|
===========
|
||||||
|
|
||||||
|
in distinct bash:
|
||||||
|
```{.sh}
|
||||||
|
lutin -mdebug audio-river-sample-read?run
|
||||||
|
lutin -mdebug audio-river-sample-write?run
|
||||||
|
```
|
77
doc/configFile.md
Normal file
77
doc/configFile.md
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
River configuration file {#audio_river_config_file}
|
||||||
|
========================
|
||||||
|
|
||||||
|
@tableofcontents
|
||||||
|
|
||||||
|
Objectifs: {#audio_river_config_file_objectif}
|
||||||
|
==========
|
||||||
|
|
||||||
|
- Understand the architecture of the configuration file.
|
||||||
|
- all that can be done with it.
|
||||||
|
|
||||||
|
|
||||||
|
Basis: {#audio_river_config_file_bases}
|
||||||
|
======
|
||||||
|
|
||||||
|
The river configuration file is a json file. We use @ref ejson_mainpage_what to parse it then we have some writing facilities.
|
||||||
|
|
||||||
|
|
||||||
|
River provide a list a harware interface and virtual interface.
|
||||||
|
|
||||||
|
|
||||||
|
The hardware interface are provided by @ref audio_orchestra_mainpage_what then we will plug on every platform.
|
||||||
|
|
||||||
|
|
||||||
|
The file is simply architecture around a list of object:
|
||||||
|
|
||||||
|
```{.json}
|
||||||
|
{
|
||||||
|
"speaker":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"microphone":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"mixed-in-out":{
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
With this config we declare 3 interfaces : speaker, microphone and mixed-in-out.
|
||||||
|
|
||||||
|
|
||||||
|
Harware configuration: {#audio_river_config_file_hw_config}
|
||||||
|
======================
|
||||||
|
|
||||||
|
In every interface we need to define some Element:
|
||||||
|
- "io" : Can be input/output/... depending of virtual interface...
|
||||||
|
- "map-on": An object to configure airtaudio interface.
|
||||||
|
- "frequency": 0 to automatic select one. Or the frequency to open harware device
|
||||||
|
- "channel-map": List of all channel in the stream:
|
||||||
|
* "front-left"
|
||||||
|
* "front-center"
|
||||||
|
* "front-right"
|
||||||
|
* "rear-left"
|
||||||
|
* "rear-center"
|
||||||
|
* "rear-right"
|
||||||
|
* "surround-left",
|
||||||
|
* "surround-right",
|
||||||
|
* "sub-woofer",
|
||||||
|
* "lfe"
|
||||||
|
- "type": Fomat to open the stream:
|
||||||
|
* "auto": Detect the best type
|
||||||
|
* "int8",
|
||||||
|
* "int8-on-int16",
|
||||||
|
* "int16",
|
||||||
|
* "int16-on-int32",
|
||||||
|
* "int24",
|
||||||
|
* "int32",
|
||||||
|
* "int32-on-int64",
|
||||||
|
* "int64",
|
||||||
|
* "float",
|
||||||
|
* "double"
|
||||||
|
- "nb-chunk": Number of chunk to open the stream.
|
||||||
|
|
||||||
|
|
||||||
|
|
36
doc/faq.bb
36
doc/faq.bb
@@ -1,36 +0,0 @@
|
|||||||
=?= FAQ =?=
|
|
||||||
|
|
||||||
== What is ewol licence ==
|
|
||||||
|
|
||||||
This is really simple : APACHE-2 :
|
|
||||||
|
|
||||||
Copyright ewol Edouard DUPIN
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
[[http://www.apache.org/licenses/LICENSE-2.0]]
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
== Why we use "DECLARE_FACTORY" Macro ? ==
|
|
||||||
|
|
||||||
For some reason!!! But everything might be clear:
|
|
||||||
:** In ewol we masively use std::shared_ptr<xxx> (I have create my own but it is not "standard" (I like when we use genecic system)).
|
|
||||||
:** The main class : [class[ewol::Object]] herited from [i]std::enable_shared_from_this<Object>[/i] to permit to access at his own [i]std::shared_ptr[/i].
|
|
||||||
:** Acces At his own [i]std::shared_ptr[/i] is not allowed in the class contructor/destructor.
|
|
||||||
:** Many time for meta-widget we need to propagate our [i]std::shared_ptr[/i] in child.
|
|
||||||
|
|
||||||
Then for all these reasons, I have create a simple MACRO that create a static template funtion that create the object and just after
|
|
||||||
creation call the init(...) function to permit to create a complex widget or others with some writing convinience.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -1,8 +1,15 @@
|
|||||||
|
Read stream feedback {#audio_river_feedback}
|
||||||
|
====================
|
||||||
|
|
||||||
=== Objectif ===
|
@tableofcontents
|
||||||
:** Implement a feedback.
|
|
||||||
|
|
||||||
=== Bases: ===
|
Objectifs: {#audio_river_feedback_objectif}
|
||||||
|
==========
|
||||||
|
|
||||||
|
- Implement a feedback.
|
||||||
|
|
||||||
|
Bases: {#audio_river_feedback_base}
|
||||||
|
======
|
||||||
|
|
||||||
A feedback is a stream that is generated by an output.
|
A feedback is a stream that is generated by an output.
|
||||||
|
|
||||||
@@ -11,15 +18,13 @@ To get a feedback this is the same implementation of an input and link it on an
|
|||||||
|
|
||||||
What change:
|
What change:
|
||||||
|
|
||||||
[code style=c++]
|
```{.cpp}
|
||||||
//Get the generic feedback on speaker:
|
//Get the generic feedback on speaker:
|
||||||
interface = manager->createFeedback(48000,
|
interface = manager->createFeedback(48000,
|
||||||
std::vector<audio::channel>(),
|
std::vector<audio::channel>(),
|
||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
"speaker");
|
"speaker");
|
||||||
[/code]
|
```
|
||||||
|
|
||||||
[note]
|
**Note:** Input interface does not provide feedback.
|
||||||
Input interface does not provide feedback.
|
|
||||||
[/note]
|
|
||||||
|
|
69
doc/index.bb
69
doc/index.bb
@@ -1,69 +0,0 @@
|
|||||||
== [center]RIVER library[/center] ==
|
|
||||||
__________________________________________________
|
|
||||||
|
|
||||||
===What is RIVER, and how can I use it?===
|
|
||||||
RIVER is a multi-platform library to manage the input and output audio flow.
|
|
||||||
It can be compared with PulseAudio or Jack, but at the difference at the 2 interfaces
|
|
||||||
it is designed to be multi-platform and is based on licence that permit to integrate it
|
|
||||||
on every program we want.
|
|
||||||
|
|
||||||
===Where can I use it?===
|
|
||||||
Everywhere! RIVER is cross-platform devolopped to support bases OS:
|
|
||||||
: ** Linux (over Alsa, Pulseaudio, JackD)
|
|
||||||
: ** Windows (over ASIO)
|
|
||||||
: ** MacOs (over CoreAudio)
|
|
||||||
: ** Android (Over Ewol wrapper little complicated need to be change later)
|
|
||||||
: ** IOs (over CoreAudio for ios)
|
|
||||||
|
|
||||||
===What languages are supported?===
|
|
||||||
RIVER is written in C++11 with posibilities to compile it with C++03 + Boost
|
|
||||||
|
|
||||||
===Are there any licensing restrictions?===
|
|
||||||
RIVER is [b]FREE software[/b] and [i]all sub-library are FREE and staticly linkable !!![/i]
|
|
||||||
|
|
||||||
That allow you to use it for every program you want, including those developing proprietary software, without any license fees or royalties.
|
|
||||||
|
|
||||||
[note]The static support is important for some platform like IOs, and this limit the external library use at some license like :
|
|
||||||
:** BSD*
|
|
||||||
:** MIT
|
|
||||||
:** APPACHE-2
|
|
||||||
:** PNG
|
|
||||||
:** ZLIB
|
|
||||||
This exclude the classical extern library with licence:
|
|
||||||
:** L-GPL
|
|
||||||
:** GPL
|
|
||||||
[/note]
|
|
||||||
|
|
||||||
==== License (APACHE 2) ====
|
|
||||||
Copyright ewol Edouard DUPIN
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
[[http://www.apache.org/licenses/LICENSE-2.0]]
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
==== Depends library: ====
|
|
||||||
===== License: =====
|
|
||||||
:** [b][lib[etk | e-tk]][/b] : APACHE-2
|
|
||||||
:** [b][lib[airtaudio | airtaudio]][/b] : MIT/APACHE-2
|
|
||||||
:** [b][lib[ejson | e-json]][/b] : APACHE-2
|
|
||||||
:** [b][lib[drain | Drain]][/b] : APACHE-2
|
|
||||||
|
|
||||||
|
|
||||||
===== Program Using RIVER =====
|
|
||||||
:** [b][[http://play.google.com/store/apps/details?id=com.edouarddupin.worddown | worddown]][/b] : (Proprietary) Worddown is a simple word game threw [lib[ewolsa | ewol-simple-audio]].
|
|
||||||
|
|
||||||
== Main documentation: ==
|
|
||||||
|
|
||||||
[doc[001_bases | Global Documantation]]
|
|
||||||
|
|
||||||
[tutorial[000_Build | Tutorials]]
|
|
||||||
|
|
92
doc/mainpage.md
Normal file
92
doc/mainpage.md
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
AUDIO-RIVER library {#mainpage}
|
||||||
|
===================
|
||||||
|
|
||||||
|
@tableofcontents
|
||||||
|
|
||||||
|
What is AUDIO-RIVER: {#audio_river_mainpage_what}
|
||||||
|
====================
|
||||||
|
|
||||||
|
AUDIO-RIVER, is a multi-platform library to manage the input and output audio flow.
|
||||||
|
It can be compared with PulseAudio or Jack, but at the difference at the 2 interfaces
|
||||||
|
it is designed to be multi-platform and is based on licence that permit to integrate it
|
||||||
|
on every program we want.
|
||||||
|
|
||||||
|
|
||||||
|
What it does: {#audio_river_mainpage_what_it_does}
|
||||||
|
=============
|
||||||
|
|
||||||
|
Everywhere! RIVER is cross-platform devolopped to support bases OS:
|
||||||
|
: ** Linux (over Alsa, Pulseaudio, JackD)
|
||||||
|
: ** Windows (over ASIO)
|
||||||
|
: ** MacOs (over CoreAudio)
|
||||||
|
: ** Android (Over Ewol wrapper little complicated need to be change later)
|
||||||
|
: ** IOs (over CoreAudio for ios)
|
||||||
|
|
||||||
|
AUDIO-RIVER is dependent of the STL (compatible with MacOs stl (CXX))
|
||||||
|
|
||||||
|
Architecture:
|
||||||
|
-------------
|
||||||
|
|
||||||
|
River has been designed to replace the pulseAudio basic asyncronous interface that create
|
||||||
|
more problem that it will solve. The second point is that is not enougth portable to be
|
||||||
|
embended in a proprietary software without distributing all the sources (Ios).
|
||||||
|
|
||||||
|
Start at this point we will have simple objectives :
|
||||||
|
- Manage multiple Low level interface: @ref audio_orchestra_mainpage_what
|
||||||
|
* for linux (Alsa, Pulse, Oss)
|
||||||
|
* for Mac-OsX (CoreAudio)
|
||||||
|
* for IOs (coreAudio (embended version))
|
||||||
|
* for Windows (ASIO)
|
||||||
|
* For Android (Java (JDK...))
|
||||||
|
- Synchronous interface ==> no delay and reduce latency
|
||||||
|
- Manage the thread priority (need sometimes to be more reactive)
|
||||||
|
- manage mixing of some flow (2 inputs stereo and the user want 1 input quad)
|
||||||
|
- AEC Acoustic Echo Cancelation (TODO : in the current implementation we have a simple sound cutter)
|
||||||
|
- Equalizer (done with @ref audio_drain_mainpage_what)
|
||||||
|
- Resmpling (done by the libspeexDSP)
|
||||||
|
- Correct volume management (and configurable)
|
||||||
|
- Fade-in and Fade-out @ref audio_drain_mainpage_what
|
||||||
|
- Channel reorganisation @ref audio_drain_mainpage_what
|
||||||
|
- A correct feedback interface
|
||||||
|
|
||||||
|
|
||||||
|
What languages are supported? {#audio_river_mainpage_language}
|
||||||
|
=============================
|
||||||
|
|
||||||
|
AUDIO-RIVER is written in C++.
|
||||||
|
|
||||||
|
|
||||||
|
Are there any licensing restrictions? {#audio_river_mainpage_license_restriction}
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
AUDIO-RIVER is **FREE software** and _all sub-library are FREE and staticly linkable !!!_
|
||||||
|
|
||||||
|
|
||||||
|
License (APACHE-2.0) {#audio_river_mainpage_license}
|
||||||
|
====================
|
||||||
|
|
||||||
|
Copyright AUDIO-RIVER Edouard DUPIN
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
<http://www.apache.org/licenses/LICENSE-2.0>
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
Other pages {#audio_river_mainpage_sub_page}
|
||||||
|
===========
|
||||||
|
|
||||||
|
- @ref audio_river_build
|
||||||
|
- @ref audio_river_read
|
||||||
|
- @ref audio_river_write
|
||||||
|
- @ref audio_river_feedback
|
||||||
|
- @ref audio_river_config_file
|
||||||
|
- [**ewol coding style**](http://atria-soft.github.io/ewol/ewol_coding_style.html)
|
||||||
|
|
115
doc/read.md
Normal file
115
doc/read.md
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
Read stream form Audio input {#audio_river_read}
|
||||||
|
============================
|
||||||
|
|
||||||
|
@tableofcontents
|
||||||
|
|
||||||
|
Objectifs: {#audio_river_read_objectif}
|
||||||
|
==========
|
||||||
|
|
||||||
|
- Understand basis of river
|
||||||
|
- Create a simple recording interface that print the average of sample absolute value.
|
||||||
|
|
||||||
|
|
||||||
|
When you will create an application based on the river audio interface you need :
|
||||||
|
|
||||||
|
Include: {#audio_river_read_include}
|
||||||
|
========
|
||||||
|
|
||||||
|
Include manager and interface node
|
||||||
|
@snippet read.cpp audio_river_sample_include
|
||||||
|
|
||||||
|
Initilize the River library: {#audio_river_read_init}
|
||||||
|
============================
|
||||||
|
|
||||||
|
We first need to initialize etk sub library (needed to select the log level of sub-libraries and file access abstraction
|
||||||
|
@snippet read.cpp audio_river_sample_init
|
||||||
|
|
||||||
|
Now we will initilaize the river library.
|
||||||
|
To do this We have 2 posibilities:
|
||||||
|
With a file:
|
||||||
|
------------
|
||||||
|
|
||||||
|
```{.cpp}
|
||||||
|
// initialize river interface
|
||||||
|
river::init("DATA:configFileName.json");
|
||||||
|
```
|
||||||
|
|
||||||
|
With a json string:
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
@snippet read.cpp audio_river_sample_read_config_file
|
||||||
|
|
||||||
|
```{.cpp}
|
||||||
|
// initialize river interface
|
||||||
|
river::initString(configurationRiver);
|
||||||
|
```
|
||||||
|
|
||||||
|
For the example we select the second solution (faster to implement example and resource at the same position.
|
||||||
|
|
||||||
|
river::init / river::initString must be called only one time for all the application, this represent the hardware configuration.
|
||||||
|
It is NOT dynamic
|
||||||
|
|
||||||
|
To understand the configuration file Please see @ref audio_river_config_file
|
||||||
|
|
||||||
|
This json is parsed by the @ref {#ejson_mainpage_what} it contain some update like:
|
||||||
|
- Optionnal " in the name of element.
|
||||||
|
- The possibilities to remplace " with '.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Get the river interface manager: {#audio_river_read_river_interface}
|
||||||
|
================================
|
||||||
|
|
||||||
|
An application can have many interface and only one Manager. And a process can contain many application.
|
||||||
|
|
||||||
|
Then, we will get the first application manager handle.
|
||||||
|
@snippet read.cpp audio_river_sample_get_interface
|
||||||
|
|
||||||
|
*Note:* You can get back the application handle when you create a new one with the same name.
|
||||||
|
|
||||||
|
Create your read interface: {#audio_river_read_river_read_interface}
|
||||||
|
===========================
|
||||||
|
|
||||||
|
Generic code:
|
||||||
|
@snippet read.cpp audio_river_sample_create_read_interface
|
||||||
|
|
||||||
|
Here we create an interface with:
|
||||||
|
- The frequency of 48000 Hz.
|
||||||
|
- The default Low level definition channel
|
||||||
|
- A data interface of 16 bits samples coded in [-32768..32767]
|
||||||
|
- Select input interaface name "microphone"
|
||||||
|
|
||||||
|
|
||||||
|
set data callback: {#audio_river_read_get_data}
|
||||||
|
==================
|
||||||
|
|
||||||
|
The best way to get data is to instanciate a simple callback.
|
||||||
|
The callback is called when sample arrive and you have the nbChunk/frequency
|
||||||
|
to process the data, otherwise you can generate error in data stream.
|
||||||
|
|
||||||
|
@snippet read.cpp audio_river_sample_set_callback
|
||||||
|
|
||||||
|
Callback inplementation: {#audio_river_read_callback}
|
||||||
|
========================
|
||||||
|
|
||||||
|
Simply declare your function and do what you want inside.
|
||||||
|
|
||||||
|
@snippet read.cpp audio_river_sample_callback_implement
|
||||||
|
|
||||||
|
start and stop the stream: {#audio_river_read_start_stop}
|
||||||
|
==========================
|
||||||
|
|
||||||
|
@snippet read.cpp audio_river_sample_read_start_stop
|
||||||
|
|
||||||
|
Remove interfaces: {#audio_river_read_reset}
|
||||||
|
==================
|
||||||
|
|
||||||
|
@snippet read.cpp audio_river_sample_read_reset
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Full Sample: {#audio_river_read_full_sample}
|
||||||
|
============
|
||||||
|
|
||||||
|
@snippet read.cpp audio_river_sample_read_all
|
@@ -1,57 +0,0 @@
|
|||||||
=?=River extract and build examples an example=?=
|
|
||||||
|
|
||||||
All developpement software will start by getting the dependency and the sources.
|
|
||||||
|
|
||||||
=== Linux dependency packages ===
|
|
||||||
[code style=shell]
|
|
||||||
sudo apt-get install g++ zlib1g-dev libasound2-dev
|
|
||||||
# if you want to compile with clang :
|
|
||||||
sudo apt-get install clang
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
|
|
||||||
=== Download instructions ===
|
|
||||||
|
|
||||||
Download the software : This is the simple way You really need only a part of the ewol framework
|
|
||||||
[code style=shell]
|
|
||||||
# create a working directory path
|
|
||||||
mkdir your_workspace_path
|
|
||||||
cd your_workspace_path
|
|
||||||
# clone ewol and all sub-library
|
|
||||||
git clone git://github.com/HeeroYui/ewol.git
|
|
||||||
cd ewol
|
|
||||||
git submodule init
|
|
||||||
git submodule update
|
|
||||||
cd ..
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
If you prefer creating with the packege you needed :
|
|
||||||
[code style=shell]
|
|
||||||
mkdir -p your_workspace_path
|
|
||||||
cd your_workspace_path
|
|
||||||
# download all you needs
|
|
||||||
git clone git://github.com/HeeroYui/lutin.git
|
|
||||||
git clone git://github.com/HeeroYui/etk.git
|
|
||||||
git clone git://github.com/HeeroYui/audio.git
|
|
||||||
git clone git://github.com/HeeroYui/ejson.git
|
|
||||||
git clone git://github.com/HeeroYui/airtaudio.git
|
|
||||||
git clone git://github.com/HeeroYui/drain.git
|
|
||||||
git clone git://github.com/HeeroYui/river.git
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
[note]
|
|
||||||
The full build tool documentation is availlable here : [[http://heeroyui.github.io/lutin/ | lutin]]
|
|
||||||
[/note]
|
|
||||||
|
|
||||||
=== Common build instructions ===
|
|
||||||
|
|
||||||
Build the basic examples & test:
|
|
||||||
[code style=shell]
|
|
||||||
./ewol/build/lutin.py -mdebug river_sample_read
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
To run an application you will find it directly on the out 'staging' tree :
|
|
||||||
[code style=shell]
|
|
||||||
./out/Linux/debug/staging/clang/river_sample_read/usr/bin/river_sample_read -l4
|
|
||||||
[/code]
|
|
||||||
|
|
@@ -1,158 +0,0 @@
|
|||||||
|
|
||||||
=== Objectif ===
|
|
||||||
:** Understand basis of river
|
|
||||||
:** Create a simple recording interface that print the average of sample absolute value.
|
|
||||||
|
|
||||||
=== sample source: ===
|
|
||||||
[[http://github.com/HeeroYui/river.git/sample/read/ | sample source]]
|
|
||||||
|
|
||||||
=== Bases: ===
|
|
||||||
|
|
||||||
When you will create an application based on the river audio interface you need :
|
|
||||||
|
|
||||||
==== Include: ====
|
|
||||||
|
|
||||||
Include manager and interface node
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
#include <river/river.h>
|
|
||||||
#include <river/Manager.h>
|
|
||||||
#include <river/Interface.h>
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
==== Initilize the River library: ====
|
|
||||||
|
|
||||||
We first need to initialize etk sub library (needed to select the log level of sub-libraries and file access abstraction
|
|
||||||
[code style=c++]
|
|
||||||
// the only one init for etk:
|
|
||||||
etk::init(_argc, _argv);
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
Now we will initilaize the river library.
|
|
||||||
To do this We have 2 posibilities:
|
|
||||||
:** With a file:
|
|
||||||
[code style=c++]
|
|
||||||
// initialize river interface
|
|
||||||
river::init("DATA:configFileName.json");
|
|
||||||
[/code]
|
|
||||||
:** With a json string:
|
|
||||||
[code style=c++]
|
|
||||||
static const std::string configurationRiver =
|
|
||||||
"{\n"
|
|
||||||
" microphone:{\n"
|
|
||||||
" io:'input',\n"
|
|
||||||
" map-on:{\n"
|
|
||||||
" interface:'auto',\n"
|
|
||||||
" name:'default',\n"
|
|
||||||
" },\n"
|
|
||||||
" frequency:0,\n"
|
|
||||||
" channel-map:['front-left', 'front-right'],\n"
|
|
||||||
" type:'auto',\n"
|
|
||||||
" nb-chunk:1024\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n";
|
|
||||||
// initialize river interface
|
|
||||||
river::initString(configurationRiver);
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
For the example we select the second solution (faster to implement example and resource at the same position.
|
|
||||||
|
|
||||||
river::init / river::initString must be called only one time for all the application, this represent the hardware configuration.
|
|
||||||
It is Nearly not dynamic
|
|
||||||
|
|
||||||
To understand the configuration file Please see [tutorial[004_ConfigurationFile | Configuration file]]
|
|
||||||
|
|
||||||
[note]
|
|
||||||
This json is parsed by the [lib[ejson | e-json library]] it containe some update like:
|
|
||||||
:** Optionnal " in the name of element.
|
|
||||||
:** The possibilities to remplace " with '.
|
|
||||||
[/note]
|
|
||||||
|
|
||||||
|
|
||||||
==== Get the river interface manager: ====
|
|
||||||
|
|
||||||
An application can have many interface and only one Manager, And a process can contain many application.
|
|
||||||
|
|
||||||
Then, we will get the first application manager handle.
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
// Create the River manager for tha application or part of the application.
|
|
||||||
std11::shared_ptr<river::Manager> manager = river::Manager::create("river_sample_read");
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
[note]
|
|
||||||
You can get back the application handle when you create a new one with the same name.
|
|
||||||
[/note]
|
|
||||||
|
|
||||||
==== Create your read interface: ====
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
// create interface:
|
|
||||||
std11::shared_ptr<river::Interface> interface;
|
|
||||||
//Get the generic input:
|
|
||||||
interface = manager->createInput(48000,
|
|
||||||
std::vector<audio::channel>(),
|
|
||||||
audio::format_int16,
|
|
||||||
"microphone");
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
Here we create an interface with:
|
|
||||||
:** The frequency of 48000 Hz.
|
|
||||||
:** The default Low level definition channel
|
|
||||||
:** A data interface of 16 bits samples coded in [-32768..32767]
|
|
||||||
:** Select input interaface name "microphone"
|
|
||||||
|
|
||||||
|
|
||||||
==== Get datas: ====
|
|
||||||
|
|
||||||
The best way to get data is to instanciate a simple callback.
|
|
||||||
The callback is called when sample arrive and you have the nbChunk/frequency
|
|
||||||
to process the data, otherwise you can generate error in data stream.
|
|
||||||
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
// set callback mode ...
|
|
||||||
interface->setInputCallback(std11::bind(&onDataReceived,
|
|
||||||
std11::placeholders::_1,
|
|
||||||
std11::placeholders::_2,
|
|
||||||
std11::placeholders::_3,
|
|
||||||
std11::placeholders::_4,
|
|
||||||
std11::placeholders::_5,
|
|
||||||
std11::placeholders::_6));
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
==== Callback inplementation: ====
|
|
||||||
|
|
||||||
Simply declare your function and do what you want inside.
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
void onDataReceived(const void* _data,
|
|
||||||
const std11::chrono::system_clock::time_point& _time,
|
|
||||||
size_t _nbChunk,
|
|
||||||
enum audio::format _format,
|
|
||||||
uint32_t _frequency,
|
|
||||||
const std::vector<audio::channel>& _map) {
|
|
||||||
if (_format == audio::format_int16) {
|
|
||||||
// stuff here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
==== start and stop: ====
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
// start the stream
|
|
||||||
interface->start();
|
|
||||||
// wait 10 second ...
|
|
||||||
sleep(10);
|
|
||||||
// stop the stream
|
|
||||||
interface->stop();
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
==== Remove interfaces: ====
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
// remove interface and manager.
|
|
||||||
interface.reset();
|
|
||||||
manager.reset();
|
|
||||||
[/code]
|
|
@@ -1,84 +0,0 @@
|
|||||||
|
|
||||||
=== Objectif ===
|
|
||||||
:** Understand write audio stream
|
|
||||||
|
|
||||||
=== sample source: ===
|
|
||||||
[[http://github.com/HeeroYui/river.git/sample/write/ | sample source]]
|
|
||||||
|
|
||||||
=== Bases: ===
|
|
||||||
|
|
||||||
The writing work nearly like the read turoral. Then we will just see what has change.
|
|
||||||
|
|
||||||
==== File configuration: ====
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
static const std::string configurationRiver =
|
|
||||||
"{\n"
|
|
||||||
" speaker:{\n"
|
|
||||||
" io:'output',\n"
|
|
||||||
" map-on:{\n"
|
|
||||||
" interface:'auto',\n"
|
|
||||||
" name:'default',\n"
|
|
||||||
" },\n"
|
|
||||||
" frequency:0,\n"
|
|
||||||
" channel-map:['front-left', 'front-right'],\n"
|
|
||||||
" type:'auto',\n"
|
|
||||||
" nb-chunk:1024,\n"
|
|
||||||
" volume-name:'MASTER'\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n";
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
==== Create your write interface: ====
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
// create interface:
|
|
||||||
std11::shared_ptr<river::Interface> interface;
|
|
||||||
//Get the generic input:
|
|
||||||
interface = manager->createOutput(48000,
|
|
||||||
std::vector<audio::channel>(),
|
|
||||||
audio::format_int16,
|
|
||||||
"speaker");
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
Here we create an interface with:
|
|
||||||
:** The frequency of 48000 Hz.
|
|
||||||
:** The default Low level definition channel
|
|
||||||
:** A data interface of 16 bits samples coded in [-32768..32767]
|
|
||||||
:** Select input interaface name "speaker"
|
|
||||||
|
|
||||||
|
|
||||||
==== write datas: ====
|
|
||||||
|
|
||||||
The best way to get data is to instanciate a simple callback.
|
|
||||||
The callback is called when sample are needed and you have the nbChunk/frequency
|
|
||||||
to generate the data, otherwise you can generate error in data stream.
|
|
||||||
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
// set callback mode ...
|
|
||||||
interface->setOutputCallback(std11::bind(&onDataNeeded,
|
|
||||||
std11::placeholders::_1,
|
|
||||||
std11::placeholders::_2,
|
|
||||||
std11::placeholders::_3,
|
|
||||||
std11::placeholders::_4,
|
|
||||||
std11::placeholders::_5,
|
|
||||||
std11::placeholders::_6));
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
==== Callback inplementation: ====
|
|
||||||
|
|
||||||
Simply declare your function and do what you want inside.
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
void onDataNeeded(void* _data,
|
|
||||||
const std11::chrono::system_clock::time_point& _time,
|
|
||||||
size_t _nbChunk,
|
|
||||||
enum audio::format _format,
|
|
||||||
uint32_t _frequency,
|
|
||||||
const std::vector<audio::channel>& _map) {
|
|
||||||
if (_format == audio::format_int16) {
|
|
||||||
// stuff here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[/code]
|
|
@@ -1,70 +0,0 @@
|
|||||||
|
|
||||||
=== Objectif ===
|
|
||||||
:** Understand the architecture of the configuration file.
|
|
||||||
:** all that can be done with it.
|
|
||||||
|
|
||||||
|
|
||||||
=== Basis: ===
|
|
||||||
|
|
||||||
The river configuration file is a json file. We use [lib[ejson | e-json library]] to parse it then we have some writing facilities.
|
|
||||||
|
|
||||||
|
|
||||||
River provide a list a harware interface and virtual interface.
|
|
||||||
|
|
||||||
|
|
||||||
The hardware interface are provided by [lib[airtaudio | AirTAudio library]] then we will plug on every platform.
|
|
||||||
|
|
||||||
|
|
||||||
The file is simply architecture around a list of object:
|
|
||||||
|
|
||||||
[code style=json]
|
|
||||||
{
|
|
||||||
"speaker":{
|
|
||||||
|
|
||||||
},
|
|
||||||
"microphone":{
|
|
||||||
|
|
||||||
},
|
|
||||||
"mixed-in-out":{
|
|
||||||
|
|
||||||
},
|
|
||||||
}
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
With this config we declare 3 interfaces : speaker, microphone and mixed-in-out.
|
|
||||||
|
|
||||||
|
|
||||||
=== Harware configuration: ===
|
|
||||||
|
|
||||||
In every interface we need to define some Element:
|
|
||||||
:** "io" :
|
|
||||||
:: Can be input/output/... depending of virtual interface...
|
|
||||||
:** "map-on": An object to configure airtaudio interface.
|
|
||||||
:** "frequency": 0 to automatic select one. Or the frequency to open harware device
|
|
||||||
:** "channel-map": List of all channel in the stream:
|
|
||||||
::** "front-left"
|
|
||||||
::** "front-center"
|
|
||||||
::** "front-right"
|
|
||||||
::** "rear-left"
|
|
||||||
::** "rear-center"
|
|
||||||
::** "rear-right"
|
|
||||||
::** "surround-left",
|
|
||||||
::** "surround-right",
|
|
||||||
::** "sub-woofer",
|
|
||||||
::** "lfe"
|
|
||||||
:** "type": Fomat to open the stream:
|
|
||||||
::** "auto": Detect the best type
|
|
||||||
::** "int8",
|
|
||||||
::** "int8-on-int16",
|
|
||||||
::** "int16",
|
|
||||||
::** "int16-on-int32",
|
|
||||||
::** "int24",
|
|
||||||
::** "int32",
|
|
||||||
::** "int32-on-int64",
|
|
||||||
::** "int64",
|
|
||||||
::** "float",
|
|
||||||
::** "double"
|
|
||||||
:** "nb-chunk": Number of chunk to open the stream.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
53
doc/write.md
Normal file
53
doc/write.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
Write stream to Audio output {#audio_river_write}
|
||||||
|
============================
|
||||||
|
|
||||||
|
@tableofcontents
|
||||||
|
|
||||||
|
Objectifs: {#audio_river_write_objectif}
|
||||||
|
==========
|
||||||
|
|
||||||
|
- Understand write audio stream
|
||||||
|
|
||||||
|
The writing work nearly like the read turoral. Then we will just see what has change.
|
||||||
|
|
||||||
|
File configuration: {#audio_river_write_config}
|
||||||
|
===================
|
||||||
|
|
||||||
|
@snippet write.cpp audio_river_sample_write_config_file
|
||||||
|
|
||||||
|
|
||||||
|
Create your write interface: {#audio_river_write_interface}
|
||||||
|
============================
|
||||||
|
|
||||||
|
Generic code:
|
||||||
|
@snippet write.cpp audio_river_sample_create_write_interface
|
||||||
|
|
||||||
|
Here we create an interface with:
|
||||||
|
- The frequency of 48000 Hz.
|
||||||
|
- The default Low level definition channel
|
||||||
|
- A data interface of 16 bits samples coded in [-32768..32767]
|
||||||
|
- Select input interaface name "speaker"
|
||||||
|
|
||||||
|
|
||||||
|
set data callback: {#audio_river_write_get_data}
|
||||||
|
==================
|
||||||
|
|
||||||
|
The best way to get data is to instanciate a simple callback.
|
||||||
|
The callback is called when sample are needed and you have the nbChunk/frequency
|
||||||
|
to generate the data, otherwise you can generate error in data stream.
|
||||||
|
|
||||||
|
@snippet write.cpp audio_river_sample_set_callback
|
||||||
|
|
||||||
|
Callback inplementation: {#audio_river_write_callback}
|
||||||
|
========================
|
||||||
|
|
||||||
|
Simply declare your function and do what you want inside.
|
||||||
|
|
||||||
|
@snippet write.cpp audio_river_sample_callback_implement
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Full Sample: {#audio_river_write_full_sample}
|
||||||
|
============
|
||||||
|
|
||||||
|
@snippet write.cpp audio_river_sample_write_all
|
37
doxy_audio-river.py
Normal file
37
doxy_audio-river.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import os
|
||||||
|
import doxy.module as module
|
||||||
|
import doxy.debug as debug
|
||||||
|
import doxy.tools as tools
|
||||||
|
|
||||||
|
def create(target, module_name):
|
||||||
|
my_module = module.Module(__file__, module_name)
|
||||||
|
my_module.set_version("version.txt")
|
||||||
|
my_module.set_title("audio-river: Multi-nodal audio interface")
|
||||||
|
my_module.set_website("http://musicdsp.github.io/" + module_name)
|
||||||
|
my_module.set_website_sources("http://github.com/musicdsp/" + module_name)
|
||||||
|
my_module.add_path([
|
||||||
|
"audio",
|
||||||
|
"doc"
|
||||||
|
])
|
||||||
|
my_module.add_sample_path([
|
||||||
|
"sample",
|
||||||
|
])
|
||||||
|
my_module.add_depend([
|
||||||
|
'audio',
|
||||||
|
'audio-drain',
|
||||||
|
'audio-orchestra',
|
||||||
|
'ejson'
|
||||||
|
])
|
||||||
|
my_module.add_exclude_symbols([
|
||||||
|
'*operator<<*',
|
||||||
|
])
|
||||||
|
my_module.add_exclude_file([
|
||||||
|
'debug.h',
|
||||||
|
])
|
||||||
|
my_module.add_file_patterns([
|
||||||
|
'*.h',
|
||||||
|
'*.md',
|
||||||
|
])
|
||||||
|
|
||||||
|
return my_module
|
0
lutinParseSubFolders.txt
Normal file
0
lutinParseSubFolders.txt
Normal file
@@ -1,18 +1,39 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutin.module as module
|
import lutin.debug as debug
|
||||||
import lutin.tools as tools
|
import lutin.tools as tools
|
||||||
|
|
||||||
|
|
||||||
|
def get_type():
|
||||||
|
return "BINARY"
|
||||||
|
|
||||||
|
def get_sub_type():
|
||||||
|
return "TEST"
|
||||||
|
|
||||||
def get_desc():
|
def get_desc():
|
||||||
return "Multi-nodal audio interface test"
|
return "Multi-nodal audio interface test"
|
||||||
|
|
||||||
|
def get_licence():
|
||||||
|
return "APACHE-2"
|
||||||
|
|
||||||
def create(target):
|
def get_compagny_type():
|
||||||
myModule = module.Module(__file__, 'audio-river-test', 'BINARY')
|
return "com"
|
||||||
myModule.add_src_file([
|
|
||||||
'test/main.cpp',
|
def get_compagny_name():
|
||||||
'test/debug.cpp'
|
return "atria-soft"
|
||||||
|
|
||||||
|
def get_maintainer():
|
||||||
|
return "authors.txt"
|
||||||
|
|
||||||
|
def configure(target, my_module):
|
||||||
|
my_module.add_src_file([
|
||||||
|
'test/main.cpp'
|
||||||
])
|
])
|
||||||
myModule.add_module_depend(['audio-river', 'gtest', 'etk'])
|
my_module.add_depend([
|
||||||
return myModule
|
'audio-river',
|
||||||
|
'gtest',
|
||||||
|
'etk',
|
||||||
|
'test-debug'
|
||||||
|
])
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,15 +1,31 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutin.module as module
|
import lutin.debug as debug
|
||||||
import lutin.tools as tools
|
import lutin.tools as tools
|
||||||
|
|
||||||
|
|
||||||
|
def get_type():
|
||||||
|
return "LIBRARY"
|
||||||
|
|
||||||
def get_desc():
|
def get_desc():
|
||||||
return "Multi-nodal audio interface"
|
return "Multi-nodal audio interface"
|
||||||
|
|
||||||
|
def get_licence():
|
||||||
|
return "APACHE-2"
|
||||||
|
|
||||||
def create(target):
|
def get_compagny_type():
|
||||||
myModule = module.Module(__file__, 'audio-river', 'LIBRARY')
|
return "com"
|
||||||
|
|
||||||
myModule.add_src_file([
|
def get_compagny_name():
|
||||||
|
return "atria-soft"
|
||||||
|
|
||||||
|
def get_maintainer():
|
||||||
|
return "authors.txt"
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
return "version.txt"
|
||||||
|
|
||||||
|
def configure(target, my_module):
|
||||||
|
my_module.add_src_file([
|
||||||
'audio/river/debug.cpp',
|
'audio/river/debug.cpp',
|
||||||
'audio/river/river.cpp',
|
'audio/river/river.cpp',
|
||||||
'audio/river/Manager.cpp',
|
'audio/river/Manager.cpp',
|
||||||
@@ -22,13 +38,23 @@ def create(target):
|
|||||||
'audio/river/io/NodeMuxer.cpp',
|
'audio/river/io/NodeMuxer.cpp',
|
||||||
'audio/river/io/Manager.cpp'
|
'audio/river/io/Manager.cpp'
|
||||||
])
|
])
|
||||||
myModule.add_optionnal_module_depend('audio-orchestra', ["c++", "-DAUDIO_RIVER_BUILD_ORCHESTRA"])
|
my_module.add_header_file([
|
||||||
myModule.add_optionnal_module_depend('portaudio', ["c++", "-DAUDIO_RIVER_BUILD_PORTAUDIO"])
|
'audio/river/river.hpp',
|
||||||
myModule.add_module_depend(['audio', 'audio-drain', 'ejson'])
|
'audio/river/Manager.hpp',
|
||||||
myModule.add_export_path(tools.get_current_path(__file__))
|
'audio/river/Interface.hpp',
|
||||||
|
'audio/river/io/Group.hpp',
|
||||||
# add the currrent module at the
|
'audio/river/io/Node.hpp',
|
||||||
return myModule
|
'audio/river/io/Manager.hpp'
|
||||||
|
])
|
||||||
|
my_module.add_optionnal_depend('audio-orchestra', ["c++", "-DAUDIO_RIVER_BUILD_ORCHESTRA"])
|
||||||
|
my_module.add_optionnal_depend('portaudio', ["c++", "-DAUDIO_RIVER_BUILD_PORTAUDIO"])
|
||||||
|
my_module.add_depend([
|
||||||
|
'audio',
|
||||||
|
'audio-drain',
|
||||||
|
'ejson'
|
||||||
|
])
|
||||||
|
my_module.add_path(".")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import monkModule as module
|
|
||||||
import monkTools as tools
|
|
||||||
|
|
||||||
def get_desc():
|
|
||||||
return "river : Multiple flow input output audio"
|
|
||||||
|
|
||||||
|
|
||||||
def create():
|
|
||||||
# module name is 'edn' and type binary.
|
|
||||||
myModule = module.Module(__file__, 'river', 'LIBRARY')
|
|
||||||
# enable doculentation :
|
|
||||||
myModule.set_website("http://heeroyui.github.io/river/")
|
|
||||||
myModule.set_website_sources("http://github.com/heeroyui/river/")
|
|
||||||
myModule.set_path(tools.get_current_path(__file__) + "/river/")
|
|
||||||
myModule.set_path_general_doc(tools.get_current_path(__file__) + "/doc/")
|
|
||||||
# add the currrent module at the
|
|
||||||
return myModule
|
|
||||||
|
|
64
sample/ioViewer/appl/Windows.cpp
Normal file
64
sample/ioViewer/appl/Windows.cpp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ewol/ewol.hpp>
|
||||||
|
#include <appl/debug.hpp>
|
||||||
|
#include <appl/Windows.hpp>
|
||||||
|
#include <ewol/widget/Label.hpp>
|
||||||
|
#include <ewol/widget/Button.hpp>
|
||||||
|
#include <audio/river/widget/TemporalViewer.hpp>
|
||||||
|
#include <etk/tool.hpp>
|
||||||
|
|
||||||
|
appl::Windows::Windows() :
|
||||||
|
m_composer(nullptr) {
|
||||||
|
addObjectType("appl::Windows");
|
||||||
|
propertyTitle.setDirectCheck("River IO viewer");
|
||||||
|
}
|
||||||
|
|
||||||
|
void appl::Windows::init() {
|
||||||
|
ewol::widget::Windows::init();
|
||||||
|
std::string composition = std::string("");
|
||||||
|
composition += "<sizer mode='vert'>\n";
|
||||||
|
composition += " <sizer mode='hori' lock='true' min-size='10,10%'>\n";
|
||||||
|
composition += " <button name='bt-record' expend='true' fill='true'>\n";
|
||||||
|
composition += " <label>\n";
|
||||||
|
composition += " Start/Stop record\n";
|
||||||
|
composition += " </label>\n";
|
||||||
|
composition += " </button>\n";
|
||||||
|
composition += " <button name='bt-generate' expend='true' fill='true'>\n";
|
||||||
|
composition += " <label>\n";
|
||||||
|
composition += " Start/Stop Generate\n";
|
||||||
|
composition += " </label>\n";
|
||||||
|
composition += " </button>\n";
|
||||||
|
composition += " </sizer>\n";
|
||||||
|
composition += " <TemporalViewer name='displayer' expand='true' fill='true'/>\n";
|
||||||
|
composition += "</sizer>\n";
|
||||||
|
|
||||||
|
m_composer = ewol::widget::Composer::create();
|
||||||
|
if (m_composer == nullptr) {
|
||||||
|
APPL_CRITICAL(" An error occured ... in the windows creatrion ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_composer->loadFromString(composition);
|
||||||
|
setSubWidget(m_composer);
|
||||||
|
subBind(ewol::widget::Button, "bt-record", signalPressed, sharedFromThis(), &appl::Windows::onCallbackRecord);
|
||||||
|
subBind(ewol::widget::Button, "bt-generate", signalPressed, sharedFromThis(), &appl::Windows::onCallbackGenerate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void appl::Windows::onCallbackRecord() {
|
||||||
|
ememory::SharedPtr<audio::river::widget::TemporalViewer> tmpDisp = ememory::dynamicPointerCast<audio::river::widget::TemporalViewer>(getSubObjectNamed("displayer"));
|
||||||
|
if (tmpDisp != nullptr) {
|
||||||
|
tmpDisp->recordToggle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void appl::Windows::onCallbackGenerate() {
|
||||||
|
ememory::SharedPtr<audio::river::widget::TemporalViewer> tmpDisp = ememory::dynamicPointerCast<audio::river::widget::TemporalViewer>(getSubObjectNamed("displayer"));
|
||||||
|
if (tmpDisp != nullptr) {
|
||||||
|
tmpDisp->generateToggle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
25
sample/ioViewer/appl/Windows.hpp
Normal file
25
sample/ioViewer/appl/Windows.hpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ewol/widget/Windows.hpp>
|
||||||
|
#include <ewol/widget/Composer.hpp>
|
||||||
|
|
||||||
|
namespace appl {
|
||||||
|
class Windows : public ewol::widget::Windows {
|
||||||
|
private:
|
||||||
|
ememory::SharedPtr<ewol::widget::Composer> m_composer;
|
||||||
|
protected:
|
||||||
|
Windows();
|
||||||
|
void init();
|
||||||
|
public:
|
||||||
|
DECLARE_FACTORY(Windows);
|
||||||
|
public: // callback functions
|
||||||
|
void onCallbackRecord();
|
||||||
|
void onCallbackGenerate();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
13
sample/ioViewer/appl/debug.cpp
Normal file
13
sample/ioViewer/appl/debug.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <appl/debug.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
int32_t appl::getLogId() {
|
||||||
|
static int32_t g_val = elog::registerInstance("ioViewer");
|
||||||
|
return g_val;
|
||||||
|
}
|
@@ -1,20 +1,17 @@
|
|||||||
/**
|
/** @file
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
*
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
* @license APACHE v2.0 (see license file)
|
||||||
*
|
|
||||||
* @license GPL v3 (see license file)
|
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef __APPL_DEBUG_H__
|
#include <elog/log.hpp>
|
||||||
#define __APPL_DEBUG_H__
|
|
||||||
|
|
||||||
#include <etk/log.h>
|
|
||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
int32_t getLogId();
|
int32_t getLogId();
|
||||||
};
|
}
|
||||||
#define APPL_BASE(info,data) TK_LOG_BASE(appl::getLogId(),info,data)
|
|
||||||
|
#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)
|
||||||
|
|
||||||
#define APPL_PRINT(data) APPL_BASE(-1, data)
|
#define APPL_PRINT(data) APPL_BASE(-1, data)
|
||||||
#define APPL_CRITICAL(data) APPL_BASE(1, data)
|
#define APPL_CRITICAL(data) APPL_BASE(1, data)
|
||||||
@@ -40,4 +37,3 @@ namespace appl {
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#endif
|
|
71
sample/ioViewer/appl/main.cpp
Normal file
71
sample/ioViewer/appl/main.cpp
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <ewol/ewol.hpp>
|
||||||
|
#include <gale/context/commandLine.hpp>
|
||||||
|
|
||||||
|
#include <appl/debug.hpp>
|
||||||
|
#include <appl/Windows.hpp>
|
||||||
|
#include <ewol/object/Object.hpp>
|
||||||
|
#include <ewol/widget/Manager.hpp>
|
||||||
|
#include <ewol/context/Context.hpp>
|
||||||
|
#include <audio/river/widget/TemporalViewer.hpp>
|
||||||
|
|
||||||
|
static const std::string configurationRiver =
|
||||||
|
"{\n"
|
||||||
|
" microphone:{\n"
|
||||||
|
" io:'input',\n"
|
||||||
|
" map-on:{\n"
|
||||||
|
" interface:'auto',\n"
|
||||||
|
" name:'default',\n"
|
||||||
|
" },\n"
|
||||||
|
" frequency:0,\n"
|
||||||
|
" channel-map:['front-left', 'front-right'],\n"
|
||||||
|
" type:'auto',\n"
|
||||||
|
" nb-chunk:1024\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
|
class MainApplication : public ewol::context::Application {
|
||||||
|
public:
|
||||||
|
bool init(ewol::Context& _context, size_t _initId) {
|
||||||
|
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
|
||||||
|
|
||||||
|
audio::river::initString(configurationRiver);
|
||||||
|
|
||||||
|
_context.setSize(vec2(800, 600));
|
||||||
|
|
||||||
|
// select internal data for font ...
|
||||||
|
_context.getFontDefault().setUseExternal(true);
|
||||||
|
_context.getFontDefault().setSize(19);
|
||||||
|
|
||||||
|
audio::river::widget::TemporalViewer::createManagerWidget(_context.getWidgetManager());
|
||||||
|
|
||||||
|
ememory::SharedPtr<ewol::widget::Windows> basicWindows = appl::Windows::create();
|
||||||
|
// create the specific windows
|
||||||
|
_context.setWindows(basicWindows);
|
||||||
|
APPL_INFO("==> Init APPL (END)");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void unInit(ewol::Context& _context) {
|
||||||
|
APPL_INFO("==> Un-Init APPL (START)");
|
||||||
|
// nothing to do...
|
||||||
|
APPL_INFO("==> Un-Init APPL (END)");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
|
||||||
|
* @param std IO
|
||||||
|
* @return std IO
|
||||||
|
*/
|
||||||
|
int main(int _argc, const char *_argv[]) {
|
||||||
|
// second possibility
|
||||||
|
return ewol::run(new MainApplication(), _argc, _argv);
|
||||||
|
}
|
39
sample/ioViewer/lutin_ioViewer.py
Normal file
39
sample/ioViewer/lutin_ioViewer.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import lutin.debug as debug
|
||||||
|
import lutin.tools as tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def get_type():
|
||||||
|
return "BINARY"
|
||||||
|
|
||||||
|
def get_desc():
|
||||||
|
return "Simpleaudio IO viewer and test ..."
|
||||||
|
|
||||||
|
def get_licence():
|
||||||
|
return "APACHE-2"
|
||||||
|
|
||||||
|
def get_compagny_type():
|
||||||
|
return "com"
|
||||||
|
|
||||||
|
def get_compagny_name():
|
||||||
|
return "atria-soft"
|
||||||
|
|
||||||
|
def get_maintainer():
|
||||||
|
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||||
|
|
||||||
|
def configure(target, my_module):
|
||||||
|
my_module.add_extra_flags()
|
||||||
|
my_module.add_src_file([
|
||||||
|
'appl/debug.cpp',
|
||||||
|
'appl/main.cpp',
|
||||||
|
'appl/Windows.cpp'])
|
||||||
|
my_module.add_depend(['ewol', 'audio-river', 'audio-river-widget'])
|
||||||
|
my_module.add_path(".")
|
||||||
|
# set the package properties :
|
||||||
|
my_module.set_pkg("SECTION", ["Development"])
|
||||||
|
my_module.set_pkg("PRIORITY", "optional")
|
||||||
|
|
||||||
|
my_module.add_pkg("RIGHT", "RECORD_AUDIO")
|
||||||
|
return True
|
||||||
|
|
@@ -1,18 +1,38 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutin.module as module
|
import lutin.debug as debug
|
||||||
import lutin.tools as tools
|
import lutin.tools as tools
|
||||||
|
|
||||||
|
|
||||||
|
def get_type():
|
||||||
|
return "BINARY"
|
||||||
|
|
||||||
|
def get_sub_type():
|
||||||
|
return "SAMPLE"
|
||||||
|
|
||||||
def get_desc():
|
def get_desc():
|
||||||
return "Read some data"
|
return "Read some data"
|
||||||
|
|
||||||
|
def get_licence():
|
||||||
|
return "APACHE-2"
|
||||||
|
|
||||||
def create(target):
|
def get_compagny_type():
|
||||||
myModule = module.Module(__file__, 'river-sample-read', 'BINARY')
|
return "com"
|
||||||
myModule.add_src_file([
|
|
||||||
'main.cpp',
|
def get_compagny_name():
|
||||||
|
return "atria-soft"
|
||||||
|
|
||||||
|
def get_maintainer():
|
||||||
|
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||||
|
|
||||||
|
def configure(target, my_module):
|
||||||
|
my_module.add_src_file([
|
||||||
|
'read.cpp',
|
||||||
])
|
])
|
||||||
myModule.add_module_depend(['audio-river', 'etk'])
|
my_module.add_depend([
|
||||||
return myModule
|
'audio-river',
|
||||||
|
'etk'
|
||||||
|
])
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,14 +4,19 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <audio/river/river.h>
|
//! [audio_river_sample_read_all]
|
||||||
#include <audio/river/Manager.h>
|
//! [audio_river_sample_include]
|
||||||
#include <audio/river/Interface.h>
|
#include <audio/river/river.hpp>
|
||||||
#include <etk/os/FSNode.h>
|
#include <audio/river/Manager.hpp>
|
||||||
#include <etk/etk.h>
|
#include <audio/river/Interface.hpp>
|
||||||
#include <unistd.h>
|
//! [audio_river_sample_include]
|
||||||
|
#include <etk/os/FSNode.hpp>
|
||||||
|
#include <etk/etk.hpp>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//! [audio_river_sample_read_config_file]
|
||||||
static const std::string configurationRiver =
|
static const std::string configurationRiver =
|
||||||
"{\n"
|
"{\n"
|
||||||
" microphone:{\n"
|
" microphone:{\n"
|
||||||
@@ -19,6 +24,7 @@ static const std::string configurationRiver =
|
|||||||
" map-on:{\n"
|
" map-on:{\n"
|
||||||
" interface:'auto',\n"
|
" interface:'auto',\n"
|
||||||
" name:'default',\n"
|
" name:'default',\n"
|
||||||
|
//" timestamp-mode:'trigered',\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" frequency:0,\n"
|
" frequency:0,\n"
|
||||||
" channel-map:['front-left', 'front-right'],\n"
|
" channel-map:['front-left', 'front-right'],\n"
|
||||||
@@ -26,8 +32,10 @@ static const std::string configurationRiver =
|
|||||||
" nb-chunk:1024\n"
|
" nb-chunk:1024\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
//! [audio_river_sample_read_config_file]
|
||||||
|
|
||||||
|
|
||||||
|
//! [audio_river_sample_callback_implement]
|
||||||
void onDataReceived(const void* _data,
|
void onDataReceived(const void* _data,
|
||||||
const audio::Time& _time,
|
const audio::Time& _time,
|
||||||
size_t _nbChunk,
|
size_t _nbChunk,
|
||||||
@@ -35,10 +43,14 @@ void onDataReceived(const void* _data,
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
etk::FSNode* _outputNode) {
|
etk::FSNode* _outputNode) {
|
||||||
if (_format != audio::format_int16) {
|
if ( _format != audio::format_int16
|
||||||
std::cout << "[ERROR] call wrong type ... (need int16_t)" << std::endl;
|
&& _format != audio::format_float) {
|
||||||
|
std::cout << "[ERROR] call wrong type ... (need int16_t.float)" << std::endl;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
//! [audio_river_sample_callback_implement]
|
||||||
if (_outputNode->fileIsOpen() == false) {
|
if (_outputNode->fileIsOpen() == false) {
|
||||||
|
if (_format != audio::format_int16) {
|
||||||
// get the curent power of the signal.
|
// get the curent power of the signal.
|
||||||
const int16_t* data = static_cast<const int16_t*>(_data);
|
const int16_t* data = static_cast<const int16_t*>(_data);
|
||||||
int64_t value = 0;
|
int64_t value = 0;
|
||||||
@@ -47,16 +59,28 @@ void onDataReceived(const void* _data,
|
|||||||
}
|
}
|
||||||
value /= (_nbChunk*_map.size());
|
value /= (_nbChunk*_map.size());
|
||||||
std::cout << "Get data ... average=" << int32_t(value) << std::endl;
|
std::cout << "Get data ... average=" << int32_t(value) << std::endl;
|
||||||
|
} else {
|
||||||
|
// get the curent power of the signal.
|
||||||
|
const float* data = static_cast<const float*>(_data);
|
||||||
|
float value = 0;
|
||||||
|
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
||||||
|
value += std::abs(data[iii]);
|
||||||
|
}
|
||||||
|
value /= (_nbChunk*_map.size());
|
||||||
|
std::cout << "Get data ... average=" << float(value) << std::endl;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// just write data
|
// just write data
|
||||||
std::cout << "Get data ... chunks=" << _nbChunk << " time=" << _time << std::endl;
|
//std::cout << "Get data ... chunks=" << _nbChunk << " time=" << _time << std::endl;
|
||||||
_outputNode->fileWrite(_data, _map.size()*audio::getFormatBytes(_format), _nbChunk);
|
_outputNode->fileWrite(_data, _map.size()*audio::getFormatBytes(_format), _nbChunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int _argc, const char **_argv) {
|
int main(int _argc, const char **_argv) {
|
||||||
|
//! [audio_river_sample_init]
|
||||||
// the only one init for etk:
|
// the only one init for etk:
|
||||||
etk::init(_argc, _argv);
|
etk::init(_argc, _argv);
|
||||||
|
//! [audio_river_sample_init]
|
||||||
// local parameter:
|
// local parameter:
|
||||||
std::string configFile;
|
std::string configFile;
|
||||||
std::string ioName="microphone";
|
std::string ioName="microphone";
|
||||||
@@ -87,10 +111,13 @@ int main(int _argc, const char **_argv) {
|
|||||||
} else {
|
} else {
|
||||||
audio::river::init(configFile);
|
audio::river::init(configFile);
|
||||||
}
|
}
|
||||||
|
//! [audio_river_sample_get_interface]
|
||||||
// Create the River manager for tha application or part of the application.
|
// Create the River manager for tha application or part of the application.
|
||||||
std11::shared_ptr<audio::river::Manager> manager = audio::river::Manager::create("river_sample_read");
|
ememory::SharedPtr<audio::river::Manager> manager = audio::river::Manager::create("river_sample_read");
|
||||||
|
//! [audio_river_sample_get_interface]
|
||||||
|
//! [audio_river_sample_create_read_interface]
|
||||||
// create interface:
|
// create interface:
|
||||||
std11::shared_ptr<audio::river::Interface> interface;
|
ememory::SharedPtr<audio::river::Interface> interface;
|
||||||
//Get the generic input:
|
//Get the generic input:
|
||||||
interface = manager->createInput(48000,
|
interface = manager->createInput(48000,
|
||||||
std::vector<audio::channel>(),
|
std::vector<audio::channel>(),
|
||||||
@@ -100,30 +127,37 @@ int main(int _argc, const char **_argv) {
|
|||||||
std::cout << "nullptr interface" << std::endl;
|
std::cout << "nullptr interface" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
//! [audio_river_sample_create_read_interface]
|
||||||
etk::FSNode outputNode;
|
etk::FSNode outputNode;
|
||||||
// open output file if needed:
|
// open output file if needed:
|
||||||
if (outputFileName != "") {
|
if (outputFileName != "") {
|
||||||
outputNode.setName(outputFileName);
|
outputNode.setName(outputFileName);
|
||||||
outputNode.fileOpenWrite();
|
outputNode.fileOpenWrite();
|
||||||
}
|
}
|
||||||
|
//! [audio_river_sample_set_callback]
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
interface->setInputCallback(std11::bind(&onDataReceived,
|
interface->setInputCallback(std::bind(&onDataReceived,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6,
|
std::placeholders::_6,
|
||||||
&outputNode));
|
&outputNode));
|
||||||
|
//! [audio_river_sample_set_callback]
|
||||||
|
//! [audio_river_sample_read_start_stop]
|
||||||
// start the stream
|
// start the stream
|
||||||
interface->start();
|
interface->start();
|
||||||
// wait 10 second ...
|
// wait 10 second ...
|
||||||
sleep(10);
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
// stop the stream
|
// stop the stream
|
||||||
interface->stop();
|
interface->stop();
|
||||||
|
//! [audio_river_sample_read_start_stop]
|
||||||
|
//! [audio_river_sample_read_reset]
|
||||||
// remove interface and manager.
|
// remove interface and manager.
|
||||||
interface.reset();
|
interface.reset();
|
||||||
manager.reset();
|
manager.reset();
|
||||||
|
//! [audio_river_sample_read_reset]
|
||||||
// close the output file
|
// close the output file
|
||||||
if (outputFileName != "") {
|
if (outputFileName != "") {
|
||||||
outputNode.fileClose();
|
outputNode.fileClose();
|
||||||
@@ -131,3 +165,5 @@ int main(int _argc, const char **_argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! [audio_river_sample_read_all]
|
@@ -1,18 +1,38 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutin.module as module
|
import lutin.debug as debug
|
||||||
import lutin.tools as tools
|
import lutin.tools as tools
|
||||||
|
|
||||||
|
|
||||||
|
def get_type():
|
||||||
|
return "BINARY"
|
||||||
|
|
||||||
|
def get_sub_type():
|
||||||
|
return "SAMPLE"
|
||||||
|
|
||||||
def get_desc():
|
def get_desc():
|
||||||
return "Write some data"
|
return "Write some data"
|
||||||
|
|
||||||
|
def get_licence():
|
||||||
|
return "APACHE-2"
|
||||||
|
|
||||||
def create(target):
|
def get_compagny_type():
|
||||||
myModule = module.Module(__file__, 'river-sample-write', 'BINARY')
|
return "com"
|
||||||
myModule.add_src_file([
|
|
||||||
'main.cpp',
|
def get_compagny_name():
|
||||||
|
return "atria-soft"
|
||||||
|
|
||||||
|
def get_maintainer():
|
||||||
|
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||||
|
|
||||||
|
def configure(target, my_module):
|
||||||
|
my_module.add_src_file([
|
||||||
|
'write.cpp',
|
||||||
])
|
])
|
||||||
myModule.add_module_depend(['audio-river', 'etk'])
|
my_module.add_depend([
|
||||||
return myModule
|
'audio-river',
|
||||||
|
'etk'
|
||||||
|
])
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,51 +4,62 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <audio/river/river.h>
|
//! [audio_river_sample_write_all]
|
||||||
#include <audio/river/Manager.h>
|
|
||||||
#include <audio/river/Interface.h>
|
#include <audio/river/river.hpp>
|
||||||
#include <etk/etk.h>
|
#include <audio/river/Manager.hpp>
|
||||||
#include <unistd.h>
|
#include <audio/river/Interface.hpp>
|
||||||
|
#include <etk/etk.hpp>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
|
||||||
|
//! [audio_river_sample_write_config_file]
|
||||||
static const std::string configurationRiver =
|
static const std::string configurationRiver =
|
||||||
"{\n"
|
"{\n"
|
||||||
" speaker:{\n"
|
" speaker:{\n"
|
||||||
" io:'output',\n"
|
" io:'output',\n"
|
||||||
" map-on:{\n"
|
" map-on:{\n"
|
||||||
" interface:'auto',\n"
|
" interface:'alsa',\n"
|
||||||
" name:'default',\n"
|
" name:'hw:0,0',\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" frequency:0,\n"
|
" frequency:48000,\n"
|
||||||
|
//" channel-map:['front-left', 'front-right', 'rear-left', 'rear-right'],\n"
|
||||||
" channel-map:['front-left', 'front-right'],\n"
|
" channel-map:['front-left', 'front-right'],\n"
|
||||||
" type:'auto',\n"
|
" type:'int16',\n"
|
||||||
" nb-chunk:1024,\n"
|
" nb-chunk:1024,\n"
|
||||||
" volume-name:'MASTER'\n"
|
" volume-name:'MASTER'\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
//! [audio_river_sample_write_config_file]
|
||||||
|
|
||||||
|
static const int32_t nbChannelMax=8;
|
||||||
|
|
||||||
|
//! [audio_river_sample_callback_implement]
|
||||||
void onDataNeeded(void* _data,
|
void onDataNeeded(void* _data,
|
||||||
const audio::Time& _time,
|
const audio::Time& _time,
|
||||||
size_t _nbChunk,
|
size_t _nbChunk,
|
||||||
enum audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
static double phase = 0;
|
static double phase[8] = {0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
std::cout << "[ERROR] call wrong type ... (need int16_t)" << std::endl;
|
std::cout << "[ERROR] call wrong type ... (need int16_t)" << std::endl;
|
||||||
}
|
}
|
||||||
|
//std::cout << "Map " << _map << std::endl;
|
||||||
int16_t* data = static_cast<int16_t*>(_data);
|
int16_t* data = static_cast<int16_t*>(_data);
|
||||||
double baseCycle = 2.0*M_PI/(double)48000 * (double)550;
|
double baseCycle = 2.0*M_PI/double(48000) * double(440);
|
||||||
for (int32_t iii=0; iii<_nbChunk; iii++) {
|
for (int32_t iii=0; iii<_nbChunk; iii++) {
|
||||||
for (int32_t jjj=0; jjj<_map.size(); jjj++) {
|
for (int32_t jjj=0; jjj<_map.size(); jjj++) {
|
||||||
data[_map.size()*iii+jjj] = cos(phase) * 30000;
|
data[_map.size()*iii+jjj] = cos(phase[jjj]) * 30000;
|
||||||
}
|
phase[jjj] += baseCycle*jjj;
|
||||||
phase += baseCycle;
|
if (phase[jjj] >= 2*M_PI) {
|
||||||
if (phase >= 2*M_PI) {
|
phase[jjj] -= 2*M_PI;
|
||||||
phase -= 2*M_PI;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//! [audio_river_sample_callback_implement]
|
||||||
|
|
||||||
int main(int _argc, const char **_argv) {
|
int main(int _argc, const char **_argv) {
|
||||||
// the only one init for etk:
|
// the only one init for etk:
|
||||||
@@ -65,9 +76,10 @@ int main(int _argc, const char **_argv) {
|
|||||||
// initialize river interface
|
// initialize river interface
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
// Create the River manager for tha application or part of the application.
|
// Create the River manager for tha application or part of the application.
|
||||||
std11::shared_ptr<audio::river::Manager> manager = audio::river::Manager::create("river_sample_read");
|
ememory::SharedPtr<audio::river::Manager> manager = audio::river::Manager::create("river_sample_read");
|
||||||
|
//! [audio_river_sample_create_write_interface]
|
||||||
// create interface:
|
// create interface:
|
||||||
std11::shared_ptr<audio::river::Interface> interface;
|
ememory::SharedPtr<audio::river::Interface> interface;
|
||||||
//Get the generic input:
|
//Get the generic input:
|
||||||
interface = manager->createOutput(48000,
|
interface = manager->createOutput(48000,
|
||||||
std::vector<audio::channel>(),
|
std::vector<audio::channel>(),
|
||||||
@@ -77,18 +89,21 @@ int main(int _argc, const char **_argv) {
|
|||||||
std::cout << "nullptr interface" << std::endl;
|
std::cout << "nullptr interface" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
//! [audio_river_sample_create_write_interface]
|
||||||
|
//! [audio_river_sample_set_callback]
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
interface->setOutputCallback(std11::bind(&onDataNeeded,
|
interface->setOutputCallback(std::bind(&onDataNeeded,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
|
//! [audio_river_sample_set_callback]
|
||||||
// start the stream
|
// start the stream
|
||||||
interface->start();
|
interface->start();
|
||||||
// wait 10 second ...
|
// wait 10 second ...
|
||||||
sleep(10);
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
// stop the stream
|
// stop the stream
|
||||||
interface->stop();
|
interface->stop();
|
||||||
// remove interface and manager.
|
// remove interface and manager.
|
||||||
@@ -97,3 +112,5 @@ int main(int _argc, const char **_argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! [audio_river_sample_write_all]
|
||||||
|
|
@@ -1,55 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.3)
|
|
||||||
project(audio_river_test)
|
|
||||||
|
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
||||||
|
|
||||||
## Find catkin macros and libraries
|
|
||||||
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
|
|
||||||
## is used, also find other catkin packages
|
|
||||||
find_package(catkin REQUIRED COMPONENTS
|
|
||||||
audio_river
|
|
||||||
rosconsole
|
|
||||||
)
|
|
||||||
|
|
||||||
###################################
|
|
||||||
## catkin specific configuration ##
|
|
||||||
###################################
|
|
||||||
## The catkin_package macro generates cmake config files for your package
|
|
||||||
## Declare things to be passed to dependent projects
|
|
||||||
## INCLUDE_DIRS: uncomment this if you package contains header files
|
|
||||||
## LIBRARIES: libraries you create in this project that dependent projects also need
|
|
||||||
## CATKIN_DEPENDS: catkin_packages dependent projects also need
|
|
||||||
## DEPENDS: system dependencies of this project that dependent projects also need
|
|
||||||
catkin_package()
|
|
||||||
|
|
||||||
###########
|
|
||||||
## Build ##
|
|
||||||
###########
|
|
||||||
|
|
||||||
## Specify additional locations of header files
|
|
||||||
## Your package locations should be listed before other locations
|
|
||||||
include_directories(
|
|
||||||
..
|
|
||||||
${catkin_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
## Declare a cpp library
|
|
||||||
catkin_add_gtest(${PROJECT_NAME}
|
|
||||||
../debug.cpp
|
|
||||||
../main.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
## Specify libraries to link a library or executable target against
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
|
||||||
${catkin_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
||||||
#############
|
|
||||||
## Install ##
|
|
||||||
#############
|
|
||||||
|
|
||||||
## Mark executables and/or libraries for installation
|
|
||||||
#install(TARGETS ${PROJECT_NAME}
|
|
||||||
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
|
||||||
#)
|
|
||||||
|
|
@@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<package>
|
|
||||||
<name>audio_river_test</name>
|
|
||||||
<version>0.3.0</version>
|
|
||||||
<description>Ewol River test</description>
|
|
||||||
<maintainer email="yui.heero@gmail.com">Edouard DUPIN</maintainer>
|
|
||||||
<license>Apache-2.0</license>
|
|
||||||
<build_depend>gtest</build_depend>
|
|
||||||
<build_depend>audio_river</build_depend>
|
|
||||||
<buildtool_depend>catkin</buildtool_depend>
|
|
||||||
<run_depend>audio_river</run_depend>
|
|
||||||
<run_depend>gtest</run_depend>
|
|
||||||
</package>
|
|
@@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license GPL v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
int32_t appl::getLogId() {
|
|
||||||
static int32_t g_val = etk::log::registerInstance("test");
|
|
||||||
return g_val;
|
|
||||||
}
|
|
||||||
|
|
@@ -4,30 +4,48 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "debug.h"
|
#include <test-debug/debug.hpp>
|
||||||
#include <audio/river/river.h>
|
|
||||||
#include <audio/river/Manager.h>
|
#define TEST_SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \
|
||||||
#include <audio/river/Interface.h>
|
do { \
|
||||||
|
static FILE *pointerOnFile = nullptr; \
|
||||||
|
static bool errorOpen = false; \
|
||||||
|
if (pointerOnFile == nullptr) { \
|
||||||
|
TEST_WARNING("open file '" << fileName << "' type=" << #type); \
|
||||||
|
pointerOnFile = fopen(fileName,"w"); \
|
||||||
|
if ( errorOpen == false \
|
||||||
|
&& pointerOnFile == nullptr) { \
|
||||||
|
TEST_ERROR("ERROR OPEN file ... '" << fileName << "' type=" << #type); \
|
||||||
|
errorOpen=true; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
if (pointerOnFile != nullptr) { \
|
||||||
|
fwrite((dataPointer), sizeof(type), (nbElement), pointerOnFile); \
|
||||||
|
/* fflush(pointerOnFile);*/ \
|
||||||
|
} \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <audio/river/river.hpp>
|
||||||
|
#include <audio/river/Manager.hpp>
|
||||||
|
#include <audio/river/Interface.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <etk/etk.h>
|
#include <etk/etk.hpp>
|
||||||
#include <etk/os/FSNode.h>
|
#include <etk/os/FSNode.hpp>
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unistd.h>
|
|
||||||
#include <etk/thread.h>
|
|
||||||
#include "testAEC.h"
|
|
||||||
#include "testEchoDelay.h"
|
|
||||||
#include "testFormat.h"
|
|
||||||
#include "testMuxer.h"
|
|
||||||
#include "testPlaybackCallback.h"
|
|
||||||
#include "testPlaybackWrite.h"
|
|
||||||
#include "testRecordCallback.h"
|
|
||||||
#include "testRecordRead.h"
|
|
||||||
#include "testVolume.h"
|
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
#undef __class__
|
#include "testAEC.hpp"
|
||||||
#define __class__ "test"
|
#include "testEchoDelay.hpp"
|
||||||
|
#include "testFormat.hpp"
|
||||||
|
#include "testMuxer.hpp"
|
||||||
|
#include "testPlaybackCallback.hpp"
|
||||||
|
#include "testPlaybackWrite.hpp"
|
||||||
|
#include "testRecordCallback.hpp"
|
||||||
|
#include "testRecordRead.hpp"
|
||||||
|
#include "testVolume.hpp"
|
||||||
|
|
||||||
int main(int _argc, const char** _argv) {
|
int main(int _argc, const char** _argv) {
|
||||||
// init Google test :
|
// init Google test :
|
||||||
@@ -38,8 +56,8 @@ int main(int _argc, const char** _argv) {
|
|||||||
std::string data = _argv[iii];
|
std::string data = _argv[iii];
|
||||||
if ( data == "-h"
|
if ( data == "-h"
|
||||||
|| data == "--help") {
|
|| data == "--help") {
|
||||||
APPL_PRINT("Help : ");
|
TEST_PRINT("Help : ");
|
||||||
APPL_PRINT(" ./xxx ---");
|
TEST_PRINT(" ./xxx ---");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,23 +3,20 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef __RIVER_TEST_AEC_H__
|
#include <test-debug/debug.hpp>
|
||||||
#define __RIVER_TEST_AEC_H__
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "test_aec"
|
|
||||||
|
|
||||||
namespace river_test_aec {
|
namespace river_test_aec {
|
||||||
|
|
||||||
class Linker {
|
class Linker {
|
||||||
private:
|
private:
|
||||||
std11::shared_ptr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceOut;
|
ememory::SharedPtr<audio::river::Interface> m_interfaceOut;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceIn;
|
ememory::SharedPtr<audio::river::Interface> m_interfaceIn;
|
||||||
audio::drain::CircularBuffer m_buffer;
|
audio::drain::CircularBuffer m_buffer;
|
||||||
public:
|
public:
|
||||||
Linker(std11::shared_ptr<audio::river::Manager> _manager, const std::string& _input, const std::string& _output) :
|
Linker(ememory::SharedPtr<audio::river::Manager> _manager, const std::string& _input, const std::string& _output) :
|
||||||
m_manager(_manager) {
|
m_manager(_manager) {
|
||||||
//Set stereo output:
|
//Set stereo output:
|
||||||
std::vector<audio::channel> channelMap;
|
std::vector<audio::channel> channelMap;
|
||||||
@@ -29,25 +26,25 @@ namespace river_test_aec {
|
|||||||
channelMap.push_back(audio::channel_frontLeft);
|
channelMap.push_back(audio::channel_frontLeft);
|
||||||
channelMap.push_back(audio::channel_frontRight);
|
channelMap.push_back(audio::channel_frontRight);
|
||||||
}
|
}
|
||||||
m_buffer.setCapacity(std11::chrono::milliseconds(2000), sizeof(int16_t)*channelMap.size(), 48000);
|
m_buffer.setCapacity(std::chrono::milliseconds(2000), sizeof(int16_t)*channelMap.size(), 48000);
|
||||||
|
|
||||||
m_interfaceOut = m_manager->createOutput(48000,
|
m_interfaceOut = m_manager->createOutput(48000,
|
||||||
channelMap,
|
channelMap,
|
||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
_output);
|
_output);
|
||||||
if(m_interfaceOut == nullptr) {
|
if(m_interfaceOut == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceOut->setOutputCallback(std11::bind(&Linker::onDataNeeded,
|
m_interfaceOut->setOutputCallback(std::bind(&Linker::onDataNeeded,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
m_interfaceOut->addVolumeGroup("FLOW");
|
m_interfaceOut->addVolumeGroup("FLOW");
|
||||||
if ("speaker" == _output) {
|
if ("speaker" == _output) {
|
||||||
m_interfaceOut->setParameter("volume", "FLOW", "0dB");
|
m_interfaceOut->setParameter("volume", "FLOW", "0dB");
|
||||||
@@ -58,18 +55,18 @@ namespace river_test_aec {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
_input);
|
_input);
|
||||||
if(m_interfaceIn == nullptr) {
|
if(m_interfaceIn == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceIn->setInputCallback(std11::bind(&Linker::onDataReceived,
|
m_interfaceIn->setInputCallback(std::bind(&Linker::onDataReceived,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
|
|
||||||
}
|
}
|
||||||
void onDataNeeded(void* _data,
|
void onDataNeeded(void* _data,
|
||||||
@@ -79,7 +76,7 @@ namespace river_test_aec {
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
APPL_ERROR("call wrong type ... (need int16_t)");
|
TEST_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
m_buffer.read(_data, _nbChunk);
|
m_buffer.read(_data, _nbChunk);
|
||||||
}
|
}
|
||||||
@@ -90,17 +87,17 @@ namespace river_test_aec {
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
APPL_ERROR("call wrong type ... (need int16_t)");
|
TEST_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
m_buffer.write(_data, _nbChunk);
|
m_buffer.write(_data, _nbChunk);
|
||||||
}
|
}
|
||||||
void start() {
|
void start() {
|
||||||
if(m_interfaceIn == nullptr) {
|
if(m_interfaceIn == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(m_interfaceOut == nullptr) {
|
if(m_interfaceOut == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interfaceOut->start();
|
m_interfaceOut->start();
|
||||||
@@ -108,11 +105,11 @@ namespace river_test_aec {
|
|||||||
}
|
}
|
||||||
void stop() {
|
void stop() {
|
||||||
if(m_interfaceIn == nullptr) {
|
if(m_interfaceIn == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(m_interfaceOut == nullptr) {
|
if(m_interfaceOut == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_manager->generateDotAll("activeProcess.dot");
|
m_manager->generateDotAll("activeProcess.dot");
|
||||||
@@ -200,13 +197,13 @@ namespace river_test_aec {
|
|||||||
|
|
||||||
TEST(TestUser, testAECManually) {
|
TEST(TestUser, testAECManually) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
std11::shared_ptr<Linker> processLink1 = std11::make_shared<Linker>(manager, "microphone-clean", "speaker");
|
ememory::SharedPtr<Linker> processLink1 = ememory::makeShared<Linker>(manager, "microphone-clean", "speaker");
|
||||||
std11::shared_ptr<Linker> processLink2 = std11::make_shared<Linker>(manager, "microphone", "speaker-test");
|
ememory::SharedPtr<Linker> processLink2 = ememory::makeShared<Linker>(manager, "microphone", "speaker-test");
|
||||||
processLink1->start();
|
processLink1->start();
|
||||||
processLink2->start();
|
processLink2->start();
|
||||||
sleep(30);
|
std::this_thread::sleep_for(std::chrono::seconds(20));
|
||||||
processLink1->stop();
|
processLink1->stop();
|
||||||
processLink2->stop();
|
processLink2->stop();
|
||||||
|
|
||||||
@@ -217,7 +214,4 @@ namespace river_test_aec {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
|
|
||||||
#endif
|
|
@@ -3,26 +3,21 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef __RIVER_TEST_ECHO_DELAY_H__
|
#include <test-debug/debug.hpp>
|
||||||
#define __RIVER_TEST_ECHO_DELAY_H__
|
|
||||||
|
|
||||||
#include <audio/river/debug.h>
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "test_echo_delay"
|
|
||||||
|
|
||||||
namespace river_test_echo_delay {
|
namespace river_test_echo_delay {
|
||||||
class TestClass {
|
class TestClass {
|
||||||
private:
|
private:
|
||||||
std11::shared_ptr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceOut;
|
ememory::SharedPtr<audio::river::Interface> m_interfaceOut;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceIn;
|
ememory::SharedPtr<audio::river::Interface> m_interfaceIn;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceFB;
|
ememory::SharedPtr<audio::river::Interface> m_interfaceFB;
|
||||||
double m_phase;
|
double m_phase;
|
||||||
double m_freq;
|
double m_freq;
|
||||||
int32_t m_nextSampleCount;
|
int32_t m_nextSampleCount;
|
||||||
std11::chrono::milliseconds m_delayBetweenEvent;
|
std::chrono::milliseconds m_delayBetweenEvent;
|
||||||
audio::Time m_nextTick;
|
audio::Time m_nextTick;
|
||||||
audio::Time m_currentTick;
|
audio::Time m_currentTick;
|
||||||
int32_t m_stateFB;
|
int32_t m_stateFB;
|
||||||
@@ -33,7 +28,7 @@ namespace river_test_echo_delay {
|
|||||||
int16_t m_volumeInputMin;
|
int16_t m_volumeInputMin;
|
||||||
float m_gain;
|
float m_gain;
|
||||||
public:
|
public:
|
||||||
TestClass(std11::shared_ptr<audio::river::Manager> _manager) :
|
TestClass(ememory::SharedPtr<audio::river::Manager> _manager) :
|
||||||
m_manager(_manager),
|
m_manager(_manager),
|
||||||
m_phase(0),
|
m_phase(0),
|
||||||
m_freq(400),
|
m_freq(400),
|
||||||
@@ -50,18 +45,18 @@ namespace river_test_echo_delay {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
"speaker");
|
"speaker");
|
||||||
if(m_interfaceOut == nullptr) {
|
if(m_interfaceOut == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceOut->setOutputCallback(std11::bind(&TestClass::onDataNeeded,
|
m_interfaceOut->setOutputCallback(std::bind(&TestClass::onDataNeeded,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
m_interfaceOut->addVolumeGroup("FLOW");
|
m_interfaceOut->addVolumeGroup("FLOW");
|
||||||
m_interfaceOut->setParameter("volume", "FLOW", etk::to_string(m_gain) + "dB");
|
m_interfaceOut->setParameter("volume", "FLOW", etk::to_string(m_gain) + "dB");
|
||||||
|
|
||||||
@@ -70,36 +65,36 @@ namespace river_test_echo_delay {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
"microphone");
|
"microphone");
|
||||||
if(m_interfaceIn == nullptr) {
|
if(m_interfaceIn == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceIn->setInputCallback(std11::bind(&TestClass::onDataReceived,
|
m_interfaceIn->setInputCallback(std::bind(&TestClass::onDataReceived,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
|
|
||||||
m_interfaceFB = m_manager->createFeedback(48000,
|
m_interfaceFB = m_manager->createFeedback(48000,
|
||||||
channelMap,
|
channelMap,
|
||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
"speaker");
|
"speaker");
|
||||||
if(m_interfaceFB == nullptr) {
|
if(m_interfaceFB == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceFB->setInputCallback(std11::bind(&TestClass::onDataReceivedFeedBack,
|
m_interfaceFB->setInputCallback(std::bind(&TestClass::onDataReceivedFeedBack,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
|
|
||||||
m_manager->generateDotAll("activeProcess.dot");
|
m_manager->generateDotAll("activeProcess.dot");
|
||||||
}
|
}
|
||||||
@@ -135,7 +130,7 @@ namespace river_test_echo_delay {
|
|||||||
m_nextSampleCount = m_delayBetweenEvent.count()*int64_t(_frequency)/1000;
|
m_nextSampleCount = m_delayBetweenEvent.count()*int64_t(_frequency)/1000;
|
||||||
m_phase = -1;
|
m_phase = -1;
|
||||||
}
|
}
|
||||||
//APPL_INFO("sample : " << m_nextSampleCount);
|
//TEST_INFO("sample : " << m_nextSampleCount);
|
||||||
for (int32_t iii=0; iii<_nbChunk; iii++) {
|
for (int32_t iii=0; iii<_nbChunk; iii++) {
|
||||||
if (m_nextSampleCount > 0) {
|
if (m_nextSampleCount > 0) {
|
||||||
m_nextSampleCount--;
|
m_nextSampleCount--;
|
||||||
@@ -157,7 +152,7 @@ namespace river_test_echo_delay {
|
|||||||
// start detection ...
|
// start detection ...
|
||||||
m_stateFB = 0;
|
m_stateFB = 0;
|
||||||
m_stateMic = 0;
|
m_stateMic = 0;
|
||||||
APPL_WARNING("Time Pulse zero crossing: " << m_currentTick << " id=" << iii);
|
TEST_WARNING("Time Pulse zero crossing: " << m_currentTick << " id=" << iii);
|
||||||
}
|
}
|
||||||
m_phase = newPhase;
|
m_phase = newPhase;
|
||||||
if (m_phase >= 2*M_PI) {
|
if (m_phase >= 2*M_PI) {
|
||||||
@@ -182,7 +177,7 @@ namespace river_test_echo_delay {
|
|||||||
return _time + audio::Duration(0, int64_t(_pos+1)*1000000000LL/int64_t(_frequency));
|
return _time + audio::Duration(0, int64_t(_pos+1)*1000000000LL/int64_t(_frequency));
|
||||||
}
|
}
|
||||||
double xxx = double(-_val1) / double(_val2 - _val1);
|
double xxx = double(-_val1) / double(_val2 - _val1);
|
||||||
APPL_VERBOSE("deltaPos:" << xxx);
|
TEST_VERBOSE("deltaPos:" << xxx);
|
||||||
return _time + audio::Duration(0, int64_t((double(_pos)+xxx)*1000000000.0)/int64_t(_frequency));
|
return _time + audio::Duration(0, int64_t((double(_pos)+xxx)*1000000000.0)/int64_t(_frequency));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,9 +188,9 @@ namespace river_test_echo_delay {
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
APPL_ERROR("call wrong type ... (need int16_t)");
|
TEST_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
RIVER_SAVE_FILE_MACRO(int16_t, "REC_FeedBack.raw", _data, _nbChunk*_map.size());
|
TEST_SAVE_FILE_MACRO(int16_t, "REC_FeedBack.raw", _data, _nbChunk*_map.size());
|
||||||
if (m_estimateVolumeInput == true) {
|
if (m_estimateVolumeInput == true) {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
} else {
|
} else {
|
||||||
@@ -207,10 +202,10 @@ namespace river_test_echo_delay {
|
|||||||
if (m_stateFB == 0) {
|
if (m_stateFB == 0) {
|
||||||
if (data[iii*_map.size() + jjj] > INT16_MAX/5) {
|
if (data[iii*_map.size() + jjj] > INT16_MAX/5) {
|
||||||
m_stateFB = 1;
|
m_stateFB = 1;
|
||||||
APPL_VERBOSE("FB: detect Normal " << iii);
|
TEST_VERBOSE("FB: detect Normal " << iii);
|
||||||
} else if (data[iii*_map.size() + jjj] < -INT16_MAX/5) {
|
} else if (data[iii*_map.size() + jjj] < -INT16_MAX/5) {
|
||||||
m_stateFB = 2;
|
m_stateFB = 2;
|
||||||
APPL_VERBOSE("FB: detect inverse " << iii);
|
TEST_VERBOSE("FB: detect inverse " << iii);
|
||||||
}
|
}
|
||||||
} else if (m_stateFB == 1) {
|
} else if (m_stateFB == 1) {
|
||||||
// normale phase
|
// normale phase
|
||||||
@@ -218,10 +213,10 @@ namespace river_test_echo_delay {
|
|||||||
// detect inversion of signe ...
|
// detect inversion of signe ...
|
||||||
m_stateFB = 3;
|
m_stateFB = 3;
|
||||||
audio::Time time = getInterpolateTime(_time, iii-1, data[(iii-1)*_map.size() + jjj], data[iii*_map.size() + jjj], _frequency);
|
audio::Time time = getInterpolateTime(_time, iii-1, data[(iii-1)*_map.size() + jjj], data[iii*_map.size() + jjj], _frequency);
|
||||||
APPL_VERBOSE("FB: 1 position -1: " << iii-1 << " " << data[(iii-1)*_map.size() + jjj]);
|
TEST_VERBOSE("FB: 1 position -1: " << iii-1 << " " << data[(iii-1)*_map.size() + jjj]);
|
||||||
APPL_VERBOSE("FB: 1 position 0: " << iii << " " << data[iii*_map.size() + jjj]);
|
TEST_VERBOSE("FB: 1 position 0: " << iii << " " << data[iii*_map.size() + jjj]);
|
||||||
|
|
||||||
APPL_WARNING("FB: 1 time detected: " << time << " delay = " << float((time-m_currentTick).count())/1000.0f << "µs");
|
TEST_WARNING("FB: 1 time detected: " << time << " delay = " << float((time-m_currentTick).count())/1000.0f << "µs");
|
||||||
}
|
}
|
||||||
} else if (m_stateFB == 2) {
|
} else if (m_stateFB == 2) {
|
||||||
// inverse phase
|
// inverse phase
|
||||||
@@ -229,9 +224,9 @@ namespace river_test_echo_delay {
|
|||||||
// detect inversion of signe ...
|
// detect inversion of signe ...
|
||||||
m_stateFB = 3;
|
m_stateFB = 3;
|
||||||
audio::Time time = getInterpolateTime(_time, iii-1, data[(iii-1)*_map.size() + jjj], data[iii*_map.size() + jjj], _frequency);
|
audio::Time time = getInterpolateTime(_time, iii-1, data[(iii-1)*_map.size() + jjj], data[iii*_map.size() + jjj], _frequency);
|
||||||
APPL_VERBOSE("FB: 2 position -1: " << iii-1 << " " << data[(iii-1)*_map.size() + jjj]);
|
TEST_VERBOSE("FB: 2 position -1: " << iii-1 << " " << data[(iii-1)*_map.size() + jjj]);
|
||||||
APPL_VERBOSE("FB: 2 position 0: " << iii << " " << data[iii*_map.size() + jjj]);
|
TEST_VERBOSE("FB: 2 position 0: " << iii << " " << data[iii*_map.size() + jjj]);
|
||||||
APPL_WARNING("FB: 2 time detected: " << time << " delay = " << float((time-m_currentTick).count())/1000.0f << "µs");
|
TEST_WARNING("FB: 2 time detected: " << time << " delay = " << float((time-m_currentTick).count())/1000.0f << "µs");
|
||||||
}
|
}
|
||||||
} else if (m_stateFB == 3) {
|
} else if (m_stateFB == 3) {
|
||||||
// TODO : Detect the pic ...
|
// TODO : Detect the pic ...
|
||||||
@@ -248,16 +243,16 @@ namespace river_test_echo_delay {
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
APPL_ERROR("call wrong type ... (need int16_t)");
|
TEST_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
RIVER_SAVE_FILE_MACRO(int16_t, "REC_Microphone.raw", _data, _nbChunk*_map.size());
|
TEST_SAVE_FILE_MACRO(int16_t, "REC_Microphone.raw", _data, _nbChunk*_map.size());
|
||||||
const int16_t* data = static_cast<const int16_t*>(_data);
|
const int16_t* data = static_cast<const int16_t*>(_data);
|
||||||
if (m_estimateVolumeInput == true) {
|
if (m_estimateVolumeInput == true) {
|
||||||
m_stateMic ++;
|
m_stateMic ++;
|
||||||
const int16_t* data = static_cast<const int16_t*>(_data);
|
const int16_t* data = static_cast<const int16_t*>(_data);
|
||||||
if (m_stateMic <= 40) {
|
if (m_stateMic <= 40) {
|
||||||
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
||||||
//APPL_INFO("value=" << data[iii]);
|
//TEST_INFO("value=" << data[iii]);
|
||||||
m_volumeInputMax = std::max(int16_t(data[iii]), m_volumeInputMax);
|
m_volumeInputMax = std::max(int16_t(data[iii]), m_volumeInputMax);
|
||||||
m_volumeInputMin = std::min(int16_t(data[iii]), m_volumeInputMin);
|
m_volumeInputMin = std::min(int16_t(data[iii]), m_volumeInputMin);
|
||||||
}
|
}
|
||||||
@@ -269,7 +264,7 @@ namespace river_test_echo_delay {
|
|||||||
int16_t valueMax = 0;
|
int16_t valueMax = 0;
|
||||||
int16_t valueMin = 0;
|
int16_t valueMin = 0;
|
||||||
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
||||||
//APPL_INFO("value=" << data[iii]);
|
//TEST_INFO("value=" << data[iii]);
|
||||||
valueMax = std::max(int16_t(data[iii]), valueMax);
|
valueMax = std::max(int16_t(data[iii]), valueMax);
|
||||||
valueMin = std::min(int16_t(data[iii]), valueMin);
|
valueMin = std::min(int16_t(data[iii]), valueMin);
|
||||||
}
|
}
|
||||||
@@ -284,7 +279,7 @@ namespace river_test_echo_delay {
|
|||||||
m_gain += 3.0f;
|
m_gain += 3.0f;
|
||||||
m_gain = std::min(m_gain, 0.0f);
|
m_gain = std::min(m_gain, 0.0f);
|
||||||
m_interfaceOut->setParameter("volume", "FLOW", etk::to_string(m_gain) + "dB");
|
m_interfaceOut->setParameter("volume", "FLOW", etk::to_string(m_gain) + "dB");
|
||||||
APPL_INFO("Set detection volume : " << m_gain << " m_stateMic=" << m_stateMic);
|
TEST_INFO("Set detection volume : " << m_gain << " m_stateMic=" << m_stateMic);
|
||||||
m_stateMic = 3;
|
m_stateMic = 3;
|
||||||
m_phase = -1;
|
m_phase = -1;
|
||||||
m_estimateVolumeInput = false;
|
m_estimateVolumeInput = false;
|
||||||
@@ -292,7 +287,7 @@ namespace river_test_echo_delay {
|
|||||||
} else {
|
} else {
|
||||||
if (m_stateMic%2 == 0) {
|
if (m_stateMic%2 == 0) {
|
||||||
if (m_gain == 0.0f) {
|
if (m_gain == 0.0f) {
|
||||||
APPL_CRITICAL("Can not find the basicVolume ...");
|
TEST_CRITICAL("Can not find the basicVolume ...");
|
||||||
}
|
}
|
||||||
// just update volume
|
// just update volume
|
||||||
m_gain += 1.0f;
|
m_gain += 1.0f;
|
||||||
@@ -309,10 +304,10 @@ namespace river_test_echo_delay {
|
|||||||
if (m_stateMic == 0) {
|
if (m_stateMic == 0) {
|
||||||
if (data[iii*_map.size() + jjj] > m_volumeInputMax) {
|
if (data[iii*_map.size() + jjj] > m_volumeInputMax) {
|
||||||
m_stateMic = 1;
|
m_stateMic = 1;
|
||||||
APPL_VERBOSE("Mic: detect Normal " << iii);
|
TEST_VERBOSE("Mic: detect Normal " << iii);
|
||||||
} else if (data[iii*_map.size() + jjj] < m_volumeInputMin) {
|
} else if (data[iii*_map.size() + jjj] < m_volumeInputMin) {
|
||||||
m_stateMic = 2;
|
m_stateMic = 2;
|
||||||
APPL_VERBOSE("Mic: detect inverse " << iii);
|
TEST_VERBOSE("Mic: detect inverse " << iii);
|
||||||
}
|
}
|
||||||
} else if (m_stateMic == 1) {
|
} else if (m_stateMic == 1) {
|
||||||
// normale phase
|
// normale phase
|
||||||
@@ -320,11 +315,11 @@ namespace river_test_echo_delay {
|
|||||||
// detect inversion of signe ...
|
// detect inversion of signe ...
|
||||||
m_stateMic = 3;
|
m_stateMic = 3;
|
||||||
audio::Time time = getInterpolateTime(_time, iii-1, data[(iii-1)*_map.size() + jjj], data[iii*_map.size() + jjj], _frequency);
|
audio::Time time = getInterpolateTime(_time, iii-1, data[(iii-1)*_map.size() + jjj], data[iii*_map.size() + jjj], _frequency);
|
||||||
APPL_VERBOSE("MIC: 1 position -1: " << iii-1 << " " << data[(iii-1)*_map.size() + jjj]);
|
TEST_VERBOSE("MIC: 1 position -1: " << iii-1 << " " << data[(iii-1)*_map.size() + jjj]);
|
||||||
APPL_VERBOSE("MIC: 1 position 0: " << iii << " " << data[iii*_map.size() + jjj]);
|
TEST_VERBOSE("MIC: 1 position 0: " << iii << " " << data[iii*_map.size() + jjj]);
|
||||||
audio::Duration delay = time-m_currentTick;
|
audio::Duration delay = time-m_currentTick;
|
||||||
int32_t sampleDalay = (delay.count()*_frequency)/1000000000LL;
|
int32_t sampleDalay = (delay.count()*_frequency)/1000000000LL;
|
||||||
APPL_WARNING("MIC: 1 time detected: " << time << " delay = " << float(delay.count())/1000.0f << "µs samples=" << sampleDalay);
|
TEST_WARNING("MIC: 1 time detected: " << time << " delay = " << float(delay.count())/1000.0f << "µs samples=" << sampleDalay);
|
||||||
m_delayListMic.push_back(delay.count());
|
m_delayListMic.push_back(delay.count());
|
||||||
}
|
}
|
||||||
} else if (m_stateMic == 2) {
|
} else if (m_stateMic == 2) {
|
||||||
@@ -333,11 +328,11 @@ namespace river_test_echo_delay {
|
|||||||
// detect inversion of signe ...
|
// detect inversion of signe ...
|
||||||
m_stateMic = 3;
|
m_stateMic = 3;
|
||||||
audio::Time time = getInterpolateTime(_time, iii-1, data[(iii-1)*_map.size() + jjj], data[iii*_map.size() + jjj], _frequency);
|
audio::Time time = getInterpolateTime(_time, iii-1, data[(iii-1)*_map.size() + jjj], data[iii*_map.size() + jjj], _frequency);
|
||||||
APPL_VERBOSE("MIC: 2 position -1: " << iii-1 << " " << data[(iii-1)*_map.size() + jjj]);
|
TEST_VERBOSE("MIC: 2 position -1: " << iii-1 << " " << data[(iii-1)*_map.size() + jjj]);
|
||||||
APPL_VERBOSE("MIC: 2 position 0: " << iii << " " << data[iii*_map.size() + jjj]);
|
TEST_VERBOSE("MIC: 2 position 0: " << iii << " " << data[iii*_map.size() + jjj]);
|
||||||
audio::Duration delay = time-m_currentTick;
|
audio::Duration delay = time-m_currentTick;
|
||||||
int32_t sampleDalay = (delay.count()*_frequency)/1000000000LL;
|
int32_t sampleDalay = (delay.count()*_frequency)/1000000000LL;
|
||||||
APPL_WARNING("MIC: 2 time detected: " << time << " delay = " << float(delay.count())/1000.0f << "µs samples=" << sampleDalay);
|
TEST_WARNING("MIC: 2 time detected: " << time << " delay = " << float(delay.count())/1000.0f << "µs samples=" << sampleDalay);
|
||||||
m_delayListMic.push_back(delay.count());
|
m_delayListMic.push_back(delay.count());
|
||||||
}
|
}
|
||||||
} else if (m_stateMic == 3) {
|
} else if (m_stateMic == 3) {
|
||||||
@@ -350,24 +345,24 @@ namespace river_test_echo_delay {
|
|||||||
}
|
}
|
||||||
void run() {
|
void run() {
|
||||||
if(m_interfaceIn == nullptr) {
|
if(m_interfaceIn == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(m_interfaceOut == nullptr) {
|
if(m_interfaceOut == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(m_interfaceFB == nullptr) {
|
if(m_interfaceFB == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interfaceOut->start();
|
m_interfaceOut->start();
|
||||||
m_interfaceIn->start();
|
m_interfaceIn->start();
|
||||||
//m_interfaceFB->start();
|
//m_interfaceFB->start();
|
||||||
while (m_estimateVolumeInput == true) {
|
while (m_estimateVolumeInput == true) {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
}
|
}
|
||||||
usleep(10000000);
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
//m_interfaceFB->stop();
|
//m_interfaceFB->stop();
|
||||||
m_interfaceIn->stop();
|
m_interfaceIn->stop();
|
||||||
m_interfaceOut->stop();
|
m_interfaceOut->stop();
|
||||||
@@ -380,7 +375,7 @@ namespace river_test_echo_delay {
|
|||||||
delayAverage /= m_delayListMic.size();
|
delayAverage /= m_delayListMic.size();
|
||||||
}
|
}
|
||||||
int32_t sampleDalay = (delayAverage*48000)/1000000000LL;
|
int32_t sampleDalay = (delayAverage*48000)/1000000000LL;
|
||||||
APPL_ERROR("Average delay in ns : " << delayAverage << " nbSample=" << sampleDalay);
|
TEST_ERROR("Average delay in ns : " << delayAverage << " nbSample=" << sampleDalay);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -418,17 +413,14 @@ namespace river_test_echo_delay {
|
|||||||
|
|
||||||
TEST(TestTime, testDelay) {
|
TEST(TestTime, testDelay) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
std11::shared_ptr<TestClass> process = std11::make_shared<TestClass>(manager);
|
ememory::SharedPtr<TestClass> process = ememory::makeShared<TestClass>(manager);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
|
|
||||||
#endif
|
|
@@ -3,12 +3,7 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __RIVER_TEST_FORMAT_H__
|
|
||||||
#define __RIVER_TEST_FORMAT_H__
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "test_format"
|
|
||||||
|
|
||||||
namespace river_test_format {
|
namespace river_test_format {
|
||||||
static const std::string configurationRiver =
|
static const std::string configurationRiver =
|
||||||
@@ -28,15 +23,15 @@ namespace river_test_format {
|
|||||||
"}\n";
|
"}\n";
|
||||||
class testOutCallbackType {
|
class testOutCallbackType {
|
||||||
private:
|
private:
|
||||||
std11::shared_ptr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interface;
|
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||||
double m_phase;
|
double m_phase;
|
||||||
float m_freq;
|
float m_freq;
|
||||||
int32_t m_nbChannels;
|
int32_t m_nbChannels;
|
||||||
float m_generateFreq;
|
float m_generateFreq;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
testOutCallbackType(const std11::shared_ptr<audio::river::Manager>& _manager,
|
testOutCallbackType(const ememory::SharedPtr<audio::river::Manager>& _manager,
|
||||||
float _freq=48000.0f,
|
float _freq=48000.0f,
|
||||||
int32_t _nbChannels=2,
|
int32_t _nbChannels=2,
|
||||||
audio::format _format=audio::format_int16) :
|
audio::format _format=audio::format_int16) :
|
||||||
@@ -58,7 +53,7 @@ namespace river_test_format {
|
|||||||
channelMap.push_back(audio::channel_rearLeft);
|
channelMap.push_back(audio::channel_rearLeft);
|
||||||
channelMap.push_back(audio::channel_rearRight);
|
channelMap.push_back(audio::channel_rearRight);
|
||||||
} else {
|
} else {
|
||||||
APPL_ERROR("Can not generate with channel != 1,2,4");
|
TEST_ERROR("Can not generate with channel != 1,2,4");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interface = m_manager->createOutput(m_freq,
|
m_interface = m_manager->createOutput(m_freq,
|
||||||
@@ -67,18 +62,18 @@ namespace river_test_format {
|
|||||||
"speaker",
|
"speaker",
|
||||||
"WriteModeCallbackType");
|
"WriteModeCallbackType");
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interface->setOutputCallback(std11::bind(&testOutCallbackType::onDataNeeded,
|
m_interface->setOutputCallback(std::bind(&testOutCallbackType::onDataNeeded,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
}
|
}
|
||||||
void onDataNeeded(void* _data,
|
void onDataNeeded(void* _data,
|
||||||
const audio::Time& _time,
|
const audio::Time& _time,
|
||||||
@@ -86,7 +81,7 @@ namespace river_test_format {
|
|||||||
enum audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
//APPL_DEBUG("Get data ... " << _format << " map=" << _map << " chunk=" << _nbChunk);
|
//TEST_DEBUG("Get data ... " << _format << " map=" << _map << " chunk=" << _nbChunk);
|
||||||
double baseCycle = 2.0*M_PI/double(m_freq) * double(m_generateFreq);
|
double baseCycle = 2.0*M_PI/double(m_freq) * double(m_generateFreq);
|
||||||
if (_format == audio::format_int16) {
|
if (_format == audio::format_int16) {
|
||||||
int16_t* data = static_cast<int16_t*>(_data);
|
int16_t* data = static_cast<int16_t*>(_data);
|
||||||
@@ -136,14 +131,14 @@ namespace river_test_format {
|
|||||||
}
|
}
|
||||||
void run() {
|
void run() {
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interface->start();
|
m_interface->start();
|
||||||
// wait 2 second ...
|
// wait 2 second ...
|
||||||
usleep(1000000);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
m_interface->stop();
|
m_interface->stop();
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -151,12 +146,12 @@ namespace river_test_format {
|
|||||||
class testResampling : public ::testing::TestWithParam<float> {};
|
class testResampling : public ::testing::TestWithParam<float> {};
|
||||||
TEST_P(testResampling, base) {
|
TEST_P(testResampling, base) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
std11::shared_ptr<testOutCallbackType> process = std11::make_shared<testOutCallbackType>(manager, GetParam(), 2, audio::format_int16);
|
ememory::SharedPtr<testOutCallbackType> process = ememory::makeShared<testOutCallbackType>(manager, GetParam(), 2, audio::format_int16);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,12 +163,12 @@ namespace river_test_format {
|
|||||||
class testFormat : public ::testing::TestWithParam<audio::format> {};
|
class testFormat : public ::testing::TestWithParam<audio::format> {};
|
||||||
TEST_P(testFormat, base) {
|
TEST_P(testFormat, base) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
std11::shared_ptr<testOutCallbackType> process = std11::make_shared<testOutCallbackType>(manager, 48000, 2, GetParam());
|
ememory::SharedPtr<testOutCallbackType> process = ememory::makeShared<testOutCallbackType>(manager, 48000, 2, GetParam());
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(InstantiationName,
|
INSTANTIATE_TEST_CASE_P(InstantiationName,
|
||||||
@@ -184,12 +179,12 @@ namespace river_test_format {
|
|||||||
class testChannels : public ::testing::TestWithParam<int32_t> {};
|
class testChannels : public ::testing::TestWithParam<int32_t> {};
|
||||||
TEST_P(testChannels, base) {
|
TEST_P(testChannels, base) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
std11::shared_ptr<testOutCallbackType> process = std11::make_shared<testOutCallbackType>(manager, 48000, GetParam(), audio::format_int16);
|
ememory::SharedPtr<testOutCallbackType> process = ememory::makeShared<testOutCallbackType>(manager, 48000, GetParam(), audio::format_int16);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(InstantiationName,
|
INSTANTIATE_TEST_CASE_P(InstantiationName,
|
||||||
@@ -199,9 +194,9 @@ namespace river_test_format {
|
|||||||
|
|
||||||
TEST(TestALL, testChannelsFormatResampling) {
|
TEST(TestALL, testChannelsFormatResampling) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
APPL_INFO("test convert flaot to output (callback mode)");
|
TEST_INFO("test convert flaot to output (callback mode)");
|
||||||
std::vector<float> listFreq;
|
std::vector<float> listFreq;
|
||||||
listFreq.push_back(4000);
|
listFreq.push_back(4000);
|
||||||
listFreq.push_back(8000);
|
listFreq.push_back(8000);
|
||||||
@@ -227,21 +222,16 @@ namespace river_test_format {
|
|||||||
for (size_t fff=0; fff<listFreq.size(); ++fff) {
|
for (size_t fff=0; fff<listFreq.size(); ++fff) {
|
||||||
for (size_t ccc=0; ccc<listChannel.size(); ++ccc) {
|
for (size_t ccc=0; ccc<listChannel.size(); ++ccc) {
|
||||||
for (size_t iii=0; iii<listFormat.size(); ++iii) {
|
for (size_t iii=0; iii<listFormat.size(); ++iii) {
|
||||||
APPL_INFO("freq=" << listFreq[fff] << " channel=" << listChannel[ccc] << " format=" << getFormatString(listFormat[iii]));
|
TEST_INFO("freq=" << listFreq[fff] << " channel=" << listChannel[ccc] << " format=" << getFormatString(listFormat[iii]));
|
||||||
std11::shared_ptr<testOutCallbackType> process = std11::make_shared<testOutCallbackType>(manager, listFreq[fff], listChannel[ccc], listFormat[iii]);
|
ememory::SharedPtr<testOutCallbackType> process = ememory::makeShared<testOutCallbackType>(manager, listFreq[fff], listChannel[ccc], listFormat[iii]);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
|
|
||||||
#endif
|
|
@@ -3,24 +3,19 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef __RIVER_TEST_MUXER_H__
|
#include <test-debug/debug.hpp>
|
||||||
#define __RIVER_TEST_MUXER_H__
|
|
||||||
|
|
||||||
#include <audio/river/debug.h>
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "test_muxer"
|
|
||||||
|
|
||||||
namespace river_test_muxer {
|
namespace river_test_muxer {
|
||||||
class TestClass {
|
class TestClass {
|
||||||
private:
|
private:
|
||||||
std11::shared_ptr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceIn;
|
ememory::SharedPtr<audio::river::Interface> m_interfaceIn;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interfaceOut;
|
ememory::SharedPtr<audio::river::Interface> m_interfaceOut;
|
||||||
double m_phase;
|
double m_phase;
|
||||||
public:
|
public:
|
||||||
TestClass(std11::shared_ptr<audio::river::Manager> _manager) :
|
TestClass(ememory::SharedPtr<audio::river::Manager> _manager) :
|
||||||
m_manager(_manager),
|
m_manager(_manager),
|
||||||
m_phase(0) {
|
m_phase(0) {
|
||||||
std::vector<audio::channel> channelMap;
|
std::vector<audio::channel> channelMap;
|
||||||
@@ -31,18 +26,18 @@ namespace river_test_muxer {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
"speaker");
|
"speaker");
|
||||||
if(m_interfaceOut == nullptr) {
|
if(m_interfaceOut == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceOut->setOutputCallback(std11::bind(&TestClass::onDataNeeded,
|
m_interfaceOut->setOutputCallback(std::bind(&TestClass::onDataNeeded,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
m_interfaceOut->addVolumeGroup("FLOW");
|
m_interfaceOut->addVolumeGroup("FLOW");
|
||||||
//m_interfaceOut->setParameter("volume", "FLOW", "-6dB");
|
//m_interfaceOut->setParameter("volume", "FLOW", "-6dB");
|
||||||
|
|
||||||
@@ -52,18 +47,18 @@ namespace river_test_muxer {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
"microphone-muxed");
|
"microphone-muxed");
|
||||||
if(m_interfaceIn == nullptr) {
|
if(m_interfaceIn == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interfaceIn->setInputCallback(std11::bind(&TestClass::onDataReceived,
|
m_interfaceIn->setInputCallback(std::bind(&TestClass::onDataReceived,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
m_manager->generateDotAll("activeProcess.dot");
|
m_manager->generateDotAll("activeProcess.dot");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,23 +87,23 @@ namespace river_test_muxer {
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
APPL_ERROR("call wrong type ... (need int16_t)");
|
TEST_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
RIVER_SAVE_FILE_MACRO(int16_t, "REC_MicrophoneMuxed.raw", _data, _nbChunk*_map.size());
|
TEST_SAVE_FILE_MACRO(int16_t, "REC_MicrophoneMuxed.raw", _data, _nbChunk*_map.size());
|
||||||
APPL_ERROR("Receive data ... " << _nbChunk << " map=" << _map);
|
TEST_ERROR("Receive data ... " << _nbChunk << " map=" << _map);
|
||||||
}
|
}
|
||||||
void run() {
|
void run() {
|
||||||
if(m_interfaceIn == nullptr) {
|
if(m_interfaceIn == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(m_interfaceOut == nullptr) {
|
if(m_interfaceOut == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interfaceOut->start();
|
m_interfaceOut->start();
|
||||||
m_interfaceIn->start();
|
m_interfaceIn->start();
|
||||||
usleep(10000000);
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
m_interfaceIn->stop();
|
m_interfaceIn->stop();
|
||||||
m_interfaceOut->stop();
|
m_interfaceOut->stop();
|
||||||
}
|
}
|
||||||
@@ -168,17 +163,14 @@ namespace river_test_muxer {
|
|||||||
|
|
||||||
TEST(TestMuxer, testMuxing) {
|
TEST(TestMuxer, testMuxing) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
std11::shared_ptr<TestClass> process = std11::make_shared<TestClass>(manager);
|
ememory::SharedPtr<TestClass> process = ememory::makeShared<TestClass>(manager);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
|
|
||||||
#endif
|
|
@@ -3,22 +3,17 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __RIVER_TEST_PLAYBACK_CALLBACK_H__
|
|
||||||
#define __RIVER_TEST_PLAYBACK_CALLBACK_H__
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "test_playback_callback"
|
|
||||||
|
|
||||||
namespace river_test_playback_callback {
|
namespace river_test_playback_callback {
|
||||||
|
|
||||||
class testOutCallback {
|
class testOutCallback {
|
||||||
public:
|
public:
|
||||||
std11::shared_ptr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interface;
|
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||||
double m_phase;
|
double m_phase;
|
||||||
public:
|
public:
|
||||||
testOutCallback(std11::shared_ptr<audio::river::Manager> _manager, const std::string& _io="speaker") :
|
testOutCallback(ememory::SharedPtr<audio::river::Manager> _manager, const std::string& _io="speaker") :
|
||||||
m_manager(_manager),
|
m_manager(_manager),
|
||||||
m_phase(0) {
|
m_phase(0) {
|
||||||
//Set stereo output:
|
//Set stereo output:
|
||||||
@@ -30,18 +25,18 @@ namespace river_test_playback_callback {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
_io);
|
_io);
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interface->setOutputCallback(std11::bind(&testOutCallback::onDataNeeded,
|
m_interface->setOutputCallback(std::bind(&testOutCallback::onDataNeeded,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
}
|
}
|
||||||
void onDataNeeded(void* _data,
|
void onDataNeeded(void* _data,
|
||||||
const audio::Time& _time,
|
const audio::Time& _time,
|
||||||
@@ -50,7 +45,7 @@ namespace river_test_playback_callback {
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
APPL_ERROR("call wrong type ... (need int16_t)");
|
TEST_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
int16_t* data = static_cast<int16_t*>(_data);
|
int16_t* data = static_cast<int16_t*>(_data);
|
||||||
double baseCycle = 2.0*M_PI/(double)48000 * (double)550;
|
double baseCycle = 2.0*M_PI/(double)48000 * (double)550;
|
||||||
@@ -66,12 +61,12 @@ namespace river_test_playback_callback {
|
|||||||
}
|
}
|
||||||
void run() {
|
void run() {
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interface->start();
|
m_interface->start();
|
||||||
// wait 2 second ...
|
// wait 2 second ...
|
||||||
usleep(2000000);
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
m_interface->stop();
|
m_interface->stop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -94,48 +89,42 @@ namespace river_test_playback_callback {
|
|||||||
|
|
||||||
TEST(TestALL, testOutputCallBack) {
|
TEST(TestALL, testOutputCallBack) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
|
|
||||||
APPL_INFO("test output (callback mode)");
|
TEST_INFO("test output (callback mode)");
|
||||||
std11::shared_ptr<testOutCallback> process = std11::make_shared<testOutCallback>(manager, "speaker");
|
ememory::SharedPtr<testOutCallback> process = ememory::makeShared<testOutCallback>(manager, "speaker");
|
||||||
ASSERT_NE(process, nullptr);
|
ASSERT_NE(process, nullptr);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TestALL, testOutputCallBackPulse) {
|
TEST(TestALL, testOutputCallBackPulse) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
|
|
||||||
APPL_INFO("test output (callback mode)");
|
TEST_INFO("test output (callback mode)");
|
||||||
std11::shared_ptr<testOutCallback> process = std11::make_shared<testOutCallback>(manager, "speaker-pulse");
|
ememory::SharedPtr<testOutCallback> process = ememory::makeShared<testOutCallback>(manager, "speaker-pulse");
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TestALL, testOutputCallBackJack) {
|
TEST(TestALL, testOutputCallBackJack) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
|
|
||||||
APPL_INFO("test output (callback mode)");
|
TEST_INFO("test output (callback mode)");
|
||||||
std11::shared_ptr<testOutCallback> process = std11::make_shared<testOutCallback>(manager, "speaker-jack");
|
ememory::SharedPtr<testOutCallback> process = ememory::makeShared<testOutCallback>(manager, "speaker-jack");
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
|
|
||||||
#endif
|
|
@@ -3,12 +3,7 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __RIVER_TEST_PLAYBACK_WRITE_H__
|
|
||||||
#define __RIVER_TEST_PLAYBACK_WRITE_H__
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "test_playback_write"
|
|
||||||
|
|
||||||
namespace river_test_playback_write {
|
namespace river_test_playback_write {
|
||||||
static const std::string configurationRiver =
|
static const std::string configurationRiver =
|
||||||
@@ -30,10 +25,10 @@ namespace river_test_playback_write {
|
|||||||
class testOutWrite {
|
class testOutWrite {
|
||||||
public:
|
public:
|
||||||
std::vector<audio::channel> m_channelMap;
|
std::vector<audio::channel> m_channelMap;
|
||||||
std11::shared_ptr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interface;
|
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||||
public:
|
public:
|
||||||
testOutWrite(std11::shared_ptr<audio::river::Manager> _manager) :
|
testOutWrite(ememory::SharedPtr<audio::river::Manager> _manager) :
|
||||||
m_manager(_manager) {
|
m_manager(_manager) {
|
||||||
//Set stereo output:
|
//Set stereo output:
|
||||||
m_channelMap.push_back(audio::channel_frontLeft);
|
m_channelMap.push_back(audio::channel_frontLeft);
|
||||||
@@ -43,14 +38,14 @@ namespace river_test_playback_write {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
"speaker");
|
"speaker");
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interface->setReadwrite();
|
m_interface->setReadwrite();
|
||||||
}
|
}
|
||||||
void run() {
|
void run() {
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double phase=0;
|
double phase=0;
|
||||||
@@ -83,7 +78,7 @@ namespace river_test_playback_write {
|
|||||||
}
|
}
|
||||||
m_interface->write(&data[0], data.size()/m_channelMap.size());
|
m_interface->write(&data[0], data.size()/m_channelMap.size());
|
||||||
// TODO : Add a function to get number of time we need to wait enought time ...
|
// TODO : Add a function to get number of time we need to wait enought time ...
|
||||||
usleep(15000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(15));
|
||||||
}
|
}
|
||||||
m_interface->stop();
|
m_interface->stop();
|
||||||
}
|
}
|
||||||
@@ -91,24 +86,24 @@ namespace river_test_playback_write {
|
|||||||
|
|
||||||
TEST(TestALL, testOutputWrite) {
|
TEST(TestALL, testOutputWrite) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
|
|
||||||
APPL_INFO("test output (write mode)");
|
TEST_INFO("test output (write mode)");
|
||||||
std11::shared_ptr<testOutWrite> process = std11::make_shared<testOutWrite>(manager);
|
ememory::SharedPtr<testOutWrite> process = ememory::makeShared<testOutWrite>(manager);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
class testOutWriteCallback {
|
class testOutWriteCallback {
|
||||||
public:
|
public:
|
||||||
std11::shared_ptr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interface;
|
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||||
double m_phase;
|
double m_phase;
|
||||||
public:
|
public:
|
||||||
testOutWriteCallback(std11::shared_ptr<audio::river::Manager> _manager) :
|
testOutWriteCallback(ememory::SharedPtr<audio::river::Manager> _manager) :
|
||||||
m_manager(_manager),
|
m_manager(_manager),
|
||||||
m_phase(0) {
|
m_phase(0) {
|
||||||
std::vector<audio::channel> channelMap;
|
std::vector<audio::channel> channelMap;
|
||||||
@@ -120,17 +115,17 @@ namespace river_test_playback_write {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
"speaker");
|
"speaker");
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interface->setReadwrite();
|
m_interface->setReadwrite();
|
||||||
m_interface->setWriteCallback(std11::bind(&testOutWriteCallback::onDataNeeded,
|
m_interface->setWriteCallback(std::bind(&testOutWriteCallback::onDataNeeded,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5));
|
std::placeholders::_5));
|
||||||
}
|
}
|
||||||
void onDataNeeded(const audio::Time& _time,
|
void onDataNeeded(const audio::Time& _time,
|
||||||
size_t _nbChunk,
|
size_t _nbChunk,
|
||||||
@@ -138,7 +133,7 @@ namespace river_test_playback_write {
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
APPL_ERROR("call wrong type ... (need int16_t)");
|
TEST_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
std::vector<int16_t> data;
|
std::vector<int16_t> data;
|
||||||
data.resize(1024*_map.size());
|
data.resize(1024*_map.size());
|
||||||
@@ -157,31 +152,27 @@ namespace river_test_playback_write {
|
|||||||
}
|
}
|
||||||
void run() {
|
void run() {
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interface->start();
|
m_interface->start();
|
||||||
usleep(1000000);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
m_interface->stop();
|
m_interface->stop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(TestALL, testOutputWriteWithCallback) {
|
TEST(TestALL, testOutputWriteWithCallback) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
|
|
||||||
APPL_INFO("test output (write with callback event mode)");
|
TEST_INFO("test output (write with callback event mode)");
|
||||||
std11::shared_ptr<testOutWriteCallback> process = std11::make_shared<testOutWriteCallback>(manager);
|
ememory::SharedPtr<testOutWriteCallback> process = ememory::makeShared<testOutWriteCallback>(manager);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
|
|
||||||
#endif
|
|
@@ -3,14 +3,9 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef __RIVER_TEST_RECORD_CALLBACK_H__
|
#include <test-debug/debug.hpp>
|
||||||
#define __RIVER_TEST_RECORD_CALLBACK_H__
|
|
||||||
|
|
||||||
#include <audio/river/debug.h>
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "test_record_callback"
|
|
||||||
|
|
||||||
namespace river_test_record_callback {
|
namespace river_test_record_callback {
|
||||||
static const std::string configurationRiver =
|
static const std::string configurationRiver =
|
||||||
@@ -30,10 +25,10 @@ namespace river_test_record_callback {
|
|||||||
|
|
||||||
class testInCallback {
|
class testInCallback {
|
||||||
public:
|
public:
|
||||||
std11::shared_ptr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interface;
|
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||||
public:
|
public:
|
||||||
testInCallback(std11::shared_ptr<audio::river::Manager> _manager, const std::string& _input="microphone") :
|
testInCallback(ememory::SharedPtr<audio::river::Manager> _manager, const std::string& _input="microphone") :
|
||||||
m_manager(_manager) {
|
m_manager(_manager) {
|
||||||
//Set stereo output:
|
//Set stereo output:
|
||||||
std::vector<audio::channel> channelMap;
|
std::vector<audio::channel> channelMap;
|
||||||
@@ -42,18 +37,18 @@ namespace river_test_record_callback {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
_input);
|
_input);
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interface->setInputCallback(std11::bind(&testInCallback::onDataReceived,
|
m_interface->setInputCallback(std::bind(&testInCallback::onDataReceived,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
}
|
}
|
||||||
void onDataReceived(const void* _data,
|
void onDataReceived(const void* _data,
|
||||||
const audio::Time& _time,
|
const audio::Time& _time,
|
||||||
@@ -62,44 +57,40 @@ namespace river_test_record_callback {
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
APPL_ERROR("call wrong type ... (need int16_t)");
|
TEST_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
RIVER_SAVE_FILE_MACRO(int16_t, "REC_INPUT.raw", _data, _nbChunk * _map.size());
|
TEST_SAVE_FILE_MACRO(int16_t, "REC_INPUT.raw", _data, _nbChunk * _map.size());
|
||||||
const int16_t* data = static_cast<const int16_t*>(_data);
|
const int16_t* data = static_cast<const int16_t*>(_data);
|
||||||
int64_t value = 0;
|
int64_t value = 0;
|
||||||
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
||||||
value += std::abs(data[iii]);
|
value += std::abs(data[iii]);
|
||||||
}
|
}
|
||||||
value /= (_nbChunk*_map.size());
|
value /= (_nbChunk*_map.size());
|
||||||
APPL_INFO("Get data ... average=" << int32_t(value));
|
TEST_INFO("Get data ... average=" << int32_t(value));
|
||||||
}
|
}
|
||||||
void run() {
|
void run() {
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interface->start();
|
m_interface->start();
|
||||||
// wait 2 second ...
|
// wait 2 second ...
|
||||||
usleep(20000000);
|
std::this_thread::sleep_for(std::chrono::seconds(20));
|
||||||
m_interface->stop();
|
m_interface->stop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(TestALL, testInputCallBack) {
|
TEST(TestALL, testInputCallBack) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
APPL_INFO("test input (callback mode)");
|
TEST_INFO("test input (callback mode)");
|
||||||
std11::shared_ptr<testInCallback> process = std11::make_shared<testInCallback>(manager);
|
ememory::SharedPtr<testInCallback> process = ememory::makeShared<testInCallback>(manager);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,20 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RIVER_TEST_RECORD_READ_H__
|
|
||||||
#define __RIVER_TEST_RECORD_READ_H__
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "test_record_read"
|
|
||||||
|
|
||||||
namespace river_test_record_read {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
|
|
||||||
#endif
|
|
11
test/testRecordRead.hpp
Normal file
11
test/testRecordRead.hpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace river_test_record_read {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@@ -3,12 +3,7 @@
|
|||||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef __RIVER_TEST_VOLUME_H__
|
|
||||||
#define __RIVER_TEST_VOLUME_H__
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "test_volume"
|
|
||||||
|
|
||||||
namespace river_test_volume {
|
namespace river_test_volume {
|
||||||
static const std::string configurationRiver =
|
static const std::string configurationRiver =
|
||||||
@@ -29,11 +24,11 @@ namespace river_test_volume {
|
|||||||
|
|
||||||
class testCallbackVolume {
|
class testCallbackVolume {
|
||||||
private:
|
private:
|
||||||
std11::shared_ptr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
std11::shared_ptr<audio::river::Interface> m_interface;
|
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||||
double m_phase;
|
double m_phase;
|
||||||
public:
|
public:
|
||||||
testCallbackVolume(std11::shared_ptr<audio::river::Manager> _manager) :
|
testCallbackVolume(ememory::SharedPtr<audio::river::Manager> _manager) :
|
||||||
m_manager(_manager),
|
m_manager(_manager),
|
||||||
m_phase(0) {
|
m_phase(0) {
|
||||||
//Set stereo output:
|
//Set stereo output:
|
||||||
@@ -45,18 +40,18 @@ namespace river_test_volume {
|
|||||||
audio::format_int16,
|
audio::format_int16,
|
||||||
"speaker");
|
"speaker");
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interface->setOutputCallback(std11::bind(&testCallbackVolume::onDataNeeded,
|
m_interface->setOutputCallback(std::bind(&testCallbackVolume::onDataNeeded,
|
||||||
this,
|
this,
|
||||||
std11::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std11::placeholders::_2,
|
std::placeholders::_2,
|
||||||
std11::placeholders::_3,
|
std::placeholders::_3,
|
||||||
std11::placeholders::_4,
|
std::placeholders::_4,
|
||||||
std11::placeholders::_5,
|
std::placeholders::_5,
|
||||||
std11::placeholders::_6));
|
std::placeholders::_6));
|
||||||
m_interface->addVolumeGroup("MEDIA");
|
m_interface->addVolumeGroup("MEDIA");
|
||||||
m_interface->addVolumeGroup("FLOW");
|
m_interface->addVolumeGroup("FLOW");
|
||||||
}
|
}
|
||||||
@@ -80,62 +75,59 @@ namespace river_test_volume {
|
|||||||
}
|
}
|
||||||
void run() {
|
void run() {
|
||||||
if(m_interface == nullptr) {
|
if(m_interface == nullptr) {
|
||||||
APPL_ERROR("nullptr interface");
|
TEST_ERROR("nullptr interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_interface->start();
|
m_interface->start();
|
||||||
usleep(1000000);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
m_interface->setParameter("volume", "FLOW", "-3dB");
|
m_interface->setParameter("volume", "FLOW", "-3dB");
|
||||||
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
TEST_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_interface->setParameter("volume", "FLOW", "-6dB");
|
m_interface->setParameter("volume", "FLOW", "-6dB");
|
||||||
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
TEST_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_interface->setParameter("volume", "FLOW", "-9dB");
|
m_interface->setParameter("volume", "FLOW", "-9dB");
|
||||||
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
TEST_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_interface->setParameter("volume", "FLOW", "-12dB");
|
m_interface->setParameter("volume", "FLOW", "-12dB");
|
||||||
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
TEST_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_interface->setParameter("volume", "FLOW", "-3dB");
|
m_interface->setParameter("volume", "FLOW", "-3dB");
|
||||||
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
TEST_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_interface->setParameter("volume", "FLOW", "3dB");
|
m_interface->setParameter("volume", "FLOW", "3dB");
|
||||||
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
TEST_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_interface->setParameter("volume", "FLOW", "6dB");
|
m_interface->setParameter("volume", "FLOW", "6dB");
|
||||||
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
TEST_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_interface->setParameter("volume", "FLOW", "9dB");
|
m_interface->setParameter("volume", "FLOW", "9dB");
|
||||||
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
TEST_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_interface->setParameter("volume", "FLOW", "0dB");
|
m_interface->setParameter("volume", "FLOW", "0dB");
|
||||||
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
TEST_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_manager->setVolume("MASTER", -3.0f);
|
m_manager->setVolume("MASTER", -3.0f);
|
||||||
APPL_INFO("get volume MASTER: " << m_manager->getVolume("MASTER") );
|
TEST_INFO("get volume MASTER: " << m_manager->getVolume("MASTER") );
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
m_manager->setVolume("MEDIA", -3.0f);
|
m_manager->setVolume("MEDIA", -3.0f);
|
||||||
APPL_INFO("get volume MEDIA: " << m_manager->getVolume("MEDIA") );
|
TEST_INFO("get volume MEDIA: " << m_manager->getVolume("MEDIA") );
|
||||||
usleep(1000000);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
m_interface->stop();
|
m_interface->stop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(TestALL, testVolume) {
|
TEST(TestALL, testVolume) {
|
||||||
audio::river::initString(configurationRiver);
|
audio::river::initString(configurationRiver);
|
||||||
std11::shared_ptr<audio::river::Manager> manager;
|
ememory::SharedPtr<audio::river::Manager> manager;
|
||||||
manager = audio::river::Manager::create("testApplication");
|
manager = audio::river::Manager::create("testApplication");
|
||||||
std11::shared_ptr<testCallbackVolume> process = std11::make_shared<testCallbackVolume>(manager);
|
ememory::SharedPtr<testCallbackVolume> process = ememory::makeShared<testCallbackVolume>(manager);
|
||||||
process->run();
|
process->run();
|
||||||
process.reset();
|
process.reset();
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
audio::river::unInit();
|
audio::river::unInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
|
|
||||||
#endif
|
|
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0.4.0
|
156
widget/audio/river/widget/TemporalViewer.cpp
Normal file
156
widget/audio/river/widget/TemporalViewer.cpp
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <audio/river/widget/debug.hpp>
|
||||||
|
#include <audio/river/widget/TemporalViewer.hpp>
|
||||||
|
#include <etk/tool.hpp>
|
||||||
|
|
||||||
|
static const int32_t nbSecond = 3;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
audio::river::widget::TemporalViewer::TemporalViewer() :
|
||||||
|
m_minVal(-1.0f),
|
||||||
|
m_maxVal(1.0f),
|
||||||
|
m_sampleRate(48000) {
|
||||||
|
addObjectType("audio::river::widget::TemporalViewer");
|
||||||
|
}
|
||||||
|
|
||||||
|
void audio::river::widget::TemporalViewer::init() {
|
||||||
|
ewol::Widget::init();
|
||||||
|
m_manager = audio::river::Manager::create("audio::river::widget::TemporalViewer");
|
||||||
|
m_data.resize(m_sampleRate*3, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
audio::river::widget::TemporalViewer::~TemporalViewer() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void audio::river::widget::TemporalViewer::onDataReceived(const void* _data,
|
||||||
|
const audio::Time& _time,
|
||||||
|
size_t _nbChunk,
|
||||||
|
enum audio::format _format,
|
||||||
|
uint32_t _frequency,
|
||||||
|
const std::vector<audio::channel>& _map) {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
if (_format != audio::format_float) {
|
||||||
|
std::cout << "[ERROR] call wrong type ... (need int16_t)" << std::endl;
|
||||||
|
}
|
||||||
|
// get the curent power of the signal.
|
||||||
|
const float* data = static_cast<const float*>(_data);
|
||||||
|
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
||||||
|
m_data.push_back(data[iii]);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (m_data.size()>m_sampleRate*nbSecond*10) {
|
||||||
|
m_data.erase(m_data.begin(), m_data.begin()+(m_data.size()-m_sampleRate*nbSecond));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//markToRedraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void audio::river::widget::TemporalViewer::recordToggle() {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
if (m_interface == nullptr) {
|
||||||
|
//Get the generic input:
|
||||||
|
std::vector<audio::channel> channel;
|
||||||
|
channel.push_back(audio::channel_frontLeft);
|
||||||
|
m_interface = m_manager->createInput(m_sampleRate,
|
||||||
|
channel,
|
||||||
|
audio::format_float,
|
||||||
|
"microphone");
|
||||||
|
if(m_interface == nullptr) {
|
||||||
|
ARW_ERROR("nullptr interface");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// set callback mode ...
|
||||||
|
m_interface->setInputCallback(std::bind(&audio::river::widget::TemporalViewer::onDataReceived,
|
||||||
|
this,
|
||||||
|
std::placeholders::_1,
|
||||||
|
std::placeholders::_2,
|
||||||
|
std::placeholders::_3,
|
||||||
|
std::placeholders::_4,
|
||||||
|
std::placeholders::_5,
|
||||||
|
std::placeholders::_6));
|
||||||
|
// start the stream
|
||||||
|
m_interface->start();
|
||||||
|
periodicCallEnable();
|
||||||
|
} else {
|
||||||
|
m_interface->stop();
|
||||||
|
m_interface.reset();
|
||||||
|
periodicCallDisable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void audio::river::widget::TemporalViewer::onDraw() {
|
||||||
|
m_draw.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void audio::river::widget::TemporalViewer::onRegenerateDisplay() {
|
||||||
|
//!< Check if we really need to redraw the display, if not needed, we redraw the previous data ...
|
||||||
|
if (needRedraw() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// remove previous data
|
||||||
|
m_draw.clear();
|
||||||
|
// set background
|
||||||
|
m_draw.setColor(etk::color::black);
|
||||||
|
m_draw.setPos(vec2(0,0));
|
||||||
|
m_draw.rectangleWidth(m_size);
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
if (m_data.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// create n section for display:
|
||||||
|
int32_t nbSlot = m_size.x();
|
||||||
|
int32_t sizeSlot = m_size.x()/nbSlot;
|
||||||
|
std::vector<float> list;
|
||||||
|
//ARW_INFO("nbSlot : " << nbSlot << " sizeSlot=" << sizeSlot << " m_size=" << m_size);
|
||||||
|
list.resize(nbSlot,0.0f);
|
||||||
|
int32_t step = m_sampleRate*nbSecond/nbSlot;
|
||||||
|
for (size_t kkk=0; kkk<m_sampleRate*nbSecond; ++kkk) {
|
||||||
|
int32_t id = kkk/step;
|
||||||
|
if (id < list.size()) {
|
||||||
|
if (kkk < m_data.size()) {
|
||||||
|
list[id] = std::max(list[id],m_data[kkk]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// set all the line:
|
||||||
|
m_draw.setColor(etk::color::white);
|
||||||
|
m_draw.setThickness(1);
|
||||||
|
float origin = m_size.y()*0.5f;
|
||||||
|
|
||||||
|
float ratioY = m_size.y() / (m_maxVal - m_minVal);
|
||||||
|
float baseX = 0;
|
||||||
|
for (size_t iii=1; iii<list.size(); ++iii) {
|
||||||
|
m_draw.setPos(vec2(iii*sizeSlot, origin - ratioY*list[iii]));
|
||||||
|
m_draw.rectangle(vec2((iii+1)*sizeSlot, origin + ratioY*list[iii]));
|
||||||
|
if ((iii+1)*sizeSlot > m_size.x()) {
|
||||||
|
ARW_ERROR("wrong display position");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void audio::river::widget::TemporalViewer::periodicCall(const ewol::event::Time& _event) {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
int32_t nbSampleDelta = _event.getDeltaCall() * float(m_sampleRate);
|
||||||
|
if (m_data.size()>m_sampleRate*nbSecond) {
|
||||||
|
if (nbSampleDelta < m_data.size()) {
|
||||||
|
m_data.erase(m_data.begin(), m_data.begin()+nbSampleDelta);
|
||||||
|
} else {
|
||||||
|
m_data.erase(m_data.begin(), m_data.begin()+(m_data.size()-m_sampleRate*nbSecond));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
markToRedraw();
|
||||||
|
}
|
59
widget/audio/river/widget/TemporalViewer.hpp
Normal file
59
widget/audio/river/widget/TemporalViewer.hpp
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ewol/widget/Widget.hpp>
|
||||||
|
#include <ewol/compositing/Drawing.hpp>
|
||||||
|
#include <audio/river/river.hpp>
|
||||||
|
#include <audio/river/Manager.hpp>
|
||||||
|
#include <audio/river/Interface.hpp>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
namespace audio {
|
||||||
|
namespace river {
|
||||||
|
namespace widget {
|
||||||
|
class TemporalViewer : public ewol::Widget {
|
||||||
|
private:
|
||||||
|
mutable std::mutex m_mutex;
|
||||||
|
private:
|
||||||
|
ewol::compositing::Drawing m_draw; //!< drawing instance
|
||||||
|
protected:
|
||||||
|
//! @brief constructor
|
||||||
|
TemporalViewer();
|
||||||
|
void init();
|
||||||
|
public:
|
||||||
|
DECLARE_WIDGET_FACTORY(TemporalViewer, "TemporalViewer");
|
||||||
|
//! @brief destructor
|
||||||
|
virtual ~TemporalViewer();
|
||||||
|
|
||||||
|
void recordToggle();
|
||||||
|
void generateToggle() {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::vector<float> m_data;
|
||||||
|
private:
|
||||||
|
float m_minVal; //!< display minimum value
|
||||||
|
float m_maxVal; //!< display maximum value
|
||||||
|
public: // herited function
|
||||||
|
virtual void onDraw();
|
||||||
|
virtual void onRegenerateDisplay();
|
||||||
|
virtual void periodicCall(const ewol::event::Time& _event);
|
||||||
|
private:
|
||||||
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
|
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||||
|
void onDataReceived(const void* _data,
|
||||||
|
const audio::Time& _time,
|
||||||
|
size_t _nbChunk,
|
||||||
|
enum audio::format _format,
|
||||||
|
uint32_t _frequency,
|
||||||
|
const std::vector<audio::channel>& _map);
|
||||||
|
int32_t m_sampleRate;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
13
widget/audio/river/widget/debug.cpp
Normal file
13
widget/audio/river/widget/debug.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <audio/river/widget/debug.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
int32_t audio::river::widget::getLogId() {
|
||||||
|
static int32_t g_val = elog::registerInstance("audio-river-widget");
|
||||||
|
return g_val;
|
||||||
|
}
|
43
widget/audio/river/widget/debug.hpp
Normal file
43
widget/audio/river/widget/debug.hpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <elog/log.hpp>
|
||||||
|
|
||||||
|
namespace audio {
|
||||||
|
namespace river {
|
||||||
|
namespace widget {
|
||||||
|
int32_t getLogId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ARW_BASE(info,data) ELOG_BASE(audio::river::widget::getLogId(),info,data)
|
||||||
|
|
||||||
|
#define ARW_PRINT(data) ARW_BASE(-1, data)
|
||||||
|
#define ARW_CRITICAL(data) ARW_BASE(1, data)
|
||||||
|
#define ARW_ERROR(data) ARW_BASE(2, data)
|
||||||
|
#define ARW_WARNING(data) ARW_BASE(3, data)
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define ARW_INFO(data) ARW_BASE(4, data)
|
||||||
|
#define ARW_DEBUG(data) ARW_BASE(5, data)
|
||||||
|
#define ARW_VERBOSE(data) ARW_BASE(6, data)
|
||||||
|
#define ARW_TODO(data) ARW_BASE(4, "TODO : " << data)
|
||||||
|
#else
|
||||||
|
#define ARW_INFO(data) do { } while(false)
|
||||||
|
#define ARW_DEBUG(data) do { } while(false)
|
||||||
|
#define ARW_VERBOSE(data) do { } while(false)
|
||||||
|
#define ARW_TODO(data) do { } while(false)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ARW_ASSERT(cond,data) \
|
||||||
|
do { \
|
||||||
|
if (!(cond)) { \
|
||||||
|
ARW_CRITICAL(data); \
|
||||||
|
assert(!#cond); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
43
widget/lutin_audio-river-widget.py
Normal file
43
widget/lutin_audio-river-widget.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import lutin.debug as debug
|
||||||
|
import lutin.tools as tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def get_type():
|
||||||
|
return "LIBRARY"
|
||||||
|
|
||||||
|
def get_desc():
|
||||||
|
return "audio specific widget"
|
||||||
|
|
||||||
|
def get_licence():
|
||||||
|
return "APACHE-2"
|
||||||
|
|
||||||
|
def get_compagny_type():
|
||||||
|
return "com"
|
||||||
|
|
||||||
|
def get_compagny_name():
|
||||||
|
return "atria-soft"
|
||||||
|
|
||||||
|
def get_maintainer():
|
||||||
|
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
return [0,0,0]
|
||||||
|
|
||||||
|
def configure(target, my_module):
|
||||||
|
my_module.add_src_file([
|
||||||
|
'audio/river/widget/TemporalViewer.cpp',
|
||||||
|
'audio/river/widget/debug.cpp'
|
||||||
|
])
|
||||||
|
my_module.add_header_file([
|
||||||
|
'audio/river/widget/TemporalViewer.hpp'
|
||||||
|
])
|
||||||
|
my_module.add_depend([
|
||||||
|
'ewol',
|
||||||
|
'audio-river'
|
||||||
|
])
|
||||||
|
my_module.add_path(".")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user