CTRE Phoenix C++ 5.33.1
ctre::phoenix::music::Orchestra Class Reference

An Orchestra is used to play music through Talon FX motor controllers. More...

#include <ctre/phoenix/music/Orchestra.h>

Public Member Functions

 Orchestra ()
 Constructor for an Orchestra Object. More...
 
ErrorCode LoadMusic (const std::string &filePath)
 Loads a Chirp file at the specified file path. More...
 
ErrorCode Play ()
 Plays the music file that's loaded. More...
 
ErrorCode Pause ()
 Pauses the music file that's loaded. More...
 
ErrorCode Stop ()
 Stops the music file that's loaded. More...
 
bool IsPlaying ()
 Returns whether the current track is actively playing or not. More...
 
uint32_t GetCurrentTime ()
 
ErrorCode AddInstrument (ctre::phoenix::motorcontrol::can::TalonFX &instrument)
 Adds another instrument to the orchestra. More...
 
ErrorCode ClearInstruments ()
 Clears all instruments in the orchestra. More...
 

Detailed Description

An Orchestra is used to play music through Talon FX motor controllers.

It uses a "Chirp" (.chrp) music file that can be generated using Phoenix Tuner.

Chirp files are generated from standard MIDI files. Each Talon FX can only play a single track within the music file. For multi-track files, multiple Talon FXs are needed. ie, 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.

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

To use the Orchestra:

  • Add the Talon FXs to be used as instruments
  • Load the Chirp file to be played using the LoadMusic routine.

Once ready, the Orchestra can be controlled using standard play/pause/stop routines.

New music files can be loaded at any time.

The robot must be enabled to play music.

Calling set on any of the TalonFX instruments while the orchestra is playing will pause the orchestra.

Constructor & Destructor Documentation

◆ Orchestra()

ctre::phoenix::music::Orchestra::Orchestra ( )

Constructor for an Orchestra Object.

Call AddInstrument after this to add the instruments.

Member Function Documentation

◆ AddInstrument()

ErrorCode ctre::phoenix::music::Orchestra::AddInstrument ( ctre::phoenix::motorcontrol::can::TalonFX instrument)

Adds another instrument to the orchestra.

Parameters
instrumentTalonFX to add to orchestra
Returns
Error Code generated by function. 0 indicates no error.

◆ ClearInstruments()

ErrorCode ctre::phoenix::music::Orchestra::ClearInstruments ( )

Clears all instruments in the orchestra.

Returns
Error Code generated by function. 0 indicates no error.

◆ GetCurrentTime()

uint32_t ctre::phoenix::music::Orchestra::GetCurrentTime ( )
Returns
The current timestamp of the music file (playing or paused) in milliseconds. The timestamp will reset to zero whenever LoadMusic() or Stop() is called. If IsPlaying() returns false, this routine can be used to determine if music is stopped or paused.

◆ IsPlaying()

bool ctre::phoenix::music::Orchestra::IsPlaying ( )

Returns whether the current track is actively playing or not.

Returns
True if playing, false otherwise

◆ LoadMusic()

ErrorCode ctre::phoenix::music::Orchestra::LoadMusic ( const std::string &  filePath)

Loads a Chirp file at the specified file path.

If the Chirp file is inside your "src/main/deploy" directory this file will be automatically deployed to a default directory in the RoboRIO when you deploy code. For these files, the name and file extension is sufficient.

Use Tuner to create a Chirp file.

Parameters
filepathThe path to the Chirp File.
Returns
Error Code generated by function. 0 indicates no error.

◆ Pause()

ErrorCode ctre::phoenix::music::Orchestra::Pause ( )

Pauses the music file that's loaded.

This saves the current position in the track, so it can be resumed later. Pausing while stopped is an invalid request.

Returns
Error Code generated by function. 0 indicates no error.

◆ Play()

ErrorCode ctre::phoenix::music::Orchestra::Play ( )

Plays the music file that's loaded.

If the player is paused, this will resume. This will also resume a song if the orchestra was interrupted.

Returns
Error Code generated by function. 0 indicates no error.

◆ Stop()

ErrorCode ctre::phoenix::music::Orchestra::Stop ( )

Stops the music file that's loaded.

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

Returns
Error Code generated by function. 0 indicates no error.

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