diff options
Diffstat (limited to 'backends')
| -rw-r--r-- | backends/lua.md | 4 | ||||
| -rw-r--r-- | backends/maweb.c | 2 | ||||
| -rw-r--r-- | backends/python.c | 9 | ||||
| -rw-r--r-- | backends/python.md | 3 | 
4 files changed, 11 insertions, 7 deletions
diff --git a/backends/lua.md b/backends/lua.md index 4e58ded..b2f40e0 100644 --- a/backends/lua.md +++ b/backends/lua.md @@ -26,8 +26,8 @@ The following functions are provided within the Lua interpreter for interaction  | `thread(function)`		| `thread(run_show)`		| Run a function as a Lua thread (see below) |  | `sleep(number)`		| `sleep(100)`			| Suspend current thread for time specified in milliseconds | -While a channel handler executes, calling `input_value` for that channel returns the previous value. Once -the handler returns, the internal buffer is updated. +While a channel handler executes, calling `input_value` for that channel returns the previous value. +The stored value is updated once the handler returns.  Example script:  ```lua diff --git a/backends/maweb.c b/backends/maweb.c index 5242f36..97d4cea 100644 --- a/backends/maweb.c +++ b/backends/maweb.c @@ -570,7 +570,7 @@ static int maweb_request_playbacks(instance* inst){  				item_types,  				view,  				data->session); -		rv |= maweb_send_frame(inst, ws_text, (uint8_t*) xmit_buffer, strlen(xmit_buffer)); +		maweb_send_frame(inst, ws_text, (uint8_t*) xmit_buffer, strlen(xmit_buffer));  		DBGPF("Poll request: %s", xmit_buffer);  		updates_inflight++;  	} diff --git a/backends/python.c b/backends/python.c index 28b95a9..bd73a20 100644 --- a/backends/python.c +++ b/backends/python.c @@ -559,18 +559,19 @@ static int python_set(instance* inst, size_t num, channel** c, channel_value* v)  	for(u = 0; u < num; u++){  		chan = data->channel + c[u]->ident; -		//update input value buffer -		chan->in = v[u].normalised; -  		//call handler if present  		if(chan->handler){  			DBGPF("Calling handler for %s.%s", inst->name, chan->name);  			data->current_channel = chan; -			result = PyObject_CallFunction(chan->handler, "d", chan->in); +			result = PyObject_CallFunction(chan->handler, "d", v[u].normalised);  			Py_XDECREF(result);  			data->current_channel = NULL;  			DBGPF("Done with handler for %s.%s", inst->name, chan->name);  		} + +		//update input value buffer after finishing the handler +		chan->in = v[u].normalised; +  	}  	//release interpreter diff --git a/backends/python.md b/backends/python.md index ab0fb38..a78d972 100644 --- a/backends/python.md +++ b/backends/python.md @@ -26,6 +26,9 @@ The `midimonster` module provides the following functions:  | `manage(function, socket)`	| `midimonster.manage(handler, socket)`	| Register a (connected/listening) socket to the MIDIMonster core. Calls `function(socket)` when the socket is ready to read. Calling this method with `None` as the function argument unregisters the socket. A socket may only have one associated handler |  | `cleanup_handler(function)`	| `midimonster.cleanup_handler(save_all)`| Register a function to be called when the instance is destroyed (on MIDIMonster shutdown). One cleanup handler can be registered per instance. Calling this function when the instance already has a cleanup handler registered replaces the handler, returning the old one. | +When a channel handler executes, calling `midimonster.inputvalue()` for that exact channel returns the previous value, +while the argument to the handler is the current value. The stored value is updated after the handler finishes executing. +  Example Python module:  ```python  import socket  | 
