speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/8] added pitch_range support to the msg_settings system, and de


From: Luke Yelavich
Subject: [PATCH 2/8] added pitch_range support to the msg_settings system, and defined macros in msg.h
Date: Fri, 24 Oct 2014 14:44:39 -0400

From: Hussain Jasim <address@hidden>
To: address@hidden

---
 src/server/configuration.c |  5 ++++
 src/server/msg.h           | 62 ++++++++++++++++++++++++----------------------
 src/server/output.c        |  2 ++
 src/server/parse.c         | 11 ++++++++
 src/server/set.c           | 19 ++++++++++++++
 src/server/set.h           |  3 +++
 6 files changed, 73 insertions(+), 29 deletions(-)

diff --git a/src/server/configuration.c b/src/server/configuration.c
index 5db1dbe..5d60dc5 100644
--- a/src/server/configuration.c
+++ b/src/server/configuration.c
@@ -189,6 +189,8 @@ GLOBAL_FDSET_OPTION_CB_STR(DefaultModule, output_module)
                           && (val <= +100), "Rate out of range.")
     GLOBAL_FDSET_OPTION_CB_INT(DefaultPitch, msg_settings.pitch, (val >= -100)
                           && (val <= +100), "Pitch out of range.")
+    GLOBAL_FDSET_OPTION_CB_INT(DefaultPitchRange, msg_settings.pitch_range, 
(val >= -100)
+                          && (val <= +100), "Pitch range out of range.")
     GLOBAL_FDSET_OPTION_CB_INT(DefaultVolume, msg_settings.volume, (val >= 
-100)
                           && (val <= +100), "Volume out of range.")
     GLOBAL_FDSET_OPTION_CB_INT(DefaultSpelling, msg_settings.spelling_mode, 1,
@@ -337,6 +339,7 @@ DOTCONF_CB(cb_BeginClient)
        /*  Warning: If you modify this, you must also modify 
update_cl_settings() in set.c ! */
        SET_PAR(msg_settings.rate, -101)
            SET_PAR(msg_settings.pitch, -101)
+           SET_PAR(msg_settings.pitch_range, -101)
            SET_PAR(msg_settings.volume, -101)
            SET_PAR(msg_settings.punctuation_mode, -1)
            SET_PAR(msg_settings.spelling_mode, -1)
@@ -411,6 +414,7 @@ configoption_t *load_config_options(int *num_options)
        ADD_CONFIG_OPTION(LanguageDefaultModule, ARG_LIST);
        ADD_CONFIG_OPTION(DefaultRate, ARG_INT);
        ADD_CONFIG_OPTION(DefaultPitch, ARG_INT);
+       ADD_CONFIG_OPTION(DefaultPitchRange, ARG_INT);
        ADD_CONFIG_OPTION(DefaultVolume, ARG_INT);
        ADD_CONFIG_OPTION(DefaultLanguage, ARG_STR);
        ADD_CONFIG_OPTION(DefaultPriority, ARG_STR);
@@ -445,6 +449,7 @@ void load_default_global_set_options()
        GlobalFDSet.msg_settings.spelling_mode = 0;
        GlobalFDSet.msg_settings.rate = 0;
        GlobalFDSet.msg_settings.pitch = 0;
+       GlobalFDSet.msg_settings.pitch_range = 0;
        GlobalFDSet.msg_settings.volume = 0;
        GlobalFDSet.client_name = g_strdup("unknown:unknown:unknown");
        GlobalFDSet.msg_settings.voice.language = g_strdup("en");
diff --git a/src/server/msg.h b/src/server/msg.h
index 4d9d2e5..5756b5d 100644
--- a/src/server/msg.h
+++ b/src/server/msg.h
@@ -28,31 +28,32 @@
 #define OK_PRIORITY_SET                         "202 OK PRIORITY SET\r\n"
 #define OK_RATE_SET                             "203 OK RATE SET\r\n"
 #define OK_PITCH_SET                           "204 OK PITCH SET\r\n"
-#define OK_PUNCT_MODE_SET                      "205 OK PUNCTUATION SET\r\n"
-#define OK_CAP_LET_RECOGN_SET                  "206 OK CAP LET RECOGNITION 
SET\r\n"
-#define OK_SPELLING_SET                                "207 OK SPELLING 
SET\r\n"
-#define OK_CLIENT_NAME_SET                     "208 OK CLIENT NAME SET\r\n"
-#define OK_VOICE_SET                           "209 OK VOICE SET\r\n"
-#define OK_STOPPED                              "210 OK STOPPED\r\n"
-#define OK_PAUSED                              "211 OK PAUSED\r\n"
-#define OK_RESUMED                             "212 OK RESUMED\r\n"
-#define OK_CANCELED                            "213 OK CANCELED\r\n"
-#define OK_TABLE_SET                            "215 OK TABLE SET\r\n"
-#define OK_OUTPUT_MODULE_SET                    "216 OK OUTPUT MODULE SET\r\n"
-#define OK_PAUSE_CONTEXT_SET                    "217 OK PAUSE CONTEXT SET\r\n"
-#define OK_VOLUME_SET                           "218 OK VOLUME SET\r\n"
-#define OK_SSML_MODE_SET                        "219 OK SSML MODE SET\r\n"
-#define OK_NOTIFICATION_SET                     "220 OK NOTIFICATION SET\r\n"
-
-#define OK_CUR_SET_FIRST                       "220 OK CURSOR SET FIRST\r\n"
-#define OK_CUR_SET_LAST                                "221 OK CURSOR SET 
LAST\r\n"
-#define OK_CUR_SET_POS                         "222 OK CURSOR SET TO 
POSITION\r\n"
-#define OK_CUR_MOV_FOR                         "223 OK CURSOR MOVED 
FORWARD\r\n"
-#define OK_CUR_MOV_BACK                                "224 OK CURSOR MOVED 
BACKWARD\r\n"
-#define C_OK_MESSAGE_QUEUED                     "225"
-#define OK_MESSAGE_QUEUED                      "225 OK MESSAGE QUEUED\r\n"
-#define OK_SND_ICON_QUEUED                     "226 OK SOUND ICON QUEUED\r\n"
-#define OK_MSG_CANCELED                                "227 OK MESSAGE 
CANCELED\r\n"
+#define OK_PITCH_RANGE_SET                     "205 OK PITCH RANGE SET\r\n"
+#define OK_PUNCT_MODE_SET                      "206 OK PUNCTUATION SET\r\n"
+#define OK_CAP_LET_RECOGN_SET                  "207 OK CAP LET RECOGNITION 
SET\r\n"
+#define OK_SPELLING_SET                                "208 OK SPELLING 
SET\r\n"
+#define OK_CLIENT_NAME_SET                     "209 OK CLIENT NAME SET\r\n"
+#define OK_VOICE_SET                           "210 OK VOICE SET\r\n"
+#define OK_STOPPED                              "211 OK STOPPED\r\n"
+#define OK_PAUSED                              "212 OK PAUSED\r\n"
+#define OK_RESUMED                             "213 OK RESUMED\r\n"
+#define OK_CANCELED                            "214 OK CANCELED\r\n"
+#define OK_TABLE_SET                            "216 OK TABLE SET\r\n"
+#define OK_OUTPUT_MODULE_SET                    "217 OK OUTPUT MODULE SET\r\n"
+#define OK_PAUSE_CONTEXT_SET                    "218 OK PAUSE CONTEXT SET\r\n"
+#define OK_VOLUME_SET                           "219 OK VOLUME SET\r\n"
+#define OK_SSML_MODE_SET                        "220 OK SSML MODE SET\r\n"
+#define OK_NOTIFICATION_SET                     "221 OK NOTIFICATION SET\r\n"
+
+#define OK_CUR_SET_FIRST                       "222 OK CURSOR SET FIRST\r\n"
+#define OK_CUR_SET_LAST                                "223 OK CURSOR SET 
LAST\r\n"
+#define OK_CUR_SET_POS                         "224 OK CURSOR SET TO 
POSITION\r\n"
+#define OK_CUR_MOV_FOR                         "225 OK CURSOR MOVED 
FORWARD\r\n"
+#define OK_CUR_MOV_BACK                                "226 OK CURSOR MOVED 
BACKWARD\r\n"
+#define C_OK_MESSAGE_QUEUED                     "227"
+#define OK_MESSAGE_QUEUED                      "227 OK MESSAGE QUEUED\r\n"
+#define OK_SND_ICON_QUEUED                     "228 OK SOUND ICON QUEUED\r\n"
+#define OK_MSG_CANCELED                                "229 OK MESSAGE 
CANCELED\r\n"
 
 #define OK_RECEIVE_DATA                                "230 OK RECEIVING 
DATA\r\n"
 #define OK_BYE                                 "231 HAPPY HACKING\r\n"
@@ -99,16 +100,19 @@
 #define ERR_RATE_TOO_LOW                        "410 ERR RATE TOO LOW\r\n"
 #define ERR_PITCH_TOO_HIGH                      "411 ERR PITCH TOO HIGH\r\n"
 #define ERR_PITCH_TOO_LOW                       "412 ERR PITCH TOO LOW\r\n"
-#define ERR_VOLUME_TOO_HIGH                      "413 ERR PITCH TOO HIGH\r\n"
-#define ERR_VOLUME_TOO_LOW                       "414 ERR PITCH TOO LOW\r\n"
+#define ERR_PITCH_RANGE_TOO_HIGH                "413 ERR PITCH RANGE TOO 
HIGH\r\n"
+#define ERR_PITCH_RANGE_TOO_LOW                 "414 ERR PITCH RANGE TOO 
LOW\r\n"
+#define ERR_VOLUME_TOO_HIGH                      "415 ERR VOLUME TOO HIGH\r\n"
+#define ERR_VOLUME_TOO_LOW                       "416 ERR VOLUME TOO LOW\r\n"
 
 #define ERR_INTERNAL                           "300 ERR INTERNAL\r\n"
 #define ERR_COULDNT_SET_PRIORITY                "301 ERR COULDNT SET 
PRIORITY\r\n"
 #define ERR_COULDNT_SET_LANGUAGE                "302 ERR COULDNT SET 
LANGUAGE\r\n"
 #define ERR_COULDNT_SET_RATE                    "303 ERR COULDNT SET RATE\r\n"
 #define ERR_COULDNT_SET_PITCH                   "304 ERR COULDNT SET PITCH\r\n"
-#define ERR_COULDNT_SET_PUNCT_MODE              "305 ERR COULDNT SET PUNCT 
MODE\r\n"
-#define ERR_COULDNT_SET_CAP_LET_RECOG           "306 ERR COULDNT SET CAP LET 
RECOGNITION\r\n"
+#define ERR_COULDNT_SET_PITCH_RANGE             "305 ERR COULDNT SET PITCH 
RANGE\r\n"
+#define ERR_COULDNT_SET_PUNCT_MODE              "306 ERR COULDNT SET PUNCT 
MODE\r\n"
+#define ERR_COULDNT_SET_CAP_LET_RECOG           "307 ERR COULDNT SET CAP LET 
RECOGNITION\r\n"
 #define ERR_COULDNT_SET_SPELLING                "308 ERR COULDNT SET 
SPELLING\r\n"
 #define ERR_COULDNT_SET_VOICE                   "309 ERR COULDNT SET VOICE\r\n"
 #define ERR_COULDNT_SET_TABLE                   "310 ERR COULDNT SET TABLE\r\n"
diff --git a/src/server/output.c b/src/server/output.c
index 22c1fd6..40b7e8c 100644
--- a/src/server/output.c
+++ b/src/server/output.c
@@ -405,6 +405,8 @@ output_send_settings(TSpeechDMessage *msg, OutputModule 
*output)
     set_str = g_string_new("");
     g_string_append_printf(set_str, "pitch=%d\n",
                            msg->settings.msg_settings.pitch);
+    g_string_append_printf(set_str, "pitch_range=%d\n",
+                           msg->settings.msg_settings.pitch_range);
     g_string_append_printf(set_str, "rate=%d\n",
                            msg->settings.msg_settings.rate);
     g_string_append_printf(set_str, "volume=%d\n",
diff --git a/src/server/parse.c b/src/server/parse.c
index f6f7c23..ad7ed81 100644
--- a/src/server/parse.c
+++ b/src/server/parse.c
@@ -491,6 +491,17 @@ parse_set(const char *buf, const int bytes, const int fd, 
const TSpeechDSock *sp
         if (ret) return g_strdup(ERR_COULDNT_SET_PITCH);
         return g_strdup(OK_PITCH_SET);
     }
+    else if (TEST_CMD(set_sub, "pitch_range")){
+        signed int pitch_range;
+        GET_PARAM_INT(pitch_range, 3);
+
+        if(pitch_range < -100) return g_strdup(ERR_PITCH_RANGE_TOO_LOW);
+        if(pitch_range > +100) return g_strdup(ERR_PITCH_RANGE_TOO_HIGH);
+
+        SSIP_SET_COMMAND(pitch_range);
+        if (ret) return g_strdup(ERR_COULDNT_SET_PITCH_RANGE);
+        return g_strdup(OK_PITCH_RANGE_SET);
+    }
     else if (TEST_CMD(set_sub, "volume")){
         signed int volume;
         GET_PARAM_INT(volume, 3);
diff --git a/src/server/set.c b/src/server/set.c
index bb13ad0..f8592b3 100644
--- a/src/server/set.c
+++ b/src/server/set.c
@@ -121,6 +121,23 @@ int set_pitch_uid(int uid, int pitch)
        return 0;
 }
 
+SET_SELF_ALL(int, pitch_range)
+
+int set_pitch_range_uid(int uid, int pitch_range)
+{
+       TFDSetElement *settings;
+
+       if ((pitch_range > 100) || (pitch_range < -100))
+               return 1;
+
+       settings = get_client_settings_by_uid(uid);
+       if (settings == NULL)
+               return 1;
+
+       settings->msg_settings.pitch_range = pitch_range;
+       return 0;
+}
+
 SET_SELF_ALL(int, volume)
 
 int set_volume_uid(int uid, int volume)
@@ -286,6 +303,7 @@ void update_cl_settings(gpointer data, gpointer user_data)
        /*  Warning: If you modify this, you must also modify cb_BeginClient in 
config.c ! */
        CHECK_SET_PAR(msg_settings.rate, -101)
            CHECK_SET_PAR(msg_settings.pitch, -101)
+           CHECK_SET_PAR(msg_settings.pitch_range, -101)
            CHECK_SET_PAR(msg_settings.volume, -101)
            CHECK_SET_PAR(msg_settings.punctuation_mode, -1)
            CHECK_SET_PAR(msg_settings.spelling_mode, -1)
@@ -485,6 +503,7 @@ TFDSetElement *default_fd_set(void)
            GlobalFDSet.msg_settings.punctuation_mode;
        new->msg_settings.rate = GlobalFDSet.msg_settings.rate;
        new->msg_settings.pitch = GlobalFDSet.msg_settings.pitch;
+       new->msg_settings.pitch_range = GlobalFDSet.msg_settings.pitch_range;
        new->msg_settings.volume = GlobalFDSet.msg_settings.volume;
        new->msg_settings.voice.language =
            g_strdup(GlobalFDSet.msg_settings.voice.language);
diff --git a/src/server/set.h b/src/server/set.h
index 90b5483..08866ab 100644
--- a/src/server/set.h
+++ b/src/server/set.h
@@ -37,6 +37,7 @@ int set_priority_uid(int uid, SPDPriority priority);
 int set_language_uid(int uid, char *language);
 int set_rate_uid(int uid, int rate);
 int set_pitch_uid(int uid, int pitch);
+int set_pitch_range_uid(int uid, int pitch_range);
 int set_volume_uid(int uid, int volume);
 int set_punct_mode_uid(int uid, int punct);
 int set_cap_let_recog_uid(int uid, int recog);
@@ -56,6 +57,7 @@ int set_priority_self(int fd, SPDPriority priority);
 int set_language_self(int fd, char *language);
 int set_rate_self(int fd, int rate);
 int set_pitch_self(int fd, int pitch);
+int set_pitch_range_self(int fd, int pitch_range);
 int set_volume_self(int fd, int volume);
 int set_punct_mode_self(int fd, int punct);
 int set_cap_let_recog_self(int fd, int recog);
@@ -76,6 +78,7 @@ int set_priority_all(SPDPriority priority);
 int set_language_all(char *language);
 int set_rate_all(int rate);
 int set_pitch_all(int pitch);
+int set_pitch_range_all(int pitch_range);
 int set_volume_all(int volume);
 int set_punct_mode_all(int punct);
 int set_cap_let_recog_all(int recog);
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]