def render_project(path='.'): if path != '.': print 'Entering', path os.chdir(path) if dir_is_project('.'): processed.append(path) print colored('Re-rendering project %s' % path, 'green') raw = False for filename in os.listdir('.'): if filename.startswith('LOOP'): raw = True if raw: print colored('Extracting files', 'green') os.system('jamman_extract') if not raw and os.path.isfile('preview.wav'): print colored('Cleaning project', 'green') os.system('jamman_clean') print colored('Rendering project', 'green') os.system('jamman_render') print colored('Compressing project', 'green') os.system('jamman_compress') else: print 'Dir is not a project' if path != '.': print 'Walking back' os.chdir('..')
import jamman.utils as utils normalize = True play_preview = False show_info = False sequence_file = 'sequence.jam' preview_name = 'preview.wav' merge_cmd = 'wavmerge -o %s' % preview_name normalize_cmd = 'normalize-audio %s' % preview_name info_cmd = 'wavinfo %s' % preview_name playback_cmd = 'mplayer %s' % preview_name wave_files = list() if utils.dir_is_project('.', quit=True): print colored('Rendering project %s\n' % utils.get_project_name(), 'green') files = os.listdir('.') for filename in files: if filename.upper().endswith('.wav'): if filename != preview_name: wave_files.append(filename) if os.path.isfile(preview_name): print colored('File %s already exists, not merging' % preview_name, 'red') answear = raw_input('Do you want to overwrite it ? y/N ') if 'Y' in answear.upper(): os.remove(preview_name) if os.path.isfile(preview_name):
def compress_to(filename, codec): if codec in ['mp3', 'flac']: print colored('Encoding file %s to %s format' % (filename, codec), 'green') output_filename = os.path.join( folder, ('%s.%s' % (os.path.splitext(filename)[0], codec))) os.system('ffmpeg -ab %s -i %s %s' % (bitrate, filename, output_filename)) return output_filename return None def play_file(filename): print colored('Playing encoded file file %s' % filename, 'green') os.system('mplayer %s' % filename) if dir_is_project('.', quit=True): if not os.path.isdir(folder): os.mkdir(folder) codecs = ['mp3', 'flac'] for codec in codecs: out = compress_to('preview.wav', codec) if preview: play_file(out) print colored('All done', 'green')
os.system('jamman_clean') print colored('Rendering project', 'green') os.system('jamman_render') print colored('Compressing project', 'green') os.system('jamman_compress') else: print 'Dir is not a project' if path != '.': print 'Walking back' os.chdir('..') def walk_cb(arg, dirname, fnames): #print 'Walk: directory %s, filenames: %s' %(dirname, fnames) for fname in fnames: if os.path.isdir(fname): render_project(os.path.join(dirname, fname)) if not dir_is_project('.'): os.path.walk('.', walk_cb, None) else: render_project('.') processed.sort() print colored('Processed:', 'green') for name in processed: print '\t', name
print '\nAvailable samples are' for sample in samples: print '\t%s' % sample print '\nEnter\n * sequence number separated by spaces\n * add ? to listen to the sample\n * "q" to quit' print 'Examples: 1 2 3 or 1? 2?\n' seq = raw_input('> ') numbers = seq.strip().split(' ') sequence = '' previewed = False for number in numbers: if number == 'q': import sys sys.exit() if '?' not in number: sample = '%s.wav' % number if os.path.isfile(sample): sequence += '%s ' % sample else: filename = "%s.wav" % number.replace('?', '') play_file(filename) previewed = True if sequence != '' and not previewed: print 'Sequence: %s' % sequence write_sequence(sequence) else: record_sequence() if dir_is_project(quit=True): record_sequence()