~hp/orbit.lv2

632717dcd4289742d557eb06a420e4fa3217abe5 — Hanspeter Portner 3 months ago 9c1822b
Add {bar,beat}_dutycycle to orbit:beatbox
3 files changed, 63 insertions(+), 3 deletions(-)

M meson_options.txt
M src/orbit_beatbox.c
M ttl/orbit.ttl
M meson_options.txt => meson_options.txt +1 -1
@@ 9,4 9,4 @@ option('lv2libdir',
	type : 'string',
	value : 'lib/lv2')

option('version', type : 'string', value : '0.1.713')
option('version', type : 'string', value : '0.1.715')

M src/orbit_beatbox.c => src/orbit_beatbox.c +43 -1
@@ 11,7 11,7 @@
#include <timely.lv2/timely.h>
#include <props.lv2/props.h>

#define MAX_NPROPS 12
#define MAX_NPROPS 14

typedef struct _plugstate_t plugstate_t;
typedef struct _plughandle_t plughandle_t;


@@ 27,6 27,8 @@ struct _plugstate_t {
	int32_t beat_vel;
	int32_t bar_channel;
	int32_t beat_channel;
	float   bar_dutycycle;
	float   beat_dutycycle;
	int32_t bar_led;
	int32_t beat_led;
};


@@ 64,6 66,8 @@ struct _plughandle_t {
	bool beat_on;
	int bar_count;
	int beat_count;
	int64_t beat_cycles;
	int64_t bar_cycles;

	PROPS_T(props, MAX_NPROPS);
	


@@ 218,6 222,16 @@ static const props_def_t defs [MAX_NPROPS] = {
		.event_cb = _beat_intercept
	},
	{
		.property = ORBIT_URI"#beatbox_bar_dutycycle",
		.offset = offsetof(plugstate_t, bar_dutycycle),
		.type = LV2_ATOM__Float,
	},
	{
		.property = ORBIT_URI"#beatbox_beat_dutycycle",
		.offset = offsetof(plugstate_t, beat_dutycycle),
		.type = LV2_ATOM__Float,
	},
	{
		.property = ORBIT_URI"#beatbox_bar_led",
		.offset = offsetof(plugstate_t, bar_led),
		.access = LV2_PATCH__readable,


@@ 271,6 285,8 @@ _cb(timely_t *timely, int64_t frames, LV2_URID type, void *data)
			{
				_note_on(handle, frames, handle->state.beat_channel, handle->state.beat_note, handle->state.beat_vel);
				handle->beat_on = true;
				handle->beat_cycles = frames
					+ TIMELY_FRAMES_PER_BEAT(&handle->timely) * handle->state.beat_dutycycle;

				// toggle LED
				handle->state.beat_led = 1;


@@ 297,6 313,8 @@ _cb(timely_t *timely, int64_t frames, LV2_URID type, void *data)
			{
				_note_on(handle, frames, handle->state.bar_channel, handle->state.bar_note, handle->state.bar_vel);
				handle->bar_on = true;
				handle->bar_cycles = frames
					+ TIMELY_FRAMES_PER_BEAT(&handle->timely) * handle->state.bar_dutycycle;

				// toggle LED
				handle->state.bar_led = 1;


@@ 418,6 436,30 @@ run(LV2_Handle instance, uint32_t nsamples)

	timely_advance(&handle->timely, NULL, last_t, nsamples);

	if(handle->bar_on)
	{
		//FIXME make this sample-accurate
		handle->bar_cycles -= nsamples;

		if(handle->bar_cycles <= 0)
		{
			_note_off(handle, nsamples - 1, handle->state.bar_channel, handle->state.bar_note);
			handle->bar_on = false;
		}
	}

	if(handle->beat_on)
	{
		//FIXME make this sample-accurate
		handle->beat_cycles -= nsamples;

		if(handle->beat_cycles <= 0)
		{
			_note_off(handle, nsamples - 1, handle->state.beat_channel, handle->state.beat_note);
			handle->beat_on = false;
		}
	}

	if(handle->state.bar_led)
	{
		handle->bar_count -= nsamples;

M ttl/orbit.ttl => ttl/orbit.ttl +19 -1
@@ 431,6 431,20 @@ orbit:beatbox_beat_led
	rdfs:range atom:Bool ;
	rdfs:comment "blink on beat" ;
	rdfs:label "Beat LED" .
orbit:beatbox_bar_dutycycle
	a lv2:Parameter ;
	rdfs:range atom:Float ;
	rdfs:comment "set duty cycle for bar events" ;
	rdfs:label "Bar Dutycycle" ;
	lv2:minimum 0.0 ;
	lv2:maximum 1.0 .
orbit:beatbox_beat_dutycycle
	a lv2:Parameter ;
	rdfs:range atom:Float ;
	rdfs:comment "set duty cycle for beat events" ;
	rdfs:label "Beat Dutycycle" ;
	lv2:minimum 0.0 ;
	lv2:maximum 1.0 .

orbit:beatbox
	a lv2:Plugin ,


@@ 480,7 494,9 @@ orbit:beatbox
		orbit:beatbox_bar_velocity ,
		orbit:beatbox_beat_velocity ,
		orbit:beatbox_bar_channel ,
		orbit:beatbox_beat_channel ;
		orbit:beatbox_beat_channel ,
		orbit:beatbox_bar_dutycycle ,
		orbit:beatbox_beat_dutycycle ;

	state:state [
		orbit:beatbox_bar_enabled true ;


@@ 493,6 509,8 @@ orbit:beatbox
		orbit:beatbox_beat_velocity 64 ;
		orbit:beatbox_bar_channel 0 ;
		orbit:beatbox_beat_channel 0 ;
		orbit:beatbox_bar_dutycycle "0.5"^^xsd:float ;
		orbit:beatbox_beat_dutycycle "0.5"^^xsd:float ;
	] .

# Orbit Subspace