Skip to content

Commit

Permalink
plugset + error handling, fixes + it/ableton vibrato/lfo + filter
Browse files Browse the repository at this point in the history
  • Loading branch information
SatyrDiamond committed Sep 23, 2024
1 parent 9e20097 commit 90701dc
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 37 deletions.
4 changes: 2 additions & 2 deletions dawvert_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
parser = argparse.ArgumentParser()
parser.add_argument("-i", default=None)
parser.add_argument("-it", default=None)
parser.add_argument("-ips", default=None)
parser.add_argument("-o", default=None)
parser.add_argument("-ot", default=None)
parser.add_argument("--soundfont", default=None)
parser.add_argument("--songnum", default=1)
parser.add_argument("--extrafile", default=None)
parser.add_argument("--plugset-input", default=None)
parser.add_argument("--mi2m--output-unused-nle", action='store_true')
parser.add_argument("--nonfree-plugins", action='store_true')
parser.add_argument("--shareware-plugins", action='store_true')
Expand Down Expand Up @@ -63,7 +63,7 @@
if args.songnum != None: core.config_data.songnum = int(args.songnum)
if args.extrafile != None: core.config_data.path_extrafile = args.extrafile
if args.mi2m__output_unused_nle == True: core.config_data.flags_convproj.append('mi2m-output-unused-nle')
if args.plugset_input: pluginset = args.plugset_input
if args.ips: pluginset = args.ips
if args.nonfree_plugins == True: core.config_data.extplug_cat.append('nonfree')
if args.shareware_plugins == True: core.config_data.extplug_cat.append('shareware')
if args.old_plugins == True: core.config_data.extplug_cat.append('old')
Expand Down
5 changes: 3 additions & 2 deletions objects/convproj/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,9 @@ def copy_to_self(self, other_color):
self.priority = other_color.priority

def merge(self, other_color):
if other_color and not self: self.copy_to_self(other_color)
elif other_color.priority > self.priority and other_color: self.copy_to_self(other_color)
if other_color:
if not self: self.copy_to_self(other_color)
elif other_color.priority > self.priority and other_color: self.copy_to_self(other_color)

class cvpj_visual_ui:
def __init__(self):
Expand Down
10 changes: 7 additions & 3 deletions objects/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from plugins import base as dv_plugins
from functions_plugin_ext import plugin_vst2

#from experiments_plugin_input import base as experiments_plugin_input
from functions import song_compat
from functions import plug_conv

Expand Down Expand Up @@ -170,8 +169,13 @@ def output_set(self, pluginname): return self.currentplug_output.set(pluginname)
def parse_input(self, in_file, dv_config):
self.convproj_obj = convproj.cvpj_project()
dv_config.searchpaths.append(os.path.dirname(in_file))
plug_obj = self.currentplug_input.selected_plugin.plug_obj
plug_obj.parse(self.convproj_obj, in_file, dv_config)
selected_plugin = self.currentplug_input.selected_plugin
plug_obj = selected_plugin.plug_obj
if selected_plugin.usable:
plug_obj.parse(self.convproj_obj, in_file, dv_config)
else:
logger_core.error(self.currentplug_input.selected_shortname+' is not usable: '+selected_plugin.usable_meg)
exit()

def convert_type_output(self, dv_config):
global in_dawinfo
Expand Down
1 change: 1 addition & 0 deletions objects/notelist_splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def process(self):
for x in xtramath.gen_float_blocks(t[1]-t[0],t[2]):
curpos += x
p_splitts[curpos] = t[2]
if int(curpos) not in p_splitts: p_splitts[int(curpos)] = t[2]
if curpos not in self.splitpoints: self.splitpoints.append(curpos)

