CTRE Phoenix C++ 5.33.1
Orchestra.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
6#include <vector>
7#include <string>
8
9namespace ctre {
10 namespace phoenix {
11 namespace music {
12
13 /**
14 * An Orchestra is used to play music through Talon FX motor controllers.
15 * It uses a "Chirp" (.chrp) music file that can be generated using Phoenix Tuner.
16 *
17 * Chirp files are generated from standard MIDI files.
18 * Each Talon FX can only play a single track within the music file.
19 * For multi-track files, multiple Talon FXs are needed.
20 * ie, The first track will be played through the first Talon FX added,
21 * the second track will be played through the second Talon FX added, etc.
22 *
23 * Any Chirp file located in the src/main/deploy directory of your FRC project
24 * will automatically be copied to the roboRIO on code deploy.
25 *
26 * To use the Orchestra:
27 * - Add the Talon FXs to be used as instruments
28 * - Load the Chirp file to be played using the LoadMusic routine.
29 *
30 * Once ready, the Orchestra can be controlled using standard
31 * play/pause/stop routines.
32 *
33 * New music files can be loaded at any time.
34 *
35 * The robot must be enabled to play music.
36 *
37 * Calling set on any of the TalonFX instruments while the orchestra is
38 * playing will pause the orchestra.
39 */
40 class Orchestra {
41 private:
42 void* m_handle;
43 public:
44 /**
45 * Constructor for an Orchestra Object.
46 * Call AddInstrument after this to add the instruments.
47 */
49 /**
50 * Loads a Chirp file at the specified file path.
51 *
52 * If the Chirp file is inside your "src/main/deploy" directory
53 * this file will be automatically deployed to a default directory in
54 * the RoboRIO when you deploy code. For these files, the name and file
55 * extension is sufficient.
56 *
57 * Use Tuner to create a Chirp file.
58 * @param filepath
59 * The path to the Chirp File.
60 * @return Error Code generated by function. 0 indicates no error.
61 */
62 ErrorCode LoadMusic(const std::string& filePath);
63 /**
64 * Plays the music file that's loaded.
65 * If the player is paused, this will resume.
66 * This will also resume a song if the orchestra was interrupted.
67 * @return Error Code generated by function. 0 indicates no error.
68 */
70 /**
71 * Pauses the music file that's loaded.
72 * This saves the current position in the track, so it can be resumed later.
73 * Pausing while stopped is an invalid request.
74 * @return Error Code generated by function. 0 indicates no error.
75 */
77 /**
78 * Stops the music file that's loaded.
79 * This resets the current position in the track to the start.
80 * @return Error Code generated by function. 0 indicates no error.
81 */
83 /**
84 * Returns whether the current track is actively playing or not
85 * @return True if playing, false otherwise
86 */
87 bool IsPlaying();
88 /**
89 * @return The current timestamp of the music file (playing or paused) in milliseconds.
90 * The timestamp will reset to zero whenever LoadMusic() or Stop() is called.
91 * If IsPlaying() returns false, this routine can be used to determine if music is stopped or paused.
92 */
93 uint32_t GetCurrentTime();
94 /**
95 * Adds another instrument to the orchestra.
96 * @param instrument
97 * TalonFX to add to orchestra
98 * @return Error Code generated by function. 0 indicates no error.
99 */
100 [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
101 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
102 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
104 /**
105 * Clears all instruments in the orchestra.
106 * @return Error Code generated by function. 0 indicates no error.
107 */
109 };
110 }
111 }
112}
CTRE Talon FX Motor Controller when used on CAN Bus.
Definition: TalonFX.h:219
An Orchestra is used to play music through Talon FX motor controllers.
Definition: Orchestra.h:40
bool IsPlaying()
Returns whether the current track is actively playing or not.
ErrorCode AddInstrument(ctre::phoenix::motorcontrol::can::TalonFX &instrument)
Adds another instrument to the orchestra.
Orchestra()
Constructor for an Orchestra Object.
ErrorCode Stop()
Stops the music file that's loaded.
ErrorCode LoadMusic(const std::string &filePath)
Loads a Chirp file at the specified file path.
ErrorCode Pause()
Pauses the music file that's loaded.
ErrorCode ClearInstruments()
Clears all instruments in the orchestra.
ErrorCode Play()
Plays the music file that's loaded.
ErrorCode
Definition: ErrorCode.h:13
namespace ctre
Definition: paramEnum.h:5