home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Audio 4.94 - Over 11,000 Files
/
audio-11000.iso
/
mac
/
soundutl
/
vmtrs10s.hqx
/
VUMeters
/
Sources
/
MaxMonitor.s
< prev
next >
Wrap
Text File
|
1993-08-25
|
6KB
|
150 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.
*/
/* MaxMonitor.s */
/*****************************************************************************/
/* */
/* Monitor the maximum sound level of the DSP. */
/* */
/*****************************************************************************/
#include <DSP3210.h>
#define MonitorName Max
#define NumSamples 240
NewModule(MonitorName, kdspSmoothModule, kdspAutoCache, max)
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(max, MonitorName)
/* sound AIAOs */
NewScalableInputAIAOSection(Left, 1, kdsp3200Float, MonitorName)
NewScalableInputAIAOSection(Right, 1, kdsp3200Float, MonitorName)
NewParameterSection(Params, kdsp3200Float, MonitorName)
#define DSPCOMPILE
#include <SoundMonitor.h>
AppendSection (max)
_max:
/* 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 */
/* be careful what comes after branch */
/* find max of current left frame */
r1 = (short) NumSamples - 1 /* r1 = loop count */
GetSectionAddress (r2, Left) /* r2 = Left AIAO */
r3 = PcLabel (zero) /* r3 = &0.0 */
a0 = *r3 /* a0 = 0.0 */
do r1
{
a1 = -*r2 /* a1 = -current sample */
a1 = ifalt (*r2++) /* a1 = abs (current sample) */
a2 = a1 - a0 /* compare current max with */
/* abs (current sample) */
a0 = ifagt (a1) /* a0 = max (a0, a1) */
}
GetSectionLabel (r1, fastLeftLevel) /* r1 = &fastLeftLevel */
*r1 = a1 = ieee (a0) /* Store result */
GetSectionLabel (r1, slowLeftLevel) /* r1 = &slowLeftLevel */
a3 = dsp (*r1) /* a3 = 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 */
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 */
/* be careful what comes after branch */
/* find max of current right frame */
r1 = (short) NumSamples - 1 /* r1 = loop count */
GetSectionAddress (r2, Right) /* r2 = Right AIAO */
r3 = PcLabel (zero) /* r3 = &0.0 */
a0 = *r3 /* a0 = Right[0] */
do r1
{
a1 = -*r2 /* a1 = -current sample */
a1 = ifalt (*r2++) /* a1 = abs (current sample) */
a2 = a1 - a0 /* compare current max with */
/* abs (current sample) */
a0 = ifagt (a1) /* a0 = max (a0, a1) */
}
GetSectionLabel (r1, fastRightLevel) /* r1 = &fastRightLevel */
*r1 = a1 = ieee (a0) /* Store result */
GetSectionLabel (r1, slowRightLevel) /* r1 = &slowRightLevel */
a3 = dsp (*r1) /* a3 = 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 */
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_right:
return (RV)
nop
max_decay: float 0.0
zero: float 0.0
/* MaxMonitor.s */