
Kas, Graham!
Ya gotta love the way you think out of the box. Break the rules to
make better ones! Thanks for the comments, code and inspiration.
Jim
---"I dream of cheese, It's toasted, mostly" Ben Gunn, Treasure Island.
On Sep 24, 2006, at 8:55 09PM, Graham Coleman
From: Graham Coleman
Date: September 24, 2006 9:50:44 AM HST To: ChucK Users Mailing List Cc: jahbin@romatictrances.com Subject: Re: [chuck-users] How can I filter silence? Reply-To: ChucK Users Mailing List I came up with some cheesy code to implement the idea. It speeds up the tape when it hits silence. You'll need to tune the time constants and the threshold for best results:
sndbuf buf => dac; buf.read("speak/wave.wav"); buf.pos( 0 );
0.05 => float tresh; 0.01 => float rt; //release const 0.4 => float at; //attack const float xd;
while(true) {
math.fabs( buf.last() )-xd => float a; //amp diff if ( a < 0 ) 0=>a; //non-negative xd*(1-rt)+at*a => xd; //the attack/release exponential filter
if ( xd
1::samp=>now; }
To compute the time constants, use this formula: //AT = 1 - e ^ (-2.2T/t
or this if t is in samples:
time const = 1.0 - exp( -2.2 / t );
best,
Graham
On Sun, 24 Sep 2006, Graham Coleman wrote:
I'm not sure if there's anything in chuck that will currently do this, but I think you could write something like a noise gate, that tracks the amplitude of samples coming from a SndBuf and skips ahead until the level rises above a threshold.
Not sure how well this would run in real time.
Better, would be something that preprocesses the file with in/out points so the skips are quick.
Graham
On Sun, 24 Sep 2006, Jim Hinds wrote:
I want to scan some audio for dropped out sections. It's long and talky with 'significant' pauses between question and answers. These sections are filled with background noise, and often several seconds long. I'd like to shorten these empty sections (there are a lot of them).
I'd like to keep the files more or less intact (not sliced up into a zillion intermediate files)
Is there a unit in chuck that will be able to delete samples as they pass through?
Jim _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
From: Kassen
Date: September 24, 2006 10:23:58 AM HST To: "ChucK Users Mailing List" Subject: Re: [chuck-users] How can I filter silence? Reply-To: ChucK Users Mailing List On 9/24/06, Graham Coleman
wrote: I'm not sure if there's anything in chuck that will currently do this, but I think you could write something like a noise gate, that tracks the amplitude of samples coming from a SndBuf and skips ahead until the level rises above a threshold. Not sure how well this would run in real time.
Better, would be something that preprocesses the file with in/out points so the skips are quick.
But.... It doesn't look like it needs to be realtime.
I'd think about playing the file once and storing the sample locations where the volume drops below a treshold (as well as the ones where it comes back) in a array, then playing it a second time and skipping those sections while writing the results to a new file. in "silent" mode this should be doable faster then realtime.
You could also make a array of the length of the file (in samples) and only write buf.last() => array[sample++] as long as it's over the treshold. Once the buffer reaches it's end you'd playback the array again and record that, taking care to stop after the highest value that "sample" got to in the first pass. This would be CPU intesive but it's quite clean as a method, I think.
It all stands or falls with the quality of the envelope follower.
I've been thinking about doing something similar to the first option and pre-scanning wavefiles for positive zero-crossings and storing those in a array. This would take extra time when loading a file but from then on you could do very clean loops, for example to loop just a few cycles. I wonder how samplers that have a "snap to zero crossings" setting do this. It might still be quite tricky because not all samplers that do this do it all that well....
Hope that's of some use. Kas.

My pleasure, thanks for the ideas. I enjoy this forum a lot. It is a supportive and positive an atmosphere that encourages all- created by developers and users alike. Excelcior! On Mon, 25 Sep 2006, Jim Hinds wrote:
Kas, Graham!
Ya gotta love the way you think out of the box. Break the rules to make better ones! Thanks for the comments, code and inspiration.
Jim ---"I dream of cheese, It's toasted, mostly" Ben Gunn, Treasure Island.
On Sep 24, 2006, at 8:55 09PM, Graham Coleman
wrote: From: Graham Coleman
Date: September 24, 2006 9:50:44 AM HST To: ChucK Users Mailing List Cc: jahbin@romatictrances.com Subject: Re: [chuck-users] How can I filter silence? Reply-To: ChucK Users Mailing List I came up with some cheesy code to implement the idea. It speeds up the tape when it hits silence. You'll need to tune the time constants and the threshold for best results:
sndbuf buf => dac; buf.read("speak/wave.wav"); buf.pos( 0 );
0.05 => float tresh; 0.01 => float rt; //release const 0.4 => float at; //attack const float xd;
while(true) {
math.fabs( buf.last() )-xd => float a; //amp diff if ( a < 0 ) 0=>a; //non-negative xd*(1-rt)+at*a => xd; //the attack/release exponential filter
if ( xd
1::samp=>now; }
To compute the time constants, use this formula: //AT = 1 - e ^ (-2.2T/t
or this if t is in samples:
time const = 1.0 - exp( -2.2 / t );
best,
Graham
On Sun, 24 Sep 2006, Graham Coleman wrote:
I'm not sure if there's anything in chuck that will currently do this, but I think you could write something like a noise gate, that tracks the amplitude of samples coming from a SndBuf and skips ahead until the level rises above a threshold.
Not sure how well this would run in real time.
Better, would be something that preprocesses the file with in/out points so the skips are quick.
Graham
On Sun, 24 Sep 2006, Jim Hinds wrote:
I want to scan some audio for dropped out sections. It's long and talky with 'significant' pauses between question and answers. These sections are filled with background noise, and often several seconds long. I'd like to shorten these empty sections (there are a lot of them).
I'd like to keep the files more or less intact (not sliced up into a zillion intermediate files)
Is there a unit in chuck that will be able to delete samples as they pass through?
Jim _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
From: Kassen
Date: September 24, 2006 10:23:58 AM HST To: "ChucK Users Mailing List" Subject: Re: [chuck-users] How can I filter silence? Reply-To: ChucK Users Mailing List On 9/24/06, Graham Coleman
wrote: I'm not sure if there's anything in chuck that will currently do this, but I think you could write something like a noise gate, that tracks the amplitude of samples coming from a SndBuf and skips ahead until the level rises above a threshold. Not sure how well this would run in real time.
Better, would be something that preprocesses the file with in/out points so the skips are quick.
But.... It doesn't look like it needs to be realtime.
I'd think about playing the file once and storing the sample locations where the volume drops below a treshold (as well as the ones where it comes back) in a array, then playing it a second time and skipping those sections while writing the results to a new file. in "silent" mode this should be doable faster then realtime.
You could also make a array of the length of the file (in samples) and only write buf.last() => array[sample++] as long as it's over the treshold. Once the buffer reaches it's end you'd playback the array again and record that, taking care to stop after the highest value that "sample" got to in the first pass. This would be CPU intesive but it's quite clean as a method, I think.
It all stands or falls with the quality of the envelope follower.
I've been thinking about doing something similar to the first option and pre-scanning wavefiles for positive zero-crossings and storing those in a array. This would take extra time when loading a file but from then on you could do very clean loops, for example to loop just a few cycles. I wonder how samplers that have a "snap to zero crossings" setting do this. It might still be quite tricky because not all samplers that do this do it all that well....
Hope that's of some use. Kas.
participants (2)
-
Graham Coleman
-
Jim Hinds