Mobile native Wearable native

Tone Player: Playing Tones

This tutorial demonstrates how you can play audio tones.

Warm-up

Become familiar with the Tone Player API basics by learning about:

Initializing the Tone Player

To initialize the tone player for use:

  1. To use the functions and data types of the Tone Player API (in mobile and wearable applications), include the <tone_player.h> and <sound_manager.h> header files in your application:

    #include <tone_player.h>
    #include <sound_manager.h>
    
  2. To start using the tone player, declare a player ID variable for identifying the tone player:

    int tone_player_id;
    

Playing a Tone

To start and stop playing a tone:

  1. To start playback, use the tone_player_start() function.

    The tone_type_e (in mobile and wearable applications) and sound_type_e (in mobile and wearable applications) enumerators define the available values for the tone type (first parameter) and sound type (second parameter).

    tone_player_start(TONE_TYPE_DEFAULT, SOUND_TYPE_MEDIA, -1, &tone_player_id);
    

    The player ID is assigned and returned if the function succeeds. The ID of the tone player that starts first is 0, the ID of the second one is 1, and so on. If you set the player ID parameter to NULL, the ID is not returned.

  2. To stop playback, use the tone_player_stop() function with the ID of the player you want to stop:

    tone_player_stop(tone_player_id);
    

Playing a Tone for a Specified Duration

To play a tone for a specified duration, use the tone_player_start() function with the duration (third parameter) set to the number of milliseconds you want playback to last:

tone_player_start(TONE_TYPE_SUP_CONGESTION, SOUND_TYPE_CALL, 1000, &tone_player_id);

When you set the duration to a specified time, playback stops automatically after that time. You can also stop playback manually using the tone_player_stop() function.

Go to top