def run(args, logger): mg.log( warning_handler=logger.warning, info_handler=logger.info, debug_handler=logger.debug, ) bit_to_subtype = {16: "PCM_16", 24: "PCM_24", 32: "FLOAT"} logger.debug(f"{mg.__title__} {mg.__version__}") logger.debug(f"Maintained by {mg.__author__}: {mg.__email__}") logger.debug(f'Contributors: {", ".join(mg.__credits__)}') try: mg.process( target=args.target, reference=args.reference, results=[ mg.Result( args.result, bit_to_subtype.get(args.bit), use_limiter=not args.no_limiter, normalize=not args.dont_normalize, ) ], ) except Exception as e: logger.exception("Got the exception while executing mg.process()")
def process(session: MGSession): if session.code != 2002: return paths = Paths(session.target.file.name, session.target.title) updater = SessionUpdater(session, paths) mg.log(info_handler=updater.info, warning_handler=updater.warning, show_codes=True) try: mg.process( target=media(session.target.file.name), reference=media(session.reference.file.name), results=[ mg.pcm16(media(paths.result16)), mg.pcm24(media(paths.result24)), ], preview_target=mg.pcm16(media(paths.preview_target)), preview_result=mg.pcm16(media(paths.preview_result)), ) except Exception as e: updater.info(str(e))
import matchering as mg # Sending all log messages to the default print function # Just delete the following line to work silently mg.log(print) mg.process( # The track you want to master target='my_song.wav', # Some "wet" reference track reference='some_popular_song.wav', # Where and how to save your results results=[ mg.pcm16('my_song_master_16bit.wav'), mg.pcm24('my_song_master_24bit.wav'), ])
import matchering as mg # Let's keep only warning outputs here, muting everything else mg.log(warning_handler=print) mg.process( target="my_song.wav", reference="some_popular_song.wav", results=[ mg.pcm16("my_song_master_16bit.wav"), mg.pcm24("my_song_master_24bit.wav"), ], # These two lines will allow you to create two 30-second FLAC files with the loudest parts of: # 'my_song.wav' and 'my_song_master_16bit.wav' # Use them to quickly compare the target audio with the resulting audio preview_target=mg.pcm16("preview_my_song.flac"), preview_result=mg.pcm16("preview_my_song_master.flac"), )
import matchering as mg # Let's keep info and warning outputs here, muting out the debug ones mg.log(info_handler=print, warning_handler=print) mg.process( target="audio_files/251.wav", reference="audio_files/fender_251.wav", # pcm16 and pcm24 are just basic shortcuts # You can also use the Result class to make some advanced results results=[ # Basic WAV 16-bit, match + master mg.pcm16("my_song_master_16bit.wav"), # FLAC 24-bit, match only (no limiter), normalized to -0.01 dB # Recommendations for adjusting the amplitude will be displayed in the debug print if it is enabled mg.Result("custom_result_24bit_no_limiter.wav", subtype="PCM_24", use_limiter=False), # AIFF 32-bit float, match only (no limiter), non-normalized # Can exceed 0 dB without clipping # So you can directly feed it to some VST limiter in your DAW # More available formats and subtypes: # https://pysoundfile.readthedocs.io/en/latest/#soundfile.available_formats # https://pysoundfile.readthedocs.io/en/latest/#soundfile.available_subtypes ], ir_file="mid_ir.wav")
# The information output will be marked with a prefix def info(text): my_print(f"INFO: {text}") # The warning output will be highlighted with exclamation marks on both sides def warning(text): my_print("!" * 20) my_print(f"! WARNING: {text}") my_print("!" * 20) # Set new handlers mg.log(warning_handler=warning, info_handler=info, debug_handler=my_print) mg.process( target="my_song.wav", reference="some_popular_song.wav", results=[ mg.pcm16("my_song_master_16bit.wav"), mg.pcm24("my_song_master_24bit.wav"), ], ) # These settings will result in the following text output: # ... # 2020-01-11 11:03:29.225821: INFO: Loading and analysis # 2020-01-11 11:03:29.225821: Loading the TARGET file: 'my_song.wav'... # 2020-01-11 11:03:29.396622: The TARGET file is loaded