示例#1
0
文件: uph2mff.py 项目: jawknee/upbhh
def main():
	"""
	main: runstring options, parse the file to a song, output song to a file.
	"""
	
	(options, args) = getoptions()
	f_name=options.filename
	out_name=options.outfilename
	txt_name=options.textfilename
	

	# Set up a Song class - basically as list of events and a way to list them
	song = songevents.Song()
	song.format = 1		# RBF - set from run-string
	song.PPQ = options.PPQ
	print "PPQ:", song.PPQ
	song.time_factor = options.time_correction_factor # stretch or shrink song length
	print "Song.tf", song.time_factor

	# parse the song into a list of events
	parse.parse_song(f_name, song)

	#song.list()	# debug...

	# for testing.  Later:  use option passed file
	#outfile = open('testout.mid','wb')
	outfile = open(out_name, 'wb')
	song.create_MFF(outfile,txt_name)	# create a MIDI file, and optionally, a text summary

	outfile.close()
	
	print "All done."
示例#2
0
def test_parse_song_attrs():
    song_file = StringIO(ATTR_SONG)

    song = parse.parse_song(song_file)

    assert song.title == 'foo'
    assert song.banner == 'foo.png'
    assert song.bg == 'bar.png'
    assert song.music == 'foo.ogg'
    assert song.offset == 1.337
    assert song.sample_st == 133.7
    assert song.sample_len == 13.37
    assert song.bpms == '13.3-133.7'