Last active
September 5, 2023 15:45
-
-
Save jarmitage/14b967a94fd8693bb8f07a64595eb35d to your computer and use it in GitHub Desktop.
Cirklon JSON MIDI mapping file to Tidal MIDI CC mapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import argparse | |
def load_json(name): | |
with open(name) as f: | |
data = json.load(f) | |
return data | |
def make_tidal_map(cc_dict, prefix): | |
tidal_map = [] | |
for num, name in cc_dict.items(): | |
line = f"{prefix}{name.lower()} p = ccv p # ccn {num}" | |
tidal_map.append(line) | |
return tidal_map | |
def save_tidal_midi_map(lines, filename): | |
with open(filename, 'w') as f: | |
f.write('let ') | |
for line in lines: | |
f.write(line + '\n ') | |
def json_to_tidal(synth_name, prefix): | |
midi_json = load_json(synth_name+'.json') | |
midi_ccs = midi_json['instrument_data'][synth_name.upper()]['CC_defs'] | |
midi_ccs = {int(key.split('_')[1]): value['label'] for key, value in midi_ccs.items()} | |
tidal_map = make_tidal_map(midi_ccs, prefix) | |
save_tidal_midi_map(tidal_map, synth_name+'.hs') | |
def main(): | |
parser = argparse.ArgumentParser(description='Convert cirklon midi map to tidal midi map') | |
parser.add_argument('synth_name', help='name of synth') | |
parser.add_argument('prefix', help='prefix for tidal midi map') | |
args = parser.parse_args() | |
print(args) | |
json_to_tidal(args.synth_name, args.prefix) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment