diff --git a/src/lib/tunes/tunes.cpp b/src/lib/tunes/tunes.cpp index a1548b4634..a820038f8e 100644 --- a/src/lib/tunes/tunes.cpp +++ b/src/lib/tunes/tunes.cpp @@ -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) case static_cast(TuneID::NOTIFY_NEUTRAL): case static_cast(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, 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; diff --git a/src/lib/tunes/tunes.h b/src/lib/tunes/tunes.h index 7b4b5507f0..160a6f6fa1 100644 --- a/src/lib/tunes/tunes.h +++ b/src/lib/tunes/tunes.h @@ -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); };