def _save_lilypond_file_as_svg(self, lilypond_file): import abjad from sasha import sasha_configuration output_filepath = self._build_path() output_directory, output_filename = os.path.split(output_filepath) if not os.path.exists(output_directory): os.makedirs(output_directory) lilypond_path = self._path_to_lilypond_path(output_filepath) lilypond_directory, _ = os.path.split(lilypond_path) if not os.path.exists(lilypond_directory): os.makedirs(lilypond_directory) suffixless_filepath, _ = os.path.splitext(output_filepath) preview_filepath = '{}.preview.{}'.format( suffixless_filepath, self.file_suffix) abjad.persist(lilypond_file).as_ly(lilypond_path) command = '{} -dbackend=svg -dpreview -dno-point-and-click -o {} {}' command = command.format( sasha_configuration.get_binary('lilypond'), suffixless_filepath, lilypond_path, ) out, err = Executable()._exec(command) if out or err: print(out) print(err) os.remove(output_filepath) os.rename(preview_filepath, output_filepath)
def __init__(self): from sasha import sasha_configuration import os executable = sasha_configuration.get_binary('convert') if not os.path.isabs(executable): path = sasha_configuration.find_executable(executable) assert path is not None
def __call__(self, input_path, output_path): from sasha import sasha_configuration executable = sasha_configuration.get_binary('convert') command = '{} {} -trim {}'.format( executable, input_path, output_path, ) out, err = self._exec(command)
def __init__(self, name): from sasha import sasha_configuration import os executable = sasha_configuration.get_binary('audiodb') if not os.path.isabs(executable): path = sasha_configuration.find_executable(executable) assert path is not None path, asset_class = sasha_configuration.get_audiodb_parameters(name) self._asset_class = asset_class self._name = name self._path = path
def __call__(self, input_path, output_path): from sasha import sasha_configuration executable = sasha_configuration.get_binary('lame') output_path = os.path.abspath(output_path) out_directory, _ = os.path.split(output_path) if not os.path.exists(out_directory): os.makedirs(out_directory) command = '{} -V0 {} {}'.format( executable, input_path, output_path, ) out, err = self._exec(command)
def _execute( self, audio_filename, analysis_filename, feature_type, bands=24, overwrite=True, ): from sasha import sasha_configuration assert os.path.exists(audio_filename) analysis_directory, _ = os.path.split(analysis_filename) if not os.path.exists(analysis_directory): os.makedirs(analysis_directory) plan_directory, _ = os.path.split(self.plan_path) if not os.path.exists(plan_directory): os.makedirs(plan_directory) if os.path.exists(analysis_filename): if not overwrite: raise Exception('File exists: {}'.format(analysis_filename)) else: os.remove(analysis_filename) if feature_type == 'chroma': assert bands in (12, 24) flags = '-c {}'.format(bands) elif feature_type == 'constant_q': assert 0 <= int(bands) flags = '-q {}'.format(bands) elif feature_type == 'log_harmonicity': flags = '-H' elif feature_type == 'log_power': flags = '-P' elif feature_type == 'mfcc': assert 0 < bands flags = '-m {} -M 3 -g 0'.format(bands) else: raise Exception('Unknown feature: {!r}'.format(feature_type)) executable = sasha_configuration.get_binary('fftextract') command = '{} -p {} -v 10 -C 2 -s {} {} {} {}'.format( executable, self.plan_path, 100, # enforce common hop size flags, audio_filename, analysis_filename, ) print(command) out, err = self._exec(command) if err: print err
def executable(self): from sasha import sasha_configuration return sasha_configuration.get_binary('audiodb')
def executable(self): from sasha import sasha_configuration return sasha_configuration.get_binary('playback')