| 1 |
|
| 2 |
nn |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include <ags/audio/fx/ags_fx_vst3_channel.h> |
| 21 |
|
| 22 |
#include <ags/plugin/ags_vst3_manager.h> |
| 23 |
#include <ags/plugin/ags_vst3_plugin.h> |
| 24 |
#include <ags/plugin/ags_base_plugin.h> |
| 25 |
#include <ags/plugin/ags_plugin_port.h> |
| 26 |
|
| 27 |
#include <ags/audio/ags_output.h> |
| 28 |
#include <ags/audio/ags_input.h> |
| 29 |
#include <ags/audio/ags_playback_domain.h> |
| 30 |
#include <ags/audio/ags_playback.h> |
| 31 |
#include <ags/audio/ags_port_util.h> |
| 32 |
|
| 33 |
#include <ags/audio/thread/ags_audio_thread.h> |
| 34 |
#include <ags/audio/thread/ags_channel_thread.h> |
| 35 |
|
| 36 |
#include <ags/audio/task/ags_write_vst3_port.h> |
| 37 |
|
| 38 |
#include <ags/audio/fx/ags_fx_vst3_audio.h> |
| 39 |
|
| 40 |
#include <ags/i18n.h> |
| 41 |
|
| 42 |
void ags_fx_vst3_channel_class_init(AgsFxVst3ChannelClass *fx_vst3_channel); |
| 43 |
void ags_fx_vst3_channel_init(AgsFxVst3Channel *fx_vst3_channel); |
| 44 |
void ags_fx_vst3_channel_dispose(GObject *gobject); |
| 45 |
void ags_fx_vst3_channel_finalize(GObject *gobject); |
| 46 |
|
| 47 |
void ags_fx_vst3_channel_notify_filename_callback(GObject *gobject, |
| 48 |
GParamSpec *pspec, |
| 49 |
gpointer user_data); |
| 50 |
void ags_fx_vst3_channel_notify_effect_callback(GObject *gobject, |
| 51 |
GParamSpec *pspec, |
| 52 |
gpointer user_data); |
| 53 |
void ags_fx_vst3_channel_notify_buffer_size_callback(GObject *gobject, |
| 54 |
GParamSpec *pspec, |
| 55 |
gpointer user_data); |
| 56 |
void ags_fx_vst3_channel_notify_samplerate_callback(GObject *gobject, |
| 57 |
GParamSpec *pspec, |
| 58 |
gpointer user_data); |
| 59 |
|
| 60 |
void ags_fx_vst3_channel_safe_write_callback(AgsPort *port, GValue *value, |
| 61 |
AgsFxVst3Channel *fx_vst3_channel); |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
static gpointer ags_fx_vst3_channel_parent_class = NULL; |
| 74 |
|
| 75 |
const gchar *ags_fx_vst3_channel_plugin_name = "ags-fx-vst3"; |
| 76 |
|
| 77 |
GType |
| 78 |
ags_fx_vst3_channel_get_type() |
| 79 |
{ |
| 80 |
static gsize g_define_type_id__static = 0; |
| 81 |
|
| 82 |
if(g_once_init_enter(&g_define_type_id__static)){ |
| 83 |
GType ags_type_fx_vst3_channel = 0; |
| 84 |
|
| 85 |
static const GTypeInfo ags_fx_vst3_channel_info = { |
| 86 |
sizeof (AgsFxVst3ChannelClass), |
| 87 |
NULL, |
| 88 |
NULL, |
| 89 |
(GClassInitFunc) ags_fx_vst3_channel_class_init, |
| 90 |
NULL, |
| 91 |
NULL, |
| 92 |
sizeof (AgsFxVst3Channel), |
| 93 |
0, |
| 94 |
(GInstanceInitFunc) ags_fx_vst3_channel_init, |
| 95 |
}; |
| 96 |
|
| 97 |
ags_type_fx_vst3_channel = g_type_register_static(AGS_TYPE_FX_NOTATION_CHANNEL, |
| 98 |
"AgsFxVst3Channel", |
| 99 |
&ags_fx_vst3_channel_info, |
| 100 |
0); |
| 101 |
|
| 102 |
g_once_init_leave(&g_define_type_id__static, ags_type_fx_vst3_channel); |
| 103 |
} |
| 104 |
|
| 105 |
return(g_define_type_id__static); |
| 106 |
} |
| 107 |
|
| 108 |
void |
| 109 |
ags_fx_vst3_channel_class_init(AgsFxVst3ChannelClass *fx_vst3_channel) |
| 110 |
{ |
| 111 |
GObjectClass *gobject; |
| 112 |
|
| 113 |
ags_fx_vst3_channel_parent_class = g_type_class_peek_parent(fx_vst3_channel); |
| 114 |
|
| 115 |
|
| 116 |
gobject = (GObjectClass *) fx_vst3_channel; |
| 117 |
|
| 118 |
gobject->dispose = ags_fx_vst3_channel_dispose; |
| 119 |
gobject->finalize = ags_fx_vst3_channel_finalize; |
| 120 |
} |
| 121 |
|
| 122 |
void |
| 123 |
ags_fx_vst3_channel_init(AgsFxVst3Channel *fx_vst3_channel) |
| 124 |
{ |
| 125 |
guint i; |
| 126 |
|
| 127 |
g_signal_connect(fx_vst3_channel, "notify::filename", |
| 128 |
G_CALLBACK(ags_fx_vst3_channel_notify_filename_callback), NULL); |
| 129 |
|
| 130 |
g_signal_connect(fx_vst3_channel, "notify::effect", |
| 131 |
G_CALLBACK(ags_fx_vst3_channel_notify_effect_callback), NULL); |
| 132 |
|
| 133 |
g_signal_connect(fx_vst3_channel, "notify::buffer-size", |
| 134 |
G_CALLBACK(ags_fx_vst3_channel_notify_buffer_size_callback), NULL); |
| 135 |
|
| 136 |
g_signal_connect(fx_vst3_channel, "notify::samplerate", |
| 137 |
G_CALLBACK(ags_fx_vst3_channel_notify_samplerate_callback), NULL); |
| 138 |
|
| 139 |
AGS_RECALL(fx_vst3_channel)->name = "ags-fx-vst3"; |
| 140 |
AGS_RECALL(fx_vst3_channel)->version = AGS_RECALL_DEFAULT_VERSION; |
| 141 |
AGS_RECALL(fx_vst3_channel)->build_id = AGS_RECALL_DEFAULT_BUILD_ID; |
| 142 |
AGS_RECALL(fx_vst3_channel)->xml_type = "ags-fx-vst3-channel"; |
| 143 |
|
| 144 |
fx_vst3_channel->output_port_count = 0; |
| 145 |
fx_vst3_channel->output_port = NULL; |
| 146 |
|
| 147 |
fx_vst3_channel->input_port_count = 0; |
| 148 |
fx_vst3_channel->input_port = NULL; |
| 149 |
|
| 150 |
fx_vst3_channel->parameter_changes[0].param_id = ~0; |
| 151 |
|
| 152 |
|
| 153 |
for(i = 0; i < AGS_SOUND_SCOPE_LAST; i++){ |
| 154 |
fx_vst3_channel->input_data[i] = ags_fx_vst3_channel_input_data_alloc(); |
| 155 |
|
| 156 |
fx_vst3_channel->input_data[i]->parent = fx_vst3_channel; |
| 157 |
} |
| 158 |
|
| 159 |
fx_vst3_channel->vst3_plugin = NULL; |
| 160 |
|
| 161 |
fx_vst3_channel->vst3_port = NULL; |
| 162 |
} |
| 163 |
|
| 164 |
void |
| 165 |
ags_fx_vst3_channel_dispose(GObject *gobject) |
| 166 |
{ |
| 167 |
AgsFxVst3Channel *fx_vst3_channel; |
| 168 |
|
| 169 |
fx_vst3_channel = AGS_FX_VST3_CHANNEL(gobject); |
| 170 |
|
| 171 |
|
| 172 |
G_OBJECT_CLASS(ags_fx_vst3_channel_parent_class)->dispose(gobject); |
| 173 |
} |
| 174 |
|
| 175 |
void |
| 176 |
ags_fx_vst3_channel_finalize(GObject *gobject) |
| 177 |
{ |
| 178 |
AgsPort **iter; |
| 179 |
AgsFxVst3Channel *fx_vst3_channel; |
| 180 |
|
| 181 |
guint i; |
| 182 |
|
| 183 |
fx_vst3_channel = AGS_FX_VST3_CHANNEL(gobject); |
| 184 |
|
| 185 |
g_free(fx_vst3_channel->output_port); |
| 186 |
g_free(fx_vst3_channel->input_port); |
| 187 |
|
| 188 |
for(i = 0; i < AGS_SOUND_SCOPE_LAST; i++){ |
| 189 |
ags_fx_vst3_channel_input_data_free(fx_vst3_channel->input_data[i]); |
| 190 |
} |
| 191 |
|
| 192 |
if(fx_vst3_channel->vst3_plugin != NULL){ |
| 193 |
g_object_unref(fx_vst3_channel->vst3_plugin); |
| 194 |
} |
| 195 |
|
| 196 |
if(fx_vst3_channel->vst3_port != NULL){ |
| 197 |
for(iter = fx_vst3_channel->vst3_port; iter[0] != NULL; iter++){ |
| 198 |
g_object_unref(iter[0]); |
| 199 |
} |
| 200 |
|
| 201 |
g_free(fx_vst3_channel->vst3_port); |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
G_OBJECT_CLASS(ags_fx_vst3_channel_parent_class)->finalize(gobject); |
| 206 |
} |
| 207 |
|
| 208 |
void |
| 209 |
ags_fx_vst3_channel_notify_filename_callback(GObject *gobject, |
| 210 |
GParamSpec *pspec, |
| 211 |
gpointer user_data) |
| 212 |
{ |
| 213 |
AgsFxVst3Channel *fx_vst3_channel; |
| 214 |
|
| 215 |
AgsVst3Manager *vst3_manager; |
| 216 |
|
| 217 |
gchar *filename, *effect; |
| 218 |
|
| 219 |
GRecMutex *recall_mutex; |
| 220 |
|
| 221 |
fx_vst3_channel = AGS_FX_VST3_CHANNEL(gobject); |
| 222 |
|
| 223 |
vst3_manager = ags_vst3_manager_get_instance(); |
| 224 |
|
| 225 |
|
| 226 |
recall_mutex = AGS_RECALL_GET_OBJ_MUTEX(fx_vst3_channel); |
| 227 |
|
| 228 |
filename = NULL; |
| 229 |
effect = NULL; |
| 230 |
|
| 231 |
g_object_get(fx_vst3_channel, |
| 232 |
"filename", &filename, |
| 233 |
"effect", &effect, |
| 234 |
NULL); |
| 235 |
|
| 236 |
|
| 237 |
g_rec_mutex_lock(recall_mutex); |
| 238 |
|
| 239 |
if(filename != NULL && |
| 240 |
effect != NULL){ |
| 241 |
fx_vst3_channel->vst3_plugin = ags_vst3_manager_find_vst3_plugin(vst3_manager, |
| 242 |
filename, effect); |
| 243 |
} |
| 244 |
|
| 245 |
g_rec_mutex_unlock(recall_mutex); |
| 246 |
|
| 247 |
g_free(filename); |
| 248 |
g_free(effect); |
| 249 |
} |
| 250 |
|
| 251 |
void |
| 252 |
ags_fx_vst3_channel_notify_effect_callback(GObject *gobject, |
| 253 |
GParamSpec *pspec, |
| 254 |
gpointer user_data) |
| 255 |
{ |
| 256 |
AgsFxVst3Channel *fx_vst3_channel; |
| 257 |
|
| 258 |
AgsVst3Manager *vst3_manager; |
| 259 |
|
| 260 |
gchar *filename, *effect; |
| 261 |
|
| 262 |
GRecMutex *recall_mutex; |
| 263 |
|
| 264 |
fx_vst3_channel = AGS_FX_VST3_CHANNEL(gobject); |
| 265 |
|
| 266 |
vst3_manager = ags_vst3_manager_get_instance(); |
| 267 |
|
| 268 |
|
| 269 |
recall_mutex = AGS_RECALL_GET_OBJ_MUTEX(fx_vst3_channel); |
| 270 |
|
| 271 |
filename = NULL; |
| 272 |
effect = NULL; |
| 273 |
|
| 274 |
g_object_get(fx_vst3_channel, |
| 275 |
"filename", &filename, |
| 276 |
"effect", &effect, |
| 277 |
NULL); |
| 278 |
|
| 279 |
|
| 280 |
g_rec_mutex_lock(recall_mutex); |
| 281 |
|
| 282 |
if(filename != NULL && |
| 283 |
effect != NULL){ |
| 284 |
fx_vst3_channel->vst3_plugin = ags_vst3_manager_find_vst3_plugin(vst3_manager, |
| 285 |
filename, effect); |
| 286 |
} |
| 287 |
|
| 288 |
g_rec_mutex_unlock(recall_mutex); |
| 289 |
|
| 290 |
g_free(filename); |
| 291 |
g_free(effect); |
| 292 |
} |
| 293 |
|
| 294 |
void |
| 295 |
ags_fx_vst3_channel_notify_buffer_size_callback(GObject *gobject, |
| 296 |
GParamSpec *pspec, |
| 297 |
gpointer user_data) |
| 298 |
{ |
| 299 |
AgsFxVst3Channel *fx_vst3_channel; |
| 300 |
|
| 301 |
guint output_port_count, input_port_count; |
| 302 |
guint buffer_size; |
| 303 |
guint i; |
| 304 |
|
| 305 |
GRecMutex *recall_mutex; |
| 306 |
|
| 307 |
fx_vst3_channel = AGS_FX_VST3_CHANNEL(gobject); |
| 308 |
|
| 309 |
if(!ags_recall_test_state_flags(AGS_RECALL(fx_vst3_channel), |
| 310 |
AGS_SOUND_STATE_PORT_LOADED)){ |
| 311 |
return; |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
recall_mutex = AGS_RECALL_GET_OBJ_MUTEX(fx_vst3_channel); |
| 316 |
|
| 317 |
|
| 318 |
g_object_get(fx_vst3_channel, |
| 319 |
"buffer-size", &buffer_size, |
| 320 |
NULL); |
| 321 |
|
| 322 |
|
| 323 |
g_rec_mutex_lock(recall_mutex); |
| 324 |
|
| 325 |
output_port_count = fx_vst3_channel->output_port_count; |
| 326 |
input_port_count = fx_vst3_channel->input_port_count; |
| 327 |
|
| 328 |
for(i = 0; i < AGS_SOUND_SCOPE_LAST; i++){ |
| 329 |
AgsFxVst3ChannelInputData *input_data; |
| 330 |
|
| 331 |
input_data = fx_vst3_channel->input_data[i]; |
| 332 |
|
| 333 |
ags_vst_process_data_set_num_samples(input_data->process_data, |
| 334 |
buffer_size); |
| 335 |
|
| 336 |
if(output_port_count > 0 && |
| 337 |
buffer_size > 0){ |
| 338 |
if(input_data->output == NULL){ |
| 339 |
input_data->output = (float *) g_malloc(output_port_count * buffer_size * sizeof(float)); |
| 340 |
}else{ |
| 341 |
input_data->output = (float *) g_realloc(input_data->output, |
| 342 |
output_port_count * buffer_size * sizeof(float)); |
| 343 |
} |
| 344 |
} |
| 345 |
|
| 346 |
if(input_port_count > 0 && |
| 347 |
buffer_size > 0){ |
| 348 |
if(input_data->input == NULL){ |
| 349 |
input_data->input = (float *) g_malloc(input_port_count * buffer_size * sizeof(float)); |
| 350 |
}else{ |
| 351 |
input_data->input = (float *) g_realloc(input_data->input, |
| 352 |
input_port_count * buffer_size * sizeof(float)); |
| 353 |
} |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 357 |
g_rec_mutex_unlock(recall_mutex); |
| 358 |
} |
| 359 |
|
| 360 |
void |
| 361 |
ags_fx_vst3_channel_notify_samplerate_callback(GObject *gobject, |
| 362 |
GParamSpec *pspec, |
| 363 |
gpointer user_data) |
| 364 |
{ |
| 365 |
AgsFxVst3Channel *fx_vst3_channel; |
| 366 |
|
| 367 |
fx_vst3_channel = AGS_FX_VST3_CHANNEL(gobject); |
| 368 |
|
| 369 |
|
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
AgsFxVst3ChannelInputData* |
| 382 |
ags_fx_vst3_channel_input_data_alloc() |
| 383 |
{ |
| 384 |
AgsFxVst3ChannelInputData *input_data; |
| 385 |
|
| 386 |
AgsConfig *config; |
| 387 |
|
| 388 |
AgsVstAudioBusBuffers *output, *input; |
| 389 |
|
| 390 |
guint buffer_size; |
| 391 |
|
| 392 |
input_data = (AgsFxVst3ChannelInputData *) g_malloc(sizeof(AgsFxVst3ChannelInputData)); |
| 393 |
|
| 394 |
config = ags_config_get_instance(); |
| 395 |
|
| 396 |
buffer_size = ags_soundcard_helper_config_get_buffer_size(config); |
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
g_rec_mutex_init(&(input_data->strct_mutex)); |
| 401 |
|
| 402 |
input_data->parent = NULL; |
| 403 |
|
| 404 |
input_data->output = g_malloc(2 * buffer_size * sizeof(float)); |
| 405 |
input_data->input = g_malloc(2 * buffer_size * sizeof(float)); |
| 406 |
|
| 407 |
input_data->icomponent = NULL; |
| 408 |
input_data->iedit_controller = NULL; |
| 409 |
input_data->iaudio_processor = NULL; |
| 410 |
|
| 411 |
input_data->iedit_controller_host_editing = NULL; |
| 412 |
|
| 413 |
input_data->icomponent_handler = NULL; |
| 414 |
|
| 415 |
input_data->begin_edit_callback = NULL; |
| 416 |
input_data->perform_edit_callback = NULL; |
| 417 |
input_data->end_edit_callback = NULL; |
| 418 |
input_data->restart_component_callback = NULL; |
| 419 |
|
| 420 |
|
| 421 |
input_data->process_data = ags_vst_process_data_alloc(); |
| 422 |
|
| 423 |
ags_vst_process_data_set_process_mode(input_data->process_data, |
| 424 |
AGS_VST_KREALTIME); |
| 425 |
|
| 426 |
ags_vst_process_data_set_symbolic_sample_size(input_data->process_data, |
| 427 |
AGS_VST_KSAMPLE32); |
| 428 |
|
| 429 |
ags_vst_process_data_set_num_samples(input_data->process_data, |
| 430 |
buffer_size); |
| 431 |
|
| 432 |
ags_vst_process_data_set_num_inputs(input_data->process_data, |
| 433 |
1); |
| 434 |
|
| 435 |
ags_vst_process_data_set_num_outputs(input_data->process_data, |
| 436 |
1); |
| 437 |
|
| 438 |
|
| 439 |
input_data->process_context = ags_vst_process_context_alloc(); |
| 440 |
|
| 441 |
ags_vst_process_data_set_process_context(input_data->process_data, |
| 442 |
input_data->process_context); |
| 443 |
|
| 444 |
|
| 445 |
input = ags_vst_audio_bus_buffers_alloc(); |
| 446 |
|
| 447 |
ags_vst_audio_bus_buffers_set_num_channels(input, |
| 448 |
2); |
| 449 |
|
| 450 |
ags_vst_audio_bus_buffers_set_silence_flags(input, |
| 451 |
0); |
| 452 |
|
| 453 |
ags_vst_audio_bus_buffers_set_samples32(input, |
| 454 |
&(input_data->input)); |
| 455 |
|
| 456 |
ags_vst_process_data_set_inputs(input_data->process_data, |
| 457 |
input); |
| 458 |
|
| 459 |
|
| 460 |
output = ags_vst_audio_bus_buffers_alloc(); |
| 461 |
|
| 462 |
ags_vst_audio_bus_buffers_set_num_channels(output, |
| 463 |
2); |
| 464 |
|
| 465 |
ags_vst_audio_bus_buffers_set_silence_flags(output, |
| 466 |
0); |
| 467 |
|
| 468 |
ags_vst_audio_bus_buffers_set_samples32(output, |
| 469 |
&(input_data->output)); |
| 470 |
|
| 471 |
ags_vst_process_data_set_outputs(input_data->process_data, |
| 472 |
output); |
| 473 |
|
| 474 |
|
| 475 |
input_data->input_parameter_changes = ags_vst_parameter_changes_new(); |
| 476 |
|
| 477 |
ags_vst_parameter_changes_set_max_parameters(input_data->input_parameter_changes, |
| 478 |
AGS_FX_VST3_CHANNEL_MAX_PARAMETER_CHANGES); |
| 479 |
|
| 480 |
ags_vst_process_data_set_input_iparameter_changes(input_data->process_data, |
| 481 |
(AgsVstIParameterChanges *) input_data->input_parameter_changes); |
| 482 |
|
| 483 |
input_data->parameter_changes[0].param_id = ~0; |
| 484 |
|
| 485 |
return(input_data); |
| 486 |
} |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
void |
| 497 |
ags_fx_vst3_channel_input_data_free(AgsFxVst3ChannelInputData *input_data) |
| 498 |
{ |
| 499 |
AgsVst3Plugin *vst3_plugin; |
| 500 |
|
| 501 |
if(input_data == NULL){ |
| 502 |
return; |
| 503 |
} |
| 504 |
|
| 505 |
g_free(input_data->output); |
| 506 |
g_free(input_data->input); |
| 507 |
|
| 508 |
if(input_data->icomponent != NULL){ |
| 509 |
GRecMutex *base_plugin_mutex; |
| 510 |
|
| 511 |
vst3_plugin = NULL; |
| 512 |
|
| 513 |
base_plugin_mutex = NULL; |
| 514 |
|
| 515 |
if(input_data->parent != NULL){ |
| 516 |
vst3_plugin = AGS_FX_VST3_CHANNEL(input_data->parent)->vst3_plugin; |
| 517 |
} |
| 518 |
|
| 519 |
if(vst3_plugin != NULL){ |
| 520 |
base_plugin_mutex = AGS_BASE_PLUGIN_GET_OBJ_MUTEX(vst3_plugin); |
| 521 |
} |
| 522 |
|
| 523 |
|
| 524 |
} |
| 525 |
|
| 526 |
g_free(input_data); |
| 527 |
} |
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
void |
| 538 |
ags_fx_vst3_channel_load_plugin(AgsFxVst3Channel *fx_vst3_channel) |
| 539 |
{ |
| 540 |
AgsVst3Manager *vst3_manager; |
| 541 |
AgsVst3Plugin *vst3_plugin; |
| 542 |
|
| 543 |
gchar *filename; |
| 544 |
gchar *effect; |
| 545 |
|
| 546 |
GRecMutex *recall_mutex; |
| 547 |
|
| 548 |
if(!AGS_IS_FX_VST3_CHANNEL(fx_vst3_channel)){ |
| 549 |
return; |
| 550 |
} |
| 551 |
|
| 552 |
vst3_manager = ags_vst3_manager_get_instance(); |
| 553 |
|
| 554 |
|
| 555 |
recall_mutex = AGS_RECALL_GET_OBJ_MUTEX(fx_vst3_channel); |
| 556 |
|
| 557 |
|
| 558 |
filename = NULL; |
| 559 |
effect = NULL; |
| 560 |
|
| 561 |
g_object_get(fx_vst3_channel, |
| 562 |
"filename", &filename, |
| 563 |
"effect", &effect, |
| 564 |
NULL); |
| 565 |
|
| 566 |
g_rec_mutex_lock(recall_mutex); |
| 567 |
|
| 568 |
if((vst3_plugin = fx_vst3_channel->vst3_plugin) == NULL){ |
| 569 |
vst3_plugin = |
| 570 |
fx_vst3_channel->vst3_plugin = ags_vst3_manager_find_vst3_plugin(vst3_manager, |
| 571 |
filename, effect); |
| 572 |
} |
| 573 |
|
| 574 |
g_rec_mutex_unlock(recall_mutex); |
| 575 |
|
| 576 |
g_free(filename); |
| 577 |
g_free(effect); |
| 578 |
} |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
void |
| 589 |
ags_fx_vst3_channel_load_port(AgsFxVst3Channel *fx_vst3_channel) |
| 590 |
{ |
| 591 |
AgsChannel *input; |
| 592 |
AgsFxVst3Audio *fx_vst3_audio; |
| 593 |
AgsPort **vst3_port; |
| 594 |
|
| 595 |
AgsVst3Plugin *vst3_plugin; |
| 596 |
|
| 597 |
GType channel_type; |
| 598 |
|
| 599 |
GList *start_plugin_port, *plugin_port; |
| 600 |
|
| 601 |
guint *output_port; |
| 602 |
guint *input_port; |
| 603 |
|
| 604 |
guint audio_channel; |
| 605 |
guint pad; |
| 606 |
guint line; |
| 607 |
guint output_port_count, input_port_count; |
| 608 |
guint control_port_count; |
| 609 |
guint samplerate; |
| 610 |
guint buffer_size; |
| 611 |
guint nth; |
| 612 |
guint i, j; |
| 613 |
gboolean is_live_instrument; |
| 614 |
|
| 615 |
GRecMutex *fx_vst3_audio_mutex; |
| 616 |
GRecMutex *fx_vst3_channel_mutex; |
| 617 |
|
| 618 |
if(!AGS_IS_FX_VST3_CHANNEL(fx_vst3_channel)){ |
| 619 |
return; |
| 620 |
} |
| 621 |
|
| 622 |
fx_vst3_channel_mutex = AGS_RECALL_GET_OBJ_MUTEX(fx_vst3_channel); |
| 623 |
|
| 624 |
g_rec_mutex_lock(fx_vst3_channel_mutex); |
| 625 |
|
| 626 |
if(fx_vst3_channel->vst3_port != NULL){ |
| 627 |
g_rec_mutex_unlock(fx_vst3_channel_mutex); |
| 628 |
|
| 629 |
return; |
| 630 |
} |
| 631 |
|
| 632 |
g_rec_mutex_unlock(fx_vst3_channel_mutex); |
| 633 |
|
| 634 |
fx_vst3_audio = NULL; |
| 635 |
|
| 636 |
samplerate = AGS_SOUNDCARD_DEFAULT_SAMPLERATE; |
| 637 |
buffer_size = AGS_SOUNDCARD_DEFAULT_BUFFER_SIZE; |
| 638 |
|
| 639 |
g_object_get(fx_vst3_channel, |
| 640 |
"recall-audio", &fx_vst3_audio, |
| 641 |
"samplerate", &samplerate, |
| 642 |
"buffer-size", &buffer_size, |
| 643 |
NULL); |
| 644 |
|
| 645 |
if(fx_vst3_audio == NULL){ |
| 646 |
return; |
| 647 |
} |
| 648 |
|
| 649 |
is_live_instrument = ags_fx_vst3_audio_test_flags(fx_vst3_audio, AGS_FX_VST3_AUDIO_LIVE_INSTRUMENT); |
| 650 |
|
| 651 |
if(is_live_instrument){ |
| 652 |
if(fx_vst3_audio != NULL){ |
| 653 |
g_object_unref(fx_vst3_audio); |
| 654 |
} |
| 655 |
|
| 656 |
return; |
| 657 |
} |
| 658 |
|
| 659 |
|
| 660 |
fx_vst3_audio_mutex = AGS_RECALL_GET_OBJ_MUTEX(fx_vst3_audio); |
| 661 |
|
| 662 |
input = NULL; |
| 663 |
|
| 664 |
g_object_get(fx_vst3_channel, |
| 665 |
"source", &input, |
| 666 |
NULL); |
| 667 |
|
| 668 |
line = ags_channel_get_line(input); |
| 669 |
|
| 670 |
channel_type = (AGS_IS_OUTPUT(input)) ? AGS_TYPE_OUTPUT: AGS_TYPE_INPUT; |
| 671 |
|
| 672 |
audio_channel = 0; |
| 673 |
pad = 0; |
| 674 |
|
| 675 |
g_object_get(input, |
| 676 |
"audio-channel", &audio_channel, |
| 677 |
"pad", &pad, |
| 678 |
NULL); |
| 679 |
|
| 680 |
|
| 681 |
g_rec_mutex_lock(fx_vst3_audio_mutex); |
| 682 |
|
| 683 |
vst3_plugin = fx_vst3_audio->vst3_plugin; |
| 684 |
|
| 685 |
output_port_count = fx_vst3_audio->output_port_count; |
| 686 |
output_port = fx_vst3_audio->output_port; |
| 687 |
|
| 688 |
input_port_count = fx_vst3_audio->input_port_count; |
| 689 |
input_port = fx_vst3_audio->input_port; |
| 690 |
|
| 691 |
g_rec_mutex_unlock(fx_vst3_audio_mutex); |
| 692 |
|
| 693 |
|
| 694 |
g_rec_mutex_lock(fx_vst3_channel_mutex); |
| 695 |
|
| 696 |
vst3_port = fx_vst3_channel->vst3_port; |
| 697 |
|
| 698 |
g_rec_mutex_unlock(fx_vst3_channel_mutex); |
| 699 |
|
| 700 |
start_plugin_port = NULL; |
| 701 |
|
| 702 |
g_object_get(vst3_plugin, |
| 703 |
"plugin-port", &start_plugin_port, |
| 704 |
NULL); |
| 705 |
|
| 706 |
if(ags_base_plugin_test_flags((AgsBasePlugin *) vst3_plugin, AGS_BASE_PLUGIN_IS_INSTRUMENT)){ |
| 707 |
|
| 708 |
plugin_port = start_plugin_port; |
| 709 |
|
| 710 |
control_port_count = 0; |
| 711 |
|
| 712 |
while(plugin_port != NULL){ |
| 713 |
if(ags_plugin_port_test_flags(plugin_port->data, |
| 714 |
AGS_PLUGIN_PORT_CONTROL)){ |
| 715 |
control_port_count++; |
| 716 |
} |
| 717 |
|
| 718 |
plugin_port = plugin_port->next; |
| 719 |
} |
| 720 |
|
| 721 |
|
| 722 |
if(control_port_count > 0){ |
| 723 |
vst3_port = (AgsPort **) g_malloc((control_port_count + 1) * sizeof(AgsPort *)); |
| 724 |
|
| 725 |
plugin_port = start_plugin_port; |
| 726 |
|
| 727 |
for(nth = 0; nth < control_port_count && plugin_port != NULL; ){ |
| 728 |
if(ags_plugin_port_test_flags(plugin_port->data, |
| 729 |
AGS_PLUGIN_PORT_CONTROL)){ |
| 730 |
AgsPluginPort *current_plugin_port; |
| 731 |
|
| 732 |
gchar *plugin_name; |
| 733 |
gchar *specifier; |
| 734 |
gchar *control_port; |
| 735 |
|
| 736 |
guint port_index; |
| 737 |
|
| 738 |
GValue default_value = {0,}; |
| 739 |
|
| 740 |
GRecMutex *plugin_port_mutex; |
| 741 |
|
| 742 |
current_plugin_port = AGS_PLUGIN_PORT(plugin_port->data); |
| 743 |
|
| 744 |
|
| 745 |
plugin_port_mutex = AGS_PLUGIN_PORT_GET_OBJ_MUTEX(current_plugin_port); |
| 746 |
|
| 747 |
|
| 748 |
plugin_name = g_strdup_printf("vst3-<%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x>", |
| 749 |
vst3_plugin->cid[0], |
| 750 |
vst3_plugin->cid[1], |
| 751 |
vst3_plugin->cid[2], |
| 752 |
vst3_plugin->cid[3], |
| 753 |
vst3_plugin->cid[4], |
| 754 |
vst3_plugin->cid[5], |
| 755 |
vst3_plugin->cid[6], |
| 756 |
vst3_plugin->cid[7], |
| 757 |
vst3_plugin->cid[8], |
| 758 |
vst3_plugin->cid[9], |
| 759 |
vst3_plugin->cid[10], |
| 760 |
vst3_plugin->cid[11], |
| 761 |
vst3_plugin->cid[12], |
| 762 |
vst3_plugin->cid[13], |
| 763 |
vst3_plugin->cid[14], |
| 764 |
vst3_plugin->cid[15]); |
| 765 |
|
| 766 |
specifier = NULL; |
| 767 |
|
| 768 |
port_index = 0; |
| 769 |
|
| 770 |
g_object_get(current_plugin_port, |
| 771 |
"port-name", &specifier, |
| 772 |
"port-index", &port_index, |
| 773 |
NULL); |
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
control_port = g_strdup_printf("%u/%u", |
| 778 |
nth, |
| 779 |
control_port_count); |
| 780 |
|
| 781 |
|
| 782 |
g_value_init(&default_value, |
| 783 |
G_TYPE_DOUBLE); |
| 784 |
|
| 785 |
g_rec_mutex_lock(plugin_port_mutex); |
| 786 |
|
| 787 |
g_value_copy(current_plugin_port->default_value, |
| 788 |
&default_value); |
| 789 |
|
| 790 |
g_rec_mutex_unlock(plugin_port_mutex); |
| 791 |
|
| 792 |
|
| 793 |
vst3_port[nth] = g_object_new(AGS_TYPE_PORT, |
| 794 |
"line", line, |
| 795 |
"channel-type", channel_type, |
| 796 |
"plugin-name", plugin_name, |
| 797 |
"specifier", specifier, |
| 798 |
"control-port", control_port, |
| 799 |
"port-value-is-pointer", FALSE, |
| 800 |
"port-value-type", G_TYPE_DOUBLE, |
| 801 |
NULL); |
| 802 |
|
| 803 |
if(ags_plugin_port_test_flags(current_plugin_port, |
| 804 |
AGS_PLUGIN_PORT_OUTPUT)){ |
| 805 |
ags_port_set_flags(vst3_port[nth], AGS_PORT_IS_OUTPUT); |
| 806 |
|
| 807 |
ags_recall_set_flags((AgsRecall *) fx_vst3_channel, |
| 808 |
AGS_RECALL_HAS_OUTPUT_PORT); |
| 809 |
|
| 810 |
}else{ |
| 811 |
if(!ags_plugin_port_test_flags(current_plugin_port, |
| 812 |
AGS_PLUGIN_PORT_INTEGER) && |
| 813 |
!ags_plugin_port_test_flags(current_plugin_port, |
| 814 |
AGS_PLUGIN_PORT_TOGGLED)){ |
| 815 |
ags_port_set_flags(vst3_port[nth], AGS_PORT_INFINITE_RANGE); |
| 816 |
} |
| 817 |
} |
| 818 |
|
| 819 |
g_object_set(vst3_port[nth], |
| 820 |
"plugin-port", current_plugin_port, |
| 821 |
NULL); |
| 822 |
|
| 823 |
ags_port_util_load_vst3_conversion(vst3_port[nth], |
| 824 |
current_plugin_port); |
| 825 |
|
| 826 |
ags_port_safe_write_raw(vst3_port[nth], |
| 827 |
&default_value); |
| 828 |
|
| 829 |
ags_recall_add_port((AgsRecall *) fx_vst3_channel, |
| 830 |
vst3_port[nth]); |
| 831 |
|
| 832 |
g_signal_connect_after(vst3_port[nth], "safe-write", |
| 833 |
G_CALLBACK(ags_fx_vst3_channel_safe_write_callback), fx_vst3_channel); |
| 834 |
|
| 835 |
g_free(plugin_name); |
| 836 |
g_free(specifier); |
| 837 |
g_free(control_port); |
| 838 |
|
| 839 |
g_value_unset(&default_value); |
| 840 |
|
| 841 |
nth++; |
| 842 |
} |
| 843 |
|
| 844 |
plugin_port = plugin_port->next; |
| 845 |
} |
| 846 |
|
| 847 |
vst3_port[nth] = NULL; |
| 848 |
} |
| 849 |
|
| 850 |
|
| 851 |
g_rec_mutex_lock(fx_vst3_channel_mutex); |
| 852 |
|
| 853 |
for(i = 0; i < AGS_SOUND_SCOPE_LAST; i++){ |
| 854 |
AgsFxVst3AudioScopeData *scope_data; |
| 855 |
|
| 856 |
scope_data = fx_vst3_audio->scope_data[i]; |
| 857 |
|
| 858 |
if(i == AGS_SOUND_SCOPE_PLAYBACK || |
| 859 |
i == AGS_SOUND_SCOPE_NOTATION || |
| 860 |
i == AGS_SOUND_SCOPE_MIDI){ |
| 861 |
AgsFxVst3AudioChannelData *channel_data; |
| 862 |
|
| 863 |
channel_data = scope_data->channel_data[audio_channel]; |
| 864 |
|
| 865 |
if(!is_live_instrument){ |
| 866 |
AgsFxVst3AudioInputData *input_data; |
| 867 |
|
| 868 |
guint nth; |
| 869 |
|
| 870 |
input_data = channel_data->input_data[pad]; |
| 871 |
|
| 872 |
if(input_data->output == NULL && |
| 873 |
output_port_count > 0 && |
| 874 |
buffer_size > 0){ |
| 875 |
input_data->output = (float *) g_malloc(output_port_count * buffer_size * sizeof(float)); |
| 876 |
} |
| 877 |
|
| 878 |
if(input_data->input == NULL && |
| 879 |
input_port_count > 0 && |
| 880 |
buffer_size > 0){ |
| 881 |
input_data->input = (float *) g_malloc(input_port_count * buffer_size * sizeof(float)); |
| 882 |
} |
| 883 |
} |
| 884 |
} |
| 885 |
} |
| 886 |
|
| 887 |
g_rec_mutex_unlock(fx_vst3_channel_mutex); |
| 888 |
}else{ |
| 889 |
|
| 890 |
plugin_port = start_plugin_port; |
| 891 |
|
| 892 |
output_port = NULL; |
| 893 |
input_port = NULL; |
| 894 |
|
| 895 |
output_port_count = 0; |
| 896 |
input_port_count = 0; |
| 897 |
|
| 898 |
control_port_count = 0; |
| 899 |
|
| 900 |
while(plugin_port != NULL){ |
| 901 |
if(ags_plugin_port_test_flags(plugin_port->data, |
| 902 |
AGS_PLUGIN_PORT_CONTROL)){ |
| 903 |
control_port_count++; |
| 904 |
} |
| 905 |
|
| 906 |
plugin_port = plugin_port->next; |
| 907 |
} |
| 908 |
|
| 909 |
|
| 910 |
if(control_port_count > 0){ |
| 911 |
vst3_port = (AgsPort **) g_malloc((control_port_count + 1) * sizeof(AgsPort *)); |
| 912 |
|
| 913 |
plugin_port = start_plugin_port; |
| 914 |
|
| 915 |
for(nth = 0; nth < control_port_count && plugin_port != NULL;){ |
| 916 |
if(ags_plugin_port_test_flags(plugin_port->data, |
| 917 |
AGS_PLUGIN_PORT_CONTROL)){ |
| 918 |
AgsPluginPort *current_plugin_port; |
| 919 |
|
| 920 |
gchar *plugin_name; |
| 921 |
gchar *specifier; |
| 922 |
gchar *control_port; |
| 923 |
|
| 924 |
guint port_index; |
| 925 |
|
| 926 |
GValue default_value = {0,}; |
| 927 |
|
| 928 |
GRecMutex *plugin_port_mutex; |
| 929 |
|
| 930 |
current_plugin_port = AGS_PLUGIN_PORT(plugin_port->data); |
| 931 |
|
| 932 |
|
| 933 |
plugin_port_mutex = AGS_PLUGIN_PORT_GET_OBJ_MUTEX(current_plugin_port); |
| 934 |
|
| 935 |
|
| 936 |
plugin_name = g_strdup_printf("vst3-<%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x>", |
| 937 |
vst3_plugin->cid[0], |
| 938 |
vst3_plugin->cid[1], |
| 939 |
vst3_plugin->cid[2], |
| 940 |
vst3_plugin->cid[3], |
| 941 |
vst3_plugin->cid[4], |
| 942 |
vst3_plugin->cid[5], |
| 943 |
vst3_plugin->cid[6], |
| 944 |
vst3_plugin->cid[7], |
| 945 |
vst3_plugin->cid[8], |
| 946 |
vst3_plugin->cid[9], |
| 947 |
vst3_plugin->cid[10], |
| 948 |
vst3_plugin->cid[11], |
| 949 |
vst3_plugin->cid[12], |
| 950 |
vst3_plugin->cid[13], |
| 951 |
vst3_plugin->cid[14], |
| 952 |
vst3_plugin->cid[15]); |
| 953 |
|
| 954 |
specifier = NULL; |
| 955 |
|
| 956 |
port_index = 0; |
| 957 |
|
| 958 |
g_object_get(current_plugin_port, |
| 959 |
"port-name", &specifier, |
| 960 |
"port-index", &port_index, |
| 961 |
NULL); |
| 962 |
|
| 963 |
control_port = g_strdup_printf("%u/%u", |
| 964 |
nth, |
| 965 |
control_port_count); |
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
g_value_init(&default_value, |
| 971 |
G_TYPE_DOUBLE); |
| 972 |
|
| 973 |
g_rec_mutex_lock(plugin_port_mutex); |
| 974 |
|
| 975 |
g_value_copy(current_plugin_port->default_value, |
| 976 |
&default_value); |
| 977 |
|
| 978 |
g_rec_mutex_unlock(plugin_port_mutex); |
| 979 |
|
| 980 |
|
| 981 |
vst3_port[nth] = g_object_new(AGS_TYPE_PORT, |
| 982 |
"plugin-name", plugin_name, |
| 983 |
"specifier", specifier, |
| 984 |
"control-port", control_port, |
| 985 |
"port-value-is-pointer", FALSE, |
| 986 |
"port-value-type", G_TYPE_DOUBLE, |
| 987 |
NULL); |
| 988 |
|
| 989 |
if(ags_plugin_port_test_flags(current_plugin_port, |
| 990 |
AGS_PLUGIN_PORT_OUTPUT)){ |
| 991 |
ags_port_set_flags(vst3_port[nth], AGS_PORT_IS_OUTPUT); |
| 992 |
|
| 993 |
ags_recall_set_flags((AgsRecall *) fx_vst3_channel, |
| 994 |
AGS_RECALL_HAS_OUTPUT_PORT); |
| 995 |
|
| 996 |
}else{ |
| 997 |
if(!ags_plugin_port_test_flags(current_plugin_port, |
| 998 |
AGS_PLUGIN_PORT_INTEGER) && |
| 999 |
!ags_plugin_port_test_flags(current_plugin_port, |
| 1000 |
AGS_PLUGIN_PORT_TOGGLED)){ |
| 1001 |
ags_port_set_flags(vst3_port[nth], AGS_PORT_INFINITE_RANGE); |
| 1002 |
} |
| 1003 |
} |
| 1004 |
|
| 1005 |
g_object_set(vst3_port[nth], |
| 1006 |
"plugin-port", current_plugin_port, |
| 1007 |
NULL); |
| 1008 |
|
| 1009 |
ags_port_util_load_vst3_conversion(vst3_port[nth], |
| 1010 |
current_plugin_port); |
| 1011 |
|
| 1012 |
ags_port_safe_write_raw(vst3_port[nth], |
| 1013 |
&default_value); |
| 1014 |
|
| 1015 |
ags_recall_add_port((AgsRecall *) fx_vst3_channel, |
| 1016 |
vst3_port[nth]); |
| 1017 |
|
| 1018 |
g_signal_connect(vst3_port[nth], "safe-write", |
| 1019 |
G_CALLBACK(ags_fx_vst3_channel_safe_write_callback), fx_vst3_channel); |
| 1020 |
|
| 1021 |
g_free(plugin_name); |
| 1022 |
g_free(specifier); |
| 1023 |
g_free(control_port); |
| 1024 |
|
| 1025 |
g_value_unset(&default_value); |
| 1026 |
|
| 1027 |
nth++; |
| 1028 |
} |
| 1029 |
|
| 1030 |
plugin_port = plugin_port->next; |
| 1031 |
} |
| 1032 |
|
| 1033 |
vst3_port[nth] = NULL; |
| 1034 |
} |
| 1035 |
|
| 1036 |
|
| 1037 |
g_rec_mutex_lock(fx_vst3_channel_mutex); |
| 1038 |
|
| 1039 |
for(i = 0; i < AGS_SOUND_SCOPE_LAST; i++){ |
| 1040 |
AgsFxVst3ChannelInputData *input_data; |
| 1041 |
|
| 1042 |
input_data = fx_vst3_channel->input_data[i]; |
| 1043 |
|
| 1044 |
if(input_data->output == NULL && |
| 1045 |
output_port_count > 0 && |
| 1046 |
buffer_size > 0){ |
| 1047 |
input_data->output = (float *) g_malloc(output_port_count * buffer_size * sizeof(float)); |
| 1048 |
} |
| 1049 |
|
| 1050 |
if(input_data->input == NULL && |
| 1051 |
input_port_count > 0 && |
| 1052 |
buffer_size > 0){ |
| 1053 |
input_data->input = (float *) g_malloc(input_port_count * buffer_size * sizeof(float)); |
| 1054 |
} |
| 1055 |
} |
| 1056 |
|
| 1057 |
fx_vst3_channel->output_port_count = output_port_count; |
| 1058 |
fx_vst3_channel->output_port = output_port; |
| 1059 |
|
| 1060 |
fx_vst3_channel->input_port_count = input_port_count; |
| 1061 |
fx_vst3_channel->input_port = input_port; |
| 1062 |
|
| 1063 |
g_rec_mutex_unlock(fx_vst3_channel_mutex); |
| 1064 |
} |
| 1065 |
|
| 1066 |
|
| 1067 |
g_rec_mutex_lock(fx_vst3_channel_mutex); |
| 1068 |
|
| 1069 |
fx_vst3_channel->vst3_port = vst3_port; |
| 1070 |
|
| 1071 |
g_rec_mutex_unlock(fx_vst3_channel_mutex); |
| 1072 |
|
| 1073 |
|
| 1074 |
if(fx_vst3_audio != NULL){ |
| 1075 |
g_object_unref(fx_vst3_audio); |
| 1076 |
} |
| 1077 |
|
| 1078 |
g_list_free_full(start_plugin_port, |
| 1079 |
(GDestroyNotify) g_object_unref); |
| 1080 |
} |
| 1081 |
|
| 1082 |
void |
| 1083 |
ags_fx_vst3_channel_safe_write_callback(AgsPort *port, GValue *value, |
| 1084 |
AgsFxVst3Channel *fx_vst3_channel) |
| 1085 |
{ |
| 1086 |
AgsAudio *audio; |
| 1087 |
AgsChannel *start_output, *output; |
| 1088 |
AgsChannel *source; |
| 1089 |
AgsPlaybackDomain *playback_domain; |
| 1090 |
|
| 1091 |
AgsFxVst3Audio *fx_vst3_audio; |
| 1092 |
|
| 1093 |
AgsVst3Plugin *vst3_plugin; |
| 1094 |
|
| 1095 |
GList *start_output_playback, *output_playback; |
| 1096 |
|
| 1097 |
guint audio_channels; |
| 1098 |
guint audio_channel; |
| 1099 |
guint i, i_start, i_stop; |
| 1100 |
guint j; |
| 1101 |
gboolean is_live_instrument; |
| 1102 |
|
| 1103 |
GRecMutex *fx_vst3_audio_mutex; |
| 1104 |
|
| 1105 |
fx_vst3_audio = NULL; |
| 1106 |
|
| 1107 |
g_object_get(fx_vst3_channel, |
| 1108 |
"recall-audio", &fx_vst3_audio, |
| 1109 |
NULL); |
| 1110 |
|
| 1111 |
if(fx_vst3_audio == NULL){ |
| 1112 |
return; |
| 1113 |
} |
| 1114 |
|
| 1115 |
|
| 1116 |
fx_vst3_audio_mutex = AGS_RECALL_GET_OBJ_MUTEX(fx_vst3_audio); |
| 1117 |
|
| 1118 |
g_rec_mutex_lock(fx_vst3_audio_mutex); |
| 1119 |
|
| 1120 |
vst3_plugin = fx_vst3_audio->vst3_plugin; |
| 1121 |
|
| 1122 |
g_rec_mutex_unlock(fx_vst3_audio_mutex); |
| 1123 |
|
| 1124 |
if(vst3_plugin == NULL){ |
| 1125 |
g_warning("can't get VST3 plugin"); |
| 1126 |
|
| 1127 |
|
| 1128 |
if(fx_vst3_audio != NULL){ |
| 1129 |
g_object_unref(fx_vst3_audio); |
| 1130 |
} |
| 1131 |
|
| 1132 |
return; |
| 1133 |
} |
| 1134 |
|
| 1135 |
audio = NULL; |
| 1136 |
source = NULL; |
| 1137 |
|
| 1138 |
audio_channels = 0; |
| 1139 |
|
| 1140 |
g_object_get(fx_vst3_audio, |
| 1141 |
"audio", &audio, |
| 1142 |
"audio-channels", &audio_channels, |
| 1143 |
NULL); |
| 1144 |
|
| 1145 |
if(audio == NULL){ |
| 1146 |
g_warning("can't get audio"); |
| 1147 |
|
| 1148 |
|
| 1149 |
if(fx_vst3_audio != NULL){ |
| 1150 |
g_object_unref(fx_vst3_audio); |
| 1151 |
} |
| 1152 |
|
| 1153 |
return; |
| 1154 |
} |
| 1155 |
|
| 1156 |
g_object_get(fx_vst3_channel, |
| 1157 |
"source", &source, |
| 1158 |
NULL); |
| 1159 |
|
| 1160 |
if(audio == NULL){ |
| 1161 |
g_warning("can't get source"); |
| 1162 |
|
| 1163 |
|
| 1164 |
if(audio != NULL){ |
| 1165 |
g_object_unref(audio); |
| 1166 |
} |
| 1167 |
|
| 1168 |
if(fx_vst3_audio != NULL){ |
| 1169 |
g_object_unref(fx_vst3_audio); |
| 1170 |
} |
| 1171 |
|
| 1172 |
return; |
| 1173 |
} |
| 1174 |
|
| 1175 |
audio_channel = ~0; |
| 1176 |
|
| 1177 |
g_object_get(source, |
| 1178 |
"audio-channel", &audio_channel, |
| 1179 |
NULL); |
| 1180 |
|
| 1181 |
|
| 1182 |
playback_domain = NULL; |
| 1183 |
start_output = NULL; |
| 1184 |
|
| 1185 |
start_output_playback = NULL; |
| 1186 |
|
| 1187 |
g_object_get(audio, |
| 1188 |
"playback-domain", &playback_domain, |
| 1189 |
"output", &start_output, |
| 1190 |
NULL); |
| 1191 |
|
| 1192 |
g_object_get(playback_domain, |
| 1193 |
"output-playback", &start_output_playback, |
| 1194 |
NULL); |
| 1195 |
|
| 1196 |
if(ags_base_plugin_test_flags((AgsBasePlugin *) vst3_plugin, AGS_BASE_PLUGIN_IS_INSTRUMENT)){ |
| 1197 |
AgsAudioThread *audio_thread; |
| 1198 |
AgsChannelThread *channel_thread; |
| 1199 |
|
| 1200 |
AgsTaskLauncher *task_launcher; |
| 1201 |
|
| 1202 |
is_live_instrument = ags_fx_vst3_audio_test_flags(fx_vst3_audio, AGS_FX_VST3_AUDIO_LIVE_INSTRUMENT); |
| 1203 |
|
| 1204 |
if(is_live_instrument){ |
| 1205 |
g_critical("invalid port access of live instrument"); |
| 1206 |
|
| 1207 |
|
| 1208 |
if(audio != NULL){ |
| 1209 |
g_object_unref(audio); |
| 1210 |
} |
| 1211 |
|
| 1212 |
if(fx_vst3_audio != NULL){ |
| 1213 |
g_object_unref(fx_vst3_audio); |
| 1214 |
} |
| 1215 |
|
| 1216 |
return; |
| 1217 |
} |
| 1218 |
|
| 1219 |
i_start = audio_channel; |
| 1220 |
i_stop = i_start + 1; |
| 1221 |
|
| 1222 |
for(i = i_start; i < i_stop && i < audio_channels; i++){ |
| 1223 |
for(j = 0; j < AGS_SOUND_SCOPE_LAST; j++){ |
| 1224 |
AgsWriteVst3Port *write_vst3_port; |
| 1225 |
|
| 1226 |
audio_thread = (AgsAudioThread *) ags_playback_domain_get_audio_thread(playback_domain, |
| 1227 |
j); |
| 1228 |
|
| 1229 |
output = ags_channel_nth(start_output, |
| 1230 |
i); |
| 1231 |
|
| 1232 |
output_playback = start_output_playback; |
| 1233 |
|
| 1234 |
while(output_playback != NULL){ |
| 1235 |
AgsChannel *current_output; |
| 1236 |
|
| 1237 |
gboolean success; |
| 1238 |
|
| 1239 |
success = FALSE; |
| 1240 |
|
| 1241 |
g_object_get(output_playback->data, |
| 1242 |
"channel", ¤t_output, |
| 1243 |
NULL); |
| 1244 |
|
| 1245 |
if(output == current_output){ |
| 1246 |
success = TRUE; |
| 1247 |
} |
| 1248 |
|
| 1249 |
if(current_output != NULL){ |
| 1250 |
g_object_unref(current_output); |
| 1251 |
} |
| 1252 |
|
| 1253 |
if(success){ |
| 1254 |
break; |
| 1255 |
} |
| 1256 |
|
| 1257 |
output_playback = output_playback->next; |
| 1258 |
} |
| 1259 |
|
| 1260 |
channel_thread = NULL; |
| 1261 |
|
| 1262 |
if(output_playback != NULL){ |
| 1263 |
channel_thread = (AgsChannelThread *) ags_playback_get_channel_thread(output_playback->data, |
| 1264 |
j); |
| 1265 |
} |
| 1266 |
|
| 1267 |
task_launcher = NULL; |
| 1268 |
|
| 1269 |
if(ags_playback_domain_test_flags(playback_domain, AGS_PLAYBACK_DOMAIN_SUPER_THREADED_AUDIO)){ |
| 1270 |
if(!ags_playback_test_flags(output_playback->data, AGS_PLAYBACK_SUPER_THREADED_CHANNEL)){ |
| 1271 |
g_object_get(audio_thread, |
| 1272 |
"task-launcher", &task_launcher, |
| 1273 |
NULL); |
| 1274 |
}else{ |
| 1275 |
g_object_get(channel_thread, |
| 1276 |
"task-launcher", &task_launcher, |
| 1277 |
NULL); |
| 1278 |
} |
| 1279 |
}else{ |
| 1280 |
|
| 1281 |
} |
| 1282 |
|
| 1283 |
write_vst3_port = ags_write_vst3_port_new(fx_vst3_audio, |
| 1284 |
port, |
| 1285 |
g_value_get_double(value), |
| 1286 |
j, |
| 1287 |
i); |
| 1288 |
|
| 1289 |
ags_task_launcher_add_task(task_launcher, |
| 1290 |
(AgsTask *) write_vst3_port); |
| 1291 |
|
| 1292 |
if(task_launcher != NULL){ |
| 1293 |
g_object_unref(task_launcher); |
| 1294 |
} |
| 1295 |
|
| 1296 |
if(output != NULL){ |
| 1297 |
g_object_unref(output); |
| 1298 |
} |
| 1299 |
} |
| 1300 |
} |
| 1301 |
}else{ |
| 1302 |
for(j = 0; j < AGS_SOUND_SCOPE_LAST; j++){ |
| 1303 |
AgsAudioThread *audio_thread; |
| 1304 |
AgsChannelThread *channel_thread; |
| 1305 |
|
| 1306 |
AgsWriteVst3Port *write_vst3_port; |
| 1307 |
|
| 1308 |
AgsTaskLauncher *task_launcher; |
| 1309 |
|
| 1310 |
gint audio_channel; |
| 1311 |
|
| 1312 |
audio_thread = (AgsAudioThread *) ags_playback_domain_get_audio_thread(playback_domain, |
| 1313 |
j); |
| 1314 |
|
| 1315 |
output = NULL; |
| 1316 |
audio_channel = -1; |
| 1317 |
|
| 1318 |
g_object_get(fx_vst3_channel, |
| 1319 |
"source", &output, |
| 1320 |
NULL); |
| 1321 |
|
| 1322 |
if(output != NULL){ |
| 1323 |
g_object_get(output, |
| 1324 |
"audio-channel", &audio_channel, |
| 1325 |
NULL); |
| 1326 |
} |
| 1327 |
|
| 1328 |
output_playback = start_output_playback; |
| 1329 |
|
| 1330 |
while(output_playback != NULL){ |
| 1331 |
AgsChannel *current_output; |
| 1332 |
|
| 1333 |
gboolean success; |
| 1334 |
|
| 1335 |
success = FALSE; |
| 1336 |
|
| 1337 |
g_object_get(output_playback->data, |
| 1338 |
"channel", ¤t_output, |
| 1339 |
NULL); |
| 1340 |
|
| 1341 |
if(output == current_output){ |
| 1342 |
success = TRUE; |
| 1343 |
} |
| 1344 |
|
| 1345 |
if(current_output != NULL){ |
| 1346 |
g_object_unref(current_output); |
| 1347 |
} |
| 1348 |
|
| 1349 |
if(success){ |
| 1350 |
break; |
| 1351 |
} |
| 1352 |
|
| 1353 |
output_playback = output_playback->next; |
| 1354 |
} |
| 1355 |
|
| 1356 |
channel_thread = NULL; |
| 1357 |
|
| 1358 |
if(output_playback != NULL){ |
| 1359 |
channel_thread = (AgsChannelThread *) ags_playback_get_channel_thread(output_playback->data, |
| 1360 |
j); |
| 1361 |
} |
| 1362 |
|
| 1363 |
task_launcher = NULL; |
| 1364 |
|
| 1365 |
if(ags_playback_domain_test_flags(playback_domain, AGS_PLAYBACK_DOMAIN_SUPER_THREADED_AUDIO)){ |
| 1366 |
if(!ags_playback_test_flags(output_playback->data, AGS_PLAYBACK_SUPER_THREADED_CHANNEL)){ |
| 1367 |
g_object_get(audio_thread, |
| 1368 |
"task-launcher", &task_launcher, |
| 1369 |
NULL); |
| 1370 |
}else{ |
| 1371 |
g_object_get(channel_thread, |
| 1372 |
"task-launcher", &task_launcher, |
| 1373 |
NULL); |
| 1374 |
} |
| 1375 |
}else{ |
| 1376 |
|
| 1377 |
} |
| 1378 |
|
| 1379 |
if(audio_channel != -1){ |
| 1380 |
write_vst3_port = ags_write_vst3_port_new(fx_vst3_audio, |
| 1381 |
port, |
| 1382 |
g_value_get_double(value), |
| 1383 |
j, |
| 1384 |
audio_channel); |
| 1385 |
|
| 1386 |
ags_task_launcher_add_task(task_launcher, |
| 1387 |
(AgsTask *) write_vst3_port); |
| 1388 |
} |
| 1389 |
|
| 1390 |
if(task_launcher != NULL){ |
| 1391 |
g_object_unref(task_launcher); |
| 1392 |
} |
| 1393 |
|
| 1394 |
if(output != NULL){ |
| 1395 |
g_object_unref(output); |
| 1396 |
} |
| 1397 |
} |
| 1398 |
} |
| 1399 |
|
| 1400 |
|
| 1401 |
if(audio != NULL){ |
| 1402 |
g_object_unref(audio); |
| 1403 |
} |
| 1404 |
|
| 1405 |
if(fx_vst3_audio != NULL){ |
| 1406 |
g_object_unref(fx_vst3_audio); |
| 1407 |
} |
| 1408 |
|
| 1409 |
if(start_output != NULL){ |
| 1410 |
g_object_unref(start_output); |
| 1411 |
} |
| 1412 |
|
| 1413 |
g_list_free_full(start_output_playback, |
| 1414 |
(GDestroyNotify) g_object_unref); |
| 1415 |
} |
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
AgsFxVst3Channel* |
| 1428 |
ags_fx_vst3_channel_new(AgsChannel *channel) |
| 1429 |
{ |
| 1430 |
AgsFxVst3Channel *fx_vst3_channel; |
| 1431 |
|
| 1432 |
fx_vst3_channel = (AgsFxVst3Channel *) g_object_new(AGS_TYPE_FX_VST3_CHANNEL, |
| 1433 |
"source", channel, |
| 1434 |
NULL); |
| 1435 |
|
| 1436 |
return(fx_vst3_channel); |
| 1437 |
} |