-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop Audio Nodes #1115
base: v3_develop
Are you sure you want to change the base?
Develop Audio Nodes #1115
Conversation
@@ -647,6 +654,9 @@ target_link_libraries(${TARGET_CORE_NAME} | |||
INTERFACE | |||
XLinkPublic | |||
PRIVATE | |||
sndfile | |||
samplerate | |||
asound |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation
It'd probably be good to add comments to node / datatype getters and setters for docs generation before merging. Also might be good to run clangformat, but I'm not sure if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Filippo!
Writing here a brief TODO list as a summary:
- Address comments from the PR
- Try to make all used libraries included by Hunter and/or make them optional so DAI can be compiled without audio support
- Regardless of the option chosen above, they should be included with cmake
- Make sure the PR builds successfully on all platforms in CI
- TBD on the AudioMixer node
.def("getAlsaDevices", [](DeviceBase& d) { py::gil_scoped_release release; return d.getAlsaDevices(); }, DOC(dai, DeviceBase, getAlsaDevices)) | ||
.def("getAlsaPCMs", [](DeviceBase& d) { py::gil_scoped_release release; return d.getAlsaPCMs(); }, DOC(dai, DeviceBase, getAlsaPCMs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
- Add impl on RVC2 side of things as well to return empty arrays
namespace dai { | ||
namespace audio { | ||
|
||
std::vector<AudioDevice> GetAlsaDevices() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::vector<AudioDevice> GetAlsaDevices() { | |
std::vector<AudioDevice> getAlsaDevices() { |
return vec; | ||
} | ||
|
||
std::vector<AudioPCM> GetAlsaPCMs() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::vector<AudioPCM> GetAlsaPCMs() { | |
std::vector<AudioPCM> getAlsaPCMs() { |
Same comment for other functions
@@ -0,0 +1,234 @@ | |||
#include "depthai/utility/AudioHelpers.hpp" | |||
|
|||
#include <alsa/asoundlib.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to include this with hunter ideally or at least make it optional at compile time if we leave it for the system.
break; | ||
} | ||
|
||
// std::cout << "Duration frames: " << durationFrames << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use a logger here
public: | ||
sf_count_t frames; | ||
unsigned int bitrate; | ||
unsigned int channels; | ||
int format; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be made private?
struct AudioMixerProperties : PropertiesSerializable<Properties, AudioMixerProperties> { | ||
static constexpr int AUTO = -1; | ||
|
||
bool ready = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense for this to be a serializable property?
#!/usr/bin/env python3 | ||
|
||
import depthai as dai | ||
|
||
# Create pipeline | ||
device = dai.Device() | ||
with dai.Pipeline(device) as pipeline: | ||
in = pipeline.create(dai.node.AudioIn); | ||
in.setRunOnHost(True); | ||
in.setDeviceName("microphone"); | ||
in.setDevicePath("default"); | ||
in.setBitrate(48000); | ||
in.setFps(16); | ||
in.setChannels(2); | ||
in.setFormat(dai.AudioFrame.AUDIO_FORMAT_PCM_32); | ||
|
||
out = pipeline.create(dai.node.AudioOut); | ||
out.setRunOnHost(True); | ||
out.setDeviceName("speaker"); | ||
out.setDevicePath("default"); | ||
out.setBitrate(44100); | ||
out.setFps(16); | ||
out.setChannels(2); | ||
out.setFormat(dai.AudioFrame.AUDIO_FORMAT_PCM_16); | ||
|
||
encoder = pipeline.create(dai.node.AudioOut); | ||
out.setRunOnHost(False); | ||
out.setBitrate(44100); | ||
out.setChannels(2); | ||
out.setFormat(dai.AudioFrame.AUDIO_FORMAT_PCM_16); | ||
|
||
in.out.link(encoder.input); | ||
encoder.out.link(out.input); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's skip the semicolons
examples/python/Audio/AudioReplay.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the example to match others
dai::Pipeline pipeline; | ||
|
||
auto replay = pipeline.create<dai::node::AudioReplay>(); | ||
replay->setSourceFile("/tmp/test.wav"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add all test files to be pulled by hunter so that the examples work out of the box.
Likewise for python, so they're pulled in by install_requirements.py
script. (Check how it works for videos that are used in current replay examples)
Adding audio managment capabilities to depthai with the creation of various audio nodes for audio capture, output, mixing, encoding and replay.