Csound Csound-dev Csound-tekno Search About

[Csnd] Real-time transient detection

Date2025-08-05 14:27
FromBryan Tysinger
Subject[Csnd] Real-time transient detection
I’m working on a real-time plugin that will route audio phrases into different delay buffers. A legato phrase should go to one buffer, the next phrase will go to a subsequent buffer, etc. 

I’m currently using follow2 for this. When a new envelope starts, that’s the transient that triggers the switch to the new delay buffer. It works pretty well, though less so on signals with a rapid attack, like drums. I’m doing a crossfade, but getting that dialed in is a bit tricky. 

Is follow2 how you’d tackle this? I’ve also played with rms and vactrol. Maybe there is another I’m missing? Maybe a different approach entirely?

Here’s an example on acoustic guitar (plucked and ebowed), though I’m supplementing with a second noise gating plugin that assists: 

Thanks for any suggestions!
Bryan

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2025-08-05 19:55
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Real-time transient detection
You could try to look for rms amplitude changes, if these are large enough then you get a trigger. I would think that would work ok for drums. Generally speaking I would think finding the onset of a sound with a fast attack would be easier than with a slow attack.

What are the problems you are finding?

Oeyvind should also have something to say about this, he has a lot of experience with these kinds of applications.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 5 Aug 2025, at 10:28, Bryan Tysinger <bryantysinger@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I’m working on a real-time plugin that will route audio phrases into different delay buffers. A legato phrase should go to one buffer, the next phrase will go to a subsequent buffer, etc. 

I’m currently using follow2 for this. When a new envelope starts, that’s the transient that triggers the switch to the new delay buffer. It works pretty well, though less so on signals with a rapid attack, like drums. I’m doing a crossfade, but getting that dialed in is a bit tricky. 

Is follow2 how you’d tackle this? I’ve also played with rms and vactrol. Maybe there is another I’m missing? Maybe a different approach entirely?

Here’s an example on acoustic guitar (plucked and ebowed), though I’m supplementing with a second noise gating plugin that assists: 

Thanks for any suggestions!
Bryan

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2025-08-05 21:01
Fromjoachim heintz
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Real-time transient detection
for onset detection of percussive sounds you can also try this:
https://github.com/csudo/csudo/blob/master/misc/OnDtct.csd

On 05/08/2025 20:55, Victor Lazzarini wrote:
> You could try to look for rms amplitude changes, if these are large 
> enough then you get a trigger. I would think that would work ok for 
> drums. Generally speaking I would think finding the onset of a sound 
> with a fast attack would be easier than with a slow attack.
> 
> What are the problems you are finding?
> 
> Oeyvind should also have something to say about this, he has a lot of 
> experience with these kinds of applications.
> 
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 5 Aug 2025, at 10:28, Bryan Tysinger  wrote:
>>
>> 
>>
>>
>>   *Warning*
>>
>> This email originated from outside of Maynooth University's Mail 
>> System. Do not reply, click links or open attachments unless you 
>> recognise the sender and know the content is safe.
>>
>> I’m working on a real-time plugin that will route audio phrases into 
>> different delay buffers. A legato phrase should go to one buffer, the 
>> next phrase will go to a subsequent buffer, etc.
>>
>> I’m currently using follow2 for this. When a new envelope starts, 
>> that’s the transient that triggers the switch to the new delay buffer. 
>> It works pretty well, though less so on signals with a rapid attack, 
>> like drums. I’m doing a crossfade, but getting that dialed in is a bit 
>> tricky.
>>
>> Is follow2 how you’d tackle this? I’ve also played with rms and 
>> vactrol. Maybe there is another I’m missing? Maybe a different 
>> approach entirely?
>>
>> Here’s an example on acoustic guitar (plucked and ebowed), though I’m 
>> supplementing with a second noise gating plugin that assists:
>> https://on.soundcloud.com/Gc1OriXInKWp0LsPOZ > on.soundcloud.com/Gc1OriXInKWp0LsPOZ>
>>
>> Thanks for any suggestions!
>> Bryan
>>
>> Csound mailing list Csound@listserv.heanet.ie 
>>  https://listserv.heanet.ie/cgi-bin/ 
>> wa?A0=CSOUND  Send 
>> bugs reports to https://github.com/csound/csound/issues > github.com/csound/csound/issues> Discussions of bugs and features can 
>> be posted here
> Csound mailing list Csound@listserv.heanet.ie 
>  https://listserv.heanet.ie/cgi-bin/ 
> wa?A0=CSOUND  Send bugs 
> reports to https://github.com/csound/csound/issues  csound/csound/issues> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2025-08-05 21:16
FromTarmo Johannes
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Real-time transient detection
Nice!

