CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
ctre::phoenix6::Orchestra Class Reference

Orchestra is used to play music through devices. More...

#include <ctre/phoenix6/Orchestra.hpp>

Public Member Functions

 Orchestra ()
 Constructor for a new Orchestra.
 
 Orchestra (char const *filepath)
 Constructor for a new Orchestra using the given Chirp file.
 
 Orchestra (std::vector< hardware::ParentDevice * > const &instruments)
 Constructor for a new Orchestra using the given Chirp file.
 
template<size_t N>
 Orchestra (std::array< hardware::ParentDevice *, N > const &instruments)
 Constructor for a new Orchestra using the given Chirp file.
 
 Orchestra (std::vector< hardware::ParentDevice * > const &instruments, char const *filepath)
 Constructor for a new Orchestra using the given Chirp file.
 
template<size_t N>
 Orchestra (std::array< hardware::ParentDevice *, N > const &instruments, char const *filepath)
 Constructor for a new Orchestra using the given Chirp file.
 
 ~Orchestra ()
 
ctre::phoenix::StatusCode AddInstrument (hardware::ParentDevice const &instrument)
 Adds an instrument to the orchestra.
 
ctre::phoenix::StatusCode AddInstrument (hardware::ParentDevice const &instrument, uint16_t trackNumber)
 Adds an instrument to the orchestra on the given track.
 
ctre::phoenix::StatusCode ClearInstruments ()
 Clears all instruments in the orchestra.
 
ctre::phoenix::StatusCode LoadMusic (char const *filepath)
 Loads a Chirp file at the specified file path.
 
ctre::phoenix::StatusCode Play ()
 Plays the loaded music file.
 
ctre::phoenix::StatusCode Pause ()
 Pauses the loaded music file.
 
ctre::phoenix::StatusCode Stop ()
 Stops the loaded music file.
 
bool IsPlaying () const
 Gets whether the current track is actively playing.
 
double GetCurrentTime () const
 Gets the current timestamp of the music file.
 

Detailed Description

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.

Unless configs::AudioConfigs::AllowMusicDurDisable is enabled, 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 Pause or 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 AddInstrument.
  • Load the Chirp file to be played using LoadMusic. Both of these can also be done in the Orchestra constructor.

Once ready, the Orchestra can be controlled using Play/Pause/Stop. New music files can be loaded at any time.

Constructor & Destructor Documentation

◆ Orchestra() [1/6]

ctre::phoenix6::Orchestra::Orchestra ( )

Constructor for a new Orchestra.

◆ Orchestra() [2/6]

ctre::phoenix6::Orchestra::Orchestra ( char const * filepath)
inline

Constructor for a new Orchestra using the given Chirp file.

This API is blocking on the file read.

Parameters
filepathThe path to the music file to immediately load into the orchestra.

◆ Orchestra() [3/6]

ctre::phoenix6::Orchestra::Orchestra ( std::vector< hardware::ParentDevice * > const & instruments)
inline

Constructor for a new Orchestra using the given Chirp file.

Parameters
instrumentsA vector of device addresses that will be used as instruments in the orchestra.

◆ Orchestra() [4/6]

template<size_t N>
ctre::phoenix6::Orchestra::Orchestra ( std::array< hardware::ParentDevice *, N > const & instruments)
inline

Constructor for a new Orchestra using the given Chirp file.

Parameters
instrumentsAn array of device addresses that will be used as instruments in the orchestra.

◆ Orchestra() [5/6]

ctre::phoenix6::Orchestra::Orchestra ( std::vector< hardware::ParentDevice * > const & instruments,
char const * filepath )
inline

Constructor for a new Orchestra using the given Chirp file.

This API is blocking on the file read.

Parameters
instrumentsA vector of device addresses that will be used as instruments in the orchestra.
filepathThe path to the music file to immediately load into the orchestra.

◆ Orchestra() [6/6]

template<size_t N>
ctre::phoenix6::Orchestra::Orchestra ( std::array< hardware::ParentDevice *, N > const & instruments,
char const * filepath )
inline

Constructor for a new Orchestra using the given Chirp file.

This API is blocking on the file read.

Parameters
instrumentsAn array of device addresses that will be used as instruments in the orchestra.
filepathThe path to the music file to immediately load into the orchestra.

◆ ~Orchestra()

ctre::phoenix6::Orchestra::~Orchestra ( )

Member Function Documentation

◆ AddInstrument() [1/2]

ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::AddInstrument ( hardware::ParentDevice const & instrument)

Adds an instrument to the orchestra.

This adds the instrument to the next track; it does not wrap back to track 0 if all tracks have been filled. To assign multiple instruments to a track, use AddInstrument(hardware::ParentDevice const &, uint16_t).

Parameters
instrumentThe device to add to the orchestra
Returns
Status code of adding the device

◆ AddInstrument() [2/2]

ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::AddInstrument ( hardware::ParentDevice const & instrument,
uint16_t trackNumber )

Adds an instrument to the orchestra on the given track.

This can be used to assign multiple instruments to a track.

Parameters
instrumentThe device to add to the orchestra
trackNumberThe track number the device should play, starting at 0
Returns
Status code of adding the device

◆ ClearInstruments()

ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::ClearInstruments ( )

Clears all instruments in the orchestra.

Returns
Status code of clearing all devices

◆ GetCurrentTime()

double ctre::phoenix6::Orchestra::GetCurrentTime ( ) const

Gets the current timestamp of the music file.

The timestamp will reset to zero whenever LoadMusic or Stop is called.

If 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

◆ IsPlaying()

bool ctre::phoenix6::Orchestra::IsPlaying ( ) const

Gets whether the current track is actively playing.

Returns
true if Orchestra is playing the music file

◆ LoadMusic()

ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::LoadMusic ( char const * filepath)

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.

This API is blocking on the file read.

Parameters
filepathThe path to the Chirp file
Returns
Status code of loading the Chirp file

◆ Pause()

ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::Pause ( )

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

◆ Play()

ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::Play ( )

Plays the loaded music file.

If the player is paused, this will resume the orchestra.

Returns
Status code of playing the orchestra

◆ Stop()

ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::Stop ( )

Stops the loaded music file.

This resets the current position in the track to the start.

Returns
Status code of stopping the orchestra

The documentation for this class was generated from the following file: