C++ Audio TS
Moderators: MattKingUSA, khz
-
- Established Member
- Posts: 681
- Joined: Sat Nov 01, 2014 8:15 pm
- Location: The Internet
- Been thanked: 1 time
C++ Audio TS
I'm surprised nobody posted this: there is a proposal to get audio in the standard! I'm so excited, finally, a common base to work on so we can forget about raw pointers and all other sheganians. I'm gonna follow the development and try to convert all my audio code to be as compatible as possible or maybe even write my own implementation since things tend to take forever to get into libstdc++ and libc++.
- sadko4u
- Established Member
- Posts: 989
- Joined: Mon Sep 28, 2015 9:03 pm
- Has thanked: 2 times
- Been thanked: 361 times
Re: C++ Audio TS
You think it is better?
Dude, this is not optimal and won't scale. Another one shitty abstraction from a man who didn't ever more than just summing audio buffers.
Code: Select all
int main() {
using namespace std::experimental::audio;
auto device = get_default_output_device();
device.connect([](device& d, buffer_list& bl) {
for (auto& buffer : bl.output_buffers()) {
for (auto& channel : buffer.channels()) {
for (auto& sample : channel) {
sample = get_random_sample_value();
}
}
}
});
device.start();
while(true); // Spin forever
}
LSP (Linux Studio Plugins) Developer and Maintainer.
-
- Established Member
- Posts: 681
- Joined: Sat Nov 01, 2014 8:15 pm
- Location: The Internet
- Been thanked: 1 time
Re: C++ Audio TS
It is much better than the pointer arithmetic or even more hard to read stuff. I do agree that callback based design right now may not look great but since coroutines were added to C++20, people say that the code will be much better with them.sadko4u wrote:You think it is better?
Also, the code you've posted doesn't use ranges so ranges will also remove the need in loops in anything but the lowest level code.