Uploaded July 2025 | Updated November 2026, 1 day ago
https://audio.dev/ -- @audiodevcon
---
Wait-Free Thread Synchronisation With the SeqLock - Timur Doumler - ADC 2024
---
When developing real-time audio processing applications in C++, the following problem arises almost inevitably: how can we share data between the real-time audio thread and the other threads (such as a GUI thread) in a way that is real-time safe? How can we synchronise reads and writes to C++ objects across threads, and manage the lifetime of these objects, while remaining wait-free on the real-time thread?
This talk is the second in a series of talks about thread synchronisation in a real-time context. In the first episode, given at ADC 2022, we focused on the case where the real-time thread needs to read a sufficiently large, persistent object that is simultaneously mutated on another thread. In this second episode, we focus on the reverse case: the real-time thread needs to write the value while remaining wait-free, and while other (non-real-time) threads are reading it.
The traditional solution for this problem in audio processing code today is double buffering. This strategy works well in certain cases, but like every algorithm it has certain tradeoffs. If we look beyond the audio industry, it turns out there is actually another strategy that has more favourable tradeoffs for some use cases: the SeqLock.
We describe the general idea of the SeqLock, discuss the different parts of the algorithm, and show a working reference implementation. It turns out that in order to implement a SeqLock portably and without introducing undefined behaviour, we need to reconcile the algorithm with the C++ memory model, which presents an interesting challenge. In order to make it work and be efficient, we need to be very careful with our use of memory fences, memory ordering, and atomic vs. non-atomic memory accesses. Along the way we will learn useful things about writing lock-free code in Standard C++.
Finally, we compare the tradeoffs between SeqLock and other approaches to this problem, offer some guidelines on which approach to use when, and present a proposal to add the SeqLock algorithm to the C++ Standard.
---
Timur Doumler
Timur Doumler is the co-host of CppCast and an active member of the ISO C++ standard committee, where he is currently co-chair of SG21, the Contracts study group. Timur started his journey into C++ in computational astrophysics, where he was working on cosmological simulations. He then moved into the audio and music technology industry, where he has spent over a decade of his career, worked on projects such as NI Kontakt and the JUCE framework, and co-founded the music tech startup Cradle. In the past, Timur also worked for JetBrains, first as a developer on CLion's C++ parser and later as a Developer Advocate for C++ developer tools. Currently, Timur lives in Finland, where he organises the monthly C++ Helsinki meetup and works as an independent C++ consultant. Timur is passionate about clean code, good tools, low latency, and the evolution of the C++ language.
---
ADC is an annual event celebrating all audio development technologies, from music applications and game audio to audio processing and embedded systems. ADC’s mission is to help attendees acquire and develop new audio development skills, and build a network that will support their audio developer career.
Annual ADC Conference - https://audio.dev/
linkedin.com/company/audiodevcon
twitter.com/audiodevcon
facebook.com/audiodevcon
instagram.com/audiodevcon
reddit.com/r/audiodevcon
https://mastodon.social/@audiodevcon
---
Streamed & Edited by Digital Medium Ltd: online.digital-medium.co.uk
---
Organized and produced by JUCE: juce.com
---
Special thanks to the ADC24 Team:
Sophie Carus
Derek Heimlich
Andrew Kirk
Bobby Lombardi
Tom Poole
Ralph Richbourg
Jim Roper
Jonathan Roper
Prashant Mishra
#adc #cpp #cppprogramming #audiodev #dsp #audio #conferenceaudio #audioprocessing #audioproduction #audioprogramming #musictech #soundtech #audiotech #audiotechnology
https://audio.dev/ -- @audiodevcon
---
Wait-Free Thread Synchronisation With the SeqLock - Timur Doumler - ADC 2024
---
When developing real-time audio processing applications in C++, the following problem arises almost inevitably: how can we share data between the real-time audio thread and the other threads (such as a GUI thread) in a way that is real-time safe? How can we synchronise reads and writes to C++ objects across threads, and manage the lifetime of these objects, while remaining wait-free on the real-time thread?
This talk is the second in a series of talks about thread synchronisation in a real-time context. In the first episode, given at ADC 2022, we focused on the case where the real-time thread needs to read a sufficiently large, persistent object that is simultaneously mutated on another thread. In this second episode, we focus on the reverse case: the real-time thread needs to write the value while remaining wait-free, and while other (non-real-time) threads are reading it.
The traditional solution for this problem in audio processing code today is double buffering. This strategy works well in certain cases, but like every algorithm it has certain tradeoffs. If we look beyond the audio industry, it turns out there is actually another strategy that has more favourable tradeoffs for some use cases: the SeqLock.
We describe the general idea of the SeqLock, discuss the different parts of the algorithm, and show a working reference implementation. It turns out that in order to implement a SeqLock portably and without introducing undefined behaviour, we need to reconcile the algorithm with the C++ memory model, which presents an interesting challenge. In order to make it work and be efficient, we need to be very careful with our use of memory fences, memory ordering, and atomic vs. non-atomic memory accesses. Along the way we will learn useful things about writing lock-free code in Standard C++.
Finally, we compare the tradeoffs between SeqLock and other approaches to this problem, offer some guidelines on which approach to use when, and present a proposal to add the SeqLock algorithm to the C++ Standard.
---
Timur Doumler
Timur Doumler is the co-host of CppCast and an active member of the ISO C++ standard committee, where he is currently co-chair of SG21, the Contracts study group. Timur started his journey into C++ in computational astrophysics, where he was working on cosmological simulations. He then moved into the audio and music technology industry, where he has spent over a decade of his career, worked on projects such as NI Kontakt and the JUCE framework, and co-founded the music tech startup Cradle. In the past, Timur also worked for JetBrains, first as a developer on CLion's C++ parser and later as a Developer Advocate for C++ developer tools. Currently, Timur lives in Finland, where he organises the monthly C++ Helsinki meetup and works as an independent C++ consultant. Timur is passionate about clean code, good tools, low latency, and the evolution of the C++ language.
---
ADC is an annual event celebrating all audio development technologies, from music applications and game audio to audio processing and embedded systems. ADC’s mission is to help attendees acquire and develop new audio development skills, and build a network that will support their audio developer career.
Annual ADC Conference - https://audio.dev/
linkedin.com/company/audiodevcon
twitter.com/audiodevcon
facebook.com/audiodevcon
instagram.com/audiodevcon
reddit.com/r/audiodevcon
https://mastodon.social/@audiodevcon
---
Streamed & Edited by Digital Medium Ltd: online.digital-medium.co.uk
---
Organized and produced by JUCE: juce.com
---
Special thanks to the ADC24 Team:
Sophie Carus
Derek Heimlich
Andrew Kirk
Bobby Lombardi
Tom Poole
Ralph Richbourg
Jim Roper
Jonathan Roper
Prashant Mishra
#adc #cpp #cppprogramming #audiodev #dsp #audio #conferenceaudio #audioprocessing #audioproduction #audioprogramming #musictech #soundtech #audiotech #audiotechnology

![Guide to C++ ValueTrees - The Secret Weapon of JUCE - Brett g Porter - ADC 2024
https://audio.dev/ @audiodevcon
Guide to C++ ValueTrees - The Secret Weapon of JUCE - Brett g Porter - ADC 2024
The JUCE website says The ValueTree class is JUCEs secret weapon, and its true. They give you:
- A really easy way to capture and pass around the entire state of your applications data at run time
- A rich mechanism to watch that data at a fine degree of granularity
- Trivially easy persistence of application state
...but at the cost (in comparison to using native POD or class/struct variables) of being:
- slower
- less convenient to use
- less type-safe, since all values are stored in the JUCE var variant type.
This talk will explore the new Cello library to abstract away the underlying API calls in favor of syntax thats more like working with POD data. The original goal was to be able to write code something like the below, but using ValueTrees as the backing data store:
struct MyStruct : public cello::Object
{
cello::Value<int> x;
cello::Value<float> y;
};
MyStruct demo;
// will be executed any time the value of X changes
demo.x.onPropertyChange = [&demo] ()
{
std::cout << x changed to <<demo.x << n;
}
// after executing this line, stdout should print: x changed to 100
demo.x = 100;
...and its surprising how close to that we were able to get.
This project has a set of overlapping goals:
- make working with ValueTrees more like working with C++ objects and less like calling API functions
- add type-safety and type conversions without explicit use of VariantConverter objects
- reduce boilerplate wherever possible
- handle undo/redo management invisibly
- support validation of values when they are accessed
- explore the gray area between compile-time strong typing as in C++ and the kind of runtime dynamic typing thats possible using the ValueTree API
- explore the available methods of reactive programming enabled with this system
- build out new functionality thats implied by the capabilities of ValueTrees but perhaps not obvious, like:
- creating a kind of NoSQL database
- creating an in-process sync mechanism to make ValueTrees thread-safe
- creating a simple IPC implementation
- In general, add support for more complex use cases where the complexity can be hidden inside the framework.
Slides: https://data.audio.dev/talks/2024/beyond-valuetrees/slides.pptx
Brett g Porter
Brett g Porter is a composer, trombonist, and developer of music software, currently Lead Software Engineer at Artiphon, where he designs strange little electronic musical instruments. He is a frequent speaker on the topic of Music Technology at industry events including SXSW, the Audio Developers Conference, the NAMM Show, and the Audio Engineering Society convention. He also serves on the executive board of the MIDI Manufacturers Association, which defines and maintains the MIDI standards used by electronic instruments, and has been active in several of the working groups tasked with developing the MIDI 2.0 specifications. Brett holds degrees in composition and electronic music from the Frost School of Music at the University of Miami.
ADC is an annual event celebrating all audio development technologies, from music applications and game audio to audio processing and embedded systems. ADC’s mission is to help attendees acquire and develop new audio development skills, and build a network that will support their audio developer career.
Annual ADC Conference - https://audio.dev/
https://www.linkedin.com/company/audiodevcon
https://twitter.com/audiodevcon
https://facebook.com/audiodevcon
https://instagram.com/audiodevcon
https://www.reddit.com/r/audiodevcon/
https://mastodon.social/@audiodevcon
Streamed & Edited by Digital Medium Ltd: https://online.digital-medium.co.uk
Organized and produced by JUCE: https://juce.com/
Special thanks to the ADC24 Team:
Sophie Carus
Derek Heimlich
Andrew Kirk
Bobby Lombardi
Tom Poole
Ralph Richbourg
Jim Roper
Jonathan Roper
Prashant Mishra
#cpp #adc #juce #audiodev #dsp #audio #conferenceaudio #audioprocessing #audioproduction #audioprogramming #musictech #soundtech #audiotech #audiotechnology Guide to C++ ValueTrees - The Secret Weapon of JUCE - Brett g Porter - ADC 2024](https://i.ytimg.com/vi/usUz6CHl-Es/mqdefault.jpg)