self.splitpoints = np.array(self.splitpoints, dtype=np.uint32)
Expand Down
10 changes: 5 additions & 5 deletions objects/tracker/pat_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ def cell_fx_s3m(self, row_num, fx_type, fx_value):
if fx_type == 4: self.cell_param(row_num, 'vol_slide', getfineval(fx_value))
if fx_type == 5:
if 240 <= fx_value: self.cell_param(row_num, 'fine_slide_down', (fx_value-240)/8)
if 224 <= fx_value <= 239: self.cell_param(row_num, 'fine_slide_down', (fx_value-224)/16)
else: self.cell_param(row_num, 'slide_down', fx_value)
elif 224 <= fx_value <= 239: self.cell_param(row_num, 'fine_slide_down', (fx_value-224)/16)
else: self.cell_param(row_num, 'std_slide_down', fx_value)
if fx_type == 6:
if 240 <= fx_value: self.cell_param(row_num, 'fine_slide_up', (fx_value-240)/8)
if 224 <= fx_value <= 239: self.cell_param(row_num, 'fine_slide_up', (fx_value-224)/16)
else: self.cell_param(row_num, 'slide_up', fx_value)
if fx_type == 7: self.cell_param(row_num, 'slide_to_note', fx_value)
elif 224 <= fx_value <= 239: self.cell_param(row_num, 'fine_slide_up', (fx_value-224)/16)
else: self.cell_param(row_num, 'std_slide_up', fx_value)
if fx_type == 7: self.cell_param(row_num, 'std_slide_to_note', fx_value)
if fx_type == 8: self.cell_param(row_num, 'vibrato', splitparams(fx_value, 'speed', 'depth'))
if fx_type == 9: self.cell_param(row_num, 'tremor', splitparams(fx_value, 'ontime', 'offtime'))
if fx_type == 11: self.cell_param(row_num, 'vol_slide', getfineval(fx_value))
Expand Down
10 changes: 8 additions & 2 deletions plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def __init__(self):
self.plug_obj = None
self.supported_autodetect = False
self.priority = 100
self.usable = True
self.usable_meg = ''

def propproc(self):
if self.type in ['input','output']:
Expand Down Expand Up @@ -228,11 +230,15 @@ def __init_subclass__(plcv_obj, **kwargs):
try:
if plugintype not in base.loaded_plugins: base.loaded_plugins[plugintype] = {}
dvplug_obj = dv_plugin()
if 'get_shortname' in dir(in_object): dvplug_obj.shortname = in_object.get_shortname()
if 'get_shortname' in dir(in_object):
dvplug_obj.shortname = in_object.get_shortname()
else:
dvplug_obj.shortname = 'noname_'+str(base.noname_num)
base.noname_num += 1

if 'usable' in dir(in_object):
dvplug_obj.usable, dvplug_obj.usable_meg = in_object.usable()

if dvplug_obj.shortname not in base.loaded_plugins:
dvplug_obj.type = plugintype
dvplug_obj.plug_obj = in_object
Expand All @@ -251,7 +257,7 @@ def create_selector(plug_type):
return selector_obj

def get_list(plug_type):
return list(base.loaded_plugins['input']) if 'input' in base.loaded_plugins else []
return list(base.loaded_plugins[plug_type]) if plug_type in base.loaded_plugins else []

def load_plugindir(plug_type, plugsetname):
plugfolder = plug_type + ('_'+plugsetname if plugsetname else '')
Expand Down
3 changes: 2 additions & 1 deletion plugins/input/m_tracker_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ def env_to_cvpj(it_env, plugin_obj, t_type, i_div):
def sample_vibrato(it_samp, plugin_obj):
vibrato_on, vibrato_sweep, vibrato_wave, vibrato_speed, vibrato_depth = it_samp.vibrato_lfo()
if vibrato_on:
vibrato_speed = vibrato_speed
lfo_obj = plugin_obj.lfo_add('pitch')
lfo_obj.attack = vibrato_sweep
lfo_obj.prop.shape = vibrato_wave
lfo_obj.time.set_seconds(vibrato_speed)
lfo_obj.time.set_hz(vibrato_speed/2)
lfo_obj.amount = vibrato_depth

