Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable Climbing sound #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libraries/beeper/beeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ void beeper::setVelocity(double velocity) {
if( (beepTypeChange && !bst_isset(CLIMBING_ALARM) && !bst_isset(SINKING_ALARM) ) ||
(startAlarm) ) {
beepStartTime = millis();
beepFreqUpdatePosition = beepStartTime;
beepPaternBasePosition = 0.0;
beepPaternPosition = 0.0;
bst_set(BEEP_NEW_FREQ); //force changing freq
Expand Down Expand Up @@ -217,6 +218,10 @@ void beeper::setBeepPaternPosition(double velocity) {
if( currentLength + beepPaternBasePosition > beepPaternPosition ) {
beepPaternPosition = currentLength + beepPaternBasePosition;
}
if (currentTime > beepFreqUpdatePosition + CLIMBING_BEEP_FREQ_UPDATE && CLIMBING_BEEP_FREQ_UPDATE > 0) {
bst_set(BEEP_NEW_FREQ);
beepFreqUpdatePosition = currentTime;
}
} else {
beepPaternPosition = currentLength;
}
Expand Down
2 changes: 2 additions & 0 deletions libraries/beeper/beeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
/* climbing beep sound freq computation : BEEP_FREQ_COEFF * velocity + BEEP_BASE_FREQ */
#define CLIMBING_BEEP_BASE_FREQ 386.0
#define CLIMBING_BEEP_FREQ_COEFF 141.0
#define CLIMBING_BEEP_FREQ_UPDATE 1 // update climbing beep frequency(pitch) after X milliseconds. 0 = monotonous beep, do not update frequency while beep is playing. 1 = pitch changes smoothly every 1ms. more than 1 = pitch changed in steps every X milliseconds.

/* climbing beep velocity filter */
/* filteredVelocity = beepVelocity * BEEP_VELOCITY_FILTER_COEFF + BEEP_VELOCITY_FILTER_BASE */
Expand Down Expand Up @@ -141,6 +142,7 @@ class beeper {
double beepClimbingThreshold;
uint8_t volume;
unsigned long beepStartTime;
unsigned long beepFreqUpdatePosition;
double beepVelocity;
double beepFreq;
double beepPaternBasePosition;
Expand Down