mavsdk::Tune Class Reference

#include: tune.h


Enable creating and sending a tune to be played on the system.

Data Structures

struct TuneDescription

Public Types

Type Description
enum SongElement An element of the tune.
enum Result Possible results returned for tune requests.
std::function< void(Result)> ResultCallback Callback type for asynchronous Tune calls.

Public Member Functions

Type Name Description
  Tune (System & system) Constructor. Creates the plugin for a specific System.
  Tune (std::shared_ptr< System > system) Constructor. Creates the plugin for a specific System.
  ~Tune () override Destructor (internal use only).
  Tune (const Tune & other) Copy constructor.
void play_tune_async (TuneDescription tune_description, const ResultCallback callback) Send a tune to be played by the system.
Result play_tune (TuneDescription tune_description)const Send a tune to be played by the system.
const Tune & operator= (const Tune &)=delete Equality operator (object is not copyable).

Constructor & Destructor Documentation

Tune()

mavsdk::Tune::Tune(System &system)

Constructor. Creates the plugin for a specific System.

The plugin is typically created as shown below:

auto tune = Tune(system);

Parameters

  • System& system - The specific system associated with this plugin.

Tune()

mavsdk::Tune::Tune(std::shared_ptr< System > system)

Constructor. Creates the plugin for a specific System.

The plugin is typically created as shown below:

auto tune = Tune(system);

Parameters

  • std::shared_ptr< System > system - The specific system associated with this plugin.

~Tune()

mavsdk::Tune::~Tune() override

Destructor (internal use only).

Tune()

mavsdk::Tune::Tune(const Tune &other)

Copy constructor.

Parameters

  • const Tune& other -

Member Typdef Documentation

typedef ResultCallback

using mavsdk::Tune::ResultCallback =  std::function<void(Result)>

Callback type for asynchronous Tune calls.

Member Enumeration Documentation

enum SongElement

An element of the tune.

Value Description
StyleLegato After this element, start playing legato.
StyleNormal After this element, start playing normal.
StyleStaccato After this element, start playing staccato.
Duration1 After this element, set the note duration to 1.
Duration2 After this element, set the note duration to 2.
Duration4 After this element, set the note duration to 4.
Duration8 After this element, set the note duration to 8.
Duration16 After this element, set the note duration to 16.
Duration32 After this element, set the note duration to 32.
NoteA Play note A.
NoteB Play note B.
NoteC Play note C.
NoteD Play note D.
NoteE Play note E.
NoteF Play note F.
NoteG Play note G.
NotePause Play a rest.
Sharp After this element, sharp the note (half a step up).
Flat After this element, flat the note (half a step down).
OctaveUp After this element, shift the note 1 octave up.
OctaveDown After this element, shift the note 1 octave down.

enum Result

Possible results returned for tune requests.

Value Description
Unknown Unknown result.
Success Request succeeded.
InvalidTempo Invalid tempo (range: 32 - 255).
TuneTooLong Invalid tune: encoded string must be at most 247 chars.
Error Failed to send the request.
NoSystem No system connected.

Member Function Documentation

play_tune_async()

void mavsdk::Tune::play_tune_async(TuneDescription tune_description, const ResultCallback callback)

Send a tune to be played by the system.

This function is non-blocking. See 'play_tune' for the blocking counterpart.

Parameters

play_tune()

Result mavsdk::Tune::play_tune(TuneDescription tune_description) const

Send a tune to be played by the system.

This function is blocking. See 'play_tune_async' for the non-blocking counterpart.

Parameters

Returns

Result - Result of request.

operator=()

const Tune& mavsdk::Tune::operator=(const Tune &)=delete

Equality operator (object is not copyable).

Parameters

Returns

 const Tune & -

© MAVSDK Development Team 2017-2023. License: CC BY 4.0            Updated: 2023-12-27 03:10:20

results matching ""

    No results matching ""