本文整理汇总了Python中music.Music类的典型用法代码示例。如果您正苦于以下问题:Python Music类的具体用法?Python Music怎么用?Python Music使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Music类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
self._screen().blit(self._background(), (0, 0))
pygame.display.flip()
clock = pygame.time.Clock()
music = Music()
music.play()
while 1:
clock.tick()
self._draw_background()
self._draw_monsters()
self._draw_hero()
self._draw_coins()
self._draw_hud()
pygame.display.flip()
for event in pygame.event.get():
if event.type == QUIT:
return
elif event.type == KEYDOWN and event.key == K_ESCAPE:
return
elif event.type == KEYDOWN:
self.hero().handle_keydown(event.key)
elif event.type == KEYUP:
self.hero().handle_keyup(event.key)
示例2: main
def main():
dt = DumplingTown()
music = Music()
music.animalCrossingDay()
#music.pause()
#music.pause()
music.play()
示例3: __start
def __start(self):
music_helper = MusicHelper()
while self._file_name_list:
file_path = self._file_name_list.pop()
music_tag = music_helper.get_music_tag(file_path)
music_info = Music()
music_info.file_path = file_path
if music_tag == {}:
logger.info("Music tag can't be got: " + music_info.file_path)
else:
music_info.music_tag = music_tag
self._music_tag_queue.put(music_info)
示例4: __init__
def __init__(self):
self.window_manager = WindowManager()
self.events = Queue()
self.panel = Panel()
self.clock = Clock()
self.notification_monitor = NotificationMonitor()
try:
with open(os.path.expanduser('~/.config/mpd/credentials.conf'), 'r') as f:
mpd_settings = json.load(f)
except FileNotFoundError:
self.music = Music()
else:
self.music = Music(**mpd_settings)
self.music_controller = self.music.clone()
self.system_info = SystemInfo()
示例5: __init__
def __init__(self, sound="None", soundout="pulse"):
self.music = Music(sound, soundout)
sleep(0.25)
self.screen = curses.initscr()
self.screen.clear()
self.screen.refresh()
self.music.start()
self.mapstr = "map{}.txt"
curses.noecho()
self.game = Game(self, 0)
self.game.start()
示例6: run_game
def run_game():
pygame.init()
ai_setting = Settings()
screen = pygame.display.set_mode((ai_setting.screen_width, ai_setting.screen_height))
pygame.display.set_caption("Alien Invasion")
ship = Ship(ai_setting, screen)
bullets = Group()
aliens = Group()
stats = GameStats(ai_setting)
sb = Scoreboard(ai_setting, screen, stats)
gf.create_fleet(ai_setting, screen, ship, aliens)
play_button = Button(ai_setting, screen, "Play")
music = Music()
while True:
gf.check_events(ai_setting, screen, stats, sb, play_button, ship, aliens, bullets, music)
if stats.game_active:
music.play_bgm()
ship.update()
gf.update_bullets(ai_setting, screen, stats, sb, ship, aliens, bullets, music)
gf.update_aliens(ai_setting, screen, stats, sb, ship, aliens, bullets)
gf.update_screen(ai_setting, screen, stats, sb, ship, aliens, bullets, play_button)
示例7: parse
def parse(fname):
soup = BeautifulSoup(open(fname), 'lxml')
soup = BeautifulSoup(soup.prettify('shift-jis'), 'lxml')
music = Music()
title, artist = getHeader(soup)
keys = getKeys(soup)
lyrics = getLyrics(soup)
chords = getChords(soup)
music.title = title
music.artist = artist
music.keys = keys
music.lyrics = lyrics
music.chords = chords
return music
示例8: page_not_found
from events import Events
from users import Users
from docs import Docs
# configuration
DATABASE = 'test.json'
app = flask.Flask(__name__)
app.secret_key = settings.secret_key
#URL rules: add as needed for the various dynamic pages
app.add_url_rule('/', view_func=Main.as_view('main'), methods=('get','post'))
app.add_url_rule('/<page>/', view_func=Main.as_view('main'), methods=('get','post'))
app.add_url_rule('/login/', view_func=Login.as_view('login'), methods=('get','post'))
app.add_url_rule('/remote/', view_func=Remote.as_view('remote'), methods=('get','post'))
app.add_url_rule('/music/', view_func=Music.as_view('music'), methods=('get', 'post'))
app.add_url_rule('/events/', view_func=Events.as_view('events'), methods=('get','post'))
app.add_url_rule('/users/', view_func=Users.as_view('users'), methods=('get','post'))
app.add_url_rule('/docs/', view_func=Docs.as_view('docs'), methods=('get','post'))
#error handling wrapper
@app.errorhandler(404)
def page_not_found(error):
return flask.render_template('404.html'), 404
#database handling wrappers
@app.before_request
def before_request():
"""Make sure we are connected to the database each request."""
try:
db = open(DATABASE).read()
示例9: Display
"""
from display import Display
from controller import Controller
from music import Music
import threading
import gobject
if __name__ == '__main__':
gobject.threads_init()
display = Display()
controller = Controller()
music = Music()
mainloop = gobject.MainLoop()
# Connect signals between components.
controller.connect('change-mode', display.change_mode)
controller.connect('station-up', music.tune_station, 1)
controller.connect('station-down', music.tune_station, -1)
controller.connect('play-pause', music.play_pause)
controller.connect('next-song', music.skip_song)
music.connect('station-changed', display.change_station)
music.connect('song-changed', display.change_song)
music.connect('state-changed', display.change_state)
# Start user interface loop.
display_thread = threading.Thread(target=display.run, args=(mainloop,))
display_thread.daemon = True
示例10: __init__
class Generator:
def __init__(self):
self.music = Music()
def write_arffs(self):
for next_file in os.listdir("midi"):
if os.path.isfile("midi/" + next_file):
print "adding midi/" + next_file
self.music.load_song("midi/" + next_file)
print "generating arff files"
self.music.write_arff("test")
def train(self):
print "loading arff files"
instrument_data, note_data, velocity_data, duration_data, time_delta_data = self.music.read_arff(
"test")
self.transform_instrument = preprocessing.OneHotEncoder(categorical_features=[0,1,2,5,6,7,10,11,12,15,16,17,20,21,22])
self.transform_instrument.fit(instrument_data[:, :-1])
self.transform_note = preprocessing.OneHotEncoder(categorical_features=[0,1,2,5,6,7,10,11,12,15,16,17,20,21,22])
self.transform_note.fit(note_data[:, :-1])
self.transform_duration = preprocessing.OneHotEncoder(categorical_features=[0,1,2,5,6,7,10,11,12,15,16,17,20,21,22])
self.transform_duration.fit(duration_data[:, :-1])
self.transform_time_delta = preprocessing.OneHotEncoder(categorical_features=[0,1,2,5,6,7,10,11,12,15,16,17,20,21,22])
self.transform_time_delta.fit(time_delta_data[:, :-1])
print "training instruments"
self.instrument_clf = RandomForestClassifier(n_estimators=10)
self.instrument_clf = self.instrument_clf.fit(
self.transform_instrument.transform(instrument_data[:, :-1]), instrument_data[:, -1:])
print "training notes"
self.note_clf = RandomForestRegressor(n_estimators=10)
print note_data[:, :-1]
self.note_clf = self.note_clf.fit(self.transform_note.transform(note_data[:, :-1]), note_data[:, -1:])
print "training velocity"
self.velocity_clf = RandomForestClassifier(n_estimators=10)
self.velocity_clf = self.velocity_clf.fit(
velocity_data[:, :-1], velocity_data[:, -1:])
print "training duration"
self.duration_clf = RandomForestClassifier(n_estimators=10)
self.duration_clf = self.duration_clf.fit(
self.transform_duration.transform(duration_data[:, :-1]), duration_data[:, -1:])
print "training time_delta"
self.time_delta_clf = RandomForestClassifier(n_estimators=10)
self.time_delta_clf = self.time_delta_clf.fit(
self.transform_time_delta.transform(time_delta_data[:, :-1]), time_delta_data[:, -1:])
def generate_song(self, filename):
self.song = Song()
self.song.add_note(self.get_seed_note())
self.song.add_note(self.get_seed_note())
print "generating new song"
for _ in range(5000):
notes = self.song.get_last_notes()
notes = np.array(notes).reshape(1, -1)
instrument = self.instrument_clf.predict(self.transform_instrument.transform(notes))[0]
note = self.note_clf.predict(self.transform_note.transform(notes))[0]
velocity = self.velocity_clf.predict(notes)[0]
note_duration = self.duration_clf.predict(self.transform_duration.transform(notes))[0] * 2
time_delta = self.time_delta_clf.predict(self.transform_time_delta.transform(notes))[0] * 0.75
self.song.add_note(Note(int(instrument), int(note), int(
velocity), int(time_delta), duration=int(note_duration)))
print "writing song to " + filename
self.song.write_file(filename)
def get_seed_note(self):
return Note(0, random.randrange(0, 126), 100, 0, duration=random.randrange(1, 10) * 10)
示例11: page_not_found
app.secret_key = settings.secret_key
#Routes
app.add_url_rule('/',
view_func=Main.as_view('main')
methods=["GET"])
app.add_url_rule('/<page>/',
view_func=Main.as_view('main')
methods=["GET"])
app.add_url_rule('/Login/',
view_func=Login.as_view('login'),
methods=['GET', 'POST'])
app.add_url_rule('/remote/',
view_func=Music.as_view('remote'),
methods=(['GET'])
app.add_url_rule('/music/',
view_func=Music.as_view('music'),
methods=['GET'])
@app.errorhandler(404)
def page_not_found(error):
return flask.render_template('404.html'), 404
app.debug = True
app.run()
示例12: music
def music(jsonData):
Music.playCmd(jsonData)
示例13: page_not_found
import flask
import settings
#Views
from main import Main
from login import Login
from remote import Remote
from music import Music
app = flask.Flask(__name__)
app.secret_key = settings.secret_key
#Routes
app.add_url_rule('/', view_func=Main.as_view('main'), methods=["GET"])
app.add_url_rule('/<page>/', view_func=Main.as_view('main'), methods=["GET"])
app.add_url_rule('/login/', view_func=Login.as_view('login'), methods=["GET", "POST"])
app.add_url_rule('/remote/', view_func=Remote.as_view('remote'), methods=["GET", "POST"])
app.add_url_rule('/music/', view_func=Music.as_view('music'), methods=["GET"])
@app.errorhandler(404)
def page_not_found(error):
return flask.render_template('404.html'), 404
app.debug = True
app.run()
示例14: page_not_found
app =flask.Flask(__name__)
app.secret_key = settings.secret_key
#Routes
app.add_url_rule('/',
view_func=Main.as_view('main'),
methods=['GET'])
app.add_url_rule('/<page>/',
view_func=Main.as_view('page'),
methods=['GET'])
app.add_url_rule('/login',
view_func=Login.as_view('login'),
methods=['GET','POST'])
app.add_url_rule('/remote',
view_func=Remote.as_view('remote'),
methods=['GET','POST'])
app.add_url_rule('/music',
view_func=Music.as_view('music'),
methods=['GET'])
@app.errorhandler(404)
def page_not_found(error):
return flask.render_template('404.html'),404
app.debug=True
app.run()