home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Audio 4.94 - Over 11,000 Files
/
audio-11000.iso
/
mac
/
soundutl
/
vmtrs10s.hqx
/
VUMeters
/
Sources
/
PowerMonitor.s
< prev
next >
Wrap
Text File
|
1993-08-25
|
6KB
|
166 lines
/*
* ARTA VUMeters for Macintosh
* Malcolm Slaney
* Advanced Technology Group
* Apple Computer, Inc.
* malcolm@apple.com
* 1992-1993
*
* Warranty Information
* Even though Apple has reviewed this software, Apple makes no warranty
* or representation, either express or implied, with respect to this
* software, its quality, accuracy, merchantability, or fitness for a
* particular purpose. As a result, this software is provided "as is,"
* and you, its user, are assuming the entire risk as to its quality
* and accuracy.
*
* Copyright (c) 1992-1993 by Apple Computer, Inc
* All Rights Reserved.
*/
/* PowerMonitor.s */
/*****************************************************************************/
/* */
/* monitor the sound power level of the DSP */
/* */
/*****************************************************************************/
#include <DSP3210.h>
#define MonitorName Power
#define NumSamples 240
NewModule(MonitorName, kdspSmoothModule, kdspAutoCache, power)
long (100<<16), 240, 1000 // 10ms, 24Khz
long (200<<16), 240, 1000 // 5ms, 48Khz
long (12042240), 240, 1000 // 5.44218ms, 44.1Khz
long (6021120), 240, 1000 // 10.88435ms, 22.05Khz
NewCachedProgramSection(power, MonitorName)
/* sound AIAOs */
NewScalableInputAIAOSection(Left, 1, kdsp3200Float, MonitorName)
NewScalableInputAIAOSection(Right, 1, kdsp3200Float, MonitorName)
NewParameterSection(Params, kdsp3200Float, MonitorName)
#define DSPCOMPILE
#include <SoundMonitor.h>
AppendSection (power)
_power:
GetSectionLabel(r3,frameScale) /* r3 = &(1 / NumSamples) */
nop
nop
a0 = dsp(*r3)
nop
nop
r3 = PcLabel(d1_NumSamples)
*r3 = a0 = a0
/* Monitor left channel */
GetSectionLabel (r1, monitorLeft) /* r1 = &monitorLeft */
r1 = *r1 /* r1 = monitorLeft */
nop
r1 - 0 /* monitor left channel? */
if (eq) pcgoto skip_monitor_left /* no, then skip */
r3 = PcLabel(d1_NumSamples) /* r3 = &(1 / NumSamples) */
GetSectionAddress (r2, Left) /* r2 = Left AIAO */
a1 = *r2 * *r2 /* start unscaled total power */
a0 = *r3 * *r2++ /* start scaled dc level */
r1 = (short) NumSamples - 2 /* r1 = loop count */
do r1
{
a1 = a1 + *r2 * *r2 /* unscaled total power */
a0 = a0 + *r3 * *r2++ /* scaled dc level */
}
GetSectionLabel (r1, fastLeftLevel) /* r1 = &fastLeftLevel */
a1 = *r3 * a1 /* scale total power */
a0 = a1 - a0*a0 /* fastLeftLevel = total power - */
/* dc power */
nop
nop
*r1 = a1 = ieee (a0)
GetSectionLabel (r1, slowLeftLevel) /* r1 = &slowLeftLevel */
a3 = dsp (*r1) /* a3 = old slowLeftLevel */
GetSectionLabel (r2, decayRate) /* r2 = &decayRate */
r3 = PcLabel (max_decay) /* r3 = &max_decay */
a2 = dsp (*r2) /* a2 = decayRate */
a1 = a3 - a0 /* compare current max with */
/* last max */
nop
nop
nop
nop
a2 = ifalt (*r3) /* if max > last max decay at */
/* max_decay rate */
nop
nop
a0 = a0 + a2*a1 /* y(n) = (1-e)x(n) + ey(n-1) */
nop /* Actually y(n)=x(n)+e[y(n-1)-x(n)] */
nop /* where e is set to 0 if y(n-1)-x(n)<0 */
*r1 = a0 = ieee (a0)
skip_monitor_left:
/* Monitor right channel */
GetSectionLabel (r1, monitorRight) /* r1 = &monitorRight */
r1 = *r1 /* r1 = monitorRight */
nop
r1 - 0 /* monitor right channel? */
if (eq) pcgoto skip_monitor_right /* no, then skip */
r3 = PcLabel(d1_NumSamples) /* r3 = &(1 / NumSamples) */
GetSectionAddress (r2, Right) /* r2 = Right AIAO */
a1 = *r2 * *r2 /* start unscaled total power */
a0 = *r3 * *r2++ /* start scaled dc level */
r1 = (short) NumSamples - 2 /* r1 = loop count */
do r1
{
a1 = a1 + *r2 * *r2 /* unscaled total power */
a0 = a0 + *r3 * *r2++ /* scaled dc level */
}
GetSectionLabel (r1, fastRightLevel) /* r1 = &fastRightLevel */
a1 = *r3 * a1 /* scale total power */
a0 = a1 - a0*a0 /* fastRightLevel = total power - */
nop
nop
*r1 = a1 = ieee (a0)
/* dc power */
GetSectionLabel (r1, slowRightLevel) /* r1 = &slowRightLevel */
a3 = dsp (*r1) /* a3 = old slowRightLevel */
GetSectionLabel (r2, decayRate) /* r2 = &decayRate */
r3 = PcLabel (max_decay) /* r3 = &max_decay */
a2 = dsp (*r2) /* a2 = decayRate */
a1 = a3 - a0 /* compare current max with */
/* last max */
nop
nop
nop
nop
a2 = ifalt (*r3) /* if max < last max decay at */
/* max_decay rate*/
nop
nop
a0 = a0 + a2*a1 /* y(n) = (1-e)x(n) + ey(n-1) */
nop /* Actually y(n)=x(n)+e[y(n-1)-x(n)] */
nop /* where e is set to 0 if y(n-1)-x(n)<0 */
*r1 = a1 = ieee (a0)
skip_monitor_right:
return (RV)
nop
d1_NumSamples: float 0.00416666 /* 1 / NumSamples */
max_decay: float 0.0
/* PowerMonitor.s */