C++ Audio TS

Programming applications for making music on Linux.

Moderators: khz, MattKingUSA

Lyberta
Established Member
Posts: 681
Joined: Sat Nov 01, 2014 8:15 pm
Location: The Internet

C++ Audio TS

Postby Lyberta » Fri Mar 08, 2019 9:49 pm

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: 630
Joined: Mon Sep 28, 2015 9:03 pm

Re: C++ Audio TS

Postby sadko4u » Sat Mar 09, 2019 9:04 am

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

Re: C++ Audio TS

Postby Lyberta » Mon Mar 11, 2019 2:29 am

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.


Return to “Developer's Section”

Who is online

Users browsing this forum: No registered users and 1 guest