Programmer Guide/SPU Reference/AVR: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
 
(69 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
====AVR - averaging====
Average input <var>X</var> over evaluation cycles.
 
==<code>[SPU AVR <var>X TYP T RS</var> OUT <var>Y</var>]</code>==
=====Usage:=====
{|class="einrahmen"
 
!input !!description !!data type !!value type!!default value
<code>AVR <var>X</var> <var>TYP</var> <var>T</var> <var>RS</var></code>
|-
 
|<var>X</var>||data to be averaged ||number, vector, matrix ||variable
=====Inputs:=====
 
;<var>X</var>
 
:A number or vector.
 
;<var>TYP</var>
 
:A string or number selecting the averaging method.
 
;<var>T</var>
 
:A number used as parameter for some methods.
 
;<var>RS</var>
 
:Reset input (see the function description).
 
=====Outputs:=====
 
;<var>Y</var>
 
:The ("time") average of <var>X</var> (same type as <var>X</var>).
 
;<var>N</var>
 
:The number of average cycles since the last reset (number).
 
=====Function:=====
 
Compute an average of input <var>X</var>. The averaging is performed across a specified or infinite number of evaluation cycles. If input <var>X</var> is a vector, each element of the vector is "time"-averaged. In the table <var>X</var>(t)/<var>Y</var>(t) is used for the input/output number or one input/output vector element in the evaluation cycle t.
 
Table 5: Averaging and selection methods
 
{|
|-
|-
|value of TYP
|<var>TYP</var>||averaging method ||number (int.), string||constant
|averaging or selection method
|-
|-
|0 or LINEAR
|<var>T</var>||averaging parameter, depends on method ||number or n.c.||<var>TYP</var>=1&rarr;variable<BR><var>TYP</var>&ne;2&rarr;constant
|If T is greater than 0 it is used as number of average cycles:
[[File:1205.png]]Otherwise (<var>T</var>=0) an infinite average period is used:[[File:1206.png]]
|-
|-
|1 or EXPONENTIAL
|<var>RS</var>||reset flag||number or n.c. ||variable 
|[[File:1207.png]]with: k = U1/2 and 0 < T < 1
|-
|-
|2 or MINIMUM
!output !!description !!data type !!value type!!comment
|[[File:1208.png]]
|-
|-
|3 or MAXIMUM
|<var>Y</var>||averaged input data ||same type as <var>X</var> ||variable
|[[File:1209.png]]
|}
|}


The input RS can be used to reset the averager when the SPU is restarted. If <var>RS</var> is set to 1 the averager is reinitialised and the cycle counter (t) is set to zero. Note: the <var>RS</var> input is checked only once when the SPU (containing the averager atom) receives the start-command.
 
;Description:
The averaging algorithm is defined by the inputs <var>TYP</var> and <var>T</var>. The atom averages the elements <var>X</var>[''i'',''j'']<sub>''t''</sub> over evaluation cycles t (''i''=row index, ''j''=column index, ''t''=cycle counter) and stores the averaged value in the element <var>Y</var>[''i'',''j'']<sub>''t''</sub>.
 
The cycle counter ''t'' is initialized with 0 and incremented by 1 after each evaluation cycle. The cycle counter is reset, if the input <var>RS</var> is set to a value greater than <code>0</code>. The input <var>RS</var> is checked each time the SPU is started.
:;infinite average:
::<var>TYP</var>=<code>0</code> or <code>linear</code>
::<var>T</var>=<code>0</code>
::<math>Y[i,j]_t =
\begin{cases}
X[i,j]_t & \mbox{if }t=0 \\
\frac{1}{t+1}(t.Y[i,j]_{t-1}+X[i,j]_t) & \mbox{if }t>0
\end{cases}
</math>
:;running average:
::<var>TYP</var>=<code>0</code> or <code>linear</code>
::<var>T</var>&gt;<code>0</code>; <var>T</var> is the (integer) number of averaging cycles
::<math>Y[i,j]_t =
\begin{cases}
\frac{1}{t+1}\sum_{z=0}^t X[i,j]_z & \mbox{if }0\leqslant t < T \\
\frac{1}{T}\sum_{z=0}^{T-1}X[i,j]_{t-z} & \mbox{if }t\geqslant T
\end{cases}
</math>
:;exponential average:
::<var>TYP</var>=<code>1</code> or <code>exponential</code>
::<code>0</code>&lt;<var>T</var>&lt;<code>1</code>; <var>T</var> is the averaging factor
::<math>Y[i,j]_t =
\begin{cases}
X[i,j]_t & \mbox{if }t=0\mbox{ (or }T\mbox{ out of range)}\\
\sqrt{T}.Y[i,j]_{t-1}+(1-\sqrt{T}).X[i,j]_t & \mbox{if }t>0
\end{cases}
</math>
:;minimum:
::<var>TYP</var>=<code>2</code> or <code>minimum</code>
::<var>T</var> is not used
::<math>Y[i,j]_t =
\begin{cases}
X[i,j]_t & \mbox{if }t=0 \\
min(Y[i,j]_{t-1},X[i,j]_t) & \mbox{if }t>0
\end{cases}
</math>
:;maximum:
::<var>TYP</var>=<code>3</code> or <code>maximum</code>
::<var>T</var> is not used
::<math>Y[i,j]_t =
\begin{cases}
X[i,j]_t & \mbox{if }t=0 \\
max(Y[i,j]_{t-1},X[i,j]_t) & \mbox{if }t>0
\end{cases}
</math>
 
Since {{STx}} version 4.5.0 the following two new average modes are available, which were used to implement the spectral averaging mode <code>power</code> of the applications [[User Guide/Spectrogram and Parameter Viewer|Viewer2]]  (sectioner) and [[User Guide/Spectrum Viewer|Viewer3]].
 
:;power:
::<var>TYP</var>=<code>4</code> or <code>power</code>
::<var>T</var> is not used
::* each input element X<sub>i,j</sub> is squared
::* same averaging as for TYP</var>=<code>0</code> is performed
::* square root of each output element Y<sub>i,j</sub> is taken
:;db-power:
::<var>TYP</var>=<code>5</code> or <code>dbpower</code>
::<var>T</var> is not used
::* each input element X<sub>i,j</sub> is converted from dB to squared magnitude (power)
::* same averaging as for TYP</var>=<code>0</code> is performed
::* each output element Y<sub>i,j</sub> is converted to dB
;See also:
<[[../#Signal Processing Atoms|SP-atoms]]>
<!-- AN, 2.5.2011 -->

Latest revision as of 11:00, 16 October 2018

Average input X over evaluation cycles.

[SPU AVR X TYP T RS OUT Y]

input description data type value type default value
X data to be averaged number, vector, matrix variable
TYP averaging method number (int.), string constant
T averaging parameter, depends on method number or n.c. TYP=1→variable
TYP≠2→constant
RS reset flag number or n.c. variable
output description data type value type comment
Y averaged input data same type as X variable


Description

The averaging algorithm is defined by the inputs TYP and T. The atom averages the elements X[i,j]t over evaluation cycles t (i=row index, j=column index, t=cycle counter) and stores the averaged value in the element Y[i,j]t.

The cycle counter t is initialized with 0 and incremented by 1 after each evaluation cycle. The cycle counter is reset, if the input RS is set to a value greater than 0. The input RS is checked each time the SPU is started.

infinite average
TYP=0 or linear
T=0
{\displaystyle Y[i,j]_{t}={\begin{cases}X[i,j]_{t}&{\mbox{if }}t=0\\{\frac {1}{t+1}}(t.Y[i,j]_{t-1}+X[i,j]_{t})&{\mbox{if }}t>0\end{cases}}}
running average
TYP=0 or linear
T>0; T is the (integer) number of averaging cycles
{\displaystyle Y[i,j]_{t}={\begin{cases}{\frac {1}{t+1}}\sum _{z=0}^{t}X[i,j]_{z}&{\mbox{if }}0\leqslant t<T\\{\frac {1}{T}}\sum _{z=0}^{T-1}X[i,j]_{t-z}&{\mbox{if }}t\geqslant T\end{cases}}}
exponential average
TYP=1 or exponential
0<T<1; T is the averaging factor
{\displaystyle Y[i,j]_{t}={\begin{cases}X[i,j]_{t}&{\mbox{if }}t=0{\mbox{ (or }}T{\mbox{ out of range)}}\\{\sqrt {T}}.Y[i,j]_{t-1}+(1-{\sqrt {T}}).X[i,j]_{t}&{\mbox{if }}t>0\end{cases}}}
minimum
TYP=2 or minimum
T is not used
{\displaystyle Y[i,j]_{t}={\begin{cases}X[i,j]_{t}&{\mbox{if }}t=0\\min(Y[i,j]_{t-1},X[i,j]_{t})&{\mbox{if }}t>0\end{cases}}}
maximum
TYP=3 or maximum
T is not used
{\displaystyle Y[i,j]_{t}={\begin{cases}X[i,j]_{t}&{\mbox{if }}t=0\\max(Y[i,j]_{t-1},X[i,j]_{t})&{\mbox{if }}t>0\end{cases}}}

Since STx version 4.5.0 the following two new average modes are available, which were used to implement the spectral averaging mode power of the applications Viewer2 (sectioner) and Viewer3.

power
TYP=4 or power
T is not used
  • each input element Xi,j is squared
  • same averaging as for TYP=0 is performed
  • square root of each output element Yi,j is taken
db-power
TYP=5 or dbpower
T is not used
  • each input element Xi,j is converted from dB to squared magnitude (power)
  • same averaging as for TYP=0 is performed
  • each output element Yi,j is converted to dB
See also

<SP-atoms>

Navigation menu

Personal tools