You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,6 +83,29 @@ Ok, so how to get started?
83
83
*Note*: When adjusting parameters, the status LEDs will briefly change their role from indicating signal and compression levels to a very rough indication of the parameter that was changed. No LEDs active
84
84
signifies a very low value, with LEDs lighting up from D12 to D10 in that order for higher values. If either the low or high end of the scale is reached D13 will light up in addition.
85
85
86
+
## Background: Inside the ATMega black box
87
+
88
+
The cuircit is simple, you now know how to adjust parameters, but what exactly is happening in the code?
89
+
90
+
- Sampling windows
91
+
- Moving averages
92
+
- The actual volume adjustment is then calculated as follows: If the current signal is *n*dB above the threshold level, divide *n* by the *ratio*, and adjust the signal level to an output of *threshold* + *n*/*ratio* dB.
93
+
Now, since decibel is a logarithmic scale, that translates to the following pseudo-code (*current* is the current output voltage level, *threshold* is the threshold voltage level):
Now the ATMega is not exactly fast at floating point math, let alone at calculating logs. The above is just prohibitively slow. Fortunately it can be optimized:
Now the ATMega can handle that calculation just fine. As a last step, we simply set the duty-cycle of Pin 3 to be 255 * target_level / current_level.
108
+
86
109
## More to come
87
110
88
111
... but writing this up is more work than it may seem. If you find this useful, consider donating a bread crumb or two via Paypal: thomas.friedrichsmeier@gmx.de
0 commit comments