Skip to content

Commit 65da1d1

Browse files
authored
Add Kompari-inspired contrib script (#290)
* Initial commit of the new Kompari module * Typo * Output analog signals on CV4-6 instead of just CV6
1 parent 15ad7ae commit 65da1d1

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed

software/contrib/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ The division of the master clock that each LFO runs at, as well as each of their
6161
<i>Author: [roryjamesallen](https://github.com/roryjamesallen)</i>
6262
<br><i>Labels: LFO</i>
6363

64+
### Kompari \[ [documentation](/software/contrib/kompari.md) | [script](/software/contrib/kompari.py) \]
65+
66+
Compares `AIN` to `K1` and `K2`, outputting 5V digital signals on `CV1`-`CV5`, and an analogue output signal based on
67+
comparing all 3 sources.
68+
69+
<i>Author: [chrisib](https://github.com/chrisib)</i>
70+
<br><i>Labels: logic, gates, binary operators</i>
71+
6472
### Logic \[ [documentation](/software/contrib/logic.md) | [script](/software/contrib/logic.py) \]
6573

6674
Treats both inputs as digital on/off signals and outputs the results of binary AND, OR, XOR, NAND, NOR, and XNOR operations on outputs 1-6.

software/contrib/kompari.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Kompari
2+
3+
This program is a EuriPi re-imagining of Allen Synthesis' Kompari module.
4+
5+
## Inputs & Outputs
6+
7+
`AIN` is used for the input signal. `K1` and `K2` define the lower & upper bounds for comparisons based on
8+
the knob position.
9+
10+
Outputs:
11+
- `CV1` +5V if `K1` < `AIN`, otherwise 0
12+
- `CV2` +5V if `AIN` < `K2`, otherwise 0
13+
- `CV3` +5V if `K1` < `AIN` < `K2`, otherwise 0
14+
- `CV4` `max(K1, AIN)`
15+
- `CV5` `min(AIN, K2)`
16+
- `CV6` `max(K1, min(AIN, K2))`

software/contrib/kompari.py

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python3
2+
"""A EuroPi re-imagining of the Kompari module
3+
4+
Input A is provided in AIN. K1 and K2 provide the lower and upper bounds
5+
6+
Outputs:
7+
- CV1: +5V if K1 < AIN, otherwise 0
8+
- CV2: +5V if AIN < K2, otherwise 0
9+
- CV3: +5V if K1 < AIN < K2, otherwise 0
10+
- CV4: max( K1, AIN )
11+
- CV5: min( AIN, K2 )
12+
- CV6: max( K1, min( AIN, K2 ) ) )
13+
14+
B1, B2, and DIN are not used
15+
16+
@author Chris Iverach-Brereton
17+
@year 2023
18+
"""
19+
20+
from europi import *
21+
from europi_script import EuroPiScript
22+
23+
class Kompari(EuroPiScript):
24+
"""The main Kompari script. See module comment for usage
25+
"""
26+
HIGH_VOLTAGE = 5.0
27+
LOW_VOLTAGE = 0.0
28+
29+
def __init__(self):
30+
super().__init__()
31+
32+
@classmethod
33+
def display_name(cls):
34+
return "Kompari"
35+
36+
def main(self):
37+
"""Run the main loop
38+
"""
39+
while True:
40+
lower_bound = k1.percent()
41+
upper_bound = k2.percent()
42+
x = ain.percent()
43+
44+
if lower_bound < x:
45+
cv1.voltage(self.HIGH_VOLTAGE)
46+
else:
47+
cv1.voltage(self.LOW_VOLTAGE)
48+
49+
if x < upper_bound:
50+
cv2.voltage(self.HIGH_VOLTAGE)
51+
else:
52+
cv2.voltage(self.LOW_VOLTAGE)
53+
54+
if lower_bound < x and x < upper_bound:
55+
cv3.voltage(self.HIGH_VOLTAGE)
56+
else:
57+
cv3.voltage(self.LOW_VOLTAGE)
58+
59+
cv4.voltage(max(lower_bound, x) * MAX_OUTPUT_VOLTAGE)
60+
cv5.voltage(min(x, upper_bound) * MAX_OUTPUT_VOLTAGE)
61+
cv6.voltage(max(lower_bound, min(x, upper_bound)) * MAX_OUTPUT_VOLTAGE)
62+
63+
oled.fill(0)
64+
oled.centre_text(f"{lower_bound:0.1f} {x:0.1f} {upper_bound:0.1f}")
65+
oled.show()
66+
67+
if __name__ == "__main__":
68+
Kompari().main()

software/contrib/menu.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"contrib.harmonic_lfos.HarmonicLFOs",
2727
"contrib.hello_world.HelloWorld",
2828
"contrib.knob_playground.KnobPlayground",
29+
"contrib.kompari.Kompari",
2930
"contrib.logic.Logic",
3031
"contrib.master_clock.MasterClock",
3132
"contrib.noddy_holder.NoddyHolder",

0 commit comments

Comments
 (0)