|
111 | 111 |
|
112 | 112 | static volatile bool disableSoundProcessing = false; // if true, sound processing (FFT, filters, AGC) will be suspended. "volatile" as its shared between tasks. |
113 | 113 | static uint8_t audioSyncEnabled = AUDIOSYNC_NONE; // bit field: bit 0 - send, bit 1 - receive, bit 2 - use local if not receiving |
| 114 | +static bool audioSyncSequence = true; // if true, the receiver will drop out-of-sequence packets |
114 | 115 | static bool udpSyncConnected = false; // UDP connection status -> true if connected to multicast group |
115 | 116 |
|
116 | 117 | #define NUM_GEQ_CHANNELS 16 // number of frequency channels. Don't change !! |
@@ -1577,6 +1578,7 @@ class AudioReactive : public Usermod { |
1577 | 1578 | if(receivedPacket->frameCounter > lastFrameCounter) sequenceOK = true; // sequence OK |
1578 | 1579 | if((lastFrameCounter < 12) && (receivedPacket->frameCounter > 248)) sequenceOK = false; // prevent sequence "roll-back" due to late packets (1->254) |
1579 | 1580 | if((lastFrameCounter > 248) && (receivedPacket->frameCounter < 12)) sequenceOK = true; // handle roll-over (255 -> 0) |
| 1581 | + if(audioSyncSequence == false) sequenceOK = true; // sequence checking disabled by user |
1580 | 1582 | if((sequenceOK == false) && (receivedPacket->frameCounter != 0)) { // always accept "0" - its the legacy value |
1581 | 1583 | DEBUGSR_PRINTF("Skipping audio frame out of order or duplicated - %u vs %u\n", lastFrameCounter, receivedPacket->frameCounter); |
1582 | 1584 | return false; // reject out-of sequence frame |
@@ -2415,7 +2417,10 @@ class AudioReactive : public Usermod { |
2415 | 2417 | if (audioSyncEnabled && udpSyncConnected && (millis() - last_UDPTime < AUDIOSYNC_IDLE_MS)) { |
2416 | 2418 | if (receivedFormat == 1) infoArr.add(F(" v1")); |
2417 | 2419 | if (receivedFormat == 2) infoArr.add(F(" v2")); |
2418 | | - if (receivedFormat == 3) infoArr.add(F(" v2+")); |
| 2420 | + if (receivedFormat == 3) { |
| 2421 | + if (audioSyncSequence) infoArr.add(F(" v2+")); // Sequence checking enabled |
| 2422 | + else infoArr.add(F(" v2")); |
| 2423 | + } |
2419 | 2424 | } |
2420 | 2425 |
|
2421 | 2426 | #if defined(WLED_DEBUG) || defined(SR_DEBUG) || defined(SR_STATS) |
@@ -2567,6 +2572,7 @@ class AudioReactive : public Usermod { |
2567 | 2572 | JsonObject sync = top.createNestedObject("sync"); |
2568 | 2573 | sync[F("port")] = audioSyncPort; |
2569 | 2574 | sync[F("mode")] = audioSyncEnabled; |
| 2575 | + sync[F("check_sequence")] = audioSyncSequence; |
2570 | 2576 | } |
2571 | 2577 |
|
2572 | 2578 |
|
@@ -2635,6 +2641,7 @@ class AudioReactive : public Usermod { |
2635 | 2641 |
|
2636 | 2642 | configComplete &= getJsonValue(top["sync"][F("port")], audioSyncPort); |
2637 | 2643 | configComplete &= getJsonValue(top["sync"][F("mode")], audioSyncEnabled); |
| 2644 | + configComplete &= getJsonValue(top["sync"][F("check_sequence")], audioSyncSequence); |
2638 | 2645 |
|
2639 | 2646 | return configComplete; |
2640 | 2647 | } |
@@ -2813,7 +2820,12 @@ class AudioReactive : public Usermod { |
2813 | 2820 | #ifdef ARDUINO_ARCH_ESP32 |
2814 | 2821 | oappend(SET_F("addOption(dd,'Receive or Local',6);")); // AUDIOSYNC_REC_PLUS |
2815 | 2822 | #endif |
2816 | | - oappend(SET_F("addInfo('AudioReactive:sync:mode',1,'<br> Sync audio data with other WLEDs');")); |
| 2823 | + // check_sequence: Receiver skips out-of-sequence packets when enabled |
| 2824 | + oappend(SET_F("dd=addDropdown('AudioReactive','sync:check_sequence');")); |
| 2825 | + oappend(SET_F("addOption(dd,'Off',0);")); |
| 2826 | + oappend(SET_F("addOption(dd,'On',1);")); |
| 2827 | + |
| 2828 | + oappend(SET_F("addInfo('AudioReactive:sync:check_sequence',1,'<i>when receiving</i> ☾<br> Sync audio data with other WLEDs');")); // must append this to the last field of 'sync' |
2817 | 2829 |
|
2818 | 2830 | oappend(SET_F("addInfo('AudioReactive:digitalmic:type',1,'<i>requires reboot!</i>');")); // 0 is field type, 1 is actual field |
2819 | 2831 | #ifdef ARDUINO_ARCH_ESP32 |
@@ -2856,7 +2868,7 @@ class AudioReactive : public Usermod { |
2856 | 2868 | oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',5,' ⎌',")); oappendi(ES7243_SCLPIN); oappend(");"); |
2857 | 2869 | #endif |
2858 | 2870 | oappend(SET_F("dRO('AudioReactive:digitalmic:pin[]',5);")); // disable read only pins |
2859 | | -#endif |
| 2871 | +#endif |
2860 | 2872 | } |
2861 | 2873 |
|
2862 | 2874 |
|
|
0 commit comments