Skip to content

Commit

Permalink
fixes + more env to adsr + flp auto vst
Browse files Browse the repository at this point in the history
  • Loading branch information
SatyrDiamond committed Sep 26, 2024
1 parent 6c85da0 commit 03bb15e
Show file tree
Hide file tree
Showing 11 changed files with 357 additions and 255 deletions.
2 changes: 1 addition & 1 deletion dawvert_adpcm_dec.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from plugins import base as dv_plugins
from objects import audio_data

dv_plugins.load_plugindir('audiocodecs')
dv_plugins.load_plugindir('audiocodecs', '')

parser = argparse.ArgumentParser()
parser.add_argument("-i", default=None)
Expand Down
8 changes: 4 additions & 4 deletions dawvert_adpcm_enc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
from plugins import base as dv_plugins
from objects import audio_data

dv_plugins.load_plugindir('audiocodecs')
dv_plugins.load_plugindir('audiocodecs', '')

parser = argparse.ArgumentParser()
parser.add_argument("-i", default=None)
parser.add_argument("-it", default=None)
parser.add_argument("-ot", default=None)
parser.add_argument("-o", default=None)
args = parser.parse_args()

in_file = args.i
out_file = args.o
in_format = args.it
out_format = args.ot

file_obj = open(in_file, 'rb')
ofile_obj = open(out_file, 'wb')

audio_obj = audio_data.audio_obj()
audio_obj.set_codec('int16')
audio_obj.pcm_from_bytes(file_obj.read())
ofile_obj.write( audio_obj.encode_to_codec(in_format) )
ofile_obj.write( audio_obj.encode_to_codec(out_format) )

17 changes: 17 additions & 0 deletions functions/data_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

import re

class dif_val:
def __init__(self, inval):
self.cur_val = inval

def do_value(self, inval):
out_val = inval-self.cur_val if self.cur_val != None else None
self.cur_val = inval
return out_val

class counter:
def __init__(self, starting_num):
self.current = starting_num
Expand Down Expand Up @@ -169,6 +178,14 @@ def list__to_reigons_bool(i_list): # UNUSED

return output

def list__dif_val(i_list, startnum):
outvals = []
prev = dif_val(startnum)
for x in i_list:
outv = prev.do_value(x)
if outv != None: outvals.append(outv)
return outvals

def list__findrepeat(i_list): # UNUSED
outdata = []
for part in i_list:
Expand Down
2 changes: 2 additions & 0 deletions functions/xtramath.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import math
from functions import note_data
import struct

# -------------------------------------------- values --------------------------------------------

Expand Down Expand Up @@ -65,6 +66,7 @@ def do_math(inputv, mathtype, val1, val2, val3, val4):
elif mathtype == 'freq2note': return note_data.freq_to_note(inputv)
elif mathtype == 'from_db': return note_data.from_db(inputv)
elif mathtype == 'to_db': return note_data.to_db(inputv)
elif mathtype == 'floatbyteint2float': return struct.unpack("<f", struct.pack("<I", int(inputv)))[0]
else: return inputv

# -------------------------------------------- generators --------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions functions_plugin/flp_dec_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ def getparams(convproj_obj, pluginid, flplugin, foldername, zipfile):
plugin_vst2.replace_data(convproj_obj, plugin_obj, 'id' ,'win', wrapperdata['fourid'], 'chunk', wrapper_vstdata, None)
plugin_vst2.replace_data(convproj_obj, plugin_obj, 'name' ,'win', wrapperdata['name'], 'chunk', wrapper_vstdata, None)

numparams = plugin_obj.datavals_global.get('numparams', -1)

if numparams != -1:
for x in range(numparams):
convproj_obj.automation.calc(['id_plug', pluginid, str(x)], 'floatbyteint2float', 0, 0, 0, 0)
convproj_obj.automation.move(['id_plug', pluginid, str(x)], ['plugin',pluginid,'ext_param_'+str(x)])

if wrapper_vststate[4] in [5, 4]:
stream_data = bytereader.bytereader()
stream_data.load_raw(wrapper_vstdata)
Expand All @@ -164,6 +171,10 @@ def getparams(convproj_obj, pluginid, flplugin, foldername, zipfile):

