gb.sound.tone

Description

int8_t gb.sound.tone( uint32_t frequency [, int32_t duration = 0] )

gb.sound.tone plays a tone of a certain frequency for duration milliseconds. If duration is zero then it'll play indefinitally. It returns the track identifier or -1 on failure

Parameters

  • uint32_t frequency: frequency of the tone to play
  • int32_t duration (optional): duration in milliseconds for the tone to play

Returns

int8_t: track identifier or -1 on failure

Example

#include <Gamebuino-Meta.h>

void setup() {
gb.begin();
}

void loop() {
while(!gb.update());
if (gb.buttons.pressed(BUTTON_A)) {
// let's play a tone with a frequency of 220Hz for one second!
gb.sound.tone(220, 1000);
}
}