Esempio n. 1
0
void CtrlrMIDITransaction::constructConfirmation()
{
	MemoryBlock request;

	MemoryBlock prefix 	= getFormulaAsMemoryBlock(getProperty(Ids::transConfFormulaPrefix));
	MemoryBlock data   	= getConfirmationDataAsMemoryBlock();
	MemoryBlock suffix 	= getFormulaAsMemoryBlock(getProperty(Ids::transConfFormulaSuffix));

	if (prefix.getSize() > 0)
	{
		request.append (prefix.getData(), prefix.getSize());
	}

	if (data.getSize() > 0)
	{
		request.append (data.getData(), data.getSize());
	}

	if (suffix.getSize() > 0)
	{
		request.append (suffix.getData(), suffix.getSize());
	}

	setRequest (request);
}
Esempio n. 2
0
void CtrlrMIDITransaction::constructResponseMask()
{
	MemoryBlock responseMask;

	MemoryBlock prefix 	= getFormulaAsMemoryBlock(getProperty(Ids::transRespFormulaPrefix));
	MemoryBlock data((int)getProperty(Ids::transRespDataLen), true);
	MemoryBlock suffix 	= getFormulaAsMemoryBlock(getProperty(Ids::transRespFormulaSuffix));
	MemoryBlock name	= getNameAsMemoryBlock();

	if (data.getSize() < name.getSize())
	{
		TRANS("["+getName()+"] CtrlrMIDITransaction::constructResponseMask data block will not fit name");
	}

	if (prefix.getSize() > 0)
	{
		responseMask.append (prefix.getData(), prefix.getSize());
	}

	if (data.getSize() > 0)
	{
		responseMask.append (data.getData(), data.getSize());
	}

	if (suffix.getSize() > 0)
	{
		responseMask.append (suffix.getData(), suffix.getSize());
	}

	setResponseMask (responseMask);
}
Esempio n. 3
0
void CtrlrMIDITransaction::constructRequest()
{
	MemoryBlock request;

	MemoryBlock prefix 	= getFormulaAsMemoryBlock(getProperty(Ids::transReqFormulaPrefix));
	MemoryBlock data   	= getRequestDataAsMemoryBlock();
	MemoryBlock suffix 	= getFormulaAsMemoryBlock(getProperty(Ids::transReqFormulaSuffix));
	MemoryBlock name 	= getNameAsMemoryBlock();

	if (data.getSize() < name.getSize())
	{
		TRANS("["+getName()+"] CtrlrMIDITransaction::constructRequest data block will not fit name");
	}

	if (prefix.getSize() > 0)
	{
		request.append (prefix.getData(), prefix.getSize());
	}

	if (data.getSize() > 0)
	{
		request.append (data.getData(), data.getSize());
	}

	if (suffix.getSize() > 0)
	{
		request.append (suffix.getData(), suffix.getSize());
	}

	setRequest (request);
}
Esempio n. 4
0
void HelmPlugin::getStateInformation(MemoryBlock& dest_data) {
  var state = LoadSave::stateToVar(&synth_, gui_state_, getCallbackLock());
  String data_string = JSON::toString(state);
  MemoryOutputStream stream;
  stream.writeString(data_string);
  dest_data.append(stream.getData(), stream.getDataSize());
}
Esempio n. 5
0
//==============================================================================
void LumaPlug::getStateInformation (MemoryBlock& destData)
{
	/*
    // you can store your parameters as binary data if you want to or if you've got
    // a load of binary to put in there, but if you're not doing anything too heavy,
    // XML is a much cleaner way of doing it - here's an example of how to store your
    // params as XML..

    // create an outer XML element..
    XmlElement xmlState (T("MYPLUGINSETTINGS"));

    // add some attributes to it..
    xmlState.setAttribute (T("pluginVersion"), 1);
    //xmlState.setAttribute (T("gainLevel"), gain);
    xmlState.setAttribute (T("uiWidth"), lastUIWidth);
    xmlState.setAttribute (T("uiHeight"), lastUIHeight);

    // you could also add as many child elements as you need to here..


    // then use this helper function to stuff it into the binary blob and return it..
    copyXmlToBinary (xmlState, destData);
	*/
	
	const char* data = scriptText_.toUTF8();
	if (strlen(data) > 0)
	{
		destData.append(data, strlen(data));
	}
}
Esempio n. 6
0
static int beginRequestHandler(struct mg_connection *conn) {
    enum BeginRequestHandlerReturnValues { HANDLED = 1, NOT_HANDLED = 0 };

    struct mg_request_info *info = mg_get_request_info(conn);
    String uri(info->uri);
    if (!uri.endsWithIgnoreCase(".json") && !uri.endsWithIgnoreCase(".wav")) {
        // DBG << "Not handling as audio request" << endl;
        return NOT_HANDLED;
    }

    // DBG << "Handling URI: " << uri << endl;

    var parsed;
    // First try to look in the query string
    String queryString = urldecode(info->query_string);
    // DBG << queryString << endl;
    parsed = JSON::parse(queryString);
    // Otherwise look in the POST data
    if (!parsed) {
        MemoryBlock postDataBlock;
        char postBuffer[1024];
        int didRead;
        while ((didRead = mg_read(conn, postBuffer, sizeof(postBuffer)))) {
            postDataBlock.append(postBuffer, didRead);
        }
        MemoryInputStream postStream(postDataBlock, false);
        parsed = JSON::parse(postStream);
    }

    DBG << "Request JSON: " << JSON::toString(parsed, true) << endl;

    PluginRequestParameters params(parsed);
    if (uri.endsWithIgnoreCase(".json")) {
        params.listParameters = true;
    }

    MemoryBlock block;
    MemoryOutputStream ostream(block, false);

    // DBG << "Rendering plugin request" << endl;
    int64 startTime = Time::currentTimeMillis();
    bool result = handlePluginRequest(params, ostream);
    if (!result) {
        DBG << "-> Unable to handle plugin request!" << endl;
        mg_printf(conn, "HTTP/1.0 500 ERROR\r\n\r\n");
        return HANDLED;
    }
    DBG << "-> Rendered plugin request in " << (Time::currentTimeMillis() - startTime) << "ms" << endl;

    // Note: MemoryOutputStream::getDataSize() is the actual number of bytes written.
    // Do not use MemoryBlock::getSize() since this reports the memory allocated (but not initialized!)
    mg_printf(conn, "HTTP/1.0 200 OK\r\n"
              "Content-Length: %d\r\n"
              "Content-Type: %s\r\n"
              "\r\n",
              (int)ostream.getDataSize(), params.getContentType());
    mg_write(conn, ostream.getData(), ostream.getDataSize());

    return HANDLED;
}
Esempio n. 7
0
LMemoryBlock LMemoryBlock::getRange(const int startingPosition, const int numBytes) const
{
	MemoryBlock bl;

	if (getSize() >= (startingPosition + numBytes))
	{
		bl.append ((uint8 *)getData() + startingPosition, numBytes);
	}
	return (bl);
}
//==============================================================================
void CfpluginAudioProcessor::getStateInformation (MemoryBlock& destData)
{
	if (!follower_) { return; }

	auto options = OptionsReader();

	std::ostringstream ss;
    boost::archive::text_oarchive oa(ss);
	oa << *options;

	std::string str = ss.str();
	destData.append(str.data(), str.length());
}