Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LADSPA plugin support #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions sox/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,47 @@ def hilbert(self, num_taps=None):

return self


def ladspa(self, name='', params='', ladspa_path='/usr/lib/ladspa/'):
'''Sox supports the Linux Audio Developer's Simple Plugin API (LADSPA) standard
and will call plugins via the sox -ladspa command-line option. This
module simply passess the string name of a module and a list of parameters as a string

Parameters
----------
name : string, default = ''
The name of the LADSPA plugin file, e.g. 'mbeq_1197'.
This will get ladspa_path prepended to it, and '.so' appended.
params: string: default
String of parameters to send to the LADSPA plugin via sox.

Example: For one of Steve Harris' compressors (sudo apt-get install swh-plugins)
tfm.ladspa('mbeq_1197','mbeq -2 -3 -3 -6 -9 -9 -10 -8 -6 -5 -4 -3 -1 0 0 0')

'''
if not isinstance(name, str):
raise ValueError('name must be a string.')

if not isinstance(params, str):
raise ValueError('params must be a string')

full_name = ladspa_path + name + '.so'

if not os.path.isfile(full_name):
raise IOError('LADSPA plugin file not found at '+full_name)

effect_args = [
'ladspa',
ladspa_path + name + '.so',
params
]
self.effects.extend(effect_args)
self.effects_log.append('ladspa')

return self



def loudness(self, gain_db=-10.0, reference_level=65.0):
'''Loudness control. Similar to the gain effect, but provides
equalisation for the human auditory system.
Expand Down Expand Up @@ -1883,12 +1924,12 @@ def noiseprof(self, input_filepath, profile_path):
'''
if os.path.isdir(profile_path):
raise ValueError("profile_path {} is a directory, but filename should be specified.")

if os.path.dirname(profile_path) == '' and profile_path != '':
_abs_profile_path = os.path.join(os.getcwd(), profile_path)
else:
_abs_profile_path = profile_path

if not os.access(os.path.dirname(_abs_profile_path), os.W_OK):
raise IOError("profile_path {} is not writeable.".format(_abs_profile_path))

Expand Down