Skip to content

Commit

Permalink
v0.3.0: Added configuration persistence using dill.
Browse files Browse the repository at this point in the history
  • Loading branch information
euwbah committed Jul 9, 2021
1 parent 56446e2 commit bc3491a
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/microtonal-seaboard.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### v0.3.0

- Added config persistence with the `save` command.
- Fix minor text error when configuring splits
- Splits are fully tested and working with Pianoteq's multi-channel mapping feature.

### v0.2.2

- Fixed noticeable delay between note on and pitch bend retuning.
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ all active output channels simultaneously.

### Range splits: Get more range/keyboard splits in MIDI mode

MIDI only has 127 notes available, that's just 4 octaves of 31 edo
and a bit more.
MIDI only has 127 notes available - when using large EDOs, the effective
range of the VST quickly becomes very limited.

However, with this mapper, the seaboard is now able to output MIDI
notes spanning a much greater range.
notes across different MIDI channels to achieve a larger range using
multiple VST instances or using a VST's internal multi-channel mapping
ability.

To get more range out of Pianoteq/Kontakt/microtuning synths,
you can open multiple instances of them and set them at different
Expand Down
Binary file added config.dill
Binary file not shown.
47 changes: 47 additions & 0 deletions configs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os
from enum import Enum

import dill

from mapping import Mapping
from split import SplitData

Expand All @@ -20,3 +23,47 @@ class CONFIGS:
PITCH_BEND_RANGE = 24
MAPPING: Mapping = None
TOGGLE_SUSTAIN = False


def read_configs() -> bool:
"""
Read saved CONFIG state.
:return: True if successfully read a config file from 'config.dill'
"""
if not os.path.isfile('config.dill'):
return False

print('loading saved configurations from config.dill')

try:
with open('config.dill', 'rb') as f:
c = dill.load(f)
CONFIGS.MPE_MODE = c['MPE_MODE']
CONFIGS.SLIDE_MODE = c['SLIDE_MODE']
CONFIGS.SLIDE_FIXED_N = c['SLIDE_FIXED_N']
CONFIGS.SPLITS = c['SPLITS']
CONFIGS.PITCH_BEND_RANGE = c['PITCH_BEND_RANGE']
CONFIGS.MAPPING = c['MAPPING']
CONFIGS.TOGGLE_SUSTAIN = c['TOGGLE_SUSTAIN']

except Exception:
print('failed to load saved configurations. Delete config.dill.')
return False

return True


def save_configs():
print('saving settings into config.dill')

with open('config.dill', 'wb') as f:
c = {
'MPE_MODE': CONFIGS.MPE_MODE,
'SLIDE_MODE': CONFIGS.SLIDE_MODE,
'SLIDE_FIXED_N': CONFIGS.SLIDE_FIXED_N,
'SPLITS': CONFIGS.SPLITS,
'PITCH_BEND_RANGE': CONFIGS.PITCH_BEND_RANGE,
'MAPPING': CONFIGS.MAPPING,
'TOGGLE_SUSTAIN': CONFIGS.TOGGLE_SUSTAIN
}
dill.dump(c, f)
32 changes: 26 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from rtmidi import MidiIn, MidiOut
from rtmidi.midiutil import open_midiinput, open_midioutput

import configs
import convert
from configs import SlideMode, CONFIGS
from handler import MidiInputHandler
Expand Down Expand Up @@ -54,7 +55,7 @@ def select_splits():
while True:
i = input(f'enter midi output offset for split range channel {ch + 1} '
f'(range {convert.midinum_to_12edo_name(prev_split_pos)} - '
f'{convert.midinum_to_12edo_name(s - 1)})')
f'{convert.midinum_to_12edo_name(s - 1)}): ')

try:
offset = int(i)
Expand Down Expand Up @@ -108,6 +109,7 @@ def select_mapping(search_default=False):

root.withdraw()


def select_pitch_bend_range():
while True:
try:
Expand All @@ -125,10 +127,22 @@ def select_pitch_bend_range():
pass


def intable(s):
"""Check if a string can be converted to an int"""
try:
int(s)
return True
except ValueError:
return False


if __name__ == '__main__':
print('microtonal seaboard retuner v0.2.2')
print('microtonal seaboard retuner v0.3.0')

select_mapping(search_default=True)
has_read_configs = configs.read_configs()

if not has_read_configs:
select_mapping(search_default=True)

print('')
print('MIDI IN/OUT DEVICE SELECTION')
Expand All @@ -140,11 +154,14 @@ def select_pitch_bend_range():
print('Select the virtual MIDI output port that gets sent to the DAW/VST/Program:')
virtual_port: MidiOut = open_midioutput()[0]

print('')
select_pitch_bend_range()
if not has_read_configs:
print('')
select_pitch_bend_range()

print('')
print('Starting microtonal message forwarding in MPE mode...')

print(f'Starting microtonal message forwarding in '
f'{"MPE" if CONFIGS.MPE_MODE else "MIDI"} mode...')

seaboard.set_callback(MidiInputHandler(virtual_port))

Expand All @@ -162,6 +179,7 @@ def select_pitch_bend_range():
map select new .sbmap file
pb change pitch bend amount
sus toggles sustain pedal polarity
save saves all current settings
exit exit the program""")

while True:
Expand All @@ -172,6 +190,8 @@ def select_pitch_bend_range():
del virtual_port
del seaboard
exit(0)
if s == 'save':
configs.save_configs()
elif s == 'mpe':
print('MPE mode active')
CONFIGS.MPE_MODE = True
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ altgraph==0.17
future==0.18.2
pefile==2021.5.24
pyinstaller==4.3
pyinstaller-hooks-contrib==2021.1
pyinstaller-hooks-contrib==2021.2
python-rtmidi==1.4.9
pywin32-ctypes==0.2.0
dill==0.3.4

0 comments on commit bc3491a

Please sign in to comment.