当前位置: 首页>>代码示例>>Python>>正文


Python Song.addMeasure方法代码示例

本文整理汇总了Python中song.Song.addMeasure方法的典型用法代码示例。如果您正苦于以下问题:Python Song.addMeasure方法的具体用法?Python Song.addMeasure怎么用?Python Song.addMeasure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在song.Song的用法示例。


在下文中一共展示了Song.addMeasure方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: listen

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import addMeasure [as 别名]
def listen():
	# Plays a song generated by the master vector
	print
	print "---Listening---"
	print
	queryUser()
	master = Vector("master")
	s = Song(root,mode,title)
	for i in range(num_measures):
		s.addMeasure(master)
	s.playSong()
	print
	print "This is the best song I know how to play!\n"	
	raw_input("Press any key to return to the main menu: ")	
开发者ID:david-abel,项目名称:felix,代码行数:16,代码来源:felix.py

示例2: listen

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import addMeasure [as 别名]
def listen():
	print
	print "---Listening---"
	print
	queryUser()
	master = Vector("master")
	s = Song(root,mode,title)

	# Build and play a song based on the master vector
	for i in range(num_measures):
		s.addMeasure(master)
	print
	print "This is the best song I know how to play!\n"	
	s.playSong()
	raw_input("Press any key to return to the main menu: ")	
开发者ID:david-abel,项目名称:felix,代码行数:17,代码来源:main.py

示例3: train

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import addMeasure [as 别名]
def train():
	print
	print "---Training---"
	print
	queryUser()
	my_vector = Vector()
	s = Song(root,mode,title)
	for i in range(num_measures):
		# Generate a vector and build a measure from it.
		training_vector = Vector("user")
		s.addMeasure(training_vector)
		s.playMeasure(title,i)
		
		# Get feedback
		user_opinion = raw_input("What did you think of that measure? (scale from 0-10): ")
		while user_opinion.isdigit() == False or int(user_opinion) < 0 or int(user_opinion) > 10:
			print "Invalid Response (please select a number from 0-10)"
			user_opinion = raw_input("What did you think of that measure? (scale from 0-10): ")
		user_opinion = int(user_opinion)
		training_vector = s.measures[i].getVector() # update in the case that we repeated
		my_vector.update(training_vector,.2,user_opinion)

	# Get opinion on whole song
	print "Here is your song!\n"
	s.playSong()	
	song_opinion = int(raw_input("How much did you like that song? (scale from 0-10): "))

	while song_opinion < 0 or song_opinion > 10:
		print "Please enter an integer between 0 and 10: "
		song_opinion = raw_input("How much did you like that song? (scale from 0-10): ")
		while song_opinion.isdigit() != False or int(song_opinion) < 0 or int(song_opinion) > 10:
			print "Invalid Response (please select a number from 0-10)"
			song_opinion = raw_input("How much did you like that song? (scale from 0-10): ")
		song_opinion = int(song_opinion)

	# Update master based on user opinion
	master = Vector("master")
	master.update(my_vector,.05,song_opinion)
	master.normalize()
	master.writeToFile(".master.vct")
	if user_opinion > 6 and num_measures > 7:
		my_vector.writeToFile(".user_vectors.vct")
开发者ID:david-abel,项目名称:felix,代码行数:44,代码来源:main.py


注:本文中的song.Song.addMeasure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。