-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauxiliaryEOC.lib
110 lines (101 loc) · 3.54 KB
/
auxiliaryEOC.lib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// =============================================================================
// ========== auxiliaryEOC.lib =================================================
// =============================================================================
//
// Auxiliary functions library for testing, analysis, inspection, and debugging.
//
// The environment prefix is "au".
//
// List of functions:
//
// dirac,
// inspect,
// octaves,
// octaves_cf,
// octaves_thirds,
// octaves_thirds_cf,
// step.
//
// Copyright (c) 2019-2020, Dario Sanfilippo <sanfilippo.dario at gmail dot com>
// All rights reserved.
declare name "Auxiliary Library";
declare author "Dario Sanfilippo";
declare copyright "Copyright (c) 2019-2020, Dario Sanfilippo <sanfilippo.dario
at gmail dot com>";
declare version "2.1.0";
declare license "GPLv2.0";
au = library("auxiliary.lib");
// au.dirac; -------------------------------------------------------------------
//
// Dirac impulse: full-amplitude, 1-sample impulse.
// y[n] = 1 if n = 0; 0 otherwise.
//
// 0 inputs.
//
// 1 outputs:
// y[n].
//
dirac = 1 - 1';
// -----------------------------------------------------------------------------
// au.inspect(i, lower, upper, x[n]); ------------------------------------------
//
// Signal inspector: it displays the value of a signal at block-size rate.
//
// 1 inputs:
// x[n].
//
// 1 outputs:
// x[n].
//
// 3 compile-time arguments:
// "i", integer identifier;
// "lower", lower display limit;
// "upper", upper display limit.
//
inspect(i, lower, upper) =
_ <: _ ,
vbargraph("sig_%i [style:numerical]", lower, upper) : attach;
// -----------------------------------------------------------------------------
// au.octaves(N); --------------------------------------------------------------
//
// It generates a list of N octaves lower-bound frequencies starting from
// the base 10 ^ (.1 * 12), which is approximately 15.85 Hz.
//
octaves(N) = par(i, N, 10 ^ (.1 * (12 + i * 3)));
// -----------------------------------------------------------------------------
// au.octaves_cf(N); -----------------------------------------------------------
//
// It generates a list of N octaves centre frequencies starting from
// the base 10 ^ (.1 * 12), which is approximately 15.85 Hz.
//
octaves_cf(N) = par(i, N, 1.4142135624 * 10 ^ (.1 * (12 + i * 3)));
// -----------------------------------------------------------------------------
// au.octaves_thirds(N); -------------------------------------------------------
//
// It generates a list of N one-third-octave lower-bound frequencies starting
// from the base 10 ^ (.1 * 12), which is approximately 15.85 Hz.
//
octaves_thirds(N) = par(i, N, 10 ^ (0.1 * (i + 12)));
// -----------------------------------------------------------------------------
// au.octaves_thirds_cf(N); ----------------------------------------------------
//
// It generates a list of N one-third-octave centre frequencies starting
// from the base 10 ^ (.1 * 12), which is approximately 15.85 Hz.
//
octaves_thirds_cf(N) = par(i, N, 10 ^ 0.05 * 10 ^ (0.1 * (i + 12)));
// -----------------------------------------------------------------------------
// au.step(M); -----------------------------------------------------------------
//
// Step function: full-amplitude, M-sample step.
// y[n] = 1 if 0 <= n < M; 0 otherwise.
//
// 0 inputs.
//
// 1 outputs:
// Step().
//
// 1 compile-time arguments:
// "M", step size in samples.
//
step(M) = 1 <: _ - (_ @ M);
// -----------------------------------------------------------------------------