Ejemplo n.º 1
0
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))
Ejemplo n.º 2
0
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'),
    ])
Ejemplo n.º 3
0
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"),
)
Ejemplo n.º 4
0
def main_automaster(args, **kwargs):
    # convert from auto args template
    # TODO: if len(targets) == len(references) then match up, otherwise random choice, otherwise single

    # print(f"main_automaster args {args}")
    # if type(args.references) in [list]:
    #     args.references = args.references[0]
    
    if len(args.references) == 1:
        references = [args.references[0] for _ in range(len(args.filenames))]
    elif len(args.references) == len(args.filenames):
        references = args.references
    else:
        references = [random.choice(args.references) for _ in range(len(args.filenames))]
    if args.verbose:
        print(f"main_automaster references {references}")

    automaster_results = {
        'targets': [],
        'references': [],
        'results': [],
    }

    # print(f"main_automaster filenames {args.filenames}")
    # print(f"main_automaster references {references}")
    
    for target_i, target in enumerate(args.filenames):
        reference = references[target_i]
        # filename_export = f"{target[:-4]}_master{args.bitdepth}.wav"
        filename_export = os.path.join(
            args.rootdir,
            os.path.basename(args.filename_export) + ".wav")
        
        if args.verbose:
            print(f"main_automaster target {target}, reference {reference}, bitdepth {args.bitdepth}")
            print(f"main_automaster outputs {filename_export}")

        if not os.path.exists(target) or not os.path.exists(reference):
            print(f"main_automaster target {target} or reference {reference} doesnt exist")
            continue
        
        if args.bitdepth == 16:
            result = mg.pcm16(filename_export)
        else:
            result = mg.pcm24(filename_export)
            
        mg.process(
            # The track you want to master
            target=target,
            # Some "wet" reference track
            reference=reference,
            # Where and how to save your results
            results=[result],
        )

        # print(f"automaster result = {result}")
        
        automaster_results['targets'].append(target)
        automaster_results['references'].append(reference)
        automaster_results['results'].append(filename_export)

    results = {
        'data': {
            'output_files': [
                {'format': args.outputs[0],
                 'filename': os.path.basename(automaster_results['results'][0])}
            ],
        }
    }
        
    filename_result = os.path.join(
        args.rootdir,
        os.path.basename(args.filename_export) + ".json")

    # this saves the array in .json format
    json.dump(
        results,
        codecs.open(filename_result, 'w', encoding='utf-8'),
        # separators=(',', ':'),
        # sort_keys=True,
        # indent=4,
        # cls=NumpyEncoder,
    )

    if 'task' in kwargs:
        kwargs['task'].set_done(result_location=os.path.basename(args.filename_export) + ".json")
    
    return results
Ejemplo n.º 5
0
        ref_k_default = '11.84.0.-1.0-1.1-1'
        args.reference = references[ref_k_default]['filename']

    target_k = args.target[:-4]
    ref_k = args.reference[:-4]

    print(f'processing')
    print(f'    target {args.target}')
    print(f'       ref {args.reference}')

    # reference = references['sampa_daratofly']['filename']
    # reference = references['dj-stingray-cryptic']['filename']

    results = []
    if args.bitdepth == 24:
        results.append(mg.pcm24('{0}_master_24bit.wav'.format(target_k)))
    else:
        results.append(mg.pcm16('{0}_master_16bit.wav'.format(target_k)))

    mg.process(
        # The track you want to master
        target=args.target,

        # Some "wet" reference track
        # reference=,
        reference=args.reference,

        # Where and how to save your results
        results=results,
    )