From 06ce415b5aabeedbdbfd6d6773a5e092cff2be1a Mon Sep 17 00:00:00 2001 From: Franklin Hanson Date: Tue, 7 Oct 2025 13:24:30 -0400 Subject: [PATCH 1/2] Add ability to play random WAV files Wrapped the random SD wav commands --- src/hcr.cpp | 9 +++++++++ src/hcr.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/hcr.cpp b/src/hcr.cpp index dc8cd90..f930a72 100644 --- a/src/hcr.cpp +++ b/src/hcr.cpp @@ -462,6 +462,15 @@ void HCRVocalizer::PlayWAV(int ch,String file) { } } +void HCRVocalizer::PlayRandomWAV(int ch,String file1, String file2) { + if (millis() > lastPlayWAV) { + lastPlayWAV = millis() + 5000; + char channel[] = "VAB"; + String msg = "C" + ToString((char) channel[ch]) + file1 + "C" + ToString((char) channel[ch]) + file2 + ",QP" + ToString((char) channel[ch]); + sendCommand(msg); + } +} + void HCRVocalizer::StopWAV(int ch) { char channel[] = "VAB"; String msg = "PS" + ToString((char) channel[ch]) + ",QP" + ToString((char) channel[ch]); diff --git a/src/hcr.h b/src/hcr.h index aa307f9..c7abe11 100644 --- a/src/hcr.h +++ b/src/hcr.h @@ -211,6 +211,15 @@ class HCRVocalizer */ void PlayWAV(int v,String file); + /** + * @brief Plays a WAV file by file name + * + * @param v the channel (CH_A|CH_B) + * @param file1 the file name prefix (e.g. "0000") + * @param file2 the file name prefix (e.g. "0001") + */ + void PlayRandomWAV(int v,String file1, String file2); + /** * @brief Stops the WAV playing on the specified channel * From 23bc2bfdc42aa8fc1666d02f576fc20958365ec8 Mon Sep 17 00:00:00 2001 From: Franklin Hanson Date: Tue, 7 Oct 2025 14:39:24 -0400 Subject: [PATCH 2/2] Remove channel for second file concat --- src/hcr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hcr.cpp b/src/hcr.cpp index f930a72..9c1cedc 100644 --- a/src/hcr.cpp +++ b/src/hcr.cpp @@ -466,7 +466,7 @@ void HCRVocalizer::PlayRandomWAV(int ch,String file1, String file2) { if (millis() > lastPlayWAV) { lastPlayWAV = millis() + 5000; char channel[] = "VAB"; - String msg = "C" + ToString((char) channel[ch]) + file1 + "C" + ToString((char) channel[ch]) + file2 + ",QP" + ToString((char) channel[ch]); + String msg = "C" + ToString((char) channel[ch]) + file1 + "C" + file2 + ",QP" + ToString((char) channel[ch]); sendCommand(msg); } }