diff flattendynamics-ladspa.cpp @ 0:7632b9bf0cff

Initial stub plugin commit
author Chris Cannam
date Thu, 17 Jul 2014 12:16:02 +0100
parents
children f21753c504e1
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flattendynamics-ladspa.cpp	Thu Jul 17 12:16:02 2014 +0100
@@ -0,0 +1,153 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+#include "flattendynamics-ladspa.h"
+
+#include <alloca.h>
+#include <iostream>
+#include <cmath>
+
+const char *const
+FlattenDynamics::portNames[PortCount] =
+{
+    "Input",
+    "Output",
+};
+
+const LADSPA_PortDescriptor 
+FlattenDynamics::ports[PortCount] =
+{
+    LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
+    LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
+};
+
+const LADSPA_PortRangeHint 
+FlattenDynamics::hints[PortCount] =
+{
+    { 0, 0, 0 },
+    { 0, 0, 0 },
+};
+
+const LADSPA_Properties
+FlattenDynamics::properties = LADSPA_PROPERTY_HARD_RT_CAPABLE;
+
+const LADSPA_Descriptor 
+FlattenDynamics::ladspaDescriptor =
+{
+    0xf0b375, // "Unique" ID
+    "flattendynamics", // Label
+    properties,
+    "FlattenDynamics", // Name
+    "Queen Mary, University of London", // Maker
+    "BSD", // Copyright
+    PortCount,
+    ports,
+    portNames,
+    hints,
+    0, // Implementation data
+    instantiate,
+    connectPort,
+    activate,
+    run,
+    0, // Run adding
+    0, // Set run adding gain
+    deactivate,
+    cleanup
+};
+
+const LADSPA_Descriptor *
+FlattenDynamics::getDescriptor(unsigned long index)
+{
+    if (index == 0) return &ladspaDescriptor;
+    return 0;
+}
+
+FlattenDynamics::FlattenDynamics(int sampleRate) :
+    m_sampleRate(sampleRate),
+    m_input(0),
+    m_output(0)
+{
+    reset();
+}
+
+FlattenDynamics::~FlattenDynamics()
+{
+}
+    
+LADSPA_Handle
+FlattenDynamics::instantiate(const LADSPA_Descriptor *, unsigned long rate)
+{
+    FlattenDynamics *flatten = new FlattenDynamics(rate);
+    return flatten;
+}
+
+void
+FlattenDynamics::connectPort(LADSPA_Handle handle,
+                           unsigned long port, LADSPA_Data *location)
+{
+    FlattenDynamics *flatten = (FlattenDynamics *)handle;
+
+    float **ports[PortCount] = {
+	&flatten->m_input,
+	&flatten->m_output,
+    };
+
+    *ports[port] = (float *)location;
+}
+
+void
+FlattenDynamics::activate(LADSPA_Handle handle)
+{
+    FlattenDynamics *flatten = (FlattenDynamics *)handle;
+    flatten->reset();
+}
+
+void
+FlattenDynamics::run(LADSPA_Handle handle, unsigned long samples)
+{
+    FlattenDynamics *flatten = (FlattenDynamics *)handle;
+    flatten->runImpl(samples);
+}
+
+void
+FlattenDynamics::deactivate(LADSPA_Handle handle)
+{
+    activate(handle); // both functions just reset the plugin
+}
+
+void
+FlattenDynamics::cleanup(LADSPA_Handle handle)
+{
+    delete (FlattenDynamics *)handle;
+}
+
+void
+FlattenDynamics::reset()
+{
+}
+
+void
+FlattenDynamics::updateParameters()
+{
+}
+
+void
+FlattenDynamics::runImpl(unsigned long sampleCount)
+{
+    if (!m_input || !m_output) return;
+    updateParameters();
+
+    int ii = 0;
+    int oi = 0;
+    const int sc = sampleCount;
+
+    while (ii < sc) {
+        //!!!
+    }
+}
+
+const LADSPA_Descriptor *
+ladspa_descriptor(unsigned long ix)
+{
+    return FlattenDynamics::getDescriptor(ix);
+}
+