Enjoy the Highlands!

And great that there is some fresh winds on the plains of CsoundQt ;)

tarmo


Kontakt joachim heintz (<jh@joachimheintz.de>) kirjutas kuupäeval T, 5. august 2025 kell 23:01:
for onset detection of percussive sounds you can also try this:
https://github.com/csudo/csudo/blob/master/misc/OnDtct.csd

On 05/08/2025 20:55, Victor Lazzarini wrote:
> You could try to look for rms amplitude changes, if these are large
> enough then you get a trigger. I would think that would work ok for
> drums. Generally speaking I would think finding the onset of a sound
> with a fast attack would be easier than with a slow attack.
>
> What are the problems you are finding?
>
> Oeyvind should also have something to say about this, he has a lot of
> experience with these kinds of applications.
>
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 5 Aug 2025, at 10:28, Bryan Tysinger <bryantysinger@gmail.com> wrote:
>>
>> 
>>
>>
>>   *Warning*
>>
>> This email originated from outside of Maynooth University's Mail
>> System. Do not reply, click links or open attachments unless you
>> recognise the sender and know the content is safe.
>>
>> I’m working on a real-time plugin that will route audio phrases into
>> different delay buffers. A legato phrase should go to one buffer, the
>> next phrase will go to a subsequent buffer, etc.
>>
>> I’m currently using follow2 for this. When a new envelope starts,
>> that’s the transient that triggers the switch to the new delay buffer.
>> It works pretty well, though less so on signals with a rapid attack,
>> like drums. I’m doing a crossfade, but getting that dialed in is a bit
>> tricky.
>>
>> Is follow2 how you’d tackle this? I’ve also played with rms and
>> vactrol. Maybe there is another I’m missing? Maybe a different
>> approach entirely?
>>
>> Here’s an example on acoustic guitar (plucked and ebowed), though I’m
>> supplementing with a second noise gating plugin that assists:
>> https://on.soundcloud.com/Gc1OriXInKWp0LsPOZ <https://
>> on.soundcloud.com/Gc1OriXInKWp0LsPOZ>
>>
>> Thanks for any suggestions!
>> Bryan
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> <mailto:Csound@listserv.heanet.ie> https://listserv.heanet.ie/cgi-bin/
>> wa?A0=CSOUND <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send
>> bugs reports to https://github.com/csound/csound/issues <https://
>> github.com/csound/csound/issues> Discussions of bugs and features can
>> be posted here
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie> https://listserv.heanet.ie/cgi-bin/
> wa?A0=CSOUND <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs
> reports to https://github.com/csound/csound/issues <https://github.com/
> csound/csound/issues> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2025-08-06 14:03
FromBryan Tysinger
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Real-time transient detection
The biggest issue I’m dealing with is the envelope decaying, retriggering, and rapidly decaying again. I end up with a very short sample sent to one of the delay lines. Noticeable on percussion, but also “warbly” on sounds with long decay. 

It is a balance between an envelope follower that is sensitive on the front end, but handles the tail well. 

Bryan

On Tue, Aug 5, 2025 at 11:55 AM Victor Lazzarini <000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
You could try to look for rms amplitude changes, if these are large enough then you get a trigger. I would think that would work ok for drums. Generally speaking I would think finding the onset of a sound with a fast attack would be easier than with a slow attack.

What are the problems you are finding?

Oeyvind should also have something to say about this, he has a lot of experience with these kinds of applications.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 5 Aug 2025, at 10:28, Bryan Tysinger <bryantysinger@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I’m working on a real-time plugin that will route audio phrases into different delay buffers. A legato phrase should go to one buffer, the next phrase will go to a subsequent buffer, etc. 

I’m currently using follow2 for this. When a new envelope starts, that’s the transient that triggers the switch to the new delay buffer. It works pretty well, though less so on signals with a rapid attack, like drums. I’m doing a crossfade, but getting that dialed in is a bit tricky. 

Is follow2 how you’d tackle this? I’ve also played with rms and vactrol. Maybe there is another I’m missing? Maybe a different approach entirely?

Here’s an example on acoustic guitar (plucked and ebowed), though I’m supplementing with a second noise gating plugin that assists: 

Thanks for any suggestions!
Bryan

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2025-08-07 13:24
FromOeyvind Brandtsegg
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Real-time transient detection
AttachmentsMountainsLakes2.csd  
Hi,

Similar to Joachim's suggestion, I also have a UDO that compares the current level to a previous level. With a minimum time since the previous trigger, to avoid too many false triggers. I also set a lower threshold, to get rid of activity below the noise floor. And a decay threshold, meaning that the signal has to decay by a this amount after a trigger, before it will accept a new trigger. 
I paste the UDO in the csd below.

I have also worked quite a bit with using spectral flux as the transient indicator, in addition to the simple amp envelope.
This can help teasing out transients happening in a more busy situation, where the overall amplitude does not fall back between onsets.
For realtime applications it is a bit finicky, as one generally needs a relatively large FFT size in order to calculate flux reliably. With a short FFT (512 or less), there will be a significant difference between spectral frames even with a stable sine sound as input. I think this relates to phase issues, as the FFT frame rate will seldomly be exactly in sync with the audio signal phase (the audio signal starts at different phase in each FFT frame). This leads to some jitter between frames even though it comes out correctly over time. Victor will probably be able to describe this with more technical rigor. To get around this, I compare a smoothed spectrum with the most current FFT frame and it helps get rid of most of the jitter.
I had meant to write a paper about this, but it seems I never get around to it....

I attach the full csd, using flux in the manner described, and using the transient detector UDO to detect transients in the flux envelope combined with the amp envelope.
The csd is in the form of a Cabbage script with GUI. It is called "Mountains and Lakes" as one has separate control over audio output of transients and sustained parts of the sound.
There are also some other features, like outputting while noise shaped by transient amplitude, and a "spectral differentiation" between neighbouring transients.

all best
Øyvind 



tir. 5. aug. 2025 kl. 22:01 skrev joachim heintz <jh@joachimheintz.de>:
for onset detection of percussive sounds you can also try this:
https://github.com/csudo/csudo/blob/master/misc/OnDtct.csd

On 05/08/2025 20:55, Victor Lazzarini wrote:
> You could try to look for rms amplitude changes, if these are large
> enough then you get a trigger. I would think that would work ok for
> drums. Generally speaking I would think finding the onset of a sound
> with a fast attack would be easier than with a slow attack.
>
> What are the problems you are finding?
>
> Oeyvind should also have something to say about this, he has a lot of
> experience with these kinds of applications.
>
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 5 Aug 2025, at 10:28, Bryan Tysinger <bryantysinger@gmail.com> wrote:
>>
>> 
>>
>>
>>   *Warning*
>>
>> This email originated from outside of Maynooth University's Mail
>> System. Do not reply, click links or open attachments unless you
>> recognise the sender and know the content is safe.
>>
>> I’m working on a real-time plugin that will route audio phrases into
>> different delay buffers. A legato phrase should go to one buffer, the
>> next phrase will go to a subsequent buffer, etc.
>>
>> I’m currently using follow2 for this. When a new envelope starts,
>> that’s the transient that triggers the switch to the new delay buffer.
>> It works pretty well, though less so on signals with a rapid attack,
>> like drums. I’m doing a crossfade, but getting that dialed in is a bit
>> tricky.
>>
>> Is follow2 how you’d tackle this? I’ve also played with rms and
>> vactrol. Maybe there is another I’m missing? Maybe a different
>> approach entirely?
>>
>> Here’s an example on acoustic guitar (plucked and ebowed), though I’m
>> supplementing with a second noise gating plugin that assists:
>> https://on.soundcloud.com/Gc1OriXInKWp0LsPOZ <https://
>> on.soundcloud.com/Gc1OriXInKWp0LsPOZ>
>>
>> Thanks for any suggestions!
>> Bryan
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> <mailto:Csound@listserv.heanet.ie> https://listserv.heanet.ie/cgi-bin/
>> wa?A0=CSOUND <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send
>> bugs reports to https://github.com/csound/csound/issues <https://
>> github.com/csound/csound/issues> Discussions of bugs and features can
>> be posted here
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie> https://listserv.heanet.ie/cgi-bin/
> wa?A0=CSOUND <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs
> reports to https://github.com/csound/csound/issues <https://github.com/
> csound/csound/issues> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here