Readable LV2 active voices with control port

This commit is contained in:
Jean Pierre Cimalando 2020-07-26 13:50:35 +02:00
parent c2716c3bea
commit aff0fedb38
2 changed files with 17 additions and 36 deletions

View file

@ -63,7 +63,6 @@
#define SFIZZ__sfzFile SFIZZ_URI ":" "sfzfile"
#define SFIZZ__tuningfile SFIZZ_URI ":" "tuningfile"
#define SFIZZ__numVoices SFIZZ_URI ":" "numvoices"
#define SFIZZ__activeVoices SFIZZ_URI ":" "activevoices"
#define SFIZZ__preloadSize SFIZZ_URI ":" "preload_size"
#define SFIZZ__oversampling SFIZZ_URI ":" "oversampling"
// These ones are just for the worker
@ -115,6 +114,7 @@ typedef struct
const float *scala_root_key_port;
const float *tuning_frequency_port;
const float *stretch_tuning_port;
float *active_voices_port;
// Atom forge
LV2_Atom_Forge forge; ///< Forge for writing atoms in run thread
@ -184,6 +184,7 @@ enum
SFIZZ_SCALA_ROOT_KEY = 9,
SFIZZ_TUNING_FREQUENCY = 10,
SFIZZ_STRETCH_TUNING = 11,
SFIZZ_ACTIVE_VOICES = 12,
};
static void
@ -228,7 +229,6 @@ sfizz_lv2_map_required_uris(sfizz_plugin_t *self)
self->sfizz_log_status_uri = map->map(map->handle, SFIZZ__logStatus);
self->sfizz_log_status_uri = map->map(map->handle, SFIZZ__logStatus);
self->sfizz_check_modification_uri = map->map(map->handle, SFIZZ__checkModification);
self->sfizz_active_voices_uri = map->map(map->handle, SFIZZ__activeVoices);
self->time_position_uri = map->map(map->handle, LV2_TIME__Position);
}
@ -276,6 +276,9 @@ connect_port(LV2_Handle instance,
case SFIZZ_STRETCH_TUNING:
self->stretch_tuning_port = (const float *)data;
break;
case SFIZZ_ACTIVE_VOICES:
self->active_voices_port = (float *)data;
break;
default:
break;
}
@ -513,24 +516,6 @@ sfizz_lv2_send_file_path(sfizz_plugin_t *self, LV2_URID urid, const char *path)
lv2_atom_forge_pop(&self->forge, &frame);
}
static void
sfizz_lv2_send_active_voices(sfizz_plugin_t *self)
{
LV2_Atom_Forge_Frame frame;
const int active_voices = sfizz_get_num_active_voices(self->synth);
bool write_ok =
lv2_atom_forge_frame_time(&self->forge, 0) &&
lv2_atom_forge_object(&self->forge, &frame, 0, self->patch_set_uri) &&
lv2_atom_forge_key(&self->forge, self->patch_property_uri) &&
lv2_atom_forge_urid(&self->forge, self->sfizz_active_voices_uri) &&
lv2_atom_forge_key(&self->forge, self->patch_value_uri) &&
lv2_atom_forge_int(&self->forge, active_voices);
if (write_ok)
lv2_atom_forge_pop(&self->forge, &frame);
}
static void
sfizz_lv2_handle_atom_object(sfizz_plugin_t *self, const LV2_Atom_Object *obj)
{
@ -791,10 +776,6 @@ run(LV2_Handle instance, uint32_t sample_count)
{
sfizz_lv2_send_file_path(self, self->sfizz_scala_file_uri, self->scala_file_path);
}
else if (property->body == self->sfizz_active_voices_uri)
{
// We're sending it anyway, nothing to do
}
}
else if (obj->body.otype == self->time_position_uri)
{
@ -827,7 +808,7 @@ run(LV2_Handle instance, uint32_t sample_count)
sfizz_lv2_check_preload_size(self);
sfizz_lv2_check_oversampling(self);
sfizz_lv2_check_num_voices(self);
sfizz_lv2_send_active_voices(self);
*(self->active_voices_port) = sfizz_get_num_active_voices(self->synth);
// Log the buffer usage
self->sample_counter += (int)sample_count;

View file

@ -56,16 +56,6 @@ midnam:update a lv2:Feature .
"File Scala"@it ;
rdfs:range atom:Path .
<@LV2PLUGIN_URI@:activevoices>
a lv2:Parameter ;
pg:group <@LV2PLUGIN_URI@#status> ;
rdfs:label "Active voices",
"Voix utilisées"@fr ;
rdfs:range atom:Int ;
lv2:minimum 0 ;
lv2:maximum 256
.
<@LV2PLUGIN_URI@>
a doap:Project, lv2:Plugin, lv2:InstrumentPlugin ;
@ -95,7 +85,6 @@ midnam:update a lv2:Feature .
patch:writable <@LV2PLUGIN_URI@:sfzfile> ,
<@LV2PLUGIN_URI@:tuningfile> ;
patch:readable <@LV2PLUGIN_URI@:activevoices> ;
lv2:port [
a lv2:InputPort, atom:AtomPort ;
@ -308,4 +297,15 @@ midnam:update a lv2:Feature .
lv2:minimum 0.0 ;
lv2:maximum 1.0 ;
units:unit units:coef
] , [
a lv2:OutputPort, lv2:ControlPort ;
lv2:index 12 ;
lv2:symbol "active_voices" ;
lv2:name "Active voices",
"Voix utilisées"@fr ;
pg:group <@LV2PLUGIN_URI@#status> ;
lv2:portProperty lv2:integer ;
lv2:default 0 ;
lv2:minimum 0 ;
lv2:maximum 256 ;
] .