Page 1 of 1

C++ Audio TS

Posted: Fri Mar 08, 2019 9:49 pm
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++.

Re: C++ Audio TS

Posted: Sat Mar 09, 2019 9:04 am
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.

Re: C++ Audio TS

Posted: Mon Mar 11, 2019 2:29 am
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.