Acoustic Touch Recognition
|
This class is in charge of handling multiple instances of chuck, as much instances as the user wants, but one per device. More...
#include <libacoustic_touch.h>
Classes | |
struct | ck_soundCardAttributes |
Public Member Functions | |
ChucKHandler (const vector< string > &) | |
Construct a new Chuck Handler:: Chuck Handler object. More... | |
ChucKHandler (const vector< string > &, const vector< int > &, const vector< int > &, const string &="default") | |
Construct a new ChucKHandler object with a set of parameters. More... | |
ChucKHandler (const vector< string > &, const vector< int > &, const vector< int > &, const vector< bool > &, const string &="default") | |
Construct a new ChucKHandler object with a set of parameters. More... | |
~ChucKHandler () | |
string | getRobot () const |
Returns the value of the attribute robot_. More... | |
string | getChucKMode () const |
Returns the current mode of ChucK installed in the system. More... | |
map< string, ck_cardAttribs_t > | getSoundCards () const |
Returns a map containing the soundcards' ID's and its assigned attributes. More... | |
vector< string > | getSoundCardIDs () const |
Returns the set of soundcard ids. More... | |
string | getSoundCardID (const int &) const |
Returns a single soundcard id from an attribute vector containing all the soundcard id's. More... | |
int | getSoundCardIndex (const string &) const |
Returns the index (order given by the system) of a soundcard from its id. More... | |
int | getSoundCardNumber (const string &) const |
Returns the number (order given by the user) of a soundcard from its id. More... | |
int | getSoundCardVolume (const string &) const |
Returns the volume assigned to a soundcard. More... | |
bool | getSoundCardCapacitive (const string &) const |
Returns the capacitive condition assigned to a soundcard. More... | |
bool | getKillChucK () const |
Returns the value of the attribute kill_chuck_. More... | |
void | setRobot (const string &) |
Sets the attribute robot_. More... | |
void | setChucKMode () |
Obtains the ChucK version (alsa, pulse or jack) from the proper CLI ChucK command. More... | |
void | setSoundCards (const vector< string > &) |
Create the list of tuples based in a set of soundcard ID. It is assumed that the number of the card is correlated to its position in the vector. More... | |
void | setSoundCards (const vector< string > &, const vector< int > &) |
Sets values for a set of soundcards. It assumes no soundcards with the selected ids, so the function creates them from zero (revise this behaviour) More... | |
void | setSoundCards (const vector< string > &, const vector< int > &, const vector< int > &) |
Sets values for a set of soundcards. It assumes no soundcards with the selected ids, so the function creates them from zero (revise this behaviour) More... | |
void | setSoundCards (const vector< string > &, const vector< int > &, const vector< int > &, const vector< bool > &) |
void | setSoundCardIDs (const vector< string > &) |
Changes values of the soundcard ids contained in a vector. More... | |
void | setSoundCardIndex (const int &, const string &) |
Sets the Index (pulse or alsa) of the selected soundcard. More... | |
void | setSoundCardNumber (const int &, const string &) |
Sets the number of a soundcard internal attribute. More... | |
void | setSoundCardVolume (const int &, const string &) |
Changes the assigned volume for a certain soundcard internal attribute. It actually does not changes the values externally (e.g. in pulse or alsa) More... | |
void | setSoundCardCapacitive (const bool &, const string &) |
Sets the capacitive condition for a certain soundcard internal attribute. This capacitive condition means if there is a capacitive sensor attached to the microphone. More... | |
void | setKillChucK (const bool &) |
Changes the value of the attribute kill_chuck_. More... | |
void | printSoundCards () const |
Prints the id's and the attributes of all the soundcards contained in the Handler. Designed for debugging purpouses. More... | |
void | setAttributesAlsa () |
Fills the soundcard attributes for ChucK's Alsa mode. More... | |
void | setAttributesPulse () |
Fills the soundcard attributes for ChucK's Pulse mode. More... | |
void | setSoundCardInputVol (const int &, const string &) |
Changes the capture volume of a soundcard. More... | |
void | chucKThread (const string &) |
This function is destined to run an instance of ChucK in a C++11 thread. More... | |
void | launchChucK (const bool &=CK_DEBUG) |
Init function, prepares the ChucK command and launches an instance per soundcard through several fork() calls. More... | |
void | killChucK () |
Static Public Member Functions | |
static void | getShellOutput (const string &, string *, string *) |
Gets the shell output. Returns from sterr and stdout. More... | |
static string | fetchAlsaModel (const string &) |
Finds the corresponding model for a certain ALSA soundcard. More... | |
static vector< string > | fetchAlsaModels (const vector< string > &) |
From a given set of soundcard ids, this function return a vector with their unique soundcard models. There could be more than one model in the output, but there will not be repeated models within the resultant string. More... | |
static vector< string > | fetchAlsaIDs (const string &) |
This function tries to find a set of devices and their attributes by their common soundcard model. More... | |
static vector< int > | fetchChucKIndexes (const string &) |
Retrieves all the devices' indexes from the command 'chuck –probe' for a given soundcard model. More... | |
Private Types | |
typedef struct ChucKHandler::ck_soundCardAttributes | ck_cardAttribs_t |
Private Attributes | |
string | robot_ |
string | chuck_mode_ |
vector< string > | sndcard_ids_ |
map< string, ck_cardAttribs_t > | sound_cards_ |
vector< thread > | ck_threads_ |
bool | kill_chuck_ |
This class is in charge of handling multiple instances of chuck, as much instances as the user wants, but one per device.
|
private |
ChucKHandler::ChucKHandler | ( | const vector< string > & | soundcards | ) |
Construct a new Chuck Handler:: Chuck Handler object.
soundcards | A set of strings containing the soundcard names in the desired order |
ChucKHandler::ChucKHandler | ( | const vector< string > & | soundcards, |
const vector< int > & | mic_numbers, | ||
const vector< int > & | mic_vols, | ||
const string & | robot = "default" |
||
) |
Construct a new ChucKHandler object with a set of parameters.
soundcards | A set of soundcard ids |
mic_numbers | A number representing the order of the soundcards |
mic_vols | The corresponding input volume of the soundcards |
ChucKHandler::ChucKHandler | ( | const vector< string > & | soundcards, |
const vector< int > & | mic_numbers, | ||
const vector< int > & | mic_vols, | ||
const vector< bool > & | is_capacitive, | ||
const string & | robot = "default" |
||
) |
Construct a new ChucKHandler object with a set of parameters.
soundcards | |
mic_numbers | |
mic_vols | |
is_capacitive | |
robot |
|
inline |
void ChucKHandler::chucKThread | ( | const string & | command | ) |
This function is destined to run an instance of ChucK in a C++11 thread.
command |
|
static |
This function tries to find a set of devices and their attributes by their common soundcard model.
sndcard_model | The soundcard model |
|
static |
Finds the corresponding model for a certain ALSA soundcard.
soundcard_id | The id of the soundcard to find |
|
static |
From a given set of soundcard ids, this function return a vector with their unique soundcard models. There could be more than one model in the output, but there will not be repeated models within the resultant string.
soundcard_ids | A set of soundcard ids |
|
static |
Retrieves all the devices' indexes from the command 'chuck –probe' for a given soundcard model.
sndcard_model |
string ChucKHandler::getChucKMode | ( | ) | const |
Returns the current mode of ChucK installed in the system.
bool ChucKHandler::getKillChucK | ( | ) | const |
Returns the value of the attribute kill_chuck_.
string ChucKHandler::getRobot | ( | ) | const |
Returns the value of the attribute robot_.
|
static |
Gets the shell output. Returns from sterr and stdout.
command | The command |
std_out | The stdout output |
std_err | The stderr output |
bool ChucKHandler::getSoundCardCapacitive | ( | const string & | id | ) | const |
Returns the capacitive condition assigned to a soundcard.
id |
string ChucKHandler::getSoundCardID | ( | const int & | pos | ) | const |
Returns a single soundcard id from an attribute vector containing all the soundcard id's.
pos | The position of the id in the vector |
vector< string > ChucKHandler::getSoundCardIDs | ( | ) | const |
Returns the set of soundcard ids.
int ChucKHandler::getSoundCardIndex | ( | const string & | id | ) | const |
Returns the index (order given by the system) of a soundcard from its id.
id | The id of the soundcard |
int ChucKHandler::getSoundCardNumber | ( | const string & | id | ) | const |
Returns the number (order given by the user) of a soundcard from its id.
id | The id of the soundcard |
map< string, ChucKHandler::ck_cardAttribs_t > ChucKHandler::getSoundCards | ( | ) | const |
Returns a map containing the soundcards' ID's and its assigned attributes.
int ChucKHandler::getSoundCardVolume | ( | const string & | id | ) | const |
Returns the volume assigned to a soundcard.
id | The id of the selected soundcard |
void ChucKHandler::killChucK | ( | ) |
void ChucKHandler::launchChucK | ( | const bool & | debug = CK_DEBUG | ) |
Init function, prepares the ChucK command and launches an instance per soundcard through several fork() calls.
void ChucKHandler::printSoundCards | ( | ) | const |
Prints the id's and the attributes of all the soundcards contained in the Handler. Designed for debugging purpouses.
void ChucKHandler::setAttributesAlsa | ( | ) |
Fills the soundcard attributes for ChucK's Alsa mode.
void ChucKHandler::setAttributesPulse | ( | ) |
Fills the soundcard attributes for ChucK's Pulse mode.
void ChucKHandler::setChucKMode | ( | ) |
Obtains the ChucK version (alsa, pulse or jack) from the proper CLI ChucK command.
void ChucKHandler::setKillChucK | ( | const bool & | kill_chuck | ) |
Changes the value of the attribute kill_chuck_.
kill_chuck | A boolean representing the value to set |
void ChucKHandler::setRobot | ( | const string & | robot | ) |
Sets the attribute robot_.
robot | The robot in which the Handler is running |
void ChucKHandler::setSoundCardCapacitive | ( | const bool & | cap, |
const string & | id | ||
) |
Sets the capacitive condition for a certain soundcard internal attribute. This capacitive condition means if there is a capacitive sensor attached to the microphone.
cap | |
id |
void ChucKHandler::setSoundCardIDs | ( | const vector< string > & | sndcard_ids | ) |
Changes values of the soundcard ids contained in a vector.
sndcard_ids |
void ChucKHandler::setSoundCardIndex | ( | const int & | indx, |
const string & | id | ||
) |
Sets the Index (pulse or alsa) of the selected soundcard.
indx | The selected index to be changed |
id | The id of the card that will suffer the change |
void ChucKHandler::setSoundCardInputVol | ( | const int & | vol, |
const string & | id | ||
) |
Changes the capture volume of a soundcard.
vol | The desired volume for the soundcard |
id | The id of the corresponding soundcard |
void ChucKHandler::setSoundCardNumber | ( | const int & | num, |
const string & | id | ||
) |
Sets the number of a soundcard internal attribute.
num | The number, commonly associated with the order set by the user |
id | The id of the soundcard whose number will change |
void ChucKHandler::setSoundCards | ( | const vector< string > & | sndcard_ids | ) |
Create the list of tuples based in a set of soundcard ID. It is assumed that the number of the card is correlated to its position in the vector.
sndcard_ids | A vector containing a set of soundcard ids |
void ChucKHandler::setSoundCards | ( | const vector< string > & | sndcard_ids, |
const vector< int > & | volumes | ||
) |
Sets values for a set of soundcards. It assumes no soundcards with the selected ids, so the function creates them from zero (revise this behaviour)
sndcard_ids | The ids of the soundcards to create |
volumes | The input volume of the soundcards |
void ChucKHandler::setSoundCards | ( | const vector< string > & | sndcard_ids, |
const vector< int > & | mic_nums, | ||
const vector< int > & | volumes | ||
) |
Sets values for a set of soundcards. It assumes no soundcards with the selected ids, so the function creates them from zero (revise this behaviour)
sndcard_ids | The ids of the soundcards to create |
mic_nums | The order of the soundcards desired by the user |
volumes | The input volume of the soundcards |
void ChucKHandler::setSoundCards | ( | const vector< string > & | sndcard_ids, |
const vector< int > & | mic_nums, | ||
const vector< int > & | volumes, | ||
const vector< bool > & | is_capacitive | ||
) |
void ChucKHandler::setSoundCardVolume | ( | const int & | vol, |
const string & | id | ||
) |
Changes the assigned volume for a certain soundcard internal attribute. It actually does not changes the values externally (e.g. in pulse or alsa)
vol | The desired volume |
id | The id of the soundcard |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |