Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow a message to be sent in a context, as described by a string.

  • Loading branch information...
commit 3fa0b3430636d0f0a3381b45d7e48bf7726c6044 1 parent 5ce45ca
Martin Roth authored
13 src/PdContext.cpp
View
@@ -463,6 +463,19 @@ void PdContext::scheduleExternalMessage(const char *receiverName, PdMessage *mes
unlock();
}
+void PdContext::scheduleExternalMessage(const char *receiverName, double timestamp, const char *initString) {
+ lock();
+ int receiverNameIndex = sendController->getNameIndex(receiverName);
+ if (receiverNameIndex >= 0) { // if the receiver exists
+ int maxElements = (strlen(initString)/2)+1;
+ PdMessage *message = PD_MESSAGE_ON_STACK(maxElements);
+ char str[strlen(initString)+1]; strcpy(str, initString);
+ message->initWithString(timestamp, maxElements, str);
+ scheduleMessage(sendController, receiverNameIndex, message);
+ }
+ unlock();
+}
+
PdMessage *PdContext::scheduleMessage(MessageObject *messageObject, unsigned int outletIndex, PdMessage *message) {
// basic argument checking. It may happen that the message is NULL in case a cancel message
// is sent multiple times to a particular object, when no message is pending
7 src/PdContext.h
View
@@ -135,6 +135,13 @@ class PdContext {
void scheduleExternalMessage(const char *receiverName, PdMessage *message);
/**
+ * Schedules a message described by the given string to be sent to named receivers at the
+ * given timestamp.
+ */
+ void PdContext::scheduleExternalMessage(const char *receiverName, double timestamp,
+ const char *initString);
+
+ /**
* Schedules a <code>PdMessage</code> to be sent by the <code>MessageObject</code> from the
* <code>outletIndex</code> at the specified <code>time</code>. The message will be copied
* to the heap and the context will thereafter take over ownership and be responsible for
5 src/ZenGarden.cpp
View
@@ -332,6 +332,11 @@ void zg_context_send_message(ZGContext *context, const char *receiverName, ZGMes
context->scheduleExternalMessage(receiverName, message);
}
+void zg_context_send_message_from_string(ZGContext *context, const char *receiverName,
+ double timestamp, const char *initString) {
+ context->scheduleExternalMessage(receiverName, timestamp, initString);
+}
+
void zg_context_send_messageV(PdContext *context, const char *receiverName, double timestamp,
const char *messageFormat, ...) {
va_list ap;
4 src/ZenGarden.h
View
@@ -179,6 +179,10 @@ typedef enum ZGConnectionType {
/** Send a message to the named receiver. */
void zg_context_send_message(ZGContext *context, const char *receiverName, ZGMessage *message);
+ /** Send a message described by the <code>initString</code> to the named receiver at the given timestamp. */
+ void zg_context_send_message_from_string(ZGContext *context, const char *receiverName,
+ double timestamp, const char *initString);
+
/**
* Send a message to the named receiver with the given format at the beginning of the next audio block.
* If no receiver exists with the given name, then this funtion does nothing.
Please sign in to comment.
Something went wrong with that request. Please try again.