Browse Source

Enhances buzzer audibility on small piezos

Adjusts the duration and tempo of several buzzer melodies to make them more perceptible. Specifically, the advert sent and generic toggle sounds are modified with longer note durations and slower tempos, improving their clarity on typical small piezo speakers.
pull/2665/head
Mark Jocas 2 months ago
parent
commit
24b9bab4f1
No known key found for this signature in database GPG Key ID: F75EF1C43FC564B4
  1. 2
      examples/companion_radio/ui-new/UITask.cpp
  2. 2
      examples/companion_radio/ui-orig/UITask.cpp
  3. 2
      examples/companion_radio/ui-tiny/UITask.cpp
  4. 3
      src/helpers/ui/buzzer.cpp

2
examples/companion_radio/ui-new/UITask.cpp

@ -610,7 +610,7 @@ switch(t){
buzzer.play("ack:d=32,o=8,b=120:c"); buzzer.play("ack:d=32,o=8,b=120:c");
break; break;
case UIEventType::advertSent: case UIEventType::advertSent:
buzzer.play("Advert:d=16,o=6,b=240:c,e,g,c7"); buzzer.play("Advert:d=8,o=6,b=180:c,e,g,c7");
break; break;
case UIEventType::roomMessage: case UIEventType::roomMessage:
case UIEventType::newContactMessage: case UIEventType::newContactMessage:

2
examples/companion_radio/ui-orig/UITask.cpp

@ -104,7 +104,7 @@ switch(t){
buzzer.play("ack:d=32,o=8,b=120:c"); buzzer.play("ack:d=32,o=8,b=120:c");
break; break;
case UIEventType::advertSent: case UIEventType::advertSent:
buzzer.play("Advert:d=16,o=6,b=240:c,e,g,c7"); buzzer.play("Advert:d=8,o=6,b=180:c,e,g,c7");
break; break;
case UIEventType::roomMessage: case UIEventType::roomMessage:
case UIEventType::newContactMessage: case UIEventType::newContactMessage:

2
examples/companion_radio/ui-tiny/UITask.cpp

@ -482,7 +482,7 @@ switch(t){
buzzer.play("ack:d=32,o=8,b=120:c"); buzzer.play("ack:d=32,o=8,b=120:c");
break; break;
case UIEventType::advertSent: case UIEventType::advertSent:
buzzer.play("Advert:d=16,o=6,b=240:c,e,g,c7"); buzzer.play("Advert:d=8,o=6,b=180:c,e,g,c7");
break; break;
case UIEventType::roomMessage: case UIEventType::roomMessage:
case UIEventType::newContactMessage: case UIEventType::newContactMessage:

3
src/helpers/ui/buzzer.cpp

@ -50,7 +50,8 @@ void genericBuzzer::playToggle(int count, bool enabled) {
if (count < 1) count = 1; if (count < 1) count = 1;
if (count > max_notes) count = max_notes; if (count > max_notes) count = max_notes;
char melody[64]; char melody[64];
int n = snprintf(melody, sizeof(melody), "Tg:d=16,o=6,b=200:"); // d=8 (eighths) at b=180 -> ~166 ms per note, audible on small piezos.
int n = snprintf(melody, sizeof(melody), "Tg:d=8,o=6,b=180:");
for (int i = 0; i < count && n < (int)sizeof(melody); i++) { for (int i = 0; i < count && n < (int)sizeof(melody); i++) {
int idx = enabled ? i : (count - 1 - i); int idx = enabled ? i : (count - 1 - i);
n += snprintf(melody + n, sizeof(melody) - n, "%s%s", i ? "," : "", notes[idx]); n += snprintf(melody + n, sizeof(melody) - n, "%s%s", i ? "," : "", notes[idx]);

Loading…
Cancel
Save