Commit 8b92a8ab authored by Ali Allaoui's avatar Ali Allaoui

add cli

parent 5ec6ec21
import argparse
from pyoTools.mapping import Mapping
from pyo import *
import jack
def mapping():
parser = argparse.ArgumentParser(description="Launch pyo server for controlling miPhysics")
parser.add_argument('mapping',
help="Path of a json file describing the mapping")
parser.add_argument('--values', '-v')
args = parser.parse_args()
mapping = Mapping(args.mapping, args.values)
s = Server(audio='jack', nchnls=mapping.nb_input_channels, ichnls=2)
jclient = jack.Client("mapping")
pm_list_devices()
s.setMidiInputDevice(99) # Open all input devices.
s.boot()
mapping.load()
# for pyout in jclient.get_ports('pyo:output_*'):
# pyout.disconnect()
jclient.disconnect('pyo:output_1', 'system:playback_1')
jclient.disconnect('pyo:output_2', 'system:playback_2')
s.gui(locals())
\ No newline at end of file
import datetime
import shutil
from pyo import *
import json
......@@ -80,10 +82,10 @@ class Mapping:
if "controls" in m.keys():
modules_parameters[module][param] = dict()
for c in m["controls"]:
v = getattr(controls[p]["pyoo"], c["parameter"])
v = getattr(self.controls[p]["pyoo"], c["parameter"])
modules_parameters[module][param][c["parameter"]] = v.get()
else:
modules_parameters[module][param] = controls[p]["portamento"].get()
modules_parameters[module][param] = self.controls[p]["portamento"].get()
lines = []
for module in modules_parameters.keys():
......@@ -96,3 +98,24 @@ class Mapping:
# now = datetime.now() # current date and time
# params_df.to_csv("params" + now.strftime("%Y%m%d%H%M") + ".csv")
return modules_parameters
def save_parameters(self):
now = datetime.now() # current date and time
with open("params" + now.strftime("%Y%m%d%H%M") + ".json", 'w') as f:
json.dump(self.export_values(), f)
def print_parameters(self):
vals = json.dumps(self.export_values(),indent=4,sort_keys=True)
nb_lines = len(vals.split("\n"))
for l in range(nb_lines):
print("delete")
_delete_last_line()
print(vals, end="\r")
def _delete_last_line():
sys.stdout.write('\b\b\r')
sys.stdout.write(' ' * shutil.get_terminal_size((80, 20)).columns)
sys.stdout.write('\b\r')
sys.stdout.flush()
\ No newline at end of file
......@@ -2,7 +2,6 @@ import os
from setuptools import setup, find_packages
setup(
name="pyotools",
version=0.1,
......@@ -17,7 +16,7 @@ setup(
install_requires=["pyo>=1.0"],
entry_points={
'console_scripts': [
],
},
'miphymap=pyoTools.cli_mapping:mapping'
]
}
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment