rms — Determines the root-mean-square amplitude of an audio signal.
Determines the root-mean-square amplitude of an audio signal. It low-pass filters the actual value, to average in the manner of a VU meter.
ihp (optional, default=10) -- half-power point (in Hz) of a special internal low-pass filter. The default value is 10.
iskip (optional, default=0) -- initial disposition of internal data space (see reson). The default value is 0.
asig -- input audio signal
kres -- low-pass filtered rms value of the input signal
rms output values kres will trace the root-mean-square value of the audio input asig. This unit is not a signal modifier, but functions rather as a signal power-gauge. It uses an internal low-pass filter to make the response smoother. ihp can be used to control this smoothing. The higher the value, the "snappier" the measurement.
This opcode can also be used as an evelope follower.
The kres output from this opcode is given in aplitude and depends on 0dbfs. If you want the output in decibels, you can use dbamp
arms rms asig ; get rms value of signal asig
Here is an example of the rms opcode. It uses the file rms.csd.
Example 402. Example of the rms opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform ; Audio out Audio in No messages -odac -iadc -d -m0 ;;;RT audio I/O ; For Non-realtime ouput leave only the line below: ; -o rms.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; Initialize the global variables. sr = 44100 ksmps = 128 nchnls = 1 ;Example by Andres Cabrera 2007 0dbfs = 1 FLpanel "rms", 400, 100, 50, 50 gkrmstext, gihrmstext FLtext "Rms", -100, 0, 0.1, 3, 110, 30, 60, 50 gkihp, gihandle FLtext "ihp", 0, 10, 0.05, 1, 100, 30, 220, 50 gkrmsslider, gihrmsslider FLslider "", -60, -0.5, -1, 5, -1, 380, 20, 10, 10 FLpanelEnd FLrun FLsetVal_i 5, gihandle ; Instrument #1. instr 1 a1 inch 1 label: kval rms a1, i(gkihp) ;measures rms of input channel 1 rireturn kval = dbamp(kval) ; convert to db full scale printk 0.5, kval FLsetVal 1, kval, gihrmsslider ;update the slider and text values FLsetVal 1, kval, gihrmstext knewihp changed gkihp ; reinit when ihp text has changed if (knewihp == 1) then reinit label ;needed because ihp is an i-rate parameter endif endin </CsInstruments> <CsScore> ; Play Instrument #1 for one minute i 1 0 60 e </CsScore> </CsoundSynthesizer>