summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ardour/session_vst.cc69
-rw-r--r--libs/ardour/vst_plugin.cc63
-rw-r--r--libs/fst/vsti.c50
3 files changed, 90 insertions, 92 deletions
diff --git a/libs/ardour/session_vst.cc b/libs/ardour/session_vst.cc
index 3f2054aadc..461934b5f4 100644
--- a/libs/ardour/session_vst.cc
+++ b/libs/ardour/session_vst.cc
@@ -60,7 +60,7 @@ intptr_t Session::vst_callback (
}
if (effect && effect->user) {
- plug = (VSTPlugin *) (effect->user);
+ plug = (VSTPlugin *) (effect->user);
session = &plug->session();
#ifdef COMPILER_MSVC
SHOW_CALLBACK ("am callback 0x%x, opcode = %d, plugin = \"%s\" ", (int) pthread_self().p, opcode, plug->name());
@@ -155,7 +155,7 @@ intptr_t Session::vst_callback (
_timeInfo.samplePos = now;
_timeInfo.sampleRate = session->frame_rate();
-
+
const TempoMetric& tm (session->tempo_map().metric_at (now));
if (value & (kVstTempoValid)) {
@@ -174,22 +174,21 @@ intptr_t Session::vst_callback (
try {
session->tempo_map().bbt_time_rt (now, bbt);
-
+
/* PPQ = pulse per quarter
- VST's "pulse" is our "division".
-
- 8 divisions per bar, 1 division = quarter, so 8 quarters per bar, ppq = 1
- 8 divisions per bar, 1 division = eighth, so 4 quarters per bar, ppq = 2
- 4 divisions per bar, 1 division = quarter, so 4 quarters per bar, ppq = 1
- 4 divisions per bar, 1 division = half, so 8 quarters per bar, ppq = 0.5
- 4 divisions per bar, 1 division = fifth, so (4 * 5/4) quarters per bar, ppq = 5/4
-
- general: divs_per_bar / (note_type / 4.0)
- */
+ * VST's "pulse" is our "division".
+ *
+ * 8 divisions per bar, 1 division = quarter, so 8 quarters per bar, ppq = 1
+ * 8 divisions per bar, 1 division = eighth, so 4 quarters per bar, ppq = 2
+ * 4 divisions per bar, 1 division = quarter, so 4 quarters per bar, ppq = 1
+ * 4 divisions per bar, 1 division = half, so 8 quarters per bar, ppq = 0.5
+ * 4 divisions per bar, 1 division = fifth, so (4 * 5/4) quarters per bar, ppq = 5/4
+ *
+ * general: divs_per_bar / (note_type / 4.0)
+ */
double ppq_scaling = tm.meter().note_divisor() / 4.0;
- /* Note that this assumes constant meter/tempo throughout the session. Stupid VST
- */
+ /* Note that this assumes constant meter/tempo throughout the session. Stupid VST */
double ppqBar = double(bbt.bars - 1) * tm.meter().divisions_per_bar();
double ppqBeat = double(bbt.beats - 1);
double ppqTick = double(bbt.ticks) / Timecode::BBT_Time::ticks_per_beat;
@@ -197,17 +196,17 @@ intptr_t Session::vst_callback (
ppqBar *= ppq_scaling;
ppqBeat *= ppq_scaling;
ppqTick *= ppq_scaling;
-
+
if (value & (kVstPpqPosValid)) {
_timeInfo.ppqPos = ppqBar + ppqBeat + ppqTick;
_timeInfo.flags |= (kVstPpqPosValid);
}
-
+
if (value & (kVstBarsValid)) {
_timeInfo.barStartPos = ppqBar;
_timeInfo.flags |= (kVstBarsValid);
}
-
+
} catch (...) {
/* relax */
}
@@ -215,13 +214,13 @@ intptr_t Session::vst_callback (
if (value & (kVstSmpteValid)) {
Timecode::Time t;
-
+
session->timecode_time (now, t);
-
- _timeInfo.smpteOffset = (t.hours * t.rate * 60.0 * 60.0) +
- (t.minutes * t.rate * 60.0) +
- (t.seconds * t.rate) +
- (t.frames) +
+
+ _timeInfo.smpteOffset = (t.hours * t.rate * 60.0 * 60.0) +
+ (t.minutes * t.rate * 60.0) +
+ (t.seconds * t.rate) +
+ (t.frames) +
(t.subframes);
_timeInfo.smpteOffset *= 80.0; /* VST spec is 1/80th frames */
@@ -257,7 +256,7 @@ intptr_t Session::vst_callback (
_timeInfo.samplePos = 0;
_timeInfo.sampleRate = AudioEngine::instance()->sample_rate();
}
-
+
return (intptr_t) &_timeInfo;
case audioMasterProcessEvents:
@@ -286,14 +285,14 @@ intptr_t Session::vst_callback (
case audioMasterGetParameterQuantization:
SHOW_CALLBACK ("amc: audioMasterGetParameterQuantization\n");
- // returns the integer value for +1.0 representation,
- // or 1 if full single float precision is maintained
- // in automation. parameter index in <value> (-1: all, any)
+ // returns the integer value for +1.0 representation,
+ // or 1 if full single float precision is maintained
+ // in automation. parameter index in <value> (-1: all, any)
return 0;
case audioMasterIOChanged:
SHOW_CALLBACK ("amc: audioMasterIOChanged\n");
- // numInputs and/or numOutputs has changed
+ // numInputs and/or numOutputs has changed
return 0;
case audioMasterNeedIdle:
@@ -333,16 +332,16 @@ intptr_t Session::vst_callback (
case audioMasterGetPreviousPlug:
SHOW_CALLBACK ("amc: audioMasterGetPreviousPlug\n");
- // input pin in <value> (-1: first to come), returns cEffect*
+ // input pin in <value> (-1: first to come), returns cEffect*
return 0;
case audioMasterGetNextPlug:
SHOW_CALLBACK ("amc: audioMasterGetNextPlug\n");
- // output pin in <value> (-1: first to come), returns cEffect*
+ // output pin in <value> (-1: first to come), returns cEffect*
case audioMasterWillReplaceOrAccumulate:
SHOW_CALLBACK ("amc: audioMasterWillReplaceOrAccumulate\n");
- // returns: 0: not supported, 1: replace, 2: accumulate
+ // returns: 0: not supported, 1: replace, 2: accumulate
return 0;
case audioMasterGetCurrentProcessLevel:
@@ -364,10 +363,10 @@ intptr_t Session::vst_callback (
case audioMasterOfflineStart:
SHOW_CALLBACK ("amc: audioMasterOfflineStart\n");
return 0;
-
+
case audioMasterOfflineRead:
SHOW_CALLBACK ("amc: audioMasterOfflineRead\n");
- // ptr points to offline structure, see below. return 0: error, 1 ok
+ // ptr points to offline structure, see below. return 0: error, 1 ok
return 0;
case audioMasterOfflineWrite:
@@ -378,7 +377,7 @@ intptr_t Session::vst_callback (
case audioMasterOfflineGetCurrentPass:
SHOW_CALLBACK ("amc: audioMasterOfflineGetCurrentPass\n");
return 0;
-
+
case audioMasterOfflineGetCurrentMetaPass:
SHOW_CALLBACK ("amc: audioMasterOfflineGetCurrentMetaPass\n");
return 0;
diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc
index f22ddf525e..23383496bf 100644
--- a/libs/ardour/vst_plugin.cc
+++ b/libs/ardour/vst_plugin.cc
@@ -46,12 +46,12 @@ VSTPlugin::VSTPlugin (AudioEngine& engine, Session& session, VSTHandle* handle)
, _state (0)
, _plugin (0)
{
-
+
}
VSTPlugin::~VSTPlugin ()
{
-
+
}
void
@@ -78,7 +78,7 @@ VSTPlugin::activate ()
_plugin->dispatcher (_plugin, effMainsChanged, 0, 1, NULL, 0.0f);
}
-int
+int
VSTPlugin::set_block_size (pframes_t nframes)
{
deactivate ();
@@ -93,13 +93,13 @@ VSTPlugin::default_value (uint32_t)
return 0;
}
-float
+float
VSTPlugin::get_parameter (uint32_t which) const
{
return _plugin->getParameter (_plugin, which);
}
-void
+void
VSTPlugin::set_parameter (uint32_t which, float newval)
{
float oldval = get_parameter (which);
@@ -109,7 +109,7 @@ VSTPlugin::set_parameter (uint32_t which, float newval)
}
_plugin->setParameter (_plugin, which, newval);
-
+
float curval = get_parameter (which);
if (!PBD::floateq (curval, oldval, 1)) {
@@ -215,8 +215,8 @@ VSTPlugin::set_state (const XMLNode& node, int version)
for (n = child->children ().begin (); n != child->children ().end (); ++n) {
if ((*n)->is_content ()) {
/* XXX: this may be dubious for the same reasons that we delay
- execution of load_preset.
- */
+ execution of load_preset.
+ */
ret = set_chunk ((*n)->content().c_str(), false);
}
}
@@ -301,7 +301,7 @@ VSTPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc)
memset (label, 0, sizeof (label));
_plugin->dispatcher (_plugin, effGetParamName, which, 0, label, 0);
-
+
desc.label = label;
desc.integer_step = false;
desc.lower = 0.0f;
@@ -335,7 +335,7 @@ VSTPlugin::load_preset (PresetRecord r)
return s;
}
-bool
+bool
VSTPlugin::load_plugin_preset (PresetRecord r)
{
/* This is a plugin-provided preset.
@@ -348,7 +348,7 @@ VSTPlugin::load_plugin_preset (PresetRecord r)
#ifndef NDEBUG
int const p = sscanf (r.uri.c_str(), "VST:%d:%d", &id, &index);
assert (p == 2);
-#else
+#else
sscanf (r.uri.c_str(), "VST:%d:%d", &id, &index);
#endif
@@ -372,13 +372,12 @@ VSTPlugin::load_plugin_preset (PresetRecord r)
}
#else
-
_state->want_program = index;
#endif
return true;
}
-bool
+bool
VSTPlugin::load_user_preset (PresetRecord r)
{
/* This is a user preset; we load it, and this code also knows about the
@@ -424,7 +423,7 @@ VSTPlugin::load_user_preset (PresetRecord r)
return false;
} else {
-
+
for (XMLNodeList::const_iterator j = (*i)->children().begin(); j != (*i)->children().end(); ++j) {
if ((*j)->name() == X_("Parameter")) {
XMLProperty* index = (*j)->property (X_("index"));
@@ -442,7 +441,7 @@ VSTPlugin::load_user_preset (PresetRecord r)
return false;
}
-string
+string
VSTPlugin::do_save_preset (string name)
{
boost::shared_ptr<XMLTree> t (presets_tree ());
@@ -488,7 +487,7 @@ VSTPlugin::do_save_preset (string name)
return uri;
}
-void
+void
VSTPlugin::do_remove_preset (string name)
{
boost::shared_ptr<XMLTree> t (presets_tree ());
@@ -504,7 +503,7 @@ VSTPlugin::do_remove_preset (string name)
t->write (f);
}
-string
+string
VSTPlugin::describe_parameter (Evoral::Parameter param)
{
char name[64];
@@ -521,7 +520,7 @@ VSTPlugin::describe_parameter (Evoral::Parameter param)
return name;
}
-framecnt_t
+framecnt_t
VSTPlugin::signal_latency () const
{
if (_user_latency) {
@@ -531,7 +530,7 @@ VSTPlugin::signal_latency () const
return *((int32_t *) (((char *) &_plugin->flags) + 12)); /* initialDelay */
}
-set<Evoral::Parameter>
+set<Evoral::Parameter>
VSTPlugin::automatable () const
{
set<Evoral::Parameter> ret;
@@ -545,8 +544,8 @@ VSTPlugin::automatable () const
int
VSTPlugin::connect_and_run (BufferSet& bufs,
- ChanMapping in_map, ChanMapping out_map,
- pframes_t nframes, framecnt_t offset)
+ ChanMapping in_map, ChanMapping out_map,
+ pframes_t nframes, framecnt_t offset)
{
Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
@@ -557,14 +556,14 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
BufferSet& silent_bufs = _session.get_silent_buffers(bufs_count);
BufferSet& scratch_bufs = _session.get_scratch_buffers(bufs_count);
- /* VC++ doesn't support the C99 extension that allows
+ /* VC++ doesn't support the C99 extension that allows
typeName foo[variableDefiningSize];
-
+
Use alloca instead of dynamic array (rather than std::vector which
allocs on the heap) because this is realtime code.
*/
-
+
float** ins = (float**)alloca(_plugin->numInputs*sizeof(float*));
float** outs = (float**)alloca(_plugin->numInputs*sizeof(float*));
@@ -601,48 +600,48 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
return 0;
}
-string
+string
VSTPlugin::unique_id () const
{
char buf[32];
snprintf (buf, sizeof (buf), "%d", _plugin->uniqueID);
-
+
return string (buf);
}
-const char *
+const char *
VSTPlugin::name () const
{
return _handle->name;
}
-const char *
+const char *
VSTPlugin::maker () const
{
return _info->creator.c_str();
}
-const char *
+const char *
VSTPlugin::label () const
{
return _handle->name;
}
-uint32_t
+uint32_t
VSTPlugin::parameter_count () const
{
return _plugin->numParams;
}
-bool
+bool
VSTPlugin::has_editor () const
{
return _plugin->flags & effFlagsHasEditor;
}
-void
+void
VSTPlugin::print_parameter (uint32_t param, char *buf, uint32_t /*len*/) const
{
char *first_nonws;
diff --git a/libs/fst/vsti.c b/libs/fst/vsti.c
index e5c7d9c6c9..a1a9a8be72 100644
--- a/libs/fst/vsti.c
+++ b/libs/fst/vsti.c
@@ -1,10 +1,10 @@
/*
* VST instrument support
*
- * Derived from code that was marked:
+ * Derived from code that was marked:
* Copyright (C) Kjetil S. Matheussen 2004 (k.s.matheussen@notam02.no)
* Alsa-seq midi-code made by looking at the jack-rack source made by Bob Ham.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -41,31 +41,31 @@ create_sequencer (const char* client_name, bool isinput)
{
snd_seq_t * seq;
int err;
-
+
if ((err = snd_seq_open (&seq, "default", SND_SEQ_OPEN_DUPLEX, 0)) != 0) {
fst_error ("Could not open ALSA sequencer, aborting\n\n%s\n\n"
- "Make sure you have configure ALSA properly and that\n"
- "/proc/asound/seq/clients exists and contains relevant\n"
- "devices (%s).",
- snd_strerror (err));
+ "Make sure you have configure ALSA properly and that\n"
+ "/proc/asound/seq/clients exists and contains relevant\n"
+ "devices (%s).",
+ snd_strerror (err));
return NULL;
}
-
+
snd_seq_set_client_name (seq, client_name);
-
+
if ((err = snd_seq_create_simple_port (seq, isinput? "Input" : "Output",
- (isinput? SND_SEQ_PORT_CAP_WRITE: SND_SEQ_PORT_CAP_READ)| SND_SEQ_PORT_CAP_DUPLEX |
- SND_SEQ_PORT_CAP_SUBS_READ|SND_SEQ_PORT_CAP_SUBS_WRITE,
- SND_SEQ_PORT_TYPE_APPLICATION|SND_SEQ_PORT_TYPE_SPECIFIC)) != 0) {
+ (isinput? SND_SEQ_PORT_CAP_WRITE: SND_SEQ_PORT_CAP_READ)| SND_SEQ_PORT_CAP_DUPLEX |
+ SND_SEQ_PORT_CAP_SUBS_READ|SND_SEQ_PORT_CAP_SUBS_WRITE,
+ SND_SEQ_PORT_TYPE_APPLICATION|SND_SEQ_PORT_TYPE_SPECIFIC)) != 0) {
fst_error ("Could not create ALSA port: %s", snd_strerror (err));
snd_seq_close(seq);
return NULL;
}
-
+
return seq;
}
-static void
+static void
queue_midi (JackVST *jvst, int val1, int val2, int val3)
{
VstMidiEvent *pevent;
@@ -77,11 +77,11 @@ queue_midi (JackVST *jvst, int val1, int val2, int val3)
fst_error ("event queue has no write space");
return;
}
-
+
pevent = (VstMidiEvent *) vec[0].buf;
// printf("note: %d\n",note);
-
+
pevent->type = kVstMidiType;
pevent->byteSize = 24;
pevent->deltaFrames = 0;
@@ -96,7 +96,7 @@ queue_midi (JackVST *jvst, int val1, int val2, int val3)
pevent->midiData[1] = val2;
pevent->midiData[2] = val3;
pevent->midiData[3] = 0;
-
+
//printf("Sending: %x %x %x\n",val1,val2,val3);
jack_ringbuffer_write_advance (jvst->event_queue, sizeof (VstMidiEvent));
@@ -113,8 +113,8 @@ void *midireceiver(void *arg)
// Try to set fifo priority...
// this works, if we are root or newe sched-cap manegment is used...
- pthread_setschedparam( pthread_self(), SCHED_FIFO, &scp );
-
+ pthread_setschedparam( pthread_self(), SCHED_FIFO, &scp );
+
while (1) {
snd_seq_event_input (jvst->seq, &event);
@@ -158,28 +158,28 @@ void *midireceiver(void *arg)
break;
}
}
-
+
return NULL;
}
void stop_midireceiver (JackVST *jvst)
{
- int err;
+ int err;
snd_seq_event_t event;
snd_seq_t *seq2 = create_sequencer ("jfstquit", true);
-
+
jvst->midiquit = 1;
-
+
snd_seq_connect_to (seq2, 0, snd_seq_client_id (jvst->seq),0);
snd_seq_ev_clear (&event);
snd_seq_ev_set_direct (&event);
snd_seq_ev_set_subs (&event);
snd_seq_ev_set_source (&event, 0);
snd_seq_ev_set_controller (&event,1,0x80,50);
-
+
if ((err = snd_seq_event_output (seq2, &event)) < 0) {
fst_error ("cannot send stop event to midi thread: %s\n",
- snd_strerror (err));
+ snd_strerror (err));
}
snd_seq_drain_output (seq2);