Browse Source

libtunes: renamed config_tone() to reset()

sbg
Alessandro Simovic 7 years ago committed by Beat Küng
parent
commit
4e479b7f04
  1. 10
      src/lib/tunes/tunes.cpp
  2. 6
      src/lib/tunes/tunes.h

10
src/lib/tunes/tunes.cpp

@ -59,14 +59,14 @@ Tunes::Tunes(unsigned default_tempo, unsigned default_octave, unsigned default_n @@ -59,14 +59,14 @@ Tunes::Tunes(unsigned default_tempo, unsigned default_octave, unsigned default_n
_default_mode(default_mode),
_default_octave(default_octave)
{
config_tone(false);
reset(false);
}
Tunes::Tunes(): Tunes(TUNE_DEFAULT_TEMPO, TUNE_DEFAULT_OCTAVE, TUNE_DEFAULT_NOTE_LENGTH, NoteMode::NORMAL)
{
}
void Tunes::config_tone(bool repeat_flag)
void Tunes::reset(bool repeat_flag)
{
// reset pointer
if (!repeat_flag) {
@ -122,7 +122,7 @@ int Tunes::set_control(const tune_control_s &tune_control) @@ -122,7 +122,7 @@ int Tunes::set_control(const tune_control_s &tune_control)
case static_cast<int>(TuneID::NOTIFY_NEUTRAL):
case static_cast<int>(TuneID::NOTIFY_NEGATIVE):
reset_playing_tune = true;
config_tone(false);
reset(false);
/* FALLTHROUGH */
default:
@ -358,12 +358,12 @@ int Tunes::get_next_tune(unsigned &frequency, unsigned &duration, @@ -358,12 +358,12 @@ int Tunes::get_next_tune(unsigned &frequency, unsigned &duration,
tune_error:
// syslog(LOG_ERR, "tune error\n");
_repeat = false; // don't loop on error
config_tone(_repeat);
reset(_repeat);
return TUNE_ERROR;
// stop (and potentially restart) the tune
tune_end:
// restore intial parameter
config_tone(_repeat);
reset(_repeat);
if (_repeat) {
return TUNE_CONTINUE;

6
src/lib/tunes/tunes.h

@ -203,8 +203,10 @@ private: @@ -203,8 +203,10 @@ private:
unsigned next_dots();
/**
* if repeat false set the tune parameters to default else point to the beginning of the tune
* Reset the tune parameters. This is necessary when for example a tune moved
* one or more octaves up or down. reset() should always be called before
* (re)-starting a tune.
*/
void config_tone(bool repeat);
void reset(bool repeat_flag);
};

Loading…
Cancel
Save