Apollo 10.0
自动驾驶开放平台
respeaker.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <memory>
20#include <string>
21
22#include <google/protobuf/message.h>
23#include <portaudio.h>
24#include "cyber/cyber.h"
25#include "modules/drivers/microphone/proto/microphone_config.pb.h"
26
27namespace apollo {
28namespace drivers {
29namespace microphone {
30
32
33/* An incomplete version of PA Stream used only for respeaker as input.
34 * Refer to http://portaudio.com/docs/v19-doxydocs/ for more information
35 */
36class Stream {
37 private:
38 PaStream *pastream_ptr_;
39 PaStreamParameters *input_parameters_ptr_;
40
41 public:
42 Stream() {}
43 ~Stream();
44 void init_stream(int rate, int channels, int chunk, int input_device_index,
45 PaSampleFormat format);
46 void read_stream(int n_frames, char *buffer) const;
47};
48
49class Respeaker {
50 private:
51 std::unique_ptr<Stream> stream_ptr_;
52 const PaDeviceInfo *get_device_info(const PaDeviceIndex index) const;
53 const PaDeviceIndex host_api_device_index_to_device_index(
54 const PaHostApiIndex host_api, const int host_api_device_index) const;
55 const PaHostApiInfo *get_host_api_info(const PaHostApiIndex index) const;
56 const PaDeviceIndex get_respeaker_index() const;
57 const PaSampleFormat get_format_from_width(int width,
58 bool is_unsigned = true) const;
59
60 public:
62 ~Respeaker();
63 void init(const std::shared_ptr<const MicrophoneConfig> &microphone_config);
64 void read_stream(int n_frames, char *buffer) const;
65};
66
67} // namespace microphone
68} // namespace drivers
69} // namespace apollo
void init(const std::shared_ptr< const MicrophoneConfig > &microphone_config)
Definition respeaker.cc:73
void read_stream(int n_frames, char *buffer) const
Definition respeaker.cc:159
void read_stream(int n_frames, char *buffer) const
Definition respeaker.cc:62
void init_stream(int rate, int channels, int chunk, int input_device_index, PaSampleFormat format)
Definition respeaker.cc:38
class register implement
Definition arena_queue.h:37