C++ Audio TS

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
Lyberta
Established Member
Posts: 681
Joined: Sat Nov 01, 2014 8:15 pm
Location: The Internet
Been thanked: 1 time

C++ Audio TS

Post by Lyberta »

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++.
User avatar
sadko4u
Established Member
Posts: 986
Joined: Mon Sep 28, 2015 9:03 pm
Has thanked: 2 times
Been thanked: 359 times

Re: C++ Audio TS

Post by sadko4u »

You think it is better?

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
}
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.
LSP (Linux Studio Plugins) Developer and Maintainer.
Lyberta
Established Member
Posts: 681
Joined: Sat Nov 01, 2014 8:15 pm
Location: The Internet
Been thanked: 1 time

Re: C++ Audio TS

Post by Lyberta »

sadko4u wrote:You think it is better?
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.

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.
Post Reply