Table of Contents

Class Orchestra

Namespace
CTRE.Phoenix6
Assembly
Phoenix6.Hardware.dll

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 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: 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.
public class Orchestra
Inheritance
Orchestra
Inherited Members

Constructors

Orchestra()

Constructor for a new Orchestra.

public Orchestra()

Orchestra(params IEnumerable<CommonDevice>)

Constructor for a new Orchestra using the given instruments.

public Orchestra(params IEnumerable<CommonDevice> instruments)

Parameters

instruments IEnumerable<CommonDevice>

A collection of devices that will be used as instruments in the orchestra.

Orchestra(string)

Constructor for a new Orchestra using the given Chirp file.

This API is blocking on the file read.
public Orchestra(string filepath)

Parameters

filepath string

The path to the music file to immediately load into Orchestra

Orchestra(string, params IEnumerable<CommonDevice>)

Constructor for a new Orchestra using the given instruments and chirp file.

This API is blocking on the file read.
public Orchestra(string filepath, params IEnumerable<CommonDevice> instruments)

Parameters

filepath string

The path to the music file to immediately load into the orchestra.

instruments IEnumerable<CommonDevice>

A collection of devices that will be used as instruments in the orchestra.

Properties

CurrentTime

Gets the current timestamp of the music file in seconds. The timestamp will reset to zero whenever LoadMusic(string) or Stop() is called.

If IsPlaying() returns false, this method can be used to determine if the music is stopped or paused.
public double CurrentTime { get; }

Property Value

double

Methods

AddInstrument(CommonDevice)

Adds an instrument to the orchestra

public StatusCode AddInstrument(CommonDevice instrument)

Parameters

instrument CommonDevice

The device to add to the orchestra

Returns

StatusCode

Status code of adding the device

AddInstrument(CommonDevice, ushort)

Adds an instrument to the given track.

public StatusCode AddInstrument(CommonDevice instrument, ushort trackNumber)

Parameters

instrument CommonDevice

The device to add to the orchestra

trackNumber ushort

The track number the device should play, starting at 0

Returns

StatusCode

Status code of adding the device

ClearInstruments()

Clears all instruments in the orchestra.

public StatusCode ClearInstruments()

Returns

StatusCode

Status code of clearing all devices

Close()

Closes this Orchestra Instance

public void Close()

IsPlaying()

Gets whether the current track is actively playing.

public bool IsPlaying()

Returns

bool

true if the Orchestra is playing the music file.

LoadMusic(string)

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.
public StatusCode LoadMusic(string filepath)

Parameters

filepath string

The path to the Chirp file

Returns

StatusCode

Status code of loading the Chirp file

Pause()

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

public StatusCode Pause()

Returns

StatusCode

Status code of pausing the orchestra

Play()

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

public StatusCode Play()

Returns

StatusCode

Status code of playing the orchestra

Stop()

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

public StatusCode Stop()

Returns

StatusCode

Status code of stopping the orchestra