Skip to content

Commit

Permalink
Remove superfluous dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
simlmx committed Feb 24, 2022
1 parent 9565d58 commit c1f0e73
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 31 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ build:
docker build . -t pyvst

# To be run from the repo!
# Forwarding the 8888 port for jupyter
run:
docker run -it --rm \
--volume `pwd`:/workdir/pyvst/ \
--user `id -u`:`id -g` \
-p 8888:8888 \
pyvst bash
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
My attempt at hosting VSTs using `ctypes`.


# Running the tests
# Running in Docker

make build
make run
Expand Down
5 changes: 2 additions & 3 deletions pyvst/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,13 @@ def reload_vst(self):
for i, p in enumerate(params):
self.vst.set_param_value(i, p)

def load_vst(self, path_to_so_file, verbose=False):
def load_vst(self, path_to_so_file):
"""
Loads a vst. If there was already a vst loaded, we will release it.
:param path_to_so_file: Path to the .so file to use as a plugin.
:param verbose: Set to False (default) to capture the VST's stdout/stderr.
"""
self._vst = VstPlugin(path_to_so_file, self._callback, verbose=verbose)
self._vst = VstPlugin(path_to_so_file, self._callback)

# Not sure I need this but I've seen it in other hosts
self.vst.open()
Expand Down
35 changes: 13 additions & 22 deletions pyvst/vstplugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import contextlib
from ctypes import (cdll, POINTER, c_double,
c_void_p, c_int, c_float, c_int32,
byref, string_at, create_string_buffer)
from warnings import warn

import numpy as np
from wurlitzer import pipes


from .vstwrap import (
AudioMasterOpcodes,
Expand Down Expand Up @@ -33,22 +32,15 @@ def _default_audio_master_callback(effect, opcode, *args):


class VstPlugin:
def __init__(self, filename, audio_master_callback=None, verbose=False):
"""
:param verbose: Set to True to show the plugin's stdout/stderr. By default (False),
we capture it.
"""
self.verbose = verbose

def __init__(self, filename, audio_master_callback=None):
if audio_master_callback is None:
audio_master_callback = _default_audio_master_callback
self._lib = cdll.LoadLibrary(filename)
self._lib.VSTPluginMain.argtypes = [AUDIO_MASTER_CALLBACK_TYPE]
self._lib.VSTPluginMain.restype = POINTER(AEffect)

with pipes() if not verbose else contextlib.suppress():
self._effect = self._lib.VSTPluginMain(AUDIO_MASTER_CALLBACK_TYPE(
audio_master_callback)).contents
self._effect = self._lib.VSTPluginMain(AUDIO_MASTER_CALLBACK_TYPE(
audio_master_callback)).contents

assert self._effect.magic == MAGIC

Expand All @@ -70,9 +62,8 @@ def suspend(self):
def _dispatch(self, opcode, index=0, value=0, ptr=None, opt=0.):
if ptr is None:
ptr = c_void_p()
with pipes() if not self.verbose else contextlib.suppress():
output = self._effect.dispatcher(byref(self._effect), c_int32(opcode), c_int32(index),
vst_int_ptr(value), ptr, c_float(opt))
output = self._effect.dispatcher(byref(self._effect), c_int32(opcode), c_int32(index),
vst_int_ptr(value), ptr, c_float(opt))
return output

# Parameters
Expand Down Expand Up @@ -179,13 +170,13 @@ def process(self, input=None, sample_frames=None, double=None):

output = self._allocate_array((self.num_outputs, sample_frames), c_type)

with pipes() if not self.verbose else contextlib.suppress():
process_fn(
byref(self._effect),
input,
output,
sample_frames,
)
process_fn(
byref(self._effect),
input,
output,
sample_frames,
)

output = np.vstack([
np.ctypeslib.as_array(output[i], shape=(sample_frames,))
for i in range(self.num_outputs)
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
packages = find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
install_requires=[
'numpy>=1.16.0',
'wurlitzer>=1.0.1',
],
extras_require={
'dev': [
'pytest>=3.8.0',
'matplotlib>=3.0.0',
'jupyter>=1.0.0',
],
}
)

0 comments on commit c1f0e73

Please sign in to comment.