diff --git a/sox/transform.py b/sox/transform.py index 3dd9a1c..04e5611 100644 --- a/sox/transform.py +++ b/sox/transform.py @@ -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. @@ -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))