plugin_obj.set_program(wrapper_vstprogram)

for x in range(vst_total_params):
convproj_obj.automation.calc(['id_plug', pluginid, str(x)], 'floatbyteint2float', 0, 0, 0, 0)
convproj_obj.automation.move(['id_plug', pluginid, str(x)], ['plugin',pluginid,'ext_param_'+str(x)])

#elif '16id' in wrapperdata:
# pluginstate = wrapperdata['state']
# pluginstate_str = BytesIO(pluginstate)
Expand Down
1 change: 1 addition & 0 deletions functions_plugin_ext/plugin_vst2.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def replace_data(convproj_obj, plugin_obj, bycat, platform, in_val, datatype, da
plugin_obj.datavals_global.add('basename', pluginfo_obj.basename)
plugin_obj.datavals_global.add('fourid', int(pluginfo_obj.id))
plugin_obj.datavals_global.add('creator', pluginfo_obj.creator)
if pluginfo_obj.num_params: plugin_obj.datavals_global.add('numparams', pluginfo_obj.num_params)
plugin_obj.role = pluginfo_obj.type
plugin_obj.audioports.setnums_auto(pluginfo_obj.audio_num_inputs, pluginfo_obj.audio_num_outputs)

Expand Down
1 change: 0 additions & 1 deletion objects/audio_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def encode_to_codec(self, codecname):
codecname = audio_obj.audiocodec_selector.set(codecname)
if codecname:
selected_plugin = audio_obj.audiocodec_selector.selected_plugin
extcodec_obj = dv_plugins.plugins_audio_codec[codecname]
if selected_plugin.prop_obj.encode_supported: return selected_plugin.plug_obj.encode(self)
else: print('[plugins] codec: encoding unsupported:', codecname)
else: print('[plugins] codec: not found', codecname)
Expand Down
12 changes: 12 additions & 0 deletions objects/convproj/autopoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ def __eq__(self, aps):
s_data = self.data == aps.data
return s_time_ppq and s_time_float and s_val_type and s_points and s_data

def __getitem__(self, num):
if num == 'pos': return [x.pos for x in self.points]
elif num == 'value': return [x.value for x in self.points]
else: return self.points[num]

def __len__(self):
return self.points.__len__()

def __iter__(self):
for x in self.points:
yield x

def clear(self):
self.data = {}
self.points = []
Expand Down
28 changes: 15 additions & 13 deletions objects/convproj/autoticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@
# SPDX-License-Identifier: GPL-3.0-or-later

from functions import xtramath
from functions import data_values
from objects.convproj import time
import math

class dif_val:
def __init__(self):
self.cur_val = 0

def do_value(self, inval):
out_val = inval-self.cur_val
self.cur_val = inval
return out_val

class cvpj_autoticks:
__slots__ = ['val_type','time_ppq','time_float','points']

Expand All @@ -23,6 +15,18 @@ def __init__(self, time_ppq, time_float, val_type):
self.time_float = time_float
self.points = {}

def __getitem__(self, num):
if num == 'pos': return list(self.points)
elif num == 'value': return [x for _, x in self.points.items()]
else: return self.points[list(self.points)[num]]

def __len__(self):
return self.points[num].__len__()

def __iter__(self):
for p, v in self.points.items():
yield p, v

def iter(self):
for p, v in self.points.items():
yield p, v
Expand Down Expand Up @@ -86,8 +90,6 @@ def edit_trimmove(self, startat, endat):
prev_data = None
self.points[mpos] = v



def optimize(self):
prevval = None
norepeats = {}
Expand Down Expand Up @@ -148,8 +150,8 @@ def to_points_classic(self):
return points_out

def to_points(self):
prev_pos = dif_val()
prev_val = dif_val()
prev_pos = data_values.dif_val(0)
prev_val = data_values.dif_val(0)
prev_minus = False

tres_pos = self.time_ppq//8
Expand Down
Loading

0 comments on commit 03bb15e

Please sign in to comment.