phoenix6.orchestra#

Module Contents#

class phoenix6.orchestra.Orchestra(instruments: list[phoenix6.hardware.parent_device.ParentDevice] = [], filepath: str = '')#

Orchestra is used to play music through devices. It uses a “Chirp” (.chrp) music file that can be generated using Phoenix Tuner. Chirp files are generated from standard MIDI files.

Any Chirp file located in the src/main/deploy directory of your FRC project will automatically be copied to the roboRIO on code deploy.

The robot must be enabled to play music. Additionally, devices playing in Orchestra will not run any other control requests while Orchestra is running. Users can :ref:pause: or :ref:stop: the Orchestra to re-enable device control.

Each device can only play a single track within the music file. For multi-track files, multiple devices are needed. Devices can be added with an explicit track number. Otherwise, the first track will be played through the first Talon FX added, the second track will be played through the second Talon FX added, etc.

To use Orchestra:

  • Add the Talon FXs to be used as instruments using :ref:add_instrument:.

  • Load the Chirp file to be played using :ref:load_music:. This can also

be done in the Orchestra constructor.

Both of these can also be done in the Orchestra constructor.

Once ready, the Orchestra can be controlled using :ref:play:/:ref:pause:/:ref:stop:. New music files can be loaded at any time.

Parameters:
  • instruments (list[ParentDevice]) – A list of devices that will be used as instruments in the orchestra

  • filepath (str) – The path to the music file to immediately load into the orchestra

add_instrument(instrument: phoenix6.hardware.parent_device.ParentDevice) phoenix6.status_code.StatusCode#

Adds an instrument to the orchestra.

Parameters:

instrument (ParentDevice) – The device to add to the orchestra

Returns:

Status code of adding the device

Return type:

StatusCode

add_instrument_with_track(instrument: phoenix6.hardware.parent_device.ParentDevice, track_number: int) phoenix6.status_code.StatusCode#

Adds an instrument to the orchestra on the given track.

Parameters:
  • instrument (ParentDevice) – The device to add to the orchestra

  • track_number (int) – The track number the device should play, starting at 0

Returns:

Status code of adding the device

Return type:

StatusCode

clear_instruments() phoenix6.status_code.StatusCode#

Clears all instruments in the orchestra.

Returns:

Status code of clearing all devices

Return type:

StatusCode

load_music(filepath: str) phoenix6.status_code.StatusCode#

Loads a Chirp file at the specified file path.

If the Chirp file is inside your “src/main/deploy” directory, it will be automatically deployed to a default directory on the roboRIO when you deploy code. For these files, the name and file extension is sufficient.

A Chirp file can be created from a MIDI file using Phoenix Tuner.

Parameters:

filepath (str) – The path to the Chirp file

Returns:

Status code of loading the Chirp file

Return type:

StatusCode

play() phoenix6.status_code.StatusCode#

Plays the loaded music file. If the player is paused, this will resume the orchestra.

Returns:

Status code of playing the orchestra

Return type:

StatusCode

pause() phoenix6.status_code.StatusCode#

Pauses the loaded music file. This saves the current position in the track so it can be resumed later.

Returns:

Status code of pausing the orchestra

Return type:

StatusCode

stop() phoenix6.status_code.StatusCode#

Stops the loaded music file. This resets the current position in the track to the start.

Returns:

Status code of stopping the orchestra

Return type:

StatusCode

is_playing() bool#

Gets whether the current track is actively playing.

Returns:

True if Orchestra is playing the music file

Return type:

bool

get_current_time() phoenix6.units.second#

Gets the current timestamp of the music file. The timestamp will reset to zero whenever :ref:load_music: or :ref:stop: is called.

If :ref:isPlaying: returns false, this method can be used to determine if the music is stopped or paused.

Returns:

The current timestamp of the music file, in seconds

Return type:

second