audio_common for ROS 2
Loading...
Searching...
No Matches
audio_capturer_node.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2024 Miguel Ángel González Santamarta
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#ifndef AUDIO_COMMON__AUDIO_CAPTURER_NODE
24#define AUDIO_COMMON__AUDIO_CAPTURER_NODE
25
26#include <memory>
27#include <portaudio.h>
28#include <rclcpp/rclcpp.hpp>
29
30#include "audio_common_msgs/msg/audio_stamped.hpp"
31
32namespace audio_common {
33
34class AudioCapturerNode : public rclcpp::Node {
35public:
37 ~AudioCapturerNode() override;
38
39 void work();
40
41private:
42 PaStream *stream_;
45 int rate_;
46 int chunk_;
47 std::string frame_id_;
48
49 rclcpp::Publisher<audio_common_msgs::msg::AudioStamped>::SharedPtr audio_pub_;
50
51 // Methods
52 template <typename T> std::vector<T> read_data();
53};
54
55} // namespace audio_common
56
57#endif
~AudioCapturerNode() override
Definition audio_capturer_node.cpp:90
rclcpp::Publisher< audio_common_msgs::msg::AudioStamped >::SharedPtr audio_pub_
Definition audio_capturer_node.hpp:49
int channels_
Definition audio_capturer_node.hpp:44
int rate_
Definition audio_capturer_node.hpp:45
std::string frame_id_
Definition audio_capturer_node.hpp:47
std::vector< T > read_data()
Definition audio_capturer_node.cpp:138
void work()
Definition audio_capturer_node.cpp:96
int chunk_
Definition audio_capturer_node.hpp:46
PaStream * stream_
Definition audio_capturer_node.hpp:42
int format_
Definition audio_capturer_node.hpp:43
AudioCapturerNode()
Definition audio_capturer_node.cpp:32
Definition audio_capturer_node.hpp:32