Skip to content

Commit

Permalink
Start decoding of Program Change messages
Browse files Browse the repository at this point in the history
General MIDI groups and names
  • Loading branch information
rdoursenaud committed Dec 31, 2024
1 parent 1620dbd commit 631f47d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
52 changes: 43 additions & 9 deletions src/midiexplorer/gui/windows/mon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ def create() -> None:
# ----------------------------
for indicator in get_supported_indicators():
dpg.add_float_value(tag=f'{indicator}_active_until', default_value=0) # seconds
# ----------------
# Program decoding
# ----------------
dpg.add_string_value(tag='pc_num')
dpg.add_string_value(tag='pc_group_name')
dpg.add_string_value(tag='pc_name')
# ---------------
# SysEx decoding
# ---------------
Expand Down Expand Up @@ -533,7 +539,7 @@ def create() -> None:
# ------
# Notes
# ------
with dpg.collapsing_header(label="Notes", default_open=True):
with dpg.collapsing_header(label="Notes", default_open=not DEBUG):
dpg.add_child_window(tag='mon_notes_container', height=180, border=False)

# TODO: Staff?
Expand Down Expand Up @@ -587,10 +593,15 @@ def create() -> None:
else:
bxpos += width + margin

###
# TODO: Polyphonic Key Pressure (Aftertouch)
###
# Value timegraph

# ------------
# Controllers
# ------------
with dpg.collapsing_header(label="Controllers", default_open=True):
with dpg.collapsing_header(label="Controllers", default_open=not DEBUG):
dpg.add_child_window(tag='mon_controllers_container', height=400, border=False)

with dpg.table(tag='mon_controllers', parent='mon_controllers_container', header_row=False,
Expand Down Expand Up @@ -645,15 +656,38 @@ def create() -> None:
###
# Value timegraph

# --------------
# Program change
# --------------
###
# TODO: Polyphonic Key Pressure (Aftertouch)
# TODO: Bank Select?
# Value timegraph
###
# Value timegraph
mon_prog_height=70
if DEBUG:
mon_prog_height=120

###
# TODO: Program change status? (+ Bank Select?)
###
# Value timegraph
with dpg.collapsing_header(label="Program", default_open=True):
with dpg.child_window(tag='mon_program_container', height=mon_prog_height, border=False):
with dpg.group(horizontal=True):
dpg.add_text("Num")
dpg.add_input_text(source='pc_num', readonly=True, width=50) # 0-127
if DEBUG:
with dpg.group(horizontal=True):
dpg.add_text("Resource")
# TODO: Autoset on receiving Defined Universal Sysex non real time
dpg.add_combo(["GM", "GM2", "GS", "XG"], default_value="GM")
# TODO: Add logo
with dpg.group(horizontal=True): # TODO: Not GM modes only
dpg.add_text("Bank")
dpg.add_input_text(source='pc_bank_num', readonly=True, width=50) # 0-16383
dpg.add_input_text(source='pc_bank_name', readonly=True, width=250)
with dpg.group(horizontal=True): # TODO: GM mode only
dpg.add_text("Group")
dpg.add_input_text(source='pc_group_name', readonly=True, width=250)
with dpg.group(horizontal=True):
dpg.add_text("Name")
dpg.add_input_text(source='pc_name', readonly=True, width=250)

###
# TODO: Pitch bend change
Expand Down Expand Up @@ -687,7 +721,7 @@ def create() -> None:
# -----------------
# System Exclusive
# -----------------
with dpg.collapsing_header(label="System Exclusive", default_open=True):
with dpg.collapsing_header(label="System Exclusive", default_open=not DEBUG):

with dpg.child_window(tag='mon_sysex_container', height=120, border=False):
with dpg.group():
Expand Down
3 changes: 3 additions & 0 deletions src/midiexplorer/gui/windows/mon/blink.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def get_supported_indicators() -> list:

def get_supported_decoders() -> list:
decoders = [
'pc_num',
'pc_group_name',
'pc_name',
'syx_id_group',
'syx_id_region',
'syx_id_name',
Expand Down
11 changes: 6 additions & 5 deletions src/midiexplorer/gui/windows/mon/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
Monitor data management.
"""

import midi_const
import mido
from dearpygui import dearpygui as dpg
from midi_const import NOTE_OFF_VELOCITY
Expand Down Expand Up @@ -89,8 +89,11 @@ def update_gui_monitor(data: mido.Message, static: bool = False) -> None:
elif 'control_change' == data.type:
cc(data.control, data.value, static)
elif 'program_change' == data.type:
# TODO: Optionally decode General MIDI names.
pass
dpg.set_value('pc_num', data.program)
# Decode General MIDI names.
dpg.set_value('pc_group_name', midi_const.GENERAL_MIDI_SOUND_SET_GROUPINGS[data.program])
dpg.set_value('pc_name', midi_const.GENERAL_MIDI_SOUND_SET[data.program])
# TODO: Optionally decode other modes names.
elif 'aftertouch' == data.type:
# TODO: display
pass
Expand All @@ -109,5 +112,3 @@ def update_gui_monitor(data: mido.Message, static: bool = False) -> None:
elif 'song_select' == data.type:
# TODO: display
pass


0 comments on commit 631f47d

Please sign in to comment.