mirror of https://github.com/sipwise/sems.git
Those are from branch pbx/2.3-ha-sw-pbx: * 0925459 - dsm:mod_utils: utils.getCountRight / getCountLeft actions to get number filenames (3 weeks ago) <Stefan Sayer> * ef1d8c8 - dsm:mod_conference: conference.playMixInList action (3 weeks ago) <Stefan Sayer> * 74f59b7 - core:advanced_audio:mixin: allow generic AmAudio for mixin (3 weeks ago) <Stefan Sayer> * c897661 - dsm: clearArray and clearStruct actions (5 weeks ago) <Stefan Sayer> * ec1d1de - dsm: arrayIndex action: get the index of a string in a var array (5 weeks ago) <Stefan Sayer>changes/66/1066/1
parent
017449bf66
commit
22e0c3c0f4
@ -1,3 +1,8 @@
|
||||
sipwise/sw_vcs.patch
|
||||
sipwise/0001-core-advanced_audio-mixin-allow-generic-AmAudio-for-.patch
|
||||
sipwise/0002-dsm-mod_conference-conference.playMixInList-action.patch
|
||||
sipwise/0003-dsm-mod_utils-utils.getCountRight-getCountLeft-actio.patch
|
||||
sipwise/0004-dsm-arrayIndex-action-get-the-index-of-a-string-in-a.patch
|
||||
sipwise/0005-dsm-clearArray-and-clearStruct-actions.patch
|
||||
no_config.patch
|
||||
py_sems_path.patch
|
||||
|
||||
@ -0,0 +1,100 @@
|
||||
From 74f59b78e447cecd1fb926354ecb7244dbfcc18f Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Sayer <stefan.sayer@googlemail.com>
|
||||
Date: Wed, 10 Dec 2014 13:33:05 +0100
|
||||
Subject: [PATCH 1/4] core:advanced_audio:mixin: allow generic AmAudio for
|
||||
mixin
|
||||
|
||||
---
|
||||
core/AmAudioMixIn.cpp | 24 ++++++++++++++++--------
|
||||
core/AmAudioMixIn.h | 6 +++---
|
||||
2 files changed, 19 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/core/AmAudioMixIn.cpp b/core/AmAudioMixIn.cpp
|
||||
index 4bfa782..7f35077 100644
|
||||
--- a/core/AmAudioMixIn.cpp
|
||||
+++ b/core/AmAudioMixIn.cpp
|
||||
@@ -30,7 +30,7 @@
|
||||
#define IS_ONLY_ONCE (flags & AUDIO_MIXIN_ONCE)
|
||||
#define IS_IMMEDIATE_START (flags & AUDIO_MIXIN_IMMEDIATE_START)
|
||||
|
||||
-AmAudioMixIn::AmAudioMixIn(AmAudio* A, AmAudioFile* B,
|
||||
+AmAudioMixIn::AmAudioMixIn(AmAudio* A, AmAudio* B,
|
||||
unsigned int s, double l,
|
||||
unsigned int flags)
|
||||
: A(A),B(B), s(s), l(l),
|
||||
@@ -71,10 +71,14 @@ int AmAudioMixIn::get(unsigned long long system_ts, unsigned char* buffer,
|
||||
if (res <= 0) { // B empty
|
||||
res = A->get(system_ts, buffer, output_sample_rate, nb_samples);
|
||||
mixing = false;
|
||||
- if (IS_ONLY_ONCE)
|
||||
+ if (IS_ONLY_ONCE) {
|
||||
B = NULL;
|
||||
- else
|
||||
- B->rewind();
|
||||
+ } else {
|
||||
+ AmAudioFile* B_file = dynamic_cast<AmAudioFile*>(B);
|
||||
+ if (NULL != B_file) {
|
||||
+ B_file->rewind();
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
B_mut.unlock();
|
||||
return res;
|
||||
@@ -110,10 +114,14 @@ int AmAudioMixIn::get(unsigned long long system_ts, unsigned char* buffer,
|
||||
if (len<0) { // B finished
|
||||
mixing = false;
|
||||
|
||||
- if (IS_ONLY_ONCE)
|
||||
+ if (IS_ONLY_ONCE) {
|
||||
B = NULL;
|
||||
- else
|
||||
- B->rewind();
|
||||
+ } else {
|
||||
+ AmAudioFile* B_file = dynamic_cast<AmAudioFile*>(B);
|
||||
+ if (NULL != B_file) {
|
||||
+ B_file->rewind();
|
||||
+ }
|
||||
+ }
|
||||
} else {
|
||||
for (int i=0; i<(PCM16_B2S(len)); i++) {
|
||||
pdest[i]+=(short)(((double)mix_buf[i])*l);
|
||||
@@ -135,7 +143,7 @@ int AmAudioMixIn::put(unsigned long long system_ts, unsigned char* buffer,
|
||||
return -1;
|
||||
}
|
||||
|
||||
-void AmAudioMixIn::mixin(AmAudioFile* f) {
|
||||
+void AmAudioMixIn::mixin(AmAudio* f) {
|
||||
B_mut.lock();
|
||||
B = f;
|
||||
mixing = next_start_ts_i = false; /* so that mix in will re-start */
|
||||
diff --git a/core/AmAudioMixIn.h b/core/AmAudioMixIn.h
|
||||
index 59b57d2..e8bfdb8 100644
|
||||
--- a/core/AmAudioMixIn.h
|
||||
+++ b/core/AmAudioMixIn.h
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
class AmAudioMixIn : public AmAudio {
|
||||
AmAudio* A;
|
||||
- AmAudioFile* B;
|
||||
+ AmAudio* B;
|
||||
unsigned int s;
|
||||
double l;
|
||||
int flags;
|
||||
@@ -68,12 +68,12 @@ class AmAudioMixIn : public AmAudio {
|
||||
|
||||
|
||||
public:
|
||||
- AmAudioMixIn(AmAudio* A, AmAudioFile* B,
|
||||
+ AmAudioMixIn(AmAudio* A, AmAudio* B,
|
||||
unsigned int s, double l,
|
||||
unsigned int flags = 0);
|
||||
~AmAudioMixIn();
|
||||
|
||||
- void mixin(AmAudioFile* f);
|
||||
+ void mixin(AmAudio* f);
|
||||
|
||||
protected:
|
||||
// not used
|
||||
--
|
||||
1.9.3 (Apple Git-50)
|
||||
|
||||
@ -0,0 +1,123 @@
|
||||
From ef1d8c8f6e74383615f4c7e3d0a72e387134d0cd Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Sayer <stefan.sayer@googlemail.com>
|
||||
Date: Wed, 10 Dec 2014 13:33:26 +0100
|
||||
Subject: [PATCH 2/4] dsm:mod_conference: conference.playMixInList action
|
||||
|
||||
uses a playlist to mix in files into a list
|
||||
---
|
||||
apps/dsm/mods/mod_conference/ModConference.cpp | 55 +++++++++++++++++++++++++-
|
||||
apps/dsm/mods/mod_conference/ModConference.h | 2 +
|
||||
doc/dsm/mods/Readme.mod_conference.txt | 4 ++
|
||||
3 files changed, 59 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/apps/dsm/mods/mod_conference/ModConference.cpp b/apps/dsm/mods/mod_conference/ModConference.cpp
|
||||
index 07a3e39..6137989 100644
|
||||
--- a/apps/dsm/mods/mod_conference/ModConference.cpp
|
||||
+++ b/apps/dsm/mods/mod_conference/ModConference.cpp
|
||||
@@ -49,7 +49,8 @@ MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
|
||||
DEF_CMD("conference.teeleave", ConfTeeLeaveAction);
|
||||
|
||||
DEF_CMD("conference.setupMixIn", ConfSetupMixInAction);
|
||||
- DEF_CMD("conference.playMixIn", ConfPlayMixInAction);
|
||||
+ DEF_CMD("conference.playMixIn", ConfPlayMixInAction);
|
||||
+ DEF_CMD("conference.playMixInList", ConfPlayMixInListAction);
|
||||
|
||||
} MOD_ACTIONEXPORT_END;
|
||||
|
||||
@@ -175,7 +176,8 @@ EXEC_ACTION_START(ConfJoinAction) {
|
||||
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
|
||||
}
|
||||
} EXEC_ACTION_END;
|
||||
-
|
||||
+
|
||||
+// get conference channel or other object (mixer etc)
|
||||
template<class T>
|
||||
static T* getDSMConfChannel(DSMSession* sc_sess, const char* key_name) {
|
||||
if (sc_sess->avar.find(key_name) == sc_sess->avar.end()) {
|
||||
@@ -399,3 +401,52 @@ EXEC_ACTION_START(ConfPlayMixInAction) {
|
||||
m->mixin(af);
|
||||
|
||||
} EXEC_ACTION_END;
|
||||
+
|
||||
+
|
||||
+EXEC_ACTION_START(ConfPlayMixInListAction) {
|
||||
+ string filename = resolveVars(arg, sess, sc_sess, event_params);
|
||||
+
|
||||
+ bool has_playlist = true;
|
||||
+ // get playlist
|
||||
+ DSMDisposableT<AmPlaylist >* l_obj =
|
||||
+ getDSMConfChannel<DSMDisposableT<AmPlaylist> >(sc_sess, CONF_AKEY_MIXLIST);
|
||||
+ if (NULL == l_obj) {
|
||||
+ // playlist newly setup
|
||||
+ AmPlaylist* pl = new AmPlaylist(NULL); // no event receiver - no 'clear' event
|
||||
+ l_obj = new DSMDisposableT<AmPlaylist >(pl);
|
||||
+ AmArg c_arg;
|
||||
+ c_arg.setBorrowedPointer(l_obj);
|
||||
+ sc_sess->avar[CONF_AKEY_MIXLIST] = c_arg;
|
||||
+
|
||||
+ // add to garbage collector
|
||||
+ sc_sess->transferOwnership(l_obj);
|
||||
+ has_playlist = false;
|
||||
+ }
|
||||
+ AmPlaylist* l = l_obj->get();
|
||||
+
|
||||
+
|
||||
+ DSMDisposableAudioFile* af = new DSMDisposableAudioFile();
|
||||
+ if(af->open(filename,AmAudioFile::Read)) {
|
||||
+ ERROR("audio file '%s' could not be opened for reading.\n",
|
||||
+ filename.c_str());
|
||||
+ delete af;
|
||||
+
|
||||
+ throw DSMException("file", "path", filename);
|
||||
+ }
|
||||
+ sc_sess->transferOwnership(af);
|
||||
+
|
||||
+ DBG("adding file '%s' to mixin playlist\n", filename.c_str());
|
||||
+ l->addToPlaylist(new AmPlaylistItem(af, NULL));
|
||||
+
|
||||
+ if (!has_playlist) {
|
||||
+ // get mixin mixer
|
||||
+ DSMDisposableT<AmAudioMixIn >* m_obj =
|
||||
+ getDSMConfChannel<DSMDisposableT<AmAudioMixIn > >(sc_sess, CONF_AKEY_MIXER);
|
||||
+ if (NULL == m_obj) {
|
||||
+ throw DSMException("conference", "cause", "mixer not setup!\n");
|
||||
+ }
|
||||
+ AmAudioMixIn* m = m_obj->get();
|
||||
+ // play from list
|
||||
+ m->mixin(l);
|
||||
+ }
|
||||
+} EXEC_ACTION_END;
|
||||
diff --git a/apps/dsm/mods/mod_conference/ModConference.h b/apps/dsm/mods/mod_conference/ModConference.h
|
||||
index c1e29b2..52d59fd 100644
|
||||
--- a/apps/dsm/mods/mod_conference/ModConference.h
|
||||
+++ b/apps/dsm/mods/mod_conference/ModConference.h
|
||||
@@ -39,6 +39,7 @@ DECLARE_MODULE(MOD_CLS_NAME);
|
||||
#define CONF_AKEY_CHANNEL "conf.chan"
|
||||
#define CONF_AKEY_DEF_TEECHANNEL "conf.teechan"
|
||||
#define CONF_AKEY_MIXER "conf.mixer"
|
||||
+#define CONF_AKEY_MIXLIST "conf.mixlist"
|
||||
|
||||
/** holds a conference channel */
|
||||
class DSMConfChannel
|
||||
@@ -94,5 +95,6 @@ DEF_ACTION_1P(ConfTeeLeaveAction);
|
||||
|
||||
DEF_ACTION_2P(ConfSetupMixInAction);
|
||||
DEF_ACTION_1P(ConfPlayMixInAction);
|
||||
+DEF_ACTION_1P(ConfPlayMixInListAction);
|
||||
|
||||
#endif
|
||||
diff --git a/doc/dsm/mods/Readme.mod_conference.txt b/doc/dsm/mods/Readme.mod_conference.txt
|
||||
index 1df3b3e..71189df 100644
|
||||
--- a/doc/dsm/mods/Readme.mod_conference.txt
|
||||
+++ b/doc/dsm/mods/Readme.mod_conference.txt
|
||||
@@ -48,3 +48,7 @@ conference.setupMixIn(float level, unsigned int seconds)
|
||||
|
||||
conference.playMixIn(string filename)
|
||||
- mix in a file
|
||||
+
|
||||
+conference.playMixInList(string filename)
|
||||
+ - add a file to the mix-in playlist
|
||||
+ - the list is setup when this is called for the first time and set as mixin source
|
||||
--
|
||||
1.9.3 (Apple Git-50)
|
||||
|
||||
@ -0,0 +1,233 @@
|
||||
From 0925459582f1148cfe726fa2fd40068e9d6a6233 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Sayer <stefan.sayer@googlemail.com>
|
||||
Date: Wed, 10 Dec 2014 14:06:36 +0100
|
||||
Subject: [PATCH 3/4] dsm:mod_utils: utils.getCountRight / getCountLeft actions
|
||||
to get number filenames
|
||||
|
||||
---
|
||||
apps/dsm/mods/mod_utils/ModUtils.cpp | 147 +++++++++++++++++++++++++++++++++++
|
||||
apps/dsm/mods/mod_utils/ModUtils.h | 5 ++
|
||||
doc/dsm/mods/Readme.mod_utils.txt | 16 +++-
|
||||
3 files changed, 167 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/apps/dsm/mods/mod_utils/ModUtils.cpp b/apps/dsm/mods/mod_utils/ModUtils.cpp
|
||||
index 987ed79..8856204 100644
|
||||
--- a/apps/dsm/mods/mod_utils/ModUtils.cpp
|
||||
+++ b/apps/dsm/mods/mod_utils/ModUtils.cpp
|
||||
@@ -41,6 +41,11 @@ MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
|
||||
|
||||
DEF_CMD("utils.playCountRight", SCUPlayCountRightAction);
|
||||
DEF_CMD("utils.playCountLeft", SCUPlayCountLeftAction);
|
||||
+ DEF_CMD("utils.getCountRight", SCUGetCountRightAction);
|
||||
+ DEF_CMD("utils.getCountLeft", SCUGetCountLeftAction);
|
||||
+ DEF_CMD("utils.getCountRightNoSuffix", SCUGetCountRightNoSuffixAction);
|
||||
+ DEF_CMD("utils.getCountLeftNoSuffix", SCUGetCountLeftNoSuffixAction);
|
||||
+
|
||||
DEF_CMD("utils.getNewId", SCGetNewIdAction);
|
||||
DEF_CMD("utils.spell", SCUSpellAction);
|
||||
DEF_CMD("utils.rand", SCURandomAction);
|
||||
@@ -57,6 +62,47 @@ MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
|
||||
|
||||
MOD_CONDITIONEXPORT_NONE(MOD_CLS_NAME);
|
||||
|
||||
+vector<string> utils_get_count_files(DSMSession* sc_sess, unsigned int cnt,
|
||||
+ const string& basedir, const string& suffix, bool right) {
|
||||
+
|
||||
+ vector<string> res;
|
||||
+
|
||||
+ if (cnt <= 20) {
|
||||
+ res.push_back(basedir+int2str(cnt)+suffix);
|
||||
+ return res;
|
||||
+ }
|
||||
+
|
||||
+ for (int i=9;i>1;i--) {
|
||||
+ div_t num = div(cnt, (int)pow(10.,i));
|
||||
+ if (num.quot) {
|
||||
+ res.push_back(basedir+int2str(int(num.quot * pow(10.,i)))+suffix);
|
||||
+ }
|
||||
+ cnt = num.rem;
|
||||
+ }
|
||||
+
|
||||
+ if (!cnt)
|
||||
+ return res;
|
||||
+
|
||||
+ if ((cnt <= 20) || (!(cnt%10))) {
|
||||
+ res.push_back(basedir+int2str(cnt)+suffix);
|
||||
+ return res;
|
||||
+ }
|
||||
+
|
||||
+ div_t num = div(cnt, 10);
|
||||
+ if (right) {
|
||||
+ // language has single digits before 10s
|
||||
+ res.push_back(basedir+int2str(num.quot * 10)+suffix);
|
||||
+ res.push_back(basedir+("x"+int2str(num.rem))+suffix);
|
||||
+ } else {
|
||||
+ // language has single digits before 10s
|
||||
+ res.push_back(basedir+("x"+int2str(num.rem))+suffix);
|
||||
+ res.push_back(basedir+int2str(num.quot * 10)+suffix);
|
||||
+ }
|
||||
+
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+
|
||||
bool utils_play_count(DSMSession* sc_sess, unsigned int cnt,
|
||||
const string& basedir, const string& suffix, bool right) {
|
||||
|
||||
@@ -131,6 +177,107 @@ EXEC_ACTION_START(SCUPlayCountLeftAction) {
|
||||
sc_sess->CLR_ERRNO;
|
||||
} EXEC_ACTION_END;
|
||||
|
||||
+
|
||||
+CONST_ACTION_2P(SCUGetCountRightAction, ',', true);
|
||||
+EXEC_ACTION_START(SCUGetCountRightAction) {
|
||||
+ string cnt_s = resolveVars(par1, sess, sc_sess, event_params);
|
||||
+ string basedir = resolveVars(par2, sess, sc_sess, event_params);
|
||||
+
|
||||
+ unsigned int cnt = 0;
|
||||
+ if (str2i(cnt_s,cnt)) {
|
||||
+ ERROR("could not parse count '%s'\n", cnt_s.c_str());
|
||||
+ sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
|
||||
+ sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ vector<string> filenames = utils_get_count_files(sc_sess, cnt, basedir, ".wav", true);
|
||||
+
|
||||
+ cnt=0;
|
||||
+ for (vector<string>::iterator it=filenames.begin();it!=filenames.end();it++) {
|
||||
+ sc_sess->var["count_file["+int2str(cnt)+"]"]=*it;
|
||||
+ cnt++;
|
||||
+ }
|
||||
+
|
||||
+ sc_sess->CLR_ERRNO;
|
||||
+} EXEC_ACTION_END;
|
||||
+
|
||||
+
|
||||
+CONST_ACTION_2P(SCUGetCountLeftAction, ',', true);
|
||||
+EXEC_ACTION_START(SCUGetCountLeftAction) {
|
||||
+ string cnt_s = resolveVars(par1, sess, sc_sess, event_params);
|
||||
+ string basedir = resolveVars(par2, sess, sc_sess, event_params);
|
||||
+
|
||||
+ unsigned int cnt = 0;
|
||||
+ if (str2i(cnt_s,cnt)) {
|
||||
+ ERROR("could not parse count '%s'\n", cnt_s.c_str());
|
||||
+ sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
|
||||
+ sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ vector<string> filenames = utils_get_count_files(sc_sess, cnt, basedir, ".wav", false);
|
||||
+
|
||||
+ cnt=0;
|
||||
+ for (vector<string>::iterator it=filenames.begin();it!=filenames.end();it++) {
|
||||
+ sc_sess->var["count_file["+int2str(cnt)+"]"]=*it;
|
||||
+ cnt++;
|
||||
+ }
|
||||
+
|
||||
+ sc_sess->CLR_ERRNO;
|
||||
+} EXEC_ACTION_END;
|
||||
+
|
||||
+
|
||||
+CONST_ACTION_2P(SCUGetCountRightNoSuffixAction, ',', true);
|
||||
+EXEC_ACTION_START(SCUGetCountRightNoSuffixAction) {
|
||||
+ string cnt_s = resolveVars(par1, sess, sc_sess, event_params);
|
||||
+ string basedir = resolveVars(par2, sess, sc_sess, event_params);
|
||||
+
|
||||
+ unsigned int cnt = 0;
|
||||
+ if (str2i(cnt_s,cnt)) {
|
||||
+ ERROR("could not parse count '%s'\n", cnt_s.c_str());
|
||||
+ sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
|
||||
+ sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ vector<string> filenames = utils_get_count_files(sc_sess, cnt, basedir, "", true);
|
||||
+
|
||||
+ cnt=0;
|
||||
+ for (vector<string>::iterator it=filenames.begin();it!=filenames.end();it++) {
|
||||
+ sc_sess->var["count_file["+int2str(cnt)+"]"]=*it;
|
||||
+ cnt++;
|
||||
+ }
|
||||
+
|
||||
+ sc_sess->CLR_ERRNO;
|
||||
+} EXEC_ACTION_END;
|
||||
+
|
||||
+
|
||||
+CONST_ACTION_2P(SCUGetCountLeftNoSuffixAction, ',', true);
|
||||
+EXEC_ACTION_START(SCUGetCountLeftNoSuffixAction) {
|
||||
+ string cnt_s = resolveVars(par1, sess, sc_sess, event_params);
|
||||
+ string basedir = resolveVars(par2, sess, sc_sess, event_params);
|
||||
+
|
||||
+ unsigned int cnt = 0;
|
||||
+ if (str2i(cnt_s,cnt)) {
|
||||
+ ERROR("could not parse count '%s'\n", cnt_s.c_str());
|
||||
+ sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
|
||||
+ sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ vector<string> filenames = utils_get_count_files(sc_sess, cnt, basedir, "", false);
|
||||
+
|
||||
+ cnt=0;
|
||||
+ for (vector<string>::iterator it=filenames.begin();it!=filenames.end();it++) {
|
||||
+ sc_sess->var["count_file["+int2str(cnt)+"]"]=*it;
|
||||
+ cnt++;
|
||||
+ }
|
||||
+
|
||||
+ sc_sess->CLR_ERRNO;
|
||||
+} EXEC_ACTION_END;
|
||||
+
|
||||
+
|
||||
EXEC_ACTION_START(SCGetNewIdAction) {
|
||||
string d = resolveVars(arg, sess, sc_sess, event_params);
|
||||
sc_sess->var[d]=AmSession::getNewId();
|
||||
diff --git a/apps/dsm/mods/mod_utils/ModUtils.h b/apps/dsm/mods/mod_utils/ModUtils.h
|
||||
index aaf89c7..744e2ea 100644
|
||||
--- a/apps/dsm/mods/mod_utils/ModUtils.h
|
||||
+++ b/apps/dsm/mods/mod_utils/ModUtils.h
|
||||
@@ -37,6 +37,11 @@ DECLARE_MODULE(MOD_CLS_NAME);
|
||||
|
||||
DEF_ACTION_2P(SCUPlayCountRightAction);
|
||||
DEF_ACTION_2P(SCUPlayCountLeftAction);
|
||||
+DEF_ACTION_2P(SCUGetCountRightAction);
|
||||
+DEF_ACTION_2P(SCUGetCountLeftAction);
|
||||
+DEF_ACTION_2P(SCUGetCountRightNoSuffixAction);
|
||||
+DEF_ACTION_2P(SCUGetCountLeftNoSuffixAction);
|
||||
+
|
||||
DEF_ACTION_1P(SCGetNewIdAction);
|
||||
DEF_ACTION_2P(SCUSpellAction);
|
||||
DEF_ACTION_2P(SCURandomAction);
|
||||
diff --git a/doc/dsm/mods/Readme.mod_utils.txt b/doc/dsm/mods/Readme.mod_utils.txt
|
||||
index 413f670..09a668a 100644
|
||||
--- a/doc/dsm/mods/Readme.mod_utils.txt
|
||||
+++ b/doc/dsm/mods/Readme.mod_utils.txt
|
||||
@@ -7,10 +7,24 @@ Actions:
|
||||
* sets $errno (arg)
|
||||
|
||||
utils.playCountLeft(int cnt [, string basedir])
|
||||
- play count for laguages that have single digits befire the 10s (like german)
|
||||
+ play count for laguages that have single digits before the 10s (like german)
|
||||
* Throws "file" exeption with #path if file can not be opened
|
||||
* sets $errno (arg)
|
||||
|
||||
+ utils.getCountRight(int cnt [, string basedir])
|
||||
+ get filenames for a number for laguages that have single digits after the 10s (like english)
|
||||
+ into count_file[n] (i.e. count_file[0] .. count_file[n])
|
||||
+ * sets $errno (arg)
|
||||
+
|
||||
+ utils.getCountLeft(int cnt [, string basedir])
|
||||
+ get filenames for a number for laguages that have single digits before the 10s (like german)
|
||||
+ into count_file[n] (i.e. count_file[0] .. count_file[n])
|
||||
+ * sets $errno (arg)
|
||||
+
|
||||
+ utils.getCountRightNoSuffix(int cnt [, string basedir])
|
||||
+ utils.getCountLeftNoSuffix(int cnt [, string basedir])
|
||||
+ as above but without .wav suffix
|
||||
+
|
||||
utils.spell(string word[, string basedir])
|
||||
plays each character in the word (e.g. utils.spell(321,wav/digits/) plays
|
||||
wav/digits/3.wav, wav/digits/2.wav, wav/digits/1.wav
|
||||
--
|
||||
1.9.3 (Apple Git-50)
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
From ec1d1de937adcba32d34cebf2eb7b398b385dc50 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Sayer <stefan.sayer@googlemail.com>
|
||||
Date: Mon, 24 Nov 2014 22:03:44 +0100
|
||||
Subject: [PATCH 1/2] dsm: arrayIndex action: get the index of a string in a
|
||||
var array
|
||||
|
||||
---
|
||||
apps/dsm/DSMCoreModule.cpp | 30 ++++++++++++++++++++++++++++++
|
||||
apps/dsm/DSMCoreModule.h | 1 +
|
||||
doc/dsm/dsm_syntax.txt | 3 +++
|
||||
3 files changed, 34 insertions(+)
|
||||
|
||||
diff --git a/apps/dsm/DSMCoreModule.cpp b/apps/dsm/DSMCoreModule.cpp
|
||||
index 95453ec..fc9e43b 100644
|
||||
--- a/apps/dsm/DSMCoreModule.cpp
|
||||
+++ b/apps/dsm/DSMCoreModule.cpp
|
||||
@@ -99,6 +99,7 @@ DSMAction* DSMCoreModule::getAction(const string& from_str) {
|
||||
DEF_CMD("clear", SCClearAction);
|
||||
DEF_CMD("clearArray", SCClearArrayAction);
|
||||
DEF_CMD("size", SCSizeAction);
|
||||
+ DEF_CMD("arrayIndex", SCArrayIndexAction);
|
||||
DEF_CMD("logVars", SCLogVarsAction);
|
||||
DEF_CMD("logParams", SCLogParamsAction);
|
||||
DEF_CMD("logSelects", SCLogSelectsAction);
|
||||
@@ -881,6 +882,35 @@ EXEC_ACTION_START(SCSizeAction) {
|
||||
DBG("set $%s=%s\n", dst_name.c_str(), res.c_str());
|
||||
} EXEC_ACTION_END;
|
||||
|
||||
+CONST_ACTION_2P(SCArrayIndexAction, ',', false);
|
||||
+EXEC_ACTION_START(SCArrayIndexAction) {
|
||||
+ string array_name = par1;
|
||||
+ if (array_name.length() && array_name[0]=='$')
|
||||
+ array_name.erase(0,1);
|
||||
+
|
||||
+ string val = resolveVars(par2, sess, sc_sess, event_params);
|
||||
+ unsigned int i = 0;
|
||||
+ bool found = false;
|
||||
+ while (true) {
|
||||
+ VarMapT::iterator lb = sc_sess->var.find(array_name+"["+int2str(i)+"]");
|
||||
+ if (lb == sc_sess->var.end())
|
||||
+ break;
|
||||
+ if (val == lb->second) {
|
||||
+ found = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ i++;
|
||||
+ }
|
||||
+
|
||||
+ string res = found ? int2str(i) : "nil";
|
||||
+ if (par2[0]=='$') {
|
||||
+ sc_sess->var[par2.substr(1)+".index"] = res;
|
||||
+ DBG("set %s=%s\n", (par2+".index").c_str(), res.c_str());
|
||||
+ } else {
|
||||
+ sc_sess->var["index"] = res;
|
||||
+ DBG("set $index=%s\n", res.c_str());
|
||||
+ }
|
||||
+} EXEC_ACTION_END;
|
||||
|
||||
CONST_ACTION_2P(SCAppendAction,',', false);
|
||||
EXEC_ACTION_START(SCAppendAction) {
|
||||
diff --git a/apps/dsm/DSMCoreModule.h b/apps/dsm/DSMCoreModule.h
|
||||
index b5eefc3..a65616e 100644
|
||||
--- a/apps/dsm/DSMCoreModule.h
|
||||
+++ b/apps/dsm/DSMCoreModule.h
|
||||
@@ -94,6 +94,7 @@ DEF_ACTION_1P(SCIncAction);
|
||||
DEF_ACTION_1P(SCClearAction);
|
||||
DEF_ACTION_1P(SCClearArrayAction);
|
||||
DEF_ACTION_2P(SCSizeAction);
|
||||
+DEF_ACTION_2P(SCArrayIndexAction);
|
||||
DEF_ACTION_2P(SCSetTimerAction);
|
||||
DEF_ACTION_1P(SCRemoveTimerAction);
|
||||
DEF_ACTION_1P(SCRemoveTimersAction);
|
||||
diff --git a/doc/dsm/dsm_syntax.txt b/doc/dsm/dsm_syntax.txt
|
||||
index c104654..8bb6bb6 100644
|
||||
--- a/doc/dsm/dsm_syntax.txt
|
||||
+++ b/doc/dsm/dsm_syntax.txt
|
||||
@@ -109,6 +109,9 @@ DSM flow
|
||||
set variable $dst to size of array
|
||||
(e.g. $arrayname[0], $arrayname[1] set, $dst set to 2)
|
||||
|
||||
+ arrayIndex($array, key) - find key in $array, set $index to its index, or "nil" if not found
|
||||
+ arrayIndex($array, $var) - find $var in $array, set $var.index to its index, or "nil" if not found
|
||||
+
|
||||
inc($var)
|
||||
clear($var)
|
||||
clearArray($var)
|
||||
--
|
||||
1.9.3 (Apple Git-50)
|
||||
|
||||
@ -0,0 +1,97 @@
|
||||
From c8976619b1d32e1f433c166dfe04ab375932d253 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Sayer <stefan.sayer@googlemail.com>
|
||||
Date: Mon, 24 Nov 2014 22:40:20 +0100
|
||||
Subject: [PATCH 2/2] dsm: clearArray and clearStruct actions
|
||||
|
||||
---
|
||||
apps/dsm/DSMCoreModule.cpp | 26 ++++++++++++++++++++++++--
|
||||
apps/dsm/DSMCoreModule.h | 1 +
|
||||
doc/dsm/dsm_syntax.txt | 5 ++++-
|
||||
3 files changed, 29 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/apps/dsm/DSMCoreModule.cpp b/apps/dsm/DSMCoreModule.cpp
|
||||
index fc9e43b..6f1633f 100644
|
||||
--- a/apps/dsm/DSMCoreModule.cpp
|
||||
+++ b/apps/dsm/DSMCoreModule.cpp
|
||||
@@ -97,6 +97,7 @@ DSMAction* DSMCoreModule::getAction(const string& from_str) {
|
||||
DEF_CMD("inc", SCIncAction);
|
||||
DEF_CMD("log", SCLogAction);
|
||||
DEF_CMD("clear", SCClearAction);
|
||||
+ DEF_CMD("clearStruct", SCClearStructAction);
|
||||
DEF_CMD("clearArray", SCClearArrayAction);
|
||||
DEF_CMD("size", SCSizeAction);
|
||||
DEF_CMD("arrayIndex", SCArrayIndexAction);
|
||||
@@ -838,10 +839,10 @@ EXEC_ACTION_START(SCClearAction) {
|
||||
sc_sess->var.erase(var_name);
|
||||
} EXEC_ACTION_END;
|
||||
|
||||
-EXEC_ACTION_START(SCClearArrayAction) {
|
||||
+EXEC_ACTION_START(SCClearStructAction) {
|
||||
string varprefix = (arg.length() && arg[0] == '$')?
|
||||
arg.substr(1) : arg;
|
||||
- DBG("clear variable array '%s.*'\n", varprefix.c_str());
|
||||
+ DBG("clear variable struct '%s.*'\n", varprefix.c_str());
|
||||
|
||||
varprefix+=".";
|
||||
|
||||
@@ -857,6 +858,27 @@ EXEC_ACTION_START(SCClearArrayAction) {
|
||||
|
||||
} EXEC_ACTION_END;
|
||||
|
||||
+
|
||||
+EXEC_ACTION_START(SCClearArrayAction) {
|
||||
+ string varprefix = (arg.length() && arg[0] == '$')?
|
||||
+ arg.substr(1) : arg;
|
||||
+ DBG("clear variable array '%s[*'\n", varprefix.c_str());
|
||||
+
|
||||
+ varprefix+="[";
|
||||
+
|
||||
+ VarMapT::iterator lb = sc_sess->var.lower_bound(varprefix);
|
||||
+ while (lb != sc_sess->var.end()) {
|
||||
+ if ((lb->first.length() < varprefix.length()) ||
|
||||
+ strncmp(lb->first.c_str(), varprefix.c_str(),varprefix.length()))
|
||||
+ break;
|
||||
+ // fixme: check whether it's really an array index
|
||||
+ VarMapT::iterator lb_d = lb;
|
||||
+ lb++;
|
||||
+ sc_sess->var.erase(lb_d);
|
||||
+ }
|
||||
+
|
||||
+} EXEC_ACTION_END;
|
||||
+
|
||||
CONST_ACTION_2P(SCSizeAction, ',', false);
|
||||
EXEC_ACTION_START(SCSizeAction) {
|
||||
string array_name = par1;
|
||||
diff --git a/apps/dsm/DSMCoreModule.h b/apps/dsm/DSMCoreModule.h
|
||||
index a65616e..6ad0a91 100644
|
||||
--- a/apps/dsm/DSMCoreModule.h
|
||||
+++ b/apps/dsm/DSMCoreModule.h
|
||||
@@ -92,6 +92,7 @@ DEF_ACTION_2P(SCAppendAction);
|
||||
DEF_ACTION_2P(SCSubStrAction);
|
||||
DEF_ACTION_1P(SCIncAction);
|
||||
DEF_ACTION_1P(SCClearAction);
|
||||
+DEF_ACTION_1P(SCClearStructAction);
|
||||
DEF_ACTION_1P(SCClearArrayAction);
|
||||
DEF_ACTION_2P(SCSizeAction);
|
||||
DEF_ACTION_2P(SCArrayIndexAction);
|
||||
diff --git a/doc/dsm/dsm_syntax.txt b/doc/dsm/dsm_syntax.txt
|
||||
index 8bb6bb6..3cc8143 100644
|
||||
--- a/doc/dsm/dsm_syntax.txt
|
||||
+++ b/doc/dsm/dsm_syntax.txt
|
||||
@@ -114,9 +114,12 @@ DSM flow
|
||||
|
||||
inc($var)
|
||||
clear($var)
|
||||
- clearArray($var)
|
||||
+ clearStruct($var)
|
||||
clears all var.* variables
|
||||
+ clearArray($var)
|
||||
+ clears all var[* variables
|
||||
|
||||
+
|
||||
Playing prompts and file I/O
|
||||
----------------------------
|
||||
|
||||
--
|
||||
1.9.3 (Apple Git-50)
|
||||
|
||||
Loading…
Reference in new issue