21 #include <boost/make_shared.hpp> 25 #include <qi/anyobject.hpp> 37 p_audio_( session->service(
"ALAudioDevice")),
38 p_robot_model_(session->service(
"ALRobotModel")),
55 std::map<std::string, std::string> config_map =\
56 p_robot_model_.call<std::map<std::string, std::string> >(
"_getConfigMap");
58 micConfig = std::atoi(
59 config_map[
"RobotConfig/Head/Device/Micro/Version"].c_str());
74 publisher_ = boost::make_shared<publisher::BasicPublisher<naoqi_bridge_msgs::AudioBuffer> >( name );
75 recorder_ = boost::make_shared<recorder::BasicEventRecorder<naoqi_bridge_msgs::AudioBuffer> >( name );
76 converter_ = boost::make_shared<converter::AudioEventConverter>( name, frequency, session );
108 "setClientPreferences",
114 p_audio_.call<
void>(
"subscribe",
"ROS-Driver-Audio");
115 std::cout <<
"Audio Extractor: Start" << std::endl;
127 p_audio_.call<
void>(
"unsubscribe",
"ROS-Driver-Audio");
131 std::cout <<
"Audio Extractor: Stop" << std::endl;
177 naoqi_bridge_msgs::AudioBuffer
msg = naoqi_bridge_msgs::AudioBuffer();
179 msg.frequency = 48000;
182 std::pair<char*, size_t> buffer_pointer = buffer.asRaw();
184 int16_t* remoteBuffer = (int16_t*)buffer_pointer.first;
185 int bufferSize = nbOfChannels * samplesByChannel;
186 msg.data = std::vector<int16_t>(remoteBuffer, remoteBuffer+bufferSize);
188 std::vector<message_actions::MessageAction> actions;
205 if (actions.size() >0)
std::vector< uint8_t > channelMap
void writeDump(const ros::Time &time)
void isRecording(bool state)
qi::AnyObject p_robot_model_
void resetPublisher(ros::NodeHandle &nh)
void processRemote(int nbOfChannels, int samplesByChannel, qi::AnyValue altimestamp, qi::AnyValue buffer)
void resetRecorder(boost::shared_ptr< naoqi::recorder::GlobalRecorder > gr)
const robot::NaoqiVersion & naoqi_version_
boost::mutex subscription_mutex_
boost::shared_ptr< publisher::BasicPublisher< naoqi_bridge_msgs::AudioBuffer > > publisher_
const robot::NaoqiVersion & getNaoqiVersion(const qi::SessionPtr &session)
Function that retrieves the NAOqi version of the robot.
void isDumping(bool state)
void isPublishing(bool state)
boost::shared_ptr< converter::AudioEventConverter > converter_
AudioEventRegister(const std::string &name, const float &frequency, const qi::SessionPtr &session)
Constructor for recorder interface.
void unregisterCallback()
boost::mutex processing_mutex_
void setBufferDuration(float duration)
bool isNaoqiVersionLesser(const robot::NaoqiVersion &naoqi_version, const int &major, const int &minor, const int &patch, const int &build)
Function that returns true if the provided naoqi_version is (strictly) lesser than the specified one ...
boost::shared_ptr< recorder::BasicEventRecorder< naoqi_bridge_msgs::AudioBuffer > > recorder_