music_player module
- class music_player.MusicPlayer
Bases:
object- static convert_duration_to_sixteenths(seconds, tempo_bpm=120)
Helper method to convert old duration format to 16th note format.
- play_chant(hardware, sound_enabled, notes, tempo_bpm)
Play a chant (short, 3 repetitions).
- play_fight_song(hardware, sound_enabled, notes, tempo_bpm)
Play a fight song (long, single play).
- play_music(hardware, sound_enabled, notes, tempo_bpm, repeat_count=1, music_type='music')
Play music with unified timing system - blocking version.
- Parameters:
hardware – Hardware manager instance
sound_enabled – Whether sound is enabled
notes – List of [frequency, duration] pairs where duration is in 16th notes
tempo_bpm – Beats per minute (quarter note = 1 beat)
repeat_count – How many times to repeat (1 for fight song, 3 for chant)
music_type – “chant” or “fight_song” for logging
- play_music_with_lights(hardware, sound_enabled, notes, tempo_bpm, repeat_count=1, music_type='music', light_callback=None)
Play music with synchronized light callback.
- Parameters:
hardware – Hardware manager instance
sound_enabled – Whether sound is enabled
notes – List of [frequency, duration] pairs where duration is in 16th notes
tempo_bpm – Beats per minute (quarter note = 1 beat)
repeat_count – How many times to repeat
music_type – “chant” or “fight_song” for logging
light_callback – Function to call for light updates (hardware, beat_count, note_info)