Пример #1
0
def add_song_info(charts, music_id, music_db):
    song_info = None

    if music_db and music_db.endswith(".csv") or not music_db:
        song_info = mdb.get_song_info_from_csv(
            music_db if music_db else "gitadora_music.csv", music_id)

    if song_info is None or music_db and music_db.endswith(
            ".xml") or not music_db:
        song_info = mdb.get_song_info_from_mdb(
            music_db if music_db else "mdb_xg.xml", music_id)

    for chart_idx in range(len(charts)):
        chart = charts[chart_idx]

        if not song_info:
            continue

        game_type = ["drum", "guitar", "bass",
                     "open"][chart['header']['game_type']]

        if 'title' in song_info:
            charts[chart_idx]['header']['title'] = song_info['title']

        if 'artist' in song_info:
            charts[chart_idx]['header']['artist'] = song_info['artist']

        if 'classics_difficulty' in song_info:
            diff_idx = (chart['header']['game_type'] *
                        4) + chart['header']['difficulty']

            if diff_idx < len(song_info['classics_difficulty']):
                difficulty = song_info['classics_difficulty'][diff_idx]
            else:
                difficulty = 0

            charts[chart_idx]['header']['level'] = {game_type: difficulty * 10}

        if 'bpm' in song_info:
            charts[chart_idx]['header']['bpm'] = song_info['bpm']

        if 'bpm2' in song_info:
            charts[chart_idx]['header']['bpm2'] = song_info['bpm2']

    return charts
Пример #2
0
    exit(1)

if not guitar_bgm:
    print("Couldn't find guitar BGM")
    tmpfile.tmpcleanup()
    exit(1)

tmpfile.add_temp_file(drum_bgm_out)
tmpfile.add_temp_file(guitar_bgm_out)

music_id = int(os.path.basename(drum_bgm)[3:7])

song_info = mdb.get_song_info_from_csv("gitadora_music.csv", music_id)

if song_info is None:
    song_info = mdb.get_song_info_from_mdb("mdb_xg.xml", music_id)

if args.mix_phase:
    wavbintool.parse_bin(base_bgm, base_bgm_out)

wavbintool.parse_bin(drum_bgm, drum_bgm_out)
wavbintool.parse_bin(guitar_bgm, guitar_bgm_out)

if args.mix_phase:
    base_audio = pydub.AudioSegment.from_file(base_bgm_out).invert_phase()

drum_audio = pydub.AudioSegment.from_file(drum_bgm_out)
guitar_audio = pydub.AudioSegment.from_file(guitar_bgm_out)

if args.mix_phase:
    drum_phased = drum_audio.overlay(base_audio)
Пример #3
0
def process_file(params):
    input = params['input'] if 'input' in params else None
    input_format = params['input_format'] if 'input_format' in params else None
    output_format = params[
        'output_format'] if 'output_format' in params else None

    if output_format == "same":
        output_format = input_format

    input_handler = find_handler(input, input_format)
    output_handler = find_handler(None, output_format)

    if output_handler is None:
        output_handler = input_handler

    if input_handler is None:
        print("Could not find a handler for input file")
        exit(1)

    if output_handler is None:
        print("Could not find a handler for output file")
        exit(1)

    print("Using {} handler to process this file...".format(
        input_handler.get_format_name()))

    json_data = input_handler.to_json(params)

    # Filter based on difficulty and parts here
    json_data = filter_charts(json_data, params)

    if output_format.lower(
    ) != 'wav' and 'output' in params and not os.path.exists(params['output']):
        os.makedirs(params['output'])

    # Add music information from database
    if params.get('musicdb', None) and params.get('musicid', None):
        try:
            csv_info = mdb.get_song_info_from_csv(
                params.get('musicdb_csv', "gitadora_music.csv"),
                params['musicid'])

        except:
            csv_info = None

        mdb_info = mdb.get_song_info_from_mdb(params['musicdb'],
                                              params['musicid'])

        if csv_info:
            # Pull properly named Japanese artist and title fields from csv if it exists
            mdb_info['title'] = csv_info['title']
            mdb_info['artist'] = csv_info['artist']

            if 'movie_filename' in csv_info:
                mdb_info['movie_filename'] = csv_info['movie_filename']

        if mdb_info:
            json_data = json.loads(json_data)

            for chart in json_data['charts']:
                if chart['header']['is_metadata']:
                    continue

                chart['header']['level'] = {}

                diffs = [chart['header']['game_type']]

                if chart['header']['game_type'] == 1 and params.get(
                        'merge_guitars', False):
                    diffs.append(2)

                for x in diffs:
                    k = {
                        0: "drum",
                        1: "guitar",
                        2: "bass",
                        3: "open",
                    }[x]

                    diff = mdb_info['difficulty'][
                        x * 5 + chart['header']['difficulty']]

                    if diff > 0:
                        chart['header']['level'][k] = diff

                chart['header']['title'] = mdb_info['title']
                chart['header']['artist'] = mdb_info['artist']
                chart['header']['bpm'] = mdb_info['bpm']

            json_data = json.dumps(json_data)

    params['input'] = json_data

    output_handler.to_chart(params)