CTRE Phoenix 6 C++ 25.0.0-beta-4
|
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. | |
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:
Once ready, the Orchestra can be controlled using Play/Pause/Stop. New music files can be loaded at any time.
ctre::phoenix6::Orchestra::Orchestra | ( | ) |
Constructor for a new Orchestra.
|
inline |
Constructor for a new Orchestra using the given Chirp file.
This API is blocking on the file read.
filepath | The path to the music file to immediately load into the orchestra. |
|
inline |
Constructor for a new Orchestra using the given Chirp file.
instruments | A vector of device addresses that will be used as instruments in the orchestra. |
|
inline |
Constructor for a new Orchestra using the given Chirp file.
instruments | An array of device addresses that will be used as instruments in the orchestra. |
|
inline |
Constructor for a new Orchestra using the given Chirp file.
This API is blocking on the file read.
instruments | A vector of device addresses that will be used as instruments in the orchestra. |
filepath | The path to the music file to immediately load into the orchestra. |
|
inline |
Constructor for a new Orchestra using the given Chirp file.
This API is blocking on the file read.
instruments | An array of device addresses that will be used as instruments in the orchestra. |
filepath | The path to the music file to immediately load into the orchestra. |
ctre::phoenix6::Orchestra::~Orchestra | ( | ) |
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).
instrument | The device to add to the orchestra |
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.
instrument | The device to add to the orchestra |
trackNumber | The track number the device should play, starting at 0 |
ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::ClearInstruments | ( | ) |
Clears all instruments in the orchestra.
double ctre::phoenix6::Orchestra::GetCurrentTime | ( | ) | const |
bool ctre::phoenix6::Orchestra::IsPlaying | ( | ) | const |
Gets whether the current track is actively playing.
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.
filepath | The path to the Chirp file |
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.
ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::Play | ( | ) |
Plays the loaded music file.
If the player is paused, this will resume the orchestra.
ctre::phoenix::StatusCode ctre::phoenix6::Orchestra::Stop | ( | ) |
Stops the loaded music file.
This resets the current position in the track to the start.