def get_name(inst_name, dosfilename):
Expand Down
12 changes: 9 additions & 3 deletions plugins/input_ai/r_basicpitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later

import plugins
import sys
import importlib.util

class input_ex_basic_pitch(plugins.base):
def __init__(self): pass
Expand All @@ -10,14 +12,18 @@ def get_shortname(self): return 'basic_pitch'
def get_name(self): return 'Basic Pitch'
def get_prop(self, in_dict):
in_dict['track_nopl'] = True
def usable(self):
usable = importlib.util.find_spec('basic_pitch')
usable_meg = 'Basic Pitch is not installed. do "pip install basic_pitch"' if not usable else ''
return usable, usable_meg
def parse(self, convproj_obj, input_file, dv_config):
from basic_pitch.inference import predict
from basic_pitch import ICASSP_2022_MODEL_PATH

convproj_obj.type = 'r'
convproj_obj.set_timings(1, False)
convproj_obj.params.add('bpm', 120, 'float')

from basic_pitch.inference import predict
from basic_pitch import ICASSP_2022_MODEL_PATH

model_output, midi_data, note_events = predict(input_file)

track_obj = convproj_obj.add_track('basicpitch', 'instrument', 1, False)
Expand Down
93 changes: 78 additions & 15 deletions plugins/output/ableton.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
DEBUG_IGNORE_FX = False
DEBUG_IGNORE_PLACEMENTS = False
NOCOLORNUM = 13
LFO_SHAPE = {
'sine': 0,
'square': 1,
'triangle': 2,
'saw': 3,
'saw_down': 4,
'random': 5,
}

def fixtxt(inp):
return inp.encode("ascii", "replace").decode(encoding="utf-8", errors="ignore")
Expand Down Expand Up @@ -390,15 +398,15 @@ def add_plugindevice_native(als_track, convproj_obj, plugin_obj, pluginid):
#
# als_device = None
#
# if plugin_obj.check_match('universal', 'arpeggiator'):
# fx_on, fx_wet = plugin_obj.fxdata_get()
# als_device = als_track.DeviceChain.add_device('MidiArpeggiator')
# #do_param(convproj_obj, plugin_obj.params, 'enabled', 1, 'bool', ['slot', pluginid, 'enabled'], als_device.On, als_track.AutomationEnvelopes)
# als_device.On.Manual = fx_on
# parampaths = {}
# timing_obj = plugin_obj.timing_get('main')
# #print(timing_obj.type)
# als_device.params.import_keys(parampaths)
# #if plugin_obj.check_match('universal', 'arpeggiator'):
# # fx_on, fx_wet = plugin_obj.fxdata_get()
# # als_device = als_track.DeviceChain.add_device('MidiArpeggiator')
# # #do_param(convproj_obj, plugin_obj.params, 'enabled', 1, 'bool', ['slot', pluginid, 'enabled'], als_device.On, als_track.AutomationEnvelopes)
# # als_device.On.Manual = fx_on
# # parampaths = {}
# # timing_obj = plugin_obj.timing_get('main')
# # #print(timing_obj.type)
# # als_device.params.import_keys(parampaths)

def do_effects(convproj_obj, als_track, fxslots_audio):
if not DEBUG_IGNORE_FX:
Expand Down Expand Up @@ -573,6 +581,7 @@ def add_track(convproj_obj, project_obj, trackid, track_obj):
middlenote += plugin_obj.datavals_global.get('middlenotefix', 0)

#print(str(plugin_obj.type), plugin_obj.datavals_global.get('name', ''))
is_sampler = False

if plugin_obj.check_wildmatch('native-ableton', None):
if middlenote != 0:
Expand All @@ -593,6 +602,7 @@ def add_track(convproj_obj, project_obj, trackid, track_obj):
add_plugindevice_vst3(als_track, convproj_obj, plugin_obj, track_obj.inst_pluginid)

if plugin_obj.check_match('sampler', 'multi'):
is_sampler = True
if middlenote != 0:
als_device_pitch = als_track.DeviceChain.add_device('MidiPitcher')
pitchparamkeys['Pitch'] = ableton_parampart.as_param('Pitch', 'int', -middlenote)
Expand Down Expand Up @@ -628,9 +638,8 @@ def add_track(convproj_obj, project_obj, trackid, track_obj):

paramkeys['Globals/NumVoices'] = ableton_parampart.as_value('NumVoices', 14)

als_device.params.import_keys(paramkeys)

if plugin_obj.check_match('sampler', 'single'):
is_sampler = True

if middlenote != 0:
als_device_pitch = als_track.DeviceChain.add_device('MidiPitcher')
Expand Down Expand Up @@ -681,8 +690,6 @@ def add_track(convproj_obj, project_obj, trackid, track_obj):

paramkeys['Globals/NumVoices'] = ableton_parampart.as_value('NumVoices', 14)

als_device.params.import_keys(paramkeys)

else:
als_device = als_track.DeviceChain.add_device('OriginalSimpler')
spd = paramkeys['Player/MultiSampleMap/SampleParts'] = ableton_parampart.as_sampleparts('SampleParts')
Expand All @@ -697,9 +704,8 @@ def add_track(convproj_obj, project_obj, trackid, track_obj):
paramkeys['Pitch/TransposeKey'] = ableton_parampart.as_param('TransposeKey', 'float', round(pitchin))
paramkeys['Pitch/TransposeFine'] = ableton_parampart.as_param('TransposeFine', 'float', (pitchin-round(pitchin))*100)

als_device.params.import_keys(paramkeys)

if plugin_obj.check_match('sampler', 'slicer'):
is_sampler = True
samplepart_obj = plugin_obj.samplepart_get('sample')

als_device_pitch = als_track.DeviceChain.add_device('MidiPitcher')
Expand All @@ -715,6 +721,63 @@ def add_track(convproj_obj, project_obj, trackid, track_obj):
paramkeys['Globals/PlaybackMode'] = ableton_parampart.as_value('PlaybackMode', 2)
paramkeys['SimplerSlicing/PlaybackMode'] = ableton_parampart.as_value('PlaybackMode', 1)
paramkeys['VolumeAndPan/OneShotEnvelope/SustainMode'] = ableton_parampart.as_param('SustainMode', 'int', int(samplepart_obj.trigger != 'oneshot'))

if is_sampler:
filter_obj = plugin_obj.filter

paramkeys['Filter/IsOn'] = ableton_parampart.as_param('IsOn', 'bool', filter_obj.on)
paramkeys['Filter/Slot/Value'] = ableton_parampart.as_numset('SimplerFilter')
alsfilter = paramkeys['Filter/Slot/Value']['0/SimplerFilter'] = {}
alsfilter['Freq'] = ableton_parampart.as_param('Freq', 'float', filter_obj.freq)
alsfilter['Res'] = ableton_parampart.as_param('Res', 'float', (filter_obj.q**0.7)/3.5)
alsfilter['Slope'] = ableton_parampart.as_param('Slope', 'bool', filter_obj.slope>18)
alsfilter['ModByPitch'] = ableton_parampart.as_param('ModByPitch', 'float', 0)

if filter_obj.type.type == 'low_pass':
alsfilter['Type'] = ableton_parampart.as_param('Type', 'int', 0)

if filter_obj.type.type == 'high_pass':
alsfilter['Type'] = ableton_parampart.as_param('Type', 'int', 1)

if filter_obj.type.type == 'band_pass':
alsfilter['Type'] = ableton_parampart.as_param('Type', 'int', 2)

if filter_obj.type.type == 'notch':
alsfilter['Type'] = ableton_parampart.as_param('Type', 'int', 3)

if als_device.name == 'MultiSampler':
lfo_pan_obj = plugin_obj.lfo_get('pan')
paramkeys['Lfo/IsOn'] = ableton_parampart.as_param('IsOn', 'bool', True)
paramkeys['VolumeAndPan/PanoramaLfoAmount'] = ableton_parampart.as_param('PanoramaLfoAmount', 'float', abs(lfo_pan_obj.amount))
paramkeys['Lfo/Slot/Value'] = ableton_parampart.as_numset('SimplerLfo')
alslfo = paramkeys['Lfo/Slot/Value']['0/SimplerLfo'] = {}
if lfo_pan_obj.prop.shape in LFO_SHAPE:
alslfo['Type'] = ableton_parampart.as_param('Type', 'int', LFO_SHAPE[lfo_pan_obj.prop.shape])
alslfo['Frequency'] = ableton_parampart.as_param('Frequency', 'float', 1/lfo_pan_obj.time.speed_seconds)
alslfo['Attack'] = ableton_parampart.as_param('Attack', 'float', lfo_pan_obj.attack*1000)

lfo_vol_obj = plugin_obj.lfo_get('vol')
paramkeys['AuxLfos.0/IsOn'] = ableton_parampart.as_param('IsOn', 'bool', True)
paramkeys['AuxLfos.0/Slot/Value'] = ableton_parampart.as_numset('SimplerAuxLfo')
alslfo = paramkeys['AuxLfos.0/Slot/Value']['0/SimplerAuxLfo'] = {}
if lfo_vol_obj.prop.shape in LFO_SHAPE:
alslfo['Type'] = ableton_parampart.as_param('Type', 'int', LFO_SHAPE[lfo_vol_obj.prop.shape])
alslfo['Frequency'] = ableton_parampart.as_param('Frequency', 'float', 1/lfo_vol_obj.time.speed_seconds)
alslfo['Attack'] = ableton_parampart.as_param('Attack', 'float', lfo_vol_obj.attack*1000)
alslfo['ModDst/ModConnections.0/Amount'] = ableton_parampart.as_value('Amount', lfo_vol_obj.amount*100)
alslfo['ModDst/ModConnections.0/Connection'] = ableton_parampart.as_value('Connection', 18)

lfo_pitch_obj = plugin_obj.lfo_get('pitch')
paramkeys['AuxLfos.1/IsOn'] = ableton_parampart.as_param('IsOn', 'bool', True)
paramkeys['AuxLfos.1/Slot/Value'] = ableton_parampart.as_numset('SimplerAuxLfo')
alslfo = paramkeys['AuxLfos.1/Slot/Value']['0/SimplerAuxLfo'] = {}
if lfo_pitch_obj.prop.shape in LFO_SHAPE:
alslfo['Type'] = ableton_parampart.as_param('Type', 'int', LFO_SHAPE[lfo_pitch_obj.prop.shape])
alslfo['Frequency'] = ableton_parampart.as_param('Frequency', 'float', 1/lfo_pitch_obj.time.speed_seconds)
alslfo['Attack'] = ableton_parampart.as_param('Attack', 'float', lfo_pitch_obj.attack*1000)
alslfo['ModDst/ModConnections.0/Amount'] = ableton_parampart.as_value('Amount', (lfo_pitch_obj.amount/24)*100)
alslfo['ModDst/ModConnections.0/Connection'] = ableton_parampart.as_value('Connection', 6)

als_device.params.import_keys(paramkeys)

if als_device_pitch: als_device_pitch.params.import_keys(pitchparamkeys)
Expand Down
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ av
beautifulsoup4
blackboxprotobuf
pypng
git+https://github.com/Perlence/rpp
tinydb
imgui-bundle
termcolor
git+https://github.com/Perlence/rpp

0 comments on commit 90701dc

Please sign in to comment.