def extract_parser_handler(args): print("Extracting wavetables from {} to {}".format( args.firmware, os.path.abspath(args.out_wav_dir))) firmware = Firmware.load_from_mff(args.firmware) if args.verbose: firmware.log() wavetables_image = firmware.get_image(FirmwareImage.Type.WAVETABLES) wavetables = Wavetables.from_image(wavetables_image) mkdir_p(args.out_wav_dir) wavetables.write_tables_to_wavs(args.out_wav_dir)
def replace_parser_handler(args): print( "Replacing wavetables from {} with those in {} and writing result to {}". format( args.firmware, os.path.abspath(args.wav_dir), os.path.abspath(args.out_firmware))) firmware = Firmware.load_from_mff(args.firmware) wavetables = Wavetables.from_image(firmware.get_image(FirmwareImage.Type.WAVETABLES)) wavetables.replace_tables_with_wavs(args.wav_dir) firmware.put_image(wavetables.to_image()) if args.verbose: firmware.log() firmware.write_to_mff(args.out_firmware) # Sanity check that the file was written. assert(Firmware.load_from_mff(args.out_firmware) is not None)