1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
<?xml version="1.0"?>
<!DOCTYPE ladspa SYSTEM "ladspa-swh.dtd">
<?xml-stylesheet href="ladspa.css" type="text/css"?>
<ladspa>
<global>
<meta name="maker" value="xxx <yyy@zzz.com>"/>
<meta name="copyright" value="GPL"/>
<meta name="properties" value="HARD_RT_CAPABLE"/>
<code><![CDATA[
#include <unistd.h>
#include <stdio.h>
#include <pthread.h>
#include <lo/lo.h>
#include "../src/constants.h"
#define EXITV -999
//#define DEBUG 1
static int scene = -1;
static int thread_created = 0;
static pthread_t thread;
static void *controller_thread(void *p)
{
int last_scene = -1;
lo_address address = lo_address_new(NULL, OSC_PORT);
printf("THREAD\n");
while (scene != EXITV) {
#ifdef DEBUG
printf(". %d\n", scene);
#endif
if (last_scene != scene) {
last_scene = scene;
if (last_scene > 0 && last_scene <= NUM_SCENES) {
lo_send(address, SCENE_URI, "i", last_scene);
}
}
#ifdef DEBUG
usleep(1000000);
#else
usleep(10000);
#endif
}
lo_address_free(address);
#ifdef DEBUG
printf("DONE\n");
#endif
return NULL;
}
]]></code>
</global>
<plugin label="jaminController" id="1912" class="UtilityPlugin">
<name>JAMin Controller</name>
<callback event="instantiate"><![CDATA[
#ifdef DEBUG
printf("instantiate called\n");
#endif
scene = -1;
if (!thread_created) {
thread_created = 1;
pthread_create(&thread, NULL, controller_thread, NULL);
}
]]></callback>
<callback event="activate"><![CDATA[
#ifdef DEBUG
printf("activate called\n");
#endif
scene = -1;
]]></callback>
<callback event="run"><![CDATA[
unsigned long pos;
scene = (int)(scene_cont + 0.5f);
if (input != output) {
for (pos = 0; pos < sample_count; pos++) {
buffer_write(output[pos], input[pos]);
}
}
]]></callback>
<callback event="cleanup"><![CDATA[
#ifdef DEBUG
printf("cleanup called\n");
#endif
scene = EXITV;
thread_created = 0;
//pthread_cancel(thread);
]]></callback>
<port label="scene_cont" dir="input" type="control" hint="default_1,integer">
<name>Scene no.</name>
<p>Changes the JAMin scene number</p>
<range min="1" max="NUM_SCENES"/>
</port>
<port label="input" dir="input" type="audio">
<name>Input</name>
</port>
<port label="output" dir="output" type="audio">
<name>Output</name>
</port>
</plugin>
</ladspa>
|