00 /**********************************************************************
01 Copyright (c) 2016 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 **********************************************************************/
23
Disclaimer...
24 desc:Peak Meter, Mono, v1.0.0
25 // no decay
26
27 @init
28 buf = 0;
29 bufpos = 0;
30 buflength = srate * 0.08; // 1.2 = 1200 ms
31
32
33 @sample
34 peakValue = abs(spl0);
35 buf[bufpos] = peakValue;
36 bufpos += 1;
37 bufpos > buflength ? bufpos = 0;
38
39 bufpos % (srate * 0.040) == 0 ?
40 (
41 maxVal = 0; i = 0;
42 while ( i < buflength )
43 (
44 buf[i] > maxVal ? maxVal = buf[i];
45 i += 1;
46 );
47
48 peakDB = 20 * log10(maxVal);
49
50 );
51
52 spl0 = spl0;
53 spl1 = spl1;
54
Graphics...
56 @gfx 100 18
57 gfx_x=gfx_y=5;
58 gfx_r=0.7;
59 gfx_g=1;
60 gfx_b=0.1;
61 gfx_a=1;
62 gfx_drawchar($'P');
63 gfx_drawchar($'e');
64 gfx_drawchar($'a');
65 gfx_drawchar($'k');
66 gfx_drawchar($':');
67 gfx_drawchar($' ');
68 gfx_drawnumber(peakDB,1);
69