CppCon 2015: Timur Doumler “C++ in the Audio Industry”

preview_player
Показать описание


Sound is an essential medium for human-computer interaction and vital for applications such as games and music production software. In the audio industry, C++ is the dominating programming language. This talk provides an insight into the patterns and tools that C++ developers in the audio industry rely on. There are interesting lessons to be learned from this domain that can be useful to every C++ developer.

Handling audio in real time presents interesting technical challenges. Techniques also used in other C++ domains have to be combined: real-time multithreading, lock-free programming, efficient DSP, SIMD, and low-latency hardware communication. C++ is the language of choice to tie all these requirements together. Clever leveraging of advanced C++ techniques, template metaprogramming, and the new C++11/14 standard makes these tasks more exciting than ever.

Timur Doumler is Senior Software Developer at London-based technology company ROLI. He is working with Julian Storer to further develop JUCE, the leading cross-platform framework for creating audio applications that is used by hundreds of companies in the audio industry.

After five years of writing high-performance code in Fortran, C, and C++ for numerical simulations of the cosmic structure formation, Timur became committed to audio and music production software. Before joining ROLI, he worked on various projects at market-leading company Native Instruments, such as KONTAKT, the industry standard sampling platform used by the majority of music producers and composers for film score, games, and contemporary popular music.

Timur holds a PhD in astrophysics and is passionate about well-written code, modern C++ techniques, science-fiction, learning languages, and progressive rock music.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

Pure gold for the beginners. Thanks you Timur, you are a good teacher.

almazmusic
Автор

Timur I want to thank you for this talk. In my synthesizer project I simply moved all my graph updating logic to the GUI thread and used atomic shared ptr to swap references. Simply moving all these locks, memory alloc, file io, out of the callback has made my program crash 100% less than it did before, which was totally random. I know I'm probably not doing everything totally correctly but I can feel an enormous difference when playing my synthesizer. It is so satisfying when apps 'just work'. These talks are invaluable for audio programmers.

anthonyparks
Автор

A couple of points you didn't cover: 1. Never rely on calloc or C++ new zero initialized memory. The zeroing may be done via VM tricks that will cause a page fault upon first touching the memory. 2. Code can page fault. You should pre-warm any code you run before you run it on the audio thread.

jankopiano
Автор

This is good stuff, but a thing to note at 46:00 is that atomic free functions to manipulate shared_ptr are not lock-free. Moreover, on 48:00, the solution to delete in callback can be solved in a lock-free manner using either hazard pointers or epoch garbage collector.

budabudimir
Автор

re 44:47 - Having looked on ccpreference and having tried atomic_is_lock_free( const std::shared_ptr<T>* p) and with T = juce::String, I think the atomic access on shared pointers is not lock free. At least when T is not a basic type. From cpp reference : "These functions are typically implemented using mutexes, stored in a global hash table where the pointer value is used as the key."

MrBlm
Автор

This is a treasure! Thanks a lot! Being a beginner in the topic, it's one of the most useful conference talks I've ever watched. Hopefully, it won't be too difficult to apply these patterns in Rust.

azymohliad
Автор

im always perplexed as to how people can come with this. This is an insane amount of genius, a feel so dumb I wish i could come with everything he said. :(

lowearthsurfer
Автор

Excellent talk. About the std::atomic, now it is implemented as std::shared_ptr in C++20.

kjtov
Автор

REALLY helpful video! Everything was explained in a nice way. I want more stuff like this!

DimitrisVasil
Автор

A note: it's perfectly okay to wait on a mutex in audio thread if you can predict for how long it will be blocked. Think of audio thread waiting for all RT synthesis threads to finish. Locking and waiting is NOT BAD at all, it's bad when you wait for unpredictable threads.

michal.gawron
Автор

this is such a good introductory lesson

mr.shredder
Автор

Interesting that 10ms is the number shown as the high threshold for acceptable latency. I can't speak for keyboards, but for guitar anything above 5ms starts to noticeably affect the feel of playing. 5ms or below is definitely preferable. Historically coming up with an affordable audio interface and computer pairing that could achieve this was quite the challenge, which of course was one of the strongest arguments for dedicated hardware (a la AxeFX, Kemper, etc.) vs. software based amps.

geraldhinson
Автор

awesome tech without audio AFEs and audio DACs. very great job of coding.

annaoaulinovna
Автор

15:05 woah am I seeing a slider in the IDE setting a value?

pizzabeerengineering
Автор

39:24 If you use load/save without extra arguments, sequentially-consistent ordering will be used, which is way too slow. You should always explicitly specify memory ordering for std::atomic, if you care about performance.

TheOnlyAndreySotnikov
Автор

It was my understanding that mt19937 is O(1) *amorttized*. Most of the time it is just a few ops, but periodically it recomputes a large buffer.

jankopiano
Автор

Great content, thx! Would love to see a follow up talk on this (maybe at JUCE Summit in november?). Would definitely make a nice tutorial and add significant value to the JUCE docs imo.

Also Projucer seems like an interesting interactive IDE, don't think that talk has been posted yet though..

frydac
Автор

hello!
how can i create a random between two values to control a parameter in Faust?

francois
Автор

@Taylor Holliday Probably to preserve the deleter.

lithium
Автор

@Timur Doumler is there source code for this project anywhere? I'd love to see how the oscilloscope works. I checked thecppcon githib for this presentation but it was not there. I've been researching how to implement one but am confused. Thanks.

tim_arterbury