summaryrefslogtreecommitdiff
path: root/lv2/lv2.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-03-20 08:56:55 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-03-20 08:56:55 +0100
commit830769798357588cc68e67420a16f20504fa5d77 (patch)
tree4e18fc57c9101b863d1b74de1c117bccf35b5fb8 /lv2/lv2.cc
parent9486ad42e12884e2b3f40cbd76fba2cf889a416f (diff)
Remove obsolete files.
Diffstat (limited to 'lv2/lv2.cc')
-rw-r--r--lv2/lv2.cc250
1 files changed, 0 insertions, 250 deletions
diff --git a/lv2/lv2.cc b/lv2/lv2.cc
deleted file mode 100644
index 224fca9..0000000
--- a/lv2/lv2.cc
+++ /dev/null
@@ -1,250 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * lv2.cc
- *
- * Wed Jul 13 13:50:33 CEST 2011
- * Copyright 2011 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of DrumGizmo.
- *
- * DrumGizmo 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 3 of the License, or
- * (at your option) any later version.
- *
- * DrumGizmo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with DrumGizmo; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include <lv2/lv2plug.in/ns/lv2core/lv2.h>
-#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "lv2_gui.h"
-#include "lv2_instance.h"
-
-#include <hugin.hpp>
-
-enum {
- FREE_WHEEL_PORT = 0,
- MIDI_PORT,
- AUDIO_PORT_BASE
-};
-
-#define DRUMGIZMO_URI "http://drumgizmo.org/lv2"
-#define NS_DG DRUMGIZMO_URI "/atom#"
-
-// Stuff to handle DrumGizmo* transmission from instance to GUI.
-static LV2_DrumGizmo_Descriptor dg_descriptor;
-
-static DrumGizmo *dg_get_pci(LV2_Handle instance)
-{
- DGLV2 *dglv2 = (DGLV2 *)instance;
- return dglv2->dg;
-}
-
-LV2_State_Status dg_save(LV2_Handle instance,
- LV2_State_Store_Function store,
- LV2_State_Handle handle,
- uint32_t flags,
- const LV2_Feature *const * features)
-{
- DGLV2 *dglv2 = (DGLV2 *)instance;
-
- if(!dglv2 || !dglv2->map || !dglv2->map->map) {
- // Missing urid feature?
- return LV2_STATE_ERR_NO_FEATURE;
- }
-
- std::string config = dglv2->dg->configString();
-
- // Backwards compatible fix for errornously stored '\0' byte in < v0.9.8.
- // Remove when we reach v1.0
- config += "\n";
-
- store(handle,
- dglv2->map->map(dglv2->map->handle, NS_DG "config"),
- config.data(),
- config.length(),
- dglv2->map->map(dglv2->map->handle, LV2_ATOM__Chunk),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
-
- return LV2_STATE_SUCCESS;
-}
-
-LV2_State_Status dg_restore(LV2_Handle instance,
- LV2_State_Retrieve_Function retrieve,
- LV2_State_Handle handle,
- uint32_t flags,
- const LV2_Feature *const * features)
-{
- DGLV2 *dglv2 = (DGLV2 *)instance;
-
- if(!dglv2 || !dglv2->map || !dglv2->map->map) {
- // Missing urid feature?
- return LV2_STATE_ERR_NO_FEATURE;
- }
-
- size_t size;
- uint32_t type;
-
- const char* data =
- (const char*)retrieve(handle,
- dglv2->map->map(dglv2->map->handle, NS_DG "config"),
- &size, &type, &flags);
-
- DEBUG(lv2, "Config string size: %d, data*: %p\n", (int)size, data);
-
- if(data && size) {
- std::string config;
-
- // Fix for errornously stored '\0' byte in < v0.9.8.
- // Remove when we reach v1.0
- if(data[size - 1] == '\0') size--;
-
- config.append(data, size);
- dglv2->dg->setConfigString(config);
- }
-
- return LV2_STATE_SUCCESS;
-}
-
-static LV2_State_Interface dg_persist = {
- dg_save,
- dg_restore
-};
-
-LV2_Handle instantiate(const struct _LV2_Descriptor *descriptor,
- double sample_rate,
- const char *bundle_path,
- const LV2_Feature *const *features)
-{
- DGLV2 *dglv2 = new DGLV2;
-
- dglv2->free_wheel_port = NULL; // Not assigned
- dglv2->pos = 0; // Start from the beginning
-
- dglv2->map = NULL;
- for (int i = 0 ; features[i] ; i++) {
- if (!strcmp(features[i]->URI, LV2_URID_URI "#map")) {
- dglv2->map = (LV2_URID_Map*)features[i]->data;
- }
- }
-
- dg_descriptor.get_pci = dg_get_pci;
-
- dglv2->in = new InputLV2();
- dglv2->out = new OutputLV2();
-
- dglv2->buffer = NULL;
- dglv2->buffer_size = 0;
-
- dglv2->dg = new DrumGizmo(dglv2->out, dglv2->in);
- dglv2->dg->setSamplerate(sample_rate);
-
- return (LV2_Handle)dglv2;
-}
-
-void connect_port(LV2_Handle instance, uint32_t port, void *data_location)
-{
- DGLV2 *dglv2 = (DGLV2 *)instance;
-
- if(port == FREE_WHEEL_PORT) {
- dglv2->free_wheel_port = (float*)data_location;
- }
-
- if(port == MIDI_PORT) { // MIDI in
- dglv2->in->eventPort = (LV2_Atom_Sequence*)data_location;
- }
-
- if(port >= AUDIO_PORT_BASE) { // Audio Port
- uint32_t audio_port = port - AUDIO_PORT_BASE;
- dglv2->out->outputPorts[audio_port].samples = (sample_t*)data_location;
- dglv2->out->outputPorts[audio_port].size = 0;
- }
-}
-
-void activate(LV2_Handle instance)
-{
- // We don't really need to do anything here.
- DGLV2 *dglv2 = (DGLV2 *)instance;
- (void)dglv2;
-}
-
-void run(LV2_Handle instance, uint32_t sample_count)
-{
- DGLV2 *dglv2 = (DGLV2 *)instance;
-
- if(dglv2->free_wheel_port) {
- dglv2->dg->setFreeWheel(*dglv2->free_wheel_port);
- }
-
- if(dglv2->buffer_size != sample_count) {
- dglv2->buffer_size = sample_count;
- dglv2->dg->setFrameSize(sample_count);
- }
- dglv2->dg->run(dglv2->pos, dglv2->buffer, sample_count);
-
- dglv2->pos += sample_count;
-}
-
-void deactivate(LV2_Handle instance)
-{
- DGLV2 *dglv2 = (DGLV2 *)instance;
- dglv2->dg->stop();
-}
-
-void cleanup(LV2_Handle instance)
-{
- DGLV2 *dglv2 = (DGLV2 *)instance;
- delete dglv2->dg;
- delete dglv2->in;
- delete dglv2->out;
-}
-
-const void* extension_data(const char *uri)
-{
- if(!strcmp(uri, PLUGIN_INSTANCE_URI)) return &dg_descriptor;
- if(!strcmp(uri, LV2_STATE__interface)) return &dg_persist;
- return NULL;
-}
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static const LV2_Descriptor descriptor = {
- DRUMGIZMO_URI,
- instantiate,
- connect_port,
- activate,
- run,
- deactivate,
- cleanup,
- extension_data
-};
-
-LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
-{
- switch (index) {
- case 0:
- return &descriptor;
- default:
- return NULL;
- }
-}
-
-#ifdef __cplusplus
-}
-#endif