Csound Csound-dev Csound-tekno Search About

[Csnd] Re: Re: transient analysis

Date2008-04-22 07:49
Fromvictor
Subject[Csnd] Re: Re: transient analysis
It's a time-frequency issue...
----- Original Message -----
Sent: Tuesday, April 22, 2008 12:37 AM
Subject: [Csnd] Re: transient analysis

Hi,

I've always thought of transients as belonging to the time domain, not the frequency domain... In that case something like the rms opcode?

Cheers,
Andrés

On Mon, Apr 21, 2008 at 7:05 AM, Oeyvind Brandtsegg <obrandts@gmail.com> wrote:
Hello

I'd like to do transient analysis of an audio signal in Csound,
preferably analysis in realtime. I'm unsure about how to go about
this. I did a simple test of taking the centroid (pvscent) and looking
for steep ascending slopes. This sort of works, but not perfect. Maybe
it could be combined with amplitude (ascending) slope detection, but
I'm sure there are better ways to do this.
It would be useful to have degrees of "transient-ness", and also to
have the signal gently slope back to zero as the analyzed audio
stabilizes on a "steady state" spectrum.
Maybe a new pvs opcode ?

Oeyvind


Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2008-04-23 01:29
From"Matt J. Ingalls"
Subject[Csnd] Re: Re: Re: transient analysis
here's something i showed in Ireland festival last november that will 
sense the transients in a file and save the position in a table for later 
playback.  if you don't have a mac just replace invalue/outvalue with 
pfields or something..

  i have yet to use it in a performance, but AFAIK it works.




/***************************************************

 	Transient Analysis

***************************************************/

nchnls = 2
0dbfs = 1

;#define FILENAME #marble#
#define FILENAME #duct#
;#define FILENAME #wineEns#

gkpoints init 0


; analysis
instr 1

 	; initial values
 	kattackthresh invalue "attack"
 	iminlen init 2000

 	isilencethresh init 200
 	imaxampbufsiz init 200

 	kdur 	init	0
 	klastrms init 1

 	; get audio
 	al, ar	soundin "$FILENAME"

 	; take rms and campare to last
 	krms rms .5*(al+ar)
 	kratio = krms/klastrms

 	outvalue "ratio", 1/kratio
 	outvalue "rms", krms

 	; if rms/lastrms ratio is greater than threshold, write to table
 	if (krms > .01 && kratio > kattackthresh && kdur > iminlen) then
 		ktim times
 		printks "%f %n", 0, ktim
 		kdur = 0

 		tablew ktim, gkpoints, 2

 		gkpoints = gkpoints + 1
 		outvalue "count", gkpoints
 	endif

 	kdur = kdur+1
 	klastrms port krms, 1

 	outs al, ar

endin


; playack one transient segment (randomly chosen) of the soundfile
instr 2

 	indx linrand gkpoints
 	iskip table indx, 2
 	print iskip

 	iend table indx+1, 2

 	ipitch linrand 3
 	ipitch = ipitch + .1

 	kcount init (iend-iskip)/ipitch

 	al, ar diskin2 "$FILENAME", ipitch, iskip, 0, 0, 4

 	outs al, ar

 	kcount = kcount - 1/kr
 	if (kcount <= .1) then
 		turnoff
 	endif

endin


f1 0 512 10 1

f2 0 512 -7 35 512 35

i1 0 35

f0 9999999




Version: 3
Render: Real
Ask: Yes
SFDIR: /Users/matt/Music
Functions: ioObject
Listing: ioObject
WindowBounds: 64 44 1032 870
CurrentView: io
IOViewEdit: Off
Options: -b256 -A -s -m7 -R


ioView background {65535, 64997, 56784}
ioText {382, 13} {56, 72} label 0.000000 0.001000 "" left "Lucida Grande" 
8 {0, 0, 0} {65535, 65535, 65535} nobackground border clip count
ioText {233, 13} {114, 47} label 0.000000 0.001000 "" left "Lucida Grande" 
8 {0, 0, 0} {65535, 65535, 65535} nobackground noborder attack threshold
ioText {48, 70} {47, 28} label 0.000000 0.001000 "" left "Lucida Grande" 8 
{0, 0, 0} {65535, 65535, 65535} nobackground noborder rms
ioListing {10, 152} {395, 433}
ioGraph {410, 150} {511, 428}
ioSlider {26, 21} {247, 34} 1.000000 30.000000 3.282300 attack
ioMeter {117, 58} {92, 23} {44563, 53738, 65535} "ratio" 9.314381 "ratio" 
9.314381 fill 1 0 notrack
ioText {277, 28} {47, 24} display 3.282300 0.001000 "attack" center 
"Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder
ioMeter {20, 57} {92, 23} {44563, 53738, 65535} "rms" 0.000484 "rms" 
0.000484 fill 1 0 notrack
ioText {399, 52} {44, 35} display 24.000000 1.000000 "count" left "Lucida 
Grande" 20 {0, 0, 0} {65535, 65535, 65535} nobackground noborder 
ioButton {276, 88} {90, 48} event 1.000000 "" "Play clip" "/" i2 0 10
ioText {120, 73} {114, 47} label 0.000000 0.001000 "" left "Lucida Grande" 
8 {0, 0, 0} {65535, 65535, 65535} nobackground noborder lastrms/rms ratio



Date2008-04-23 09:46
From"Oeyvind Brandtsegg"
Subject[Csnd] Re: Re: Re: Re: transient analysis
AttachmentsNone