Compare commits
No commits in common. "master" and "DrMr2-0.1" have entirely different histories.
10
.gitignore
vendored
10
.gitignore
vendored
@ -1,9 +1,7 @@
|
|||||||
*~
|
drmr.so
|
||||||
drmr2.so
|
drmr_ui.xml
|
||||||
drmr2_ui.xml
|
drmr_ui.so
|
||||||
drmr2_ui.so
|
drmr.lv2
|
||||||
drmr2.lv2
|
|
||||||
drmr2.ttl
|
|
||||||
build
|
build
|
||||||
/logo.xcf
|
/logo.xcf
|
||||||
/htest
|
/htest
|
||||||
|
14
drmr2-mkttl
14
drmr2-mkttl
@ -70,19 +70,7 @@ add_port "," " a lv2:InputPort , atom:AtomPort;
|
|||||||
lv2:name \"Control\";"
|
lv2:name \"Control\";"
|
||||||
|
|
||||||
|
|
||||||
|
idx=1
|
||||||
add_port "," " a lv2:AudioPort, lv2:OutputPort;
|
|
||||||
lv2:index %d;
|
|
||||||
lv2:symbol \"master_out_1\";
|
|
||||||
lv2:name \"Master - Out 1\";"
|
|
||||||
|
|
||||||
add_port "," " a lv2:AudioPort, lv2:OutputPort;
|
|
||||||
lv2:index %d;
|
|
||||||
lv2:symbol \"master_out_2\";
|
|
||||||
lv2:name \"Master - Out 2\";"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
out_id=0
|
out_id=0
|
||||||
|
|
||||||
while [[ "${out_id}" -lt "${outport_nb}" ]]
|
while [[ "${out_id}" -lt "${outport_nb}" ]]
|
||||||
|
106
drmr2.c
106
drmr2.c
@ -84,7 +84,6 @@ instantiate(const LV2_Descriptor* descriptor,
|
|||||||
drmr->rate = rate;
|
drmr->rate = rate;
|
||||||
drmr->ignore_velocity = false;
|
drmr->ignore_velocity = false;
|
||||||
drmr->ignore_note_off = true;
|
drmr->ignore_note_off = true;
|
||||||
drmr->channel_nb = 0;
|
|
||||||
|
|
||||||
#ifdef DRMR_UI_ZERO_SAMP
|
#ifdef DRMR_UI_ZERO_SAMP
|
||||||
drmr->zero_position = DRMR_UI_ZERO_SAMP;
|
drmr->zero_position = DRMR_UI_ZERO_SAMP;
|
||||||
@ -166,15 +165,7 @@ connect_port(LV2_Handle instance,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if( port_index == DRMR_MASTER_LEFT)
|
if( port_index >= DRMR_LEFT_00 && port_index <= DRMR_RIGHT_31)
|
||||||
{
|
|
||||||
drmr->master_right = (float*)data;
|
|
||||||
}
|
|
||||||
else if( port_index == DRMR_MASTER_RIGHT)
|
|
||||||
{
|
|
||||||
drmr->master_left = (float*)data;
|
|
||||||
}
|
|
||||||
else if( port_index >= DRMR_LEFT_00 && port_index <= DRMR_RIGHT_31)
|
|
||||||
{
|
{
|
||||||
int outoff = (port_index - DRMR_LEFT_00) / 2;
|
int outoff = (port_index - DRMR_LEFT_00) / 2;
|
||||||
|
|
||||||
@ -199,7 +190,7 @@ connect_port(LV2_Handle instance,
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,8 +225,6 @@ static inline LV2_Atom *build_state_message(DrMr *drmr) {
|
|||||||
lv2_atom_forge_bool(&drmr->forge, drmr->ignore_velocity?true:false);
|
lv2_atom_forge_bool(&drmr->forge, drmr->ignore_velocity?true:false);
|
||||||
lv2_atom_forge_property_head(&drmr->forge, drmr->uris.note_off_toggle,0);
|
lv2_atom_forge_property_head(&drmr->forge, drmr->uris.note_off_toggle,0);
|
||||||
lv2_atom_forge_bool(&drmr->forge, drmr->ignore_note_off?true:false);
|
lv2_atom_forge_bool(&drmr->forge, drmr->ignore_note_off?true:false);
|
||||||
lv2_atom_forge_property_head(&drmr->forge, drmr->uris.channel_nb,0);
|
|
||||||
lv2_atom_forge_int(&drmr->forge, drmr->channel_nb);
|
|
||||||
lv2_atom_forge_property_head(&drmr->forge, drmr->uris.zero_position,0);
|
lv2_atom_forge_property_head(&drmr->forge, drmr->uris.zero_position,0);
|
||||||
lv2_atom_forge_int(&drmr->forge, drmr->zero_position);
|
lv2_atom_forge_int(&drmr->forge, drmr->zero_position);
|
||||||
lv2_atom_forge_pop(&drmr->forge,&set_frame);
|
lv2_atom_forge_pop(&drmr->forge,&set_frame);
|
||||||
@ -292,10 +281,6 @@ static inline void trigger_sample(DrMr *drmr, int nn, uint8_t* const data, uint3
|
|||||||
pthread_mutex_lock(&drmr->load_mutex);
|
pthread_mutex_lock(&drmr->load_mutex);
|
||||||
if (nn >= 0 && nn < drmr->num_samples) {
|
if (nn >= 0 && nn < drmr->num_samples) {
|
||||||
if (drmr->samples[nn].layer_count > 0) {
|
if (drmr->samples[nn].layer_count > 0) {
|
||||||
// drmr currently has 32 hard-coded gains so just use the last gain
|
|
||||||
// to prevent a segfault
|
|
||||||
int gain_idx = nn < 32 ? nn : 31;
|
|
||||||
layer_to_sample(drmr->samples+nn,*(drmr->gains[gain_idx]));
|
|
||||||
layer_to_sample(drmr->samples+nn,*(drmr->gains[nn]));
|
layer_to_sample(drmr->samples+nn,*(drmr->gains[nn]));
|
||||||
if (drmr->samples[nn].limit == 0)
|
if (drmr->samples[nn].limit == 0)
|
||||||
fprintf(stderr,"Failed to find layer at: %i for %f\n",nn,*drmr->gains[nn]);
|
fprintf(stderr,"Failed to find layer at: %i for %f\n",nn,*drmr->gains[nn]);
|
||||||
@ -357,37 +342,24 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
|||||||
uint8_t nn;
|
uint8_t nn;
|
||||||
uint8_t* const data = (uint8_t* const)(ev + 1);
|
uint8_t* const data = (uint8_t* const)(ev + 1);
|
||||||
uint32_t offset = (ev->time.frames > 0 && ev->time.frames < n_samples) ? ev->time.frames : 0;
|
uint32_t offset = (ev->time.frames > 0 && ev->time.frames < n_samples) ? ev->time.frames : 0;
|
||||||
int channel = *data & 15;
|
//int channel = *data & 15;
|
||||||
|
switch ((*data) >> 4) {
|
||||||
if( ( drmr->channel_nb == 0) || ( channel == ( drmr->channel_nb - 1)))
|
case 8:
|
||||||
{
|
if (!drmr->ignore_note_off) {
|
||||||
switch ((*data) >> 4)
|
nn = data[1];
|
||||||
{
|
nn-=baseNote;
|
||||||
case 8:
|
untrigger_sample(drmr,nn,offset);
|
||||||
{
|
}
|
||||||
if (!drmr->ignore_note_off)
|
break;
|
||||||
{
|
case 9: {
|
||||||
nn = data[1];
|
nn = data[1];
|
||||||
nn-=baseNote;
|
nn-=baseNote;
|
||||||
untrigger_sample(drmr,nn,offset);
|
trigger_sample(drmr,nn,data,offset);
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
}
|
default:
|
||||||
|
//printf("Unhandeled status: %i\n",(*data)>>4);
|
||||||
case 9:
|
break;
|
||||||
{
|
|
||||||
nn = data[1];
|
|
||||||
nn-=baseNote;
|
|
||||||
trigger_sample(drmr,nn,data,offset);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
//printf("Unhandeled status: %i\n",(*data)>>4);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ev->body.type == drmr->uris.atom_resource) {
|
else if (ev->body.type == drmr->uris.atom_resource) {
|
||||||
@ -397,14 +369,12 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
|||||||
const LV2_Atom* trigger = NULL;
|
const LV2_Atom* trigger = NULL;
|
||||||
const LV2_Atom* ignvel = NULL;
|
const LV2_Atom* ignvel = NULL;
|
||||||
const LV2_Atom* ignno = NULL;
|
const LV2_Atom* ignno = NULL;
|
||||||
const LV2_Atom* channel_nb = NULL;
|
|
||||||
const LV2_Atom* zerop = NULL;
|
const LV2_Atom* zerop = NULL;
|
||||||
lv2_atom_object_get(obj,
|
lv2_atom_object_get(obj,
|
||||||
drmr->uris.kit_path, &path,
|
drmr->uris.kit_path, &path,
|
||||||
drmr->uris.sample_trigger, &trigger,
|
drmr->uris.sample_trigger, &trigger,
|
||||||
drmr->uris.velocity_toggle, &ignvel,
|
drmr->uris.velocity_toggle, &ignvel,
|
||||||
drmr->uris.note_off_toggle, &ignno,
|
drmr->uris.note_off_toggle, &ignno,
|
||||||
drmr->uris.channel_nb, &channel_nb,
|
|
||||||
drmr->uris.zero_position, &zerop,
|
drmr->uris.zero_position, &zerop,
|
||||||
0);
|
0);
|
||||||
if (path) {
|
if (path) {
|
||||||
@ -430,8 +400,6 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
|||||||
drmr->ignore_velocity = ((const LV2_Atom_Bool*)ignvel)->body;
|
drmr->ignore_velocity = ((const LV2_Atom_Bool*)ignvel)->body;
|
||||||
if (ignno)
|
if (ignno)
|
||||||
drmr->ignore_note_off = ((const LV2_Atom_Bool*)ignno)->body;
|
drmr->ignore_note_off = ((const LV2_Atom_Bool*)ignno)->body;
|
||||||
if (channel_nb)
|
|
||||||
drmr->channel_nb = ((const LV2_Atom_Int*)channel_nb)->body;
|
|
||||||
if (zerop)
|
if (zerop)
|
||||||
drmr->zero_position = ((const LV2_Atom_Int*)zerop)->body;
|
drmr->zero_position = ((const LV2_Atom_Int*)zerop)->body;
|
||||||
} else if (obj->body.otype == drmr->uris.get_state) {
|
} else if (obj->body.otype == drmr->uris.get_state) {
|
||||||
@ -459,12 +427,6 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
|||||||
|
|
||||||
pthread_mutex_lock(&drmr->load_mutex);
|
pthread_mutex_lock(&drmr->load_mutex);
|
||||||
|
|
||||||
for( j = 0; j<n_samples; j++)
|
|
||||||
{
|
|
||||||
drmr->master_left[j] = 0.0f;
|
|
||||||
drmr->master_right[j] = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0;i < drmr->num_samples;i++)
|
for (i = 0;i < drmr->num_samples;i++)
|
||||||
{
|
{
|
||||||
int pos,lim;
|
int pos,lim;
|
||||||
@ -511,12 +473,8 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
|||||||
|
|
||||||
for (pos = datastart; pos < lim && pos < dataend; pos++)
|
for (pos = datastart; pos < lim && pos < dataend; pos++)
|
||||||
{
|
{
|
||||||
drmr->master_left[pos] += cs->data[cs->offset]*coef_left;
|
drmr->left[i][pos] += cs->data[cs->offset]*coef_left;
|
||||||
drmr->left[i][pos] += cs->data[cs->offset]*coef_left;
|
drmr->right[i][pos] += cs->data[cs->offset]*coef_right;
|
||||||
|
|
||||||
drmr->master_right[pos] += cs->data[cs->offset]*coef_right;
|
|
||||||
drmr->right[i][pos] += cs->data[cs->offset]*coef_right;
|
|
||||||
|
|
||||||
cs->offset++;
|
cs->offset++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,11 +485,8 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
|||||||
if (lim > n_samples) lim = n_samples;
|
if (lim > n_samples) lim = n_samples;
|
||||||
for (pos = datastart; pos < lim && pos < dataend; pos++)
|
for (pos = datastart; pos < lim && pos < dataend; pos++)
|
||||||
{
|
{
|
||||||
drmr->master_left[pos] += cs->data[cs->offset]*coef_left;
|
drmr->left[i][pos] += cs->data[cs->offset++]*coef_left;
|
||||||
drmr->left[i][pos] += cs->data[cs->offset++]*coef_left;
|
drmr->right[i][pos] += cs->data[cs->offset++]*coef_right;
|
||||||
|
|
||||||
drmr->master_right[pos] += cs->data[cs->offset]*coef_right;
|
|
||||||
drmr->right[i][pos] += cs->data[cs->offset++]*coef_right;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,14 +568,6 @@ save_state(LV2_Handle instance,
|
|||||||
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
|
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
|
||||||
if (stat) return stat;
|
if (stat) return stat;
|
||||||
|
|
||||||
stat = store(handle,
|
|
||||||
drmr->uris.channel_nb,
|
|
||||||
&drmr->channel_nb,
|
|
||||||
sizeof(int),
|
|
||||||
drmr->uris.int_urid,
|
|
||||||
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
|
|
||||||
if (stat) return stat;
|
|
||||||
|
|
||||||
stat = store(handle,
|
stat = store(handle,
|
||||||
drmr->uris.zero_position,
|
drmr->uris.zero_position,
|
||||||
&drmr->zero_position,
|
&drmr->zero_position,
|
||||||
@ -688,11 +635,6 @@ restore_state(LV2_Handle instance,
|
|||||||
if (ignore_note_off)
|
if (ignore_note_off)
|
||||||
drmr->ignore_note_off = *ignore_note_off?true:false;
|
drmr->ignore_note_off = *ignore_note_off?true:false;
|
||||||
|
|
||||||
const int* channel_nb =
|
|
||||||
retrieve(handle, drmr->uris.channel_nb, &size, &type, &fgs);
|
|
||||||
if (channel_nb)
|
|
||||||
drmr->channel_nb = *channel_nb;
|
|
||||||
|
|
||||||
const int* zero_position =
|
const int* zero_position =
|
||||||
retrieve(handle, drmr->uris.zero_position, &size, &type, &fgs);
|
retrieve(handle, drmr->uris.zero_position, &size, &type, &fgs);
|
||||||
if (zero_position)
|
if (zero_position)
|
||||||
|
10
drmr2.h
10
drmr2.h
@ -72,8 +72,6 @@ typedef struct {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DRMR_CONTROL = 0,
|
DRMR_CONTROL = 0,
|
||||||
DRMR_MASTER_LEFT,
|
|
||||||
DRMR_MASTER_RIGHT,
|
|
||||||
DRMR_LEFT_00,
|
DRMR_LEFT_00,
|
||||||
DRMR_RIGHT_00,
|
DRMR_RIGHT_00,
|
||||||
DRMR_LEFT_01,
|
DRMR_LEFT_01,
|
||||||
@ -221,14 +219,11 @@ typedef struct {
|
|||||||
LV2_URID sample_trigger;
|
LV2_URID sample_trigger;
|
||||||
LV2_URID velocity_toggle;
|
LV2_URID velocity_toggle;
|
||||||
LV2_URID note_off_toggle;
|
LV2_URID note_off_toggle;
|
||||||
LV2_URID channel_nb;
|
|
||||||
LV2_URID zero_position;
|
LV2_URID zero_position;
|
||||||
} drmr_uris;
|
} drmr_uris;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// Ports
|
// Ports
|
||||||
float* master_left;
|
|
||||||
float* master_right;
|
|
||||||
float** left;
|
float** left;
|
||||||
float** right;
|
float** right;
|
||||||
LV2_Atom_Sequence *control_port;
|
LV2_Atom_Sequence *control_port;
|
||||||
@ -237,10 +232,8 @@ typedef struct {
|
|||||||
LV2_Atom_Forge forge;
|
LV2_Atom_Forge forge;
|
||||||
|
|
||||||
// params
|
// params
|
||||||
int channel;
|
|
||||||
bool ignore_velocity;
|
bool ignore_velocity;
|
||||||
bool ignore_note_off;
|
bool ignore_note_off;
|
||||||
int channel_nb;
|
|
||||||
int zero_position;
|
int zero_position;
|
||||||
float** gains;
|
float** gains;
|
||||||
float** pans;
|
float** pans;
|
||||||
@ -300,9 +293,6 @@ void map_drmr_uris(LV2_URID_Map *map,
|
|||||||
uris->note_off_toggle =
|
uris->note_off_toggle =
|
||||||
map->map(map->handle,
|
map->map(map->handle,
|
||||||
DRMR_URI "#noteofftoggle");
|
DRMR_URI "#noteofftoggle");
|
||||||
uris->channel_nb =
|
|
||||||
map->map(map->handle,
|
|
||||||
DRMR_URI "#channelnb");
|
|
||||||
uris->zero_position =
|
uris->zero_position =
|
||||||
map->map(map->handle,
|
map->map(map->handle,
|
||||||
DRMR_URI "#zeroposition");
|
DRMR_URI "#zeroposition");
|
||||||
|
@ -87,7 +87,6 @@ struct kit_info {
|
|||||||
struct hp_info {
|
struct hp_info {
|
||||||
char scan_only;
|
char scan_only;
|
||||||
char in_info;
|
char in_info;
|
||||||
char in_component_list;
|
|
||||||
char in_instrument_list;
|
char in_instrument_list;
|
||||||
char in_instrument;
|
char in_instrument;
|
||||||
char in_layer;
|
char in_layer;
|
||||||
@ -106,30 +105,22 @@ startElement(void *userData, const char *name, const char **atts)
|
|||||||
struct hp_info* info = (struct hp_info*)userData;
|
struct hp_info* info = (struct hp_info*)userData;
|
||||||
info->cur_off = 0;
|
info->cur_off = 0;
|
||||||
if (info->in_info) {
|
if (info->in_info) {
|
||||||
if (!info->in_component_list) {
|
if (info->in_instrument) {
|
||||||
if (!strcmp(name,"componentList")) {
|
if (!strcmp(name,"layer") && !info->scan_only) {
|
||||||
info->in_component_list = 1;
|
info->in_layer = 1;
|
||||||
|
info->cur_layer = malloc(sizeof(struct instrument_layer));
|
||||||
|
memset(info->cur_layer,0,sizeof(struct instrument_layer));
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
if (info->in_instrument_list) {
|
||||||
if (info->in_instrument) {
|
if (!strcmp(name,"instrument")) {
|
||||||
if (!strcmp(name,"layer") && !info->scan_only) {
|
info->in_instrument = 1;
|
||||||
info->in_layer = 1;
|
info->cur_instrument = malloc(sizeof(struct instrument_info));
|
||||||
info->cur_layer = malloc(sizeof(struct instrument_layer));
|
memset(info->cur_instrument,0,sizeof(struct instrument_info));
|
||||||
memset(info->cur_layer,0,sizeof(struct instrument_layer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (info->in_instrument_list) {
|
|
||||||
if (!strcmp(name,"instrument")) {
|
|
||||||
info->in_instrument = 1;
|
|
||||||
info->cur_instrument = malloc(sizeof(struct instrument_info));
|
|
||||||
memset(info->cur_instrument,0,sizeof(struct instrument_info));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!strcmp(name,"instrumentList"))
|
|
||||||
info->in_instrument_list = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!strcmp(name,"instrumentList"))
|
||||||
|
info->in_instrument_list = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!strcmp(name,"drumkit_info"))
|
if (!strcmp(name,"drumkit_info"))
|
||||||
@ -144,7 +135,7 @@ endElement(void *userData, const char *name)
|
|||||||
if (info->cur_off == MAX_CHAR_DATA) info->cur_off--;
|
if (info->cur_off == MAX_CHAR_DATA) info->cur_off--;
|
||||||
info->cur_buf[info->cur_off]='\0';
|
info->cur_buf[info->cur_off]='\0';
|
||||||
|
|
||||||
if (info->in_info && !info->in_component_list && !info->in_instrument_list && !strcmp(name,"name"))
|
if (info->in_info && !info->in_instrument_list && !strcmp(name,"name"))
|
||||||
info->kit_info->name = strdup(info->cur_buf);
|
info->kit_info->name = strdup(info->cur_buf);
|
||||||
if (info->scan_only && info->in_info && !info->in_instrument_list && !strcmp(name,"info"))
|
if (info->scan_only && info->in_info && !info->in_instrument_list && !strcmp(name,"info"))
|
||||||
info->kit_info->desc = strdup(info->cur_buf);
|
info->kit_info->desc = strdup(info->cur_buf);
|
||||||
@ -196,7 +187,6 @@ endElement(void *userData, const char *name)
|
|||||||
info->cur_instrument = NULL;
|
info->cur_instrument = NULL;
|
||||||
info->in_instrument = 0;
|
info->in_instrument = 0;
|
||||||
}
|
}
|
||||||
if (info->in_component_list && !strcmp(name,"componentList")) info->in_component_list = 0;
|
|
||||||
if (info->in_instrument_list && !strcmp(name,"instrumentList")) info->in_instrument_list = 0;
|
if (info->in_instrument_list && !strcmp(name,"instrumentList")) info->in_instrument_list = 0;
|
||||||
if (info->in_info && !strcmp(name,"drumkit_info")) info->in_info = 0;
|
if (info->in_info && !strcmp(name,"drumkit_info")) info->in_info = 0;
|
||||||
}
|
}
|
||||||
@ -242,9 +232,9 @@ static char* expand_path(char* path, char* buf) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int compar_kit(const void *p1, const void *p2)
|
static int *compar_kit(const void *p1, const void *p2)
|
||||||
{
|
{
|
||||||
return (int) strcmp( (* (scanned_kit **) p1)->name, (* (scanned_kit **) p2)->name);
|
return (int) strcmp( (* (scanned_kit **) p1)->name, (* (scanned_kit **) p2)->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -349,7 +339,7 @@ kits* scan_kits() {
|
|||||||
cp = 0;
|
cp = 0;
|
||||||
struct kit_list * cur_k = scanned_kits;
|
struct kit_list * cur_k = scanned_kits;
|
||||||
while(cur_k) {
|
while(cur_k) {
|
||||||
// printf("found kit: %s\nat:%s\n\n",cur_k->skit->name,cur_k->skit->path);
|
//printf("found kit: %s\nat:%s\n\n",cur_k->skit->name,cur_k->skit->path);
|
||||||
cur_k = cur_k->next;
|
cur_k = cur_k->next;
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
95
drmr2_ui.c
95
drmr2_ui.c
@ -51,16 +51,13 @@ typedef struct {
|
|||||||
GtkListStore *kit_store;
|
GtkListStore *kit_store;
|
||||||
GtkWidget** gain_sliders;
|
GtkWidget** gain_sliders;
|
||||||
GtkWidget** pan_sliders;
|
GtkWidget** pan_sliders;
|
||||||
GtkWidget** notify_leds;
|
|
||||||
GtkWidget *channel_combo_box, *position_combo_box, *velocity_checkbox, *note_off_checkbox;
|
|
||||||
GtkScrolledWindow *sample_view;
|
|
||||||
|
|
||||||
float *gain_vals,*pan_vals;
|
float *gain_vals,*pan_vals;
|
||||||
|
|
||||||
|
GtkWidget** notify_leds;
|
||||||
|
GtkWidget *position_combo_box, *velocity_checkbox, *note_off_checkbox;
|
||||||
|
|
||||||
gchar *bundle_path;
|
gchar *bundle_path;
|
||||||
|
|
||||||
int channel;
|
|
||||||
int cols;
|
int cols;
|
||||||
int startSamp;
|
int startSamp;
|
||||||
|
|
||||||
@ -361,7 +358,9 @@ static gboolean kit_callback(gpointer data) {
|
|||||||
gain_sliders = malloc(samples*sizeof(GtkWidget*));
|
gain_sliders = malloc(samples*sizeof(GtkWidget*));
|
||||||
pan_sliders = malloc(samples*sizeof(GtkWidget*));
|
pan_sliders = malloc(samples*sizeof(GtkWidget*));
|
||||||
fill_sample_table(ui,samples,ui->kits->kits[ui->kitReq].sample_names,notify_leds,gain_sliders,pan_sliders);
|
fill_sample_table(ui,samples,ui->kits->kits[ui->kitReq].sample_names,notify_leds,gain_sliders,pan_sliders);
|
||||||
gtk_scrolled_window_add_with_viewport(ui->sample_view, GTK_WIDGET(ui->sample_table));
|
gtk_box_pack_start(GTK_BOX(ui->drmr_widget),GTK_WIDGET(ui->sample_table),
|
||||||
|
true,true,5);
|
||||||
|
gtk_box_reorder_child(GTK_BOX(ui->drmr_widget),GTK_WIDGET(ui->sample_table),1);
|
||||||
gtk_widget_show_all(GTK_WIDGET(ui->sample_table));
|
gtk_widget_show_all(GTK_WIDGET(ui->sample_table));
|
||||||
ui->samples = samples;
|
ui->samples = samples;
|
||||||
ui->notify_leds = notify_leds;
|
ui->notify_leds = notify_leds;
|
||||||
@ -418,63 +417,10 @@ static void kit_combobox_changed(GtkComboBox* box, gpointer data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void channel_data(DrMrUi *ui, gpointer data) {
|
|
||||||
lv2_atom_forge_property_head(&ui->forge, ui->uris.channel_nb,0);
|
|
||||||
lv2_atom_forge_int(&ui->forge, GPOINTER_TO_INT(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void channel_combobox_changed(GtkComboBox* box, gpointer data) {
|
|
||||||
DrMrUi* ui = (DrMrUi*)data;
|
|
||||||
gint channel = gtk_combo_box_get_active (GTK_COMBO_BOX(box));
|
|
||||||
|
|
||||||
printf( "Channel Change: [%d]\n", channel);
|
|
||||||
|
|
||||||
if (channel != ui->channel) {
|
|
||||||
ui->channel = channel;
|
|
||||||
ui->forceUpdate = true;
|
|
||||||
kit_callback(ui);
|
|
||||||
send_ui_msg(ui,&channel_data,GINT_TO_POINTER(channel));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *create_channel_combo(void)
|
|
||||||
{
|
|
||||||
GtkWidget *combo;
|
|
||||||
GtkListStore *list_store;
|
|
||||||
GtkCellRenderer *cell;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
int i;
|
|
||||||
char label[8];
|
|
||||||
|
|
||||||
list_store = gtk_list_store_new(1, G_TYPE_STRING);
|
|
||||||
|
|
||||||
gtk_list_store_append(list_store, &iter);
|
|
||||||
gtk_list_store_set (list_store, &iter, 0, "Omni", -1);
|
|
||||||
|
|
||||||
for( i = 1; i <= 16; i++) {
|
|
||||||
sprintf( label, "%02d", i);
|
|
||||||
gtk_list_store_append(list_store, &iter);
|
|
||||||
gtk_list_store_set (list_store, &iter, 0, label, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list_store));
|
|
||||||
|
|
||||||
gtk_combo_box_set_active(GTK_COMBO_BOX(combo),0);
|
|
||||||
|
|
||||||
g_object_unref(list_store);
|
|
||||||
|
|
||||||
cell = gtk_cell_renderer_text_new();
|
|
||||||
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
|
|
||||||
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), cell, "text", 0, NULL);
|
|
||||||
|
|
||||||
return combo;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void position_data(DrMrUi *ui, gpointer data) {
|
static void position_data(DrMrUi *ui, gpointer data) {
|
||||||
lv2_atom_forge_property_head(&ui->forge, ui->uris.zero_position,0);
|
lv2_atom_forge_property_head(&ui->forge, ui->uris.zero_position,0);
|
||||||
lv2_atom_forge_int(&ui->forge, GPOINTER_TO_INT(data));
|
lv2_atom_forge_int(&ui->forge, GPOINTER_TO_INT(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void position_combobox_changed(GtkComboBox* box, gpointer data) {
|
static void position_combobox_changed(GtkComboBox* box, gpointer data) {
|
||||||
DrMrUi* ui = (DrMrUi*)data;
|
DrMrUi* ui = (DrMrUi*)data;
|
||||||
gint ss = gtk_combo_box_get_active (GTK_COMBO_BOX(box));
|
gint ss = gtk_combo_box_get_active (GTK_COMBO_BOX(box));
|
||||||
@ -512,6 +458,7 @@ static GtkWidget *create_position_combo(void)
|
|||||||
gtk_combo_box_set_active(GTK_COMBO_BOX(combo),0);
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo),0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
g_object_unref(list_store);
|
g_object_unref(list_store);
|
||||||
|
|
||||||
cell = gtk_cell_renderer_text_new();
|
cell = gtk_cell_renderer_text_new();
|
||||||
@ -563,7 +510,7 @@ static void build_drmr_ui(DrMrUi* ui) {
|
|||||||
GtkWidget *drmr_ui_widget;
|
GtkWidget *drmr_ui_widget;
|
||||||
GtkWidget *opts_hbox1, *opts_hbox2,
|
GtkWidget *opts_hbox1, *opts_hbox2,
|
||||||
*kit_combo_box, *kit_label, *no_kit_label,
|
*kit_combo_box, *kit_label, *no_kit_label,
|
||||||
*base_label, *base_spin, *channel_label, *position_label, *sample_view;
|
*base_label, *base_spin, *position_label;
|
||||||
GtkCellRenderer *cell_rend;
|
GtkCellRenderer *cell_rend;
|
||||||
GtkAdjustment *base_adj;
|
GtkAdjustment *base_adj;
|
||||||
|
|
||||||
@ -604,9 +551,6 @@ static void build_drmr_ui(DrMrUi* ui) {
|
|||||||
5.0,0.0)); // page adj/size
|
5.0,0.0)); // page adj/size
|
||||||
base_spin = gtk_spin_button_new(base_adj, 1.0, 0);
|
base_spin = gtk_spin_button_new(base_adj, 1.0, 0);
|
||||||
|
|
||||||
channel_label = gtk_label_new("Midi Channel: ");
|
|
||||||
ui->channel_combo_box = create_channel_combo();
|
|
||||||
|
|
||||||
position_label = gtk_label_new("Sample Zero Position: ");
|
position_label = gtk_label_new("Sample Zero Position: ");
|
||||||
ui->position_combo_box = create_position_combo();
|
ui->position_combo_box = create_position_combo();
|
||||||
|
|
||||||
@ -624,10 +568,6 @@ static void build_drmr_ui(DrMrUi* ui) {
|
|||||||
gtk_box_pack_start(GTK_BOX(opts_hbox1),base_spin,
|
gtk_box_pack_start(GTK_BOX(opts_hbox1),base_spin,
|
||||||
true,true,0);
|
true,true,0);
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(opts_hbox2),channel_label,
|
|
||||||
false,false,15);
|
|
||||||
gtk_box_pack_start(GTK_BOX(opts_hbox2),ui->channel_combo_box,
|
|
||||||
false,false,0);
|
|
||||||
gtk_box_pack_start(GTK_BOX(opts_hbox2),position_label,
|
gtk_box_pack_start(GTK_BOX(opts_hbox2),position_label,
|
||||||
false,false,15);
|
false,false,15);
|
||||||
gtk_box_pack_start(GTK_BOX(opts_hbox2),ui->position_combo_box,
|
gtk_box_pack_start(GTK_BOX(opts_hbox2),ui->position_combo_box,
|
||||||
@ -639,20 +579,14 @@ static void build_drmr_ui(DrMrUi* ui) {
|
|||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),GTK_WIDGET(ui->current_kit_label),
|
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),GTK_WIDGET(ui->current_kit_label),
|
||||||
false,false,5);
|
false,false,5);
|
||||||
|
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),gtk_hseparator_new(),
|
||||||
|
false,false,5);
|
||||||
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox1,
|
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox1,
|
||||||
false,false,5);
|
false,false,5);
|
||||||
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox2,
|
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox2,
|
||||||
false,false,5);
|
false,false,5);
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),gtk_hseparator_new(),
|
|
||||||
false,false,5);
|
|
||||||
|
|
||||||
sample_view = gtk_scrolled_window_new(NULL, NULL);
|
|
||||||
gtk_widget_set_size_request(sample_view, -1, 300);
|
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(sample_view),
|
|
||||||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
||||||
gtk_box_pack_start(GTK_BOX(drmr_ui_widget), sample_view,
|
|
||||||
true, true, 5);
|
|
||||||
|
|
||||||
ui->drmr_widget = drmr_ui_widget;
|
ui->drmr_widget = drmr_ui_widget;
|
||||||
ui->sample_table = NULL;
|
ui->sample_table = NULL;
|
||||||
@ -660,11 +594,9 @@ static void build_drmr_ui(DrMrUi* ui) {
|
|||||||
ui->base_label = GTK_LABEL(base_label);
|
ui->base_label = GTK_LABEL(base_label);
|
||||||
ui->base_spin = GTK_SPIN_BUTTON(base_spin);
|
ui->base_spin = GTK_SPIN_BUTTON(base_spin);
|
||||||
ui->no_kit_label = no_kit_label;
|
ui->no_kit_label = no_kit_label;
|
||||||
ui->sample_view = GTK_SCROLLED_WINDOW(sample_view);
|
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(kit_combo_box),"changed",G_CALLBACK(kit_combobox_changed),ui);
|
g_signal_connect(G_OBJECT(kit_combo_box),"changed",G_CALLBACK(kit_combobox_changed),ui);
|
||||||
g_signal_connect(G_OBJECT(base_spin),"value-changed",G_CALLBACK(base_changed),ui);
|
g_signal_connect(G_OBJECT(base_spin),"value-changed",G_CALLBACK(base_changed),ui);
|
||||||
g_signal_connect(G_OBJECT(ui->channel_combo_box),"changed",G_CALLBACK(channel_combobox_changed),ui);
|
|
||||||
g_signal_connect(G_OBJECT(ui->position_combo_box),"changed",G_CALLBACK(position_combobox_changed),ui);
|
g_signal_connect(G_OBJECT(ui->position_combo_box),"changed",G_CALLBACK(position_combobox_changed),ui);
|
||||||
g_signal_connect(G_OBJECT(ui->velocity_checkbox),"toggled",G_CALLBACK(ignore_velocity_toggled),ui);
|
g_signal_connect(G_OBJECT(ui->velocity_checkbox),"toggled",G_CALLBACK(ignore_velocity_toggled),ui);
|
||||||
g_signal_connect(G_OBJECT(ui->note_off_checkbox),"toggled",G_CALLBACK(ignore_note_off_toggled),ui);
|
g_signal_connect(G_OBJECT(ui->note_off_checkbox),"toggled",G_CALLBACK(ignore_note_off_toggled),ui);
|
||||||
@ -794,18 +726,14 @@ port_event(LV2UI_Handle handle,
|
|||||||
if (!strncmp(kitpath, "file://", 7))
|
if (!strncmp(kitpath, "file://", 7))
|
||||||
kitpath += 7;
|
kitpath += 7;
|
||||||
char *realp = realpath(kitpath,NULL);
|
char *realp = realpath(kitpath,NULL);
|
||||||
// fprintf(stderr, "KitPath: [%s] RealPath: [%s]\n", kitpath, realp);
|
|
||||||
if (!realp) {
|
if (!realp) {
|
||||||
fprintf(stderr,"Passed a path I can't resolve, bailing out\n");
|
fprintf(stderr,"Passed a path I can't resolve, bailing out\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
for(i = 0;i < ui->kits->num_kits;i++)
|
for(i = 0;i < ui->kits->num_kits;i++)
|
||||||
{
|
|
||||||
// fprintf(stderr, "CheckPath: [%s] / [%s]\n", ui->kits->kits[i].path, realp);
|
|
||||||
if (!strcmp(ui->kits->kits[i].path,realp))
|
if (!strcmp(ui->kits->kits[i].path,realp))
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
if (i < ui->kits->num_kits) {
|
if (i < ui->kits->num_kits) {
|
||||||
ui->kitReq = i;
|
ui->kitReq = i;
|
||||||
g_idle_add(kit_callback,ui);
|
g_idle_add(kit_callback,ui);
|
||||||
@ -816,12 +744,10 @@ port_event(LV2UI_Handle handle,
|
|||||||
if (obj->body.otype == ui->uris.get_state) { // read out extra state info
|
if (obj->body.otype == ui->uris.get_state) { // read out extra state info
|
||||||
const LV2_Atom* ignvel = NULL;
|
const LV2_Atom* ignvel = NULL;
|
||||||
const LV2_Atom* ignno = NULL;
|
const LV2_Atom* ignno = NULL;
|
||||||
const LV2_Atom* channel_nb = NULL;
|
|
||||||
const LV2_Atom* zerop = NULL;
|
const LV2_Atom* zerop = NULL;
|
||||||
lv2_atom_object_get(obj,
|
lv2_atom_object_get(obj,
|
||||||
ui->uris.velocity_toggle, &ignvel,
|
ui->uris.velocity_toggle, &ignvel,
|
||||||
ui->uris.note_off_toggle, &ignno,
|
ui->uris.note_off_toggle, &ignno,
|
||||||
ui->uris.channel_nb, &channel_nb,
|
|
||||||
ui->uris.zero_position, &zerop,
|
ui->uris.zero_position, &zerop,
|
||||||
0);
|
0);
|
||||||
if (ignvel)
|
if (ignvel)
|
||||||
@ -830,9 +756,6 @@ port_event(LV2UI_Handle handle,
|
|||||||
if (ignno)
|
if (ignno)
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui->note_off_checkbox),
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui->note_off_checkbox),
|
||||||
((const LV2_Atom_Bool*)ignno)->body);
|
((const LV2_Atom_Bool*)ignno)->body);
|
||||||
if (channel_nb)
|
|
||||||
gtk_combo_box_set_active(GTK_COMBO_BOX(ui->channel_combo_box),
|
|
||||||
((const LV2_Atom_Int*)channel_nb)->body);
|
|
||||||
if (zerop)
|
if (zerop)
|
||||||
gtk_combo_box_set_active(GTK_COMBO_BOX(ui->position_combo_box),
|
gtk_combo_box_set_active(GTK_COMBO_BOX(ui->position_combo_box),
|
||||||
((const LV2_Atom_Int*)zerop)->body);
|
((const LV2_Atom_Int*)zerop)->body);
|
||||||
|
Loading…
Reference in New Issue
Block a user