diff --git a/companion/src/companion.qrc b/companion/src/companion.qrc
index 9c7399586..792e2f494 100644
--- a/companion/src/companion.qrc
+++ b/companion/src/companion.qrc
@@ -1273,6 +1273,22 @@
themes/yerico/48/stop.png
themes/yerico/48/write_eeprom.png
themes/yerico/48/sdsync.png
+ sounds/0.wav
+ sounds/1.wav
+ sounds/2.wav
+ sounds/3.wav
+ sounds/4.wav
+ sounds/5.wav
+ sounds/6.wav
+ sounds/7.wav
+ sounds/8.wav
+ sounds/9.wav
+ sounds/10.wav
+ sounds/11.wav
+ sounds/12.wav
+ sounds/13.wav
+ sounds/14.wav
+ sounds/15.wav
images/layouts/mask_layout1+2.png
diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp
index faa57c7c5..1d3135432 100644
--- a/companion/src/helpers.cpp
+++ b/companion/src/helpers.cpp
@@ -260,7 +260,7 @@ bool displayT16ImportWarning()
void Helpers::populateFileComboBox(QComboBox * b, const QSet & set, const QString & current)
{
b->clear();
- b->addItem("----");
+ b->addItem(CPN_STR_NONE_ITEM);
bool added = false;
// Convert set into list and sort it alphabetically case insensitive
@@ -283,7 +283,7 @@ void Helpers::populateFileComboBox(QComboBox * b, const QSet & set, con
void Helpers::getFileComboBoxValue(QComboBox * b, char * dest, int length)
{
memset(dest, 0, length+1);
- if (b->currentText() != "----") {
+ if (b->currentText() != CPN_STR_NONE_ITEM) {
strncpy(dest, b->currentText().toLatin1(), length);
}
}
diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp
index 78a63fe87..ef9fe88ee 100644
--- a/companion/src/modeledit/customfunctions.cpp
+++ b/companion/src/modeledit/customfunctions.cpp
@@ -242,29 +242,40 @@ void CustomFunctionsPanel::onMediaPlayerError(QMediaPlayer::Error error)
bool CustomFunctionsPanel::playSound(int index)
{
- QString path = g.profile[g.id()].sdPath();
- if (!QDir(path).exists())
- return false; // unlikely
+ QString path;
- if (mediaPlayer)
- stopSound(mediaPlayerCurrent);
-
- if (firmware->getCapability(VoicesAsNumbers)) { // AVR
- path.append(QString("/%1.wav").arg(int(fswtchParam[index]->value()), 4, 10, QChar('0')));
+ if (functions[index].func == FuncPlaySound) {
+ path = QString(":/sounds/%1.wav").arg(functions[index].param);
}
else {
- QString lang(generalSettings.ttsLanguage);
- if (lang.isEmpty())
- lang = "en";
- path.append(QString("/SOUNDS/%1/%2.wav").arg(lang).arg(fswtchParamArmT[index]->currentText()));
+ path = g.profile[g.id()].sdPath();
+ if (!QDir(path).exists())
+ return false; // unlikely
+
+ if (firmware->getCapability(VoicesAsNumbers)) { // AVR
+ path.append(QString("/%1.wav").arg(int(fswtchParam[index]->value()), 4, 10, QChar('0')));
+ }
+ else {
+ QString lang(generalSettings.ttsLanguage);
+ if (lang.isEmpty())
+ lang = "en";
+ path.append(QString("/SOUNDS/%1/%2.wav").arg(lang).arg(fswtchParamArmT[index]->currentText()));
+ }
}
+
if (!QFileInfo::exists(path) || !QFileInfo(path).isReadable()) {
QMessageBox::critical(this, CPN_STR_TTL_ERROR, tr("Unable to find or open sound file:\n%1").arg(path));
return false;
}
+ if (mediaPlayer)
+ stopSound(mediaPlayerCurrent);
+
mediaPlayer = new QMediaPlayer(this, QMediaPlayer::LowLatency);
- mediaPlayer->setMedia(QUrl::fromLocalFile(path));
+ if (functions[index].func == FuncPlaySound)
+ mediaPlayer->setMedia(QUrl(path.prepend("qrc")));
+ else
+ mediaPlayer->setMedia(QUrl::fromLocalFile(path));
connect(mediaPlayer, &QMediaPlayer::stateChanged, this, &CustomFunctionsPanel::onMediaPlayerStateChanged);
connect(mediaPlayer, static_cast(&QMediaPlayer::error), this, &CustomFunctionsPanel::onMediaPlayerError);
mediaPlayerCurrent = index;
@@ -489,7 +500,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
}
Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
- if (fswtchParamArmT[i]->currentText() != "----") {
+ if (fswtchParamArmT[i]->currentText() != CPN_STR_NONE_ITEM) {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
}
}
@@ -500,7 +511,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
}
Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
- if (fswtchParamArmT[i]->currentText() != "----") {
+ if (fswtchParamArmT[i]->currentText() != CPN_STR_NONE_ITEM) {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
}
}
@@ -508,7 +519,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
if (modified)
cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
- widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
+ widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_PLAY;
}
else if (func == FuncPlayHaptic) {
if (modified)
diff --git a/companion/src/sounds/0.wav b/companion/src/sounds/0.wav
new file mode 100755
index 000000000..aef8ea150
Binary files /dev/null and b/companion/src/sounds/0.wav differ
diff --git a/companion/src/sounds/1.wav b/companion/src/sounds/1.wav
new file mode 100755
index 000000000..77ddee4b5
Binary files /dev/null and b/companion/src/sounds/1.wav differ
diff --git a/companion/src/sounds/10.wav b/companion/src/sounds/10.wav
new file mode 100755
index 000000000..4e9c8ef03
Binary files /dev/null and b/companion/src/sounds/10.wav differ
diff --git a/companion/src/sounds/11.wav b/companion/src/sounds/11.wav
new file mode 100755
index 000000000..34ca0dfcf
Binary files /dev/null and b/companion/src/sounds/11.wav differ
diff --git a/companion/src/sounds/12.wav b/companion/src/sounds/12.wav
new file mode 100755
index 000000000..53cfce363
Binary files /dev/null and b/companion/src/sounds/12.wav differ
diff --git a/companion/src/sounds/13.wav b/companion/src/sounds/13.wav
new file mode 100755
index 000000000..64249a8ff
Binary files /dev/null and b/companion/src/sounds/13.wav differ
diff --git a/companion/src/sounds/14.wav b/companion/src/sounds/14.wav
new file mode 100755
index 000000000..a738278df
Binary files /dev/null and b/companion/src/sounds/14.wav differ
diff --git a/companion/src/sounds/15.wav b/companion/src/sounds/15.wav
new file mode 100755
index 000000000..a8d816000
Binary files /dev/null and b/companion/src/sounds/15.wav differ
diff --git a/companion/src/sounds/2.wav b/companion/src/sounds/2.wav
new file mode 100755
index 000000000..dba5e34c0
Binary files /dev/null and b/companion/src/sounds/2.wav differ
diff --git a/companion/src/sounds/3.wav b/companion/src/sounds/3.wav
new file mode 100755
index 000000000..cb0fbed7f
Binary files /dev/null and b/companion/src/sounds/3.wav differ
diff --git a/companion/src/sounds/4.wav b/companion/src/sounds/4.wav
new file mode 100755
index 000000000..32e9670a6
Binary files /dev/null and b/companion/src/sounds/4.wav differ
diff --git a/companion/src/sounds/5.wav b/companion/src/sounds/5.wav
new file mode 100755
index 000000000..42261baf2
Binary files /dev/null and b/companion/src/sounds/5.wav differ
diff --git a/companion/src/sounds/6.wav b/companion/src/sounds/6.wav
new file mode 100755
index 000000000..264f7cd85
Binary files /dev/null and b/companion/src/sounds/6.wav differ
diff --git a/companion/src/sounds/7.wav b/companion/src/sounds/7.wav
new file mode 100755
index 000000000..209307325
Binary files /dev/null and b/companion/src/sounds/7.wav differ
diff --git a/companion/src/sounds/8.wav b/companion/src/sounds/8.wav
new file mode 100755
index 000000000..c90fcce9a
Binary files /dev/null and b/companion/src/sounds/8.wav differ
diff --git a/companion/src/sounds/9.wav b/companion/src/sounds/9.wav
new file mode 100755
index 000000000..4fa91f35e
Binary files /dev/null and b/companion/src/sounds/9.wav differ