Add patterns
This commit is contained in:
45
src/midi.py
45
src/midi.py
@@ -1,6 +1,5 @@
|
|||||||
import mido
|
import mido
|
||||||
import asyncio
|
import asyncio
|
||||||
import time
|
|
||||||
import networking # <--- This will now correctly import your module
|
import networking # <--- This will now correctly import your module
|
||||||
|
|
||||||
|
|
||||||
@@ -43,27 +42,55 @@ async def midi_to_websocket_listener(midi_port_index: int, websocket_uri: str):
|
|||||||
match msg.type:
|
match msg.type:
|
||||||
case 'note_on':
|
case 'note_on':
|
||||||
print(f" Note ON: Note={msg.note}, Velocity={msg.velocity}, Channel={msg.channel}")
|
print(f" Note ON: Note={msg.note}, Velocity={msg.velocity}, Channel={msg.channel}")
|
||||||
|
# Add pattern_name variable to update a GUI later if needed.
|
||||||
|
pattern_name = "Unknown"
|
||||||
|
|
||||||
match msg.note:
|
match msg.note:
|
||||||
case 32:
|
case 48: # Original Note 48 for 'pulse'
|
||||||
|
pattern_name = "pulse"
|
||||||
await ws_client.send_data({
|
await ws_client.send_data({
|
||||||
"names": ["1"],
|
"names": ["1"],
|
||||||
"settings": {
|
"settings": {
|
||||||
"pattern": "pulse",
|
"pattern": pattern_name,
|
||||||
"delay": delay,
|
"delay": delay,
|
||||||
"colors": ["#00ff00"],
|
"colors": ["#00ff00"],
|
||||||
"brightness": 100,
|
"brightness": 100,
|
||||||
"num_leds": 200,
|
"num_leds": 120, # Corrected to 120
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
case 33:
|
case 49: # Original Note 49 for 'theater_chase'
|
||||||
|
pattern_name = "theater_chase"
|
||||||
await ws_client.send_data({
|
await ws_client.send_data({
|
||||||
"names": ["2"],
|
"names": ["1"],
|
||||||
"settings": {
|
"settings": {
|
||||||
"pattern": "chase",
|
"pattern": pattern_name,
|
||||||
"speed": 10,
|
"delay": delay,
|
||||||
"color": "#00FFFF",
|
"colors": ["#00ff00"],
|
||||||
|
"brightness": 100,
|
||||||
|
"num_leds": 120,
|
||||||
|
"on_width": 10,
|
||||||
|
"off_width": 10,
|
||||||
|
"n1": 0,
|
||||||
|
"n2": 100
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
case 50: # Original Note 50 for 'alternating'
|
||||||
|
pattern_name = "alternating"
|
||||||
|
print("Triggering Alternating Pattern")
|
||||||
|
await ws_client.send_data({
|
||||||
|
"names": ["1"],
|
||||||
|
"settings": {
|
||||||
|
"pattern": pattern_name,
|
||||||
|
"delay": delay,
|
||||||
|
"colors": ["#00ff00", "#0000ff"],
|
||||||
|
"brightness": 100,
|
||||||
|
"num_leds": 120,
|
||||||
|
"n1": 10,
|
||||||
|
"n2": 10
|
||||||
|
}
|
||||||
|
})
|
||||||
|
# Potentially add logic here to use pattern_name if a GUI update is desired in the future
|
||||||
|
|
||||||
case 'control_change':
|
case 'control_change':
|
||||||
match msg.control:
|
match msg.control:
|
||||||
case 36:
|
case 36:
|
||||||
|
Reference in New Issue
Block a user