Beispiel #1
0
def create_output_files(write_csv=True, write_midi=True):
    for entry in to_extract:
        (subtune, desc, seconds, starting_key, time_sig_top,
         time_sig_bottom) = entry

        sid = chiptunesak.SID()
        sid.set_options(
            sid_in_filename=sid_filename,
            subtune=subtune,
            tuning=448.93,  # above code figured this out
            vibrato_cents_margin=10,
            seconds=seconds,
            gcf_row_reduce=True,
        )

        filename_no_ext = 'examples/data/motl/motl_%s' % desc.replace(" ", "_")

        sid_dump = sid.capture()  # noqa: F841

        if write_csv:
            print("writing %s.csv" % filename_no_ext)
            sid.to_csv_file(
                project_to_absolute_path('%s.csv' % filename_no_ext))

        if write_midi:
            print("writing %s.mid" % filename_no_ext)
            rchirp_song = sid.to_rchirp(sid_filename)

            play_calls_per_quarter = 32  # can see this in the csv output
            # milliframes_per_quarter will determine the QPM/BPM
            chirp_song = \
                rchirp_song.to_chirp(milliframes_per_quarter=play_calls_per_quarter * 1000)

            chirp_song.set_key_signature(starting_key)
            chirp_song.set_time_signature(time_sig_top, time_sig_bottom)

            chiptunesak.MIDI().to_file(
                chirp_song,
                project_to_absolute_path('%s.mid' % filename_no_ext))
Beispiel #2
0
This minimal example imports a GoatTracker song and exports as MIDI.

"""

# Set up input and output paths
output_folder = str(project_to_absolute_path('examples\\data\\BWV_147')) + '\\'
input_folder = output_folder
input_file = str(project_to_absolute_path(input_folder + 'BWV_147_Bleibet.sng'))
output_midi_file = str(project_to_absolute_path(output_folder + 'BWV_147_Bleibet.mid'))

# Read in the song using the GoatTracker I/O class
print(f'Reading and converting {input_file}')
rchirp_song = chiptunesak.GoatTracker().to_rchirp(input_file, arch='PAL-C64')

# The song has a ritard at the end that will mess up the algorithm finding the beat, so eliminate it.
print(f'Removing the ritard at the end of the song')
rchirp_song.remove_tempo_changes()

# Turn the song into a ChirpSong object
print(f'Converting from RChirp to Chirp')
chirp_song = rchirp_song.to_chirp()

# We know the key signature and the time signature for the piece so set them (not required for playback)
print(f'Setting time and key signatures')
chirp_song.set_key_signature('G')
chirp_song.set_time_signature(3, 8)

# And write it to a MIDI file.
print(f'Writing to MIDI file {output_midi_file}')
chiptunesak.MIDI().to_file(chirp_song, output_midi_file)
Beispiel #3
0
It shows the steps needed for this conversion:
  1. Scale and adjust the note data to correspond to musical notes and durations
  2. Split a track with chords into 3 separate tracks
  3. Assign GoatTracker instruments to the voices
  4. Export the 5-track to a stereo GoatTracker .sng file
"""

input_file = str(
    project_to_absolute_path(
        'examples/data/lechuck/MonkeyIsland_LechuckTheme.mid'))
output_midi_file = str(
    project_to_absolute_path('examples/data/lechuck/LeChuck.mid'))
output_gt_file = str(
    project_to_absolute_path('examples/data/lechuck/LeChuck.sng'))

chirp_song = chiptunesak.MIDI().to_chirp(input_file)

print(f'Original song:')
print(f'#tracks = {len(chirp_song.tracks)}')
print(f'    ppq = {chirp_song.metadata.ppq}')
print(f'  tempo = {chirp_song.metadata.qpm} qpm')
print('Track names:')
print('\n'.join(f'{i+1}:  {t.name}' for i, t in enumerate(chirp_song.tracks)))
print()

# First thing, we rename the song
chirp_song.metadata.name = "Monkey Island - LeChuck Theme"

print('Truncating original song...')
chirp_song.truncate(21240)
Beispiel #4
0
# Make a SID for Jim Happel's last-minute CRX demo...

import chiptunesak
from chiptunesak.constants import project_to_absolute_path

input_mid_file = project_to_absolute_path(
    'examples\\data\\c128\\BWV_784_16th_to_8th.mid')
output_gt_file = project_to_absolute_path('examples\\temp\\BWV_784.sng')

chirp_song = chiptunesak.MIDI().to_chirp(input_mid_file,
                                         quantization='8',
                                         polyphony=False)

rchirp_song = chiptunesak.RChirpSong(chirp_song)
gt = chiptunesak.GoatTracker()

# TODO:  Dang, end_with_repeat=True seems to create an unplayable song.  Fix this
# after CRX
# gt.to_file(rchirp_song, output_gt_file, arch='NTSC-C64', end_with_repeat=True)
gt.to_file(rchirp_song, output_gt_file, arch='NTSC-C64')
Beispiel #5
0
chirp_song.metadata.name = "SkyFox - Main Theme"
chirp_song.metadata.composer = "Douglas Fulton"

# Now name the tracks
for t, name in zip(chirp_song.tracks, ['Square1', 'Square2', 'Square3']):
    t.name = name
    t.set_program(81)  # Set program to General Midi square lead

# Quantize the song to a suitable granularity. It turns out we can quantize this to the shortest note duration
chirp_song.quantize(80, 80)

# And remove any polyphony
chirp_song.remove_polyphony()

# Write a MIDI file to look at to be sure it makes sense
chiptunesak.MIDI().to_file(chirp_song,
                           project_to_absolute_path(output_mid_file))

# Convert to MChirp
mchirp_song = chirp_song.to_mchirp(trim_partial=True)

# Generate sheet music with LilyPond
chiptunesak.Lilypond().to_file(mchirp_song, output_ly_file, format='song')

# Change directory to the data directory so we don't fill the source directory with intermediate files.
os.chdir(output_folder)

# Adjust the path the the file
ly_file = os.path.basename(output_ly_file)
# Run lilypond
print('lilypond -o %s %s' % (output_folder, output_ly_file))
subprocess.call('lilypond -o %s %s' % (output_folder, output_ly_file),