Premier commit - Base de la structure et API LV2
This commit is contained in:
commit
27871b1f55
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
bin/
|
||||
build/
|
||||
gradle/
|
||||
25
build.gradle
Normal file
25
build.gradle
Normal file
@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
id 'application'
|
||||
id 'eclipse'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.nativelibs4java:bridj:0.7.0'
|
||||
|
||||
implementation 'com.illposed.osc:javaosc-core:0.8'
|
||||
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3'
|
||||
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.2'
|
||||
|
||||
implementation 'org.apache.logging.log4j:log4j-core:2.17.1'
|
||||
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass = 'com.bernard.sboard.SBoard'
|
||||
}
|
||||
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = 'SBoard'
|
||||
11
src/main/java/com/bernard/sboard/AddressRegistry.java
Normal file
11
src/main/java/com/bernard/sboard/AddressRegistry.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.bernard.sboard;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.bernard.sboard.saddr.SAddr;
|
||||
|
||||
public class AddressRegistry {
|
||||
|
||||
Map<String, SAddr<?>> adressesMap;
|
||||
|
||||
}
|
||||
142
src/main/java/com/bernard/sboard/JackController.java
Normal file
142
src/main/java/com/bernard/sboard/JackController.java
Normal file
@ -0,0 +1,142 @@
|
||||
package com.bernard.sboard;
|
||||
|
||||
import static com.bernard.sboard.bridj.LibJack.JackPortFlags.JackPortIsInput;
|
||||
import static com.bernard.sboard.bridj.LibJack.JackPortFlags.JackPortIsOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bridj.Pointer;
|
||||
|
||||
import com.bernard.sboard.bridj.LibJack;
|
||||
import com.bernard.sboard.bridj.LibJack.JackPortFlags;
|
||||
import com.bernard.sboard.bridj.LibJack.JackProcessCallback;
|
||||
import com.bernard.sboard.config.SBoardConfig;
|
||||
import com.bernard.sboard.effects.EffectsBox;
|
||||
|
||||
public class JackController {
|
||||
|
||||
SBoardConfig config;
|
||||
|
||||
// Boxes
|
||||
EffectsBox effectBox;
|
||||
RepeatBox repeatBox;
|
||||
SoundBox soundBox;
|
||||
MixerBox mixerBox;
|
||||
|
||||
Pointer<?> client;
|
||||
|
||||
// Input ports
|
||||
Pointer<?> micPort, computerInPort;
|
||||
|
||||
// Output ports
|
||||
Pointer<?> effectsMicPort, soundsPort, repeatedMicPort;
|
||||
Pointer<?> fakeMicPort, earLoopbackPort;
|
||||
|
||||
int bufferSize;
|
||||
|
||||
|
||||
|
||||
public JackController(SBoardConfig config, EffectsBox effectBox, RepeatBox repeatBox, SoundBox soundBox, MixerBox mixerBox) {
|
||||
this.config = config;
|
||||
this.effectBox = effectBox;
|
||||
this.repeatBox = repeatBox;
|
||||
this.soundBox = soundBox;
|
||||
this.mixerBox = mixerBox;
|
||||
}
|
||||
|
||||
public void effectsBox(int nframes) {
|
||||
Pointer<Float> inBuffer = LibJack.jack_port_get_buffer(micPort, nframes).as(Float.class);
|
||||
Pointer<Float> outBuffer = LibJack.jack_port_get_buffer(effectsMicPort, nframes).as(Float.class);
|
||||
|
||||
effectBox.applyEffects(nframes, inBuffer, outBuffer);
|
||||
}
|
||||
|
||||
public void soundBox(int nframes) {
|
||||
Pointer<?> outBuffer = LibJack.jack_port_get_buffer(soundsPort, nframes);
|
||||
|
||||
soundBox.produceFrame(nframes, outBuffer);
|
||||
}
|
||||
|
||||
public void repeatBoxIn(int nframes) {
|
||||
Pointer<?> inBuffer = LibJack.jack_port_get_buffer(repeatedMicPort, nframes);
|
||||
|
||||
repeatBox.recordBuffer(nframes, inBuffer);
|
||||
}
|
||||
|
||||
public void repeatBoxOut(int nframes) {
|
||||
Pointer<?> outBuffer = LibJack.jack_port_get_buffer(micPort, nframes);
|
||||
|
||||
repeatBox.retieveBuffer(nframes, outBuffer);
|
||||
}
|
||||
|
||||
public void mixerBox(int nframes) {
|
||||
Pointer<?> effectsMicBuffer = LibJack.jack_port_get_buffer(effectsMicPort, nframes);
|
||||
Pointer<?> soundsBuffer = LibJack.jack_port_get_buffer(soundsPort, nframes);
|
||||
Pointer<?> repeatedMicBuffer = LibJack.jack_port_get_buffer(repeatedMicPort, nframes);
|
||||
Pointer<?> computerInBuffer = LibJack.jack_port_get_buffer(computerInPort, nframes);
|
||||
Pointer<?> fakeMicBuffer = LibJack.jack_port_get_buffer(fakeMicPort, nframes);
|
||||
Pointer<?> loopbackEarBuffer = LibJack.jack_port_get_buffer(earLoopbackPort, nframes);
|
||||
|
||||
mixerBox.mixFrames(nframes, effectsMicBuffer, soundsBuffer, repeatedMicBuffer, computerInBuffer, fakeMicBuffer, loopbackEarBuffer);
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
client = LibJack.jack_client_open(Pointer.pointerToCString(config.jackControllerName), 0 /*JackNullOption*/, null);
|
||||
|
||||
setupPorts();
|
||||
|
||||
bufferSize = LibJack.jack_get_buffer_size(client);
|
||||
|
||||
LibJack.jackSetProcessCallback(client, Pointer.getPointer(new InternalJackCallback()), Pointer.NULL);
|
||||
|
||||
if(LibJack.jack_activate(client)!=0) {
|
||||
throw new IllegalStateException("Le client jack n'a pas pu être créé.");
|
||||
}
|
||||
}
|
||||
|
||||
private void setupPorts() {
|
||||
micPort = addAudioPort(config.micPortName , config.jackAudioType, JackPortIsInput );
|
||||
computerInPort = addAudioPort(config.computerInPortName , config.jackAudioType, JackPortIsInput );
|
||||
effectsMicPort = addAudioPort(config.effectsMicPortName , config.jackAudioType, JackPortIsOutput);
|
||||
soundsPort = addAudioPort(config.soundsPortName , config.jackAudioType, JackPortIsOutput);
|
||||
repeatedMicPort = addAudioPort(config.repeatedMicName , config.jackAudioType, JackPortIsOutput);
|
||||
fakeMicPort = addAudioPort(config.fakeMicPortName , config.jackAudioType, JackPortIsOutput);
|
||||
earLoopbackPort = addAudioPort(config.earLoopbackPortName, config.jackAudioType, JackPortIsOutput);
|
||||
|
||||
}
|
||||
|
||||
private Pointer<?> addAudioPort(String name, String audioType, JackPortFlags type) {
|
||||
return LibJack.jack_port_register(client, Pointer.pointerToCString(name), Pointer.pointerToCString(audioType), type.value, 0);
|
||||
}
|
||||
|
||||
private class InternalJackCallback extends JackProcessCallback {
|
||||
|
||||
@Override
|
||||
public int apply(int nframes, Pointer<?> arg) {
|
||||
|
||||
// mic --> effects_mic
|
||||
effectsBox(nframes);
|
||||
|
||||
// X --> sounds
|
||||
soundBox(nframes);
|
||||
|
||||
// repeat_mic --> X
|
||||
repeatBoxIn(nframes);
|
||||
|
||||
// X --> repeated_mic
|
||||
repeatBoxOut(nframes);
|
||||
|
||||
// Balance
|
||||
mixerBox(nframes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void close() throws IOException{
|
||||
if(LibJack.jack_client_close(client)!=0)
|
||||
throw new IOException("Le client jack n'a pas pu être fermé.");
|
||||
}
|
||||
|
||||
}
|
||||
34
src/main/java/com/bernard/sboard/MixerBox.java
Normal file
34
src/main/java/com/bernard/sboard/MixerBox.java
Normal file
@ -0,0 +1,34 @@
|
||||
package com.bernard.sboard;
|
||||
|
||||
import org.bridj.Pointer;
|
||||
|
||||
public class MixerBox {
|
||||
|
||||
float effectsMicVolume = 1.0f;
|
||||
float soundsVolume = 1.0f;
|
||||
float repeatedMicVolume = 1.0f;
|
||||
float computerInputVolume = 1.0f;
|
||||
|
||||
float master = 1.0f;
|
||||
|
||||
float fakeMicVolume = 1.0f;
|
||||
float loopbackEarVolume = 1.0f;
|
||||
|
||||
public void mixFrames(int nframes,Pointer<?> effectsBuffer, Pointer<?> soundsBuffer, Pointer<?> repeatedMicBuffer, Pointer<?> computerInBuffer, Pointer<?> fakeMicBuffer, Pointer<?> loopbackEarBuffer) {
|
||||
float volumeSum = effectsMicVolume + soundsVolume + repeatedMicVolume + computerInputVolume;
|
||||
for (int frame=0;frame<nframes;frame++) {
|
||||
float frameSum =
|
||||
effectsBuffer.getFloatAtIndex(frame) * effectsMicVolume +
|
||||
soundsBuffer.getFloatAtIndex(frame) * soundsVolume +
|
||||
repeatedMicBuffer.getFloatAtIndex(frame) * repeatedMicVolume +
|
||||
computerInBuffer.getFloatAtIndex(frame) * computerInputVolume;
|
||||
float masterFrame = Float.isNaN(master)?frameSum/4.0f:frameSum*master/volumeSum;
|
||||
fakeMicBuffer.setFloatAtIndex(frame,fakeMicVolume * masterFrame);
|
||||
loopbackEarBuffer.setFloatAtIndex(frame,loopbackEarVolume * masterFrame);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/bernard/sboard/RepeatBox.java
Normal file
19
src/main/java/com/bernard/sboard/RepeatBox.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.bernard.sboard;
|
||||
|
||||
import org.bridj.Pointer;
|
||||
|
||||
public class RepeatBox {
|
||||
|
||||
|
||||
public void recordBuffer(int nframes, Pointer<?> inBuffer) {
|
||||
|
||||
}
|
||||
|
||||
public void retieveBuffer(int nframes, Pointer<?> outBuffer) {
|
||||
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
||||
}
|
||||
}
|
||||
141
src/main/java/com/bernard/sboard/SBoard.java
Normal file
141
src/main/java/com/bernard/sboard/SBoard.java
Normal file
@ -0,0 +1,141 @@
|
||||
package com.bernard.sboard;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.bernard.sboard.config.SBoardConfig;
|
||||
import com.bernard.sboard.effects.EffectsBox;
|
||||
import com.bernard.sboard.osc.OscServer;
|
||||
import com.bernard.sboard.osc.OscUtils;
|
||||
import com.bernard.sboard.osc.SOscMessage;
|
||||
import com.fasterxml.jackson.databind.DatabindException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||
|
||||
public class SBoard {
|
||||
|
||||
public SBoardConfig config;
|
||||
|
||||
public Random random;
|
||||
|
||||
public static final String configFilename = System.getProperty("user.home")+"/.config/sboard.yml";
|
||||
|
||||
public Logger log = LogManager.getLogger(SBoard.class);
|
||||
|
||||
|
||||
EffectsBox ebox;
|
||||
RepeatBox rbox;
|
||||
SoundBox sbox;
|
||||
MixerBox mbox;
|
||||
JackController jackc;
|
||||
OscServer oscserv;
|
||||
|
||||
public SBoard(SBoardConfig config) {
|
||||
this.config = config;
|
||||
this.random = new Random();
|
||||
|
||||
ebox = new EffectsBox(this, config.effects);
|
||||
ebox.setup();
|
||||
|
||||
rbox = new RepeatBox();
|
||||
|
||||
sbox = new SoundBox();
|
||||
|
||||
mbox = new MixerBox();
|
||||
|
||||
jackc = new JackController(config, ebox, rbox, sbox, mbox);
|
||||
jackc.setup();
|
||||
|
||||
oscserv = new OscServer(this, config.osc);
|
||||
try {
|
||||
oscserv.setup();
|
||||
} catch (IOException e) {
|
||||
log.error("Could not start the oscserver",e);
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) throws InterruptedException, IOException {
|
||||
|
||||
//TODO: passer sur quelque chose de plus configurable
|
||||
BasicConfigurator.configure();
|
||||
|
||||
SBoardConfig config = readConfig(configFilename);
|
||||
|
||||
SBoard sboard = new SBoard(config);
|
||||
|
||||
Thread.sleep(100_000);
|
||||
|
||||
sboard.close();
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
||||
try {
|
||||
oscserv.close();
|
||||
}catch(IOException e) {
|
||||
log.error("Could not close osc server", e);
|
||||
}
|
||||
|
||||
try{
|
||||
jackc.close();
|
||||
}catch(IOException e){
|
||||
log.error("Could not close jack server", e);
|
||||
}
|
||||
|
||||
ebox.close();
|
||||
rbox.close();
|
||||
sbox.close();
|
||||
mbox.close();
|
||||
|
||||
}
|
||||
|
||||
public static SBoardConfig readConfig(String configFName) {
|
||||
Logger configLog = LogManager.getLogger("Config Loader");
|
||||
|
||||
SBoardConfig output = null;
|
||||
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
|
||||
|
||||
File configFile = new File(configFName);
|
||||
|
||||
if(!configFile.exists()) {
|
||||
// On écrit le fichier
|
||||
configLog.info("Création d'un nouveau fichier de configuration.");
|
||||
try {
|
||||
configFile.createNewFile();
|
||||
mapper.writeValue(new FileOutputStream(configFile), new SBoardConfig());
|
||||
} catch (DatabindException e) {
|
||||
configLog.error("Le fichier écrit n'est pas un fichier de configuration valide !",e);
|
||||
} catch (IOException e) {
|
||||
configLog.error("Impossible d'écrire le fichier de configuration par défaut !",e);
|
||||
}
|
||||
}
|
||||
|
||||
configLog.info("Lecture du fichier de configuration.");
|
||||
try {
|
||||
output = mapper.readValue(configFile,SBoardConfig.class);
|
||||
if(output==null)
|
||||
configLog.error("Impossible de lire le fichier de configuration !");
|
||||
} catch (DatabindException e) {
|
||||
configLog.error("Le fichier lu n'est pas un fichier de configuration valide !",e);
|
||||
} catch (IOException e) {
|
||||
configLog.error("Impossible d'écrire le fichier de configuration par défaut !",e);
|
||||
}
|
||||
|
||||
if(output==null)
|
||||
System.exit(13);
|
||||
|
||||
return output;
|
||||
}
|
||||
public void dispatchOscMessage(SOscMessage message) {
|
||||
if(OscUtils.addrMatch(message.getContainer(0),"effectsbox")) {
|
||||
ebox.receiveOscMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
src/main/java/com/bernard/sboard/SoundBox.java
Normal file
15
src/main/java/com/bernard/sboard/SoundBox.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.bernard.sboard;
|
||||
|
||||
import org.bridj.Pointer;
|
||||
|
||||
public class SoundBox {
|
||||
|
||||
|
||||
public void produceFrame(int nframes, Pointer<?> outBuffer) {
|
||||
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
||||
}
|
||||
}
|
||||
392
src/main/java/com/bernard/sboard/bridj/LV2_Descriptor.java
Normal file
392
src/main/java/com/bernard/sboard/bridj/LV2_Descriptor.java
Normal file
@ -0,0 +1,392 @@
|
||||
package com.bernard.sboard.bridj;
|
||||
import org.bridj.Callback;
|
||||
import org.bridj.Pointer;
|
||||
import org.bridj.StructObject;
|
||||
import org.bridj.ann.Field;
|
||||
import org.bridj.ann.Library;
|
||||
/**
|
||||
* <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i><br>
|
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
|
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
|
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> or <a href="http://bridj.googlecode.com/">BridJ</a> .
|
||||
*/
|
||||
@Library("lilv-0")
|
||||
public class LV2_Descriptor extends StructObject {
|
||||
public LV2_Descriptor() {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* A globally unique, case-sensitive identifier for this plugin.<br>
|
||||
* This MUST be a valid URI string as defined by RFC 3986. All plugins with<br>
|
||||
* the same URI MUST be compatible to some degree, see<br>
|
||||
* http://lv2plug.in/ns/lv2core for details.<br>
|
||||
* C type : const char*
|
||||
*/
|
||||
@Field(0)
|
||||
public Pointer<Byte > URI() {
|
||||
return this.io.getPointerField(this, 0);
|
||||
}
|
||||
/**
|
||||
* A globally unique, case-sensitive identifier for this plugin.<br>
|
||||
* This MUST be a valid URI string as defined by RFC 3986. All plugins with<br>
|
||||
* the same URI MUST be compatible to some degree, see<br>
|
||||
* http://lv2plug.in/ns/lv2core for details.<br>
|
||||
* C type : const char*
|
||||
*/
|
||||
@Field(0)
|
||||
public LV2_Descriptor URI(Pointer<Byte > URI) {
|
||||
this.io.setPointerField(this, 0, URI);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Instantiate the plugin.<br>
|
||||
* Note that instance initialisation should generally occur in activate()<br>
|
||||
* rather than here. If a host calls instantiate(), it MUST call cleanup()<br>
|
||||
* at some point in the future.<br>
|
||||
* @param descriptor Descriptor of the plugin to instantiate.<br>
|
||||
* @param sample_rate Sample rate, in Hz, for the new plugin instance.<br>
|
||||
* @param bundle_path Path to the LV2 bundle which contains this plugin<br>
|
||||
* binary. It MUST include the trailing directory separator so that simply<br>
|
||||
* appending a filename will yield the path to that file in the bundle.<br>
|
||||
* @param features A NULL terminated array of LV2_Feature structs which<br>
|
||||
* represent the features the host supports. Plugins may refuse to<br>
|
||||
* instantiate if required features are not found here. However, hosts MUST<br>
|
||||
* NOT use this as a discovery mechanism: instead, use the RDF data to<br>
|
||||
* determine which features are required and do not attempt to instantiate<br>
|
||||
* unsupported plugins at all. This parameter MUST NOT be NULL, i.e. a host<br>
|
||||
* that supports no features MUST pass a single element array containing<br>
|
||||
* NULL.<br>
|
||||
* @return A handle for the new plugin instance, or NULL if instantiation<br>
|
||||
* has failed.<br>
|
||||
* C type : instantiate_callback
|
||||
*/
|
||||
@Field(1)
|
||||
public Pointer<LV2_Descriptor.instantiate_callback > instantiate() {
|
||||
return this.io.getPointerField(this, 1);
|
||||
}
|
||||
/**
|
||||
* Instantiate the plugin.<br>
|
||||
* Note that instance initialisation should generally occur in activate()<br>
|
||||
* rather than here. If a host calls instantiate(), it MUST call cleanup()<br>
|
||||
* at some point in the future.<br>
|
||||
* @param descriptor Descriptor of the plugin to instantiate.<br>
|
||||
* @param sample_rate Sample rate, in Hz, for the new plugin instance.<br>
|
||||
* @param bundle_path Path to the LV2 bundle which contains this plugin<br>
|
||||
* binary. It MUST include the trailing directory separator so that simply<br>
|
||||
* appending a filename will yield the path to that file in the bundle.<br>
|
||||
* @param features A NULL terminated array of LV2_Feature structs which<br>
|
||||
* represent the features the host supports. Plugins may refuse to<br>
|
||||
* instantiate if required features are not found here. However, hosts MUST<br>
|
||||
* NOT use this as a discovery mechanism: instead, use the RDF data to<br>
|
||||
* determine which features are required and do not attempt to instantiate<br>
|
||||
* unsupported plugins at all. This parameter MUST NOT be NULL, i.e. a host<br>
|
||||
* that supports no features MUST pass a single element array containing<br>
|
||||
* NULL.<br>
|
||||
* @return A handle for the new plugin instance, or NULL if instantiation<br>
|
||||
* has failed.<br>
|
||||
* C type : instantiate_callback
|
||||
*/
|
||||
@Field(1)
|
||||
public LV2_Descriptor instantiate(Pointer<LV2_Descriptor.instantiate_callback > instantiate) {
|
||||
this.io.setPointerField(this, 1, instantiate);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Connect a port on a plugin instance to a memory location.<br>
|
||||
* Plugin writers should be aware that the host may elect to use the same<br>
|
||||
* buffer for more than one port and even use the same buffer for both<br>
|
||||
* input and output (see lv2:inPlaceBroken in lv2.ttl).<br>
|
||||
* If the plugin has the feature lv2:hardRTCapable then there are various<br>
|
||||
* things that the plugin MUST NOT do within the connect_port() function;<br>
|
||||
* see lv2core.ttl for details.<br>
|
||||
* connect_port() MUST be called at least once for each port before run()<br>
|
||||
* is called, unless that port is lv2:connectionOptional. The plugin must<br>
|
||||
* pay careful attention to the block size passed to run() since the block<br>
|
||||
* allocated may only just be large enough to contain the data, and is not<br>
|
||||
* guaranteed to remain constant between run() calls.<br>
|
||||
* connect_port() may be called more than once for a plugin instance to<br>
|
||||
* allow the host to change the buffers that the plugin is reading or<br>
|
||||
* writing. These calls may be made before or after activate() or<br>
|
||||
* deactivate() calls.<br>
|
||||
* @param instance Plugin instance containing the port.<br>
|
||||
* @param port Index of the port to connect. The host MUST NOT try to<br>
|
||||
* connect a port index that is not defined in the plugin's RDF data. If<br>
|
||||
* it does, the plugin's behaviour is undefined (a crash is likely).<br>
|
||||
* @param data_location Pointer to data of the type defined by the port<br>
|
||||
* type in the plugin's RDF data (for example, an array of float for an<br>
|
||||
* lv2:AudioPort). This pointer must be stored by the plugin instance and<br>
|
||||
* used to read/write data when run() is called. Data present at the time<br>
|
||||
* of the connect_port() call MUST NOT be considered meaningful.<br>
|
||||
* C type : connect_port_callback
|
||||
*/
|
||||
@Field(2)
|
||||
public Pointer<LV2_Descriptor.connect_port_callback > connect_port() {
|
||||
return this.io.getPointerField(this, 2);
|
||||
}
|
||||
/**
|
||||
* Connect a port on a plugin instance to a memory location.<br>
|
||||
* Plugin writers should be aware that the host may elect to use the same<br>
|
||||
* buffer for more than one port and even use the same buffer for both<br>
|
||||
* input and output (see lv2:inPlaceBroken in lv2.ttl).<br>
|
||||
* If the plugin has the feature lv2:hardRTCapable then there are various<br>
|
||||
* things that the plugin MUST NOT do within the connect_port() function;<br>
|
||||
* see lv2core.ttl for details.<br>
|
||||
* connect_port() MUST be called at least once for each port before run()<br>
|
||||
* is called, unless that port is lv2:connectionOptional. The plugin must<br>
|
||||
* pay careful attention to the block size passed to run() since the block<br>
|
||||
* allocated may only just be large enough to contain the data, and is not<br>
|
||||
* guaranteed to remain constant between run() calls.<br>
|
||||
* connect_port() may be called more than once for a plugin instance to<br>
|
||||
* allow the host to change the buffers that the plugin is reading or<br>
|
||||
* writing. These calls may be made before or after activate() or<br>
|
||||
* deactivate() calls.<br>
|
||||
* @param instance Plugin instance containing the port.<br>
|
||||
* @param port Index of the port to connect. The host MUST NOT try to<br>
|
||||
* connect a port index that is not defined in the plugin's RDF data. If<br>
|
||||
* it does, the plugin's behaviour is undefined (a crash is likely).<br>
|
||||
* @param data_location Pointer to data of the type defined by the port<br>
|
||||
* type in the plugin's RDF data (for example, an array of float for an<br>
|
||||
* lv2:AudioPort). This pointer must be stored by the plugin instance and<br>
|
||||
* used to read/write data when run() is called. Data present at the time<br>
|
||||
* of the connect_port() call MUST NOT be considered meaningful.<br>
|
||||
* C type : connect_port_callback
|
||||
*/
|
||||
@Field(2)
|
||||
public LV2_Descriptor connect_port(Pointer<LV2_Descriptor.connect_port_callback > connect_port) {
|
||||
this.io.setPointerField(this, 2, connect_port);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Initialise a plugin instance and activate it for use.<br>
|
||||
* This is separated from instantiate() to aid real-time support and so<br>
|
||||
* that hosts can reinitialise a plugin instance by calling deactivate()<br>
|
||||
* and then activate(). In this case the plugin instance MUST reset all<br>
|
||||
* state information dependent on the history of the plugin instance except<br>
|
||||
* for any data locations provided by connect_port(). If there is nothing<br>
|
||||
* for activate() to do then this field may be NULL.<br>
|
||||
* When present, hosts MUST call this function once before run() is called<br>
|
||||
* for the first time. This call SHOULD be made as close to the run() call<br>
|
||||
* as possible and indicates to real-time plugins that they are now live,<br>
|
||||
* however plugins MUST NOT rely on a prompt call to run() after<br>
|
||||
* activate().<br>
|
||||
* The host MUST NOT call activate() again until deactivate() has been<br>
|
||||
* called first. If a host calls activate(), it MUST call deactivate() at<br>
|
||||
* some point in the future. Note that connect_port() may be called before<br>
|
||||
* or after activate().<br>
|
||||
* C type : activate_callback
|
||||
*/
|
||||
@Field(3)
|
||||
public Pointer<LV2_Descriptor.activate_callback > activate() {
|
||||
return this.io.getPointerField(this, 3);
|
||||
}
|
||||
/**
|
||||
* Initialise a plugin instance and activate it for use.<br>
|
||||
* This is separated from instantiate() to aid real-time support and so<br>
|
||||
* that hosts can reinitialise a plugin instance by calling deactivate()<br>
|
||||
* and then activate(). In this case the plugin instance MUST reset all<br>
|
||||
* state information dependent on the history of the plugin instance except<br>
|
||||
* for any data locations provided by connect_port(). If there is nothing<br>
|
||||
* for activate() to do then this field may be NULL.<br>
|
||||
* When present, hosts MUST call this function once before run() is called<br>
|
||||
* for the first time. This call SHOULD be made as close to the run() call<br>
|
||||
* as possible and indicates to real-time plugins that they are now live,<br>
|
||||
* however plugins MUST NOT rely on a prompt call to run() after<br>
|
||||
* activate().<br>
|
||||
* The host MUST NOT call activate() again until deactivate() has been<br>
|
||||
* called first. If a host calls activate(), it MUST call deactivate() at<br>
|
||||
* some point in the future. Note that connect_port() may be called before<br>
|
||||
* or after activate().<br>
|
||||
* C type : activate_callback
|
||||
*/
|
||||
@Field(3)
|
||||
public LV2_Descriptor activate(Pointer<LV2_Descriptor.activate_callback > activate) {
|
||||
this.io.setPointerField(this, 3, activate);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Run a plugin instance for a block.<br>
|
||||
* Note that if an activate() function exists then it must be called before<br>
|
||||
* run(). If deactivate() is called for a plugin instance then run() may<br>
|
||||
* not be called until activate() has been called again.<br>
|
||||
* If the plugin has the feature lv2:hardRTCapable then there are various<br>
|
||||
* things that the plugin MUST NOT do within the run() function (see<br>
|
||||
* lv2core.ttl for details).<br>
|
||||
* As a special case, when `sample_count` is 0, the plugin should update<br>
|
||||
* any output ports that represent a single instant in time (for example,<br>
|
||||
* control ports, but not audio ports). This is particularly useful for<br>
|
||||
* latent plugins, which should update their latency output port so hosts<br>
|
||||
* can pre-roll plugins to compute latency. Plugins MUST NOT crash when<br>
|
||||
* `sample_count` is 0.<br>
|
||||
* @param instance Instance to be run.<br>
|
||||
* @param sample_count The block size (in samples) for which the plugin<br>
|
||||
* instance must run.<br>
|
||||
* C type : run_callback
|
||||
*/
|
||||
@Field(4)
|
||||
public Pointer<LV2_Descriptor.run_callback > run() {
|
||||
return this.io.getPointerField(this, 4);
|
||||
}
|
||||
/**
|
||||
* Run a plugin instance for a block.<br>
|
||||
* Note that if an activate() function exists then it must be called before<br>
|
||||
* run(). If deactivate() is called for a plugin instance then run() may<br>
|
||||
* not be called until activate() has been called again.<br>
|
||||
* If the plugin has the feature lv2:hardRTCapable then there are various<br>
|
||||
* things that the plugin MUST NOT do within the run() function (see<br>
|
||||
* lv2core.ttl for details).<br>
|
||||
* As a special case, when `sample_count` is 0, the plugin should update<br>
|
||||
* any output ports that represent a single instant in time (for example,<br>
|
||||
* control ports, but not audio ports). This is particularly useful for<br>
|
||||
* latent plugins, which should update their latency output port so hosts<br>
|
||||
* can pre-roll plugins to compute latency. Plugins MUST NOT crash when<br>
|
||||
* `sample_count` is 0.<br>
|
||||
* @param instance Instance to be run.<br>
|
||||
* @param sample_count The block size (in samples) for which the plugin<br>
|
||||
* instance must run.<br>
|
||||
* C type : run_callback
|
||||
*/
|
||||
@Field(4)
|
||||
public LV2_Descriptor run(Pointer<LV2_Descriptor.run_callback > run) {
|
||||
this.io.setPointerField(this, 4, run);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Deactivate a plugin instance (counterpart to activate()).<br>
|
||||
* Hosts MUST deactivate all activated instances after they have been run()<br>
|
||||
* for the last time. This call SHOULD be made as close to the last run()<br>
|
||||
* call as possible and indicates to real-time plugins that they are no<br>
|
||||
* longer live, however plugins MUST NOT rely on prompt deactivation. If<br>
|
||||
* there is nothing for deactivate() to do then this field may be NULL<br>
|
||||
* Deactivation is not similar to pausing since the plugin instance will be<br>
|
||||
* reinitialised by activate(). However, deactivate() itself MUST NOT fully<br>
|
||||
* reset plugin state. For example, the host may deactivate a plugin, then<br>
|
||||
* store its state (using some extension to do so).<br>
|
||||
* Hosts MUST NOT call deactivate() unless activate() was previously<br>
|
||||
* called. Note that connect_port() may be called before or after<br>
|
||||
* deactivate().<br>
|
||||
* C type : deactivate_callback
|
||||
*/
|
||||
@Field(5)
|
||||
public Pointer<LV2_Descriptor.deactivate_callback > deactivate() {
|
||||
return this.io.getPointerField(this, 5);
|
||||
}
|
||||
/**
|
||||
* Deactivate a plugin instance (counterpart to activate()).<br>
|
||||
* Hosts MUST deactivate all activated instances after they have been run()<br>
|
||||
* for the last time. This call SHOULD be made as close to the last run()<br>
|
||||
* call as possible and indicates to real-time plugins that they are no<br>
|
||||
* longer live, however plugins MUST NOT rely on prompt deactivation. If<br>
|
||||
* there is nothing for deactivate() to do then this field may be NULL<br>
|
||||
* Deactivation is not similar to pausing since the plugin instance will be<br>
|
||||
* reinitialised by activate(). However, deactivate() itself MUST NOT fully<br>
|
||||
* reset plugin state. For example, the host may deactivate a plugin, then<br>
|
||||
* store its state (using some extension to do so).<br>
|
||||
* Hosts MUST NOT call deactivate() unless activate() was previously<br>
|
||||
* called. Note that connect_port() may be called before or after<br>
|
||||
* deactivate().<br>
|
||||
* C type : deactivate_callback
|
||||
*/
|
||||
@Field(5)
|
||||
public LV2_Descriptor deactivate(Pointer<LV2_Descriptor.deactivate_callback > deactivate) {
|
||||
this.io.setPointerField(this, 5, deactivate);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Clean up a plugin instance (counterpart to instantiate()).<br>
|
||||
* Once an instance of a plugin has been finished with it must be deleted<br>
|
||||
* using this function. The instance handle passed ceases to be valid after<br>
|
||||
* this call.<br>
|
||||
* If activate() was called for a plugin instance then a corresponding call<br>
|
||||
* to deactivate() MUST be made before cleanup() is called. Hosts MUST NOT<br>
|
||||
* call cleanup() unless instantiate() was previously called.<br>
|
||||
* C type : cleanup_callback
|
||||
*/
|
||||
@Field(6)
|
||||
public Pointer<LV2_Lib_Descriptor.cleanup_callback > cleanup() {
|
||||
return this.io.getPointerField(this, 6);
|
||||
}
|
||||
/**
|
||||
* Clean up a plugin instance (counterpart to instantiate()).<br>
|
||||
* Once an instance of a plugin has been finished with it must be deleted<br>
|
||||
* using this function. The instance handle passed ceases to be valid after<br>
|
||||
* this call.<br>
|
||||
* If activate() was called for a plugin instance then a corresponding call<br>
|
||||
* to deactivate() MUST be made before cleanup() is called. Hosts MUST NOT<br>
|
||||
* call cleanup() unless instantiate() was previously called.<br>
|
||||
* C type : cleanup_callback
|
||||
*/
|
||||
@Field(6)
|
||||
public LV2_Descriptor cleanup(Pointer<LV2_Lib_Descriptor.cleanup_callback > cleanup) {
|
||||
this.io.setPointerField(this, 6, cleanup);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Return additional plugin data defined by some extension.<br>
|
||||
* A typical use of this facility is to return a struct containing function<br>
|
||||
* pointers to extend the LV2_Descriptor API.<br>
|
||||
* The actual type and meaning of the returned object MUST be specified<br>
|
||||
* precisely by the extension. This function MUST return NULL for any<br>
|
||||
* unsupported URI. If a plugin does not support any extension data, this<br>
|
||||
* field may be NULL.<br>
|
||||
* The host is never responsible for freeing the returned value.<br>
|
||||
* C type : extension_data_callback
|
||||
*/
|
||||
@Field(7)
|
||||
public Pointer<LV2_Descriptor.extension_data_callback > extension_data() {
|
||||
return this.io.getPointerField(this, 7);
|
||||
}
|
||||
/**
|
||||
* Return additional plugin data defined by some extension.<br>
|
||||
* A typical use of this facility is to return a struct containing function<br>
|
||||
* pointers to extend the LV2_Descriptor API.<br>
|
||||
* The actual type and meaning of the returned object MUST be specified<br>
|
||||
* precisely by the extension. This function MUST return NULL for any<br>
|
||||
* unsupported URI. If a plugin does not support any extension data, this<br>
|
||||
* field may be NULL.<br>
|
||||
* The host is never responsible for freeing the returned value.<br>
|
||||
* C type : extension_data_callback
|
||||
*/
|
||||
@Field(7)
|
||||
public LV2_Descriptor extension_data(Pointer<LV2_Descriptor.extension_data_callback > extension_data) {
|
||||
this.io.setPointerField(this, 7, extension_data);
|
||||
return this;
|
||||
}
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
public static abstract class instantiate_callback extends Callback<instantiate_callback > {
|
||||
abstract public Pointer<? > apply(Pointer<LV2_Descriptor > descriptor, double sample_rate, Pointer<Byte > bundle_path, Pointer<Pointer<LV2_Feature > > features);
|
||||
};
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
public static abstract class connect_port_callback extends Callback<connect_port_callback > {
|
||||
abstract public void apply(Pointer<? > instance, int port, Pointer<? > data_location);
|
||||
};
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
public static abstract class activate_callback extends Callback<activate_callback > {
|
||||
abstract public void apply(Pointer<? > instance);
|
||||
};
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
public static abstract class run_callback extends Callback<run_callback > {
|
||||
abstract public void apply(Pointer<? > instance, int sample_count);
|
||||
};
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
public static abstract class deactivate_callback extends Callback<deactivate_callback > {
|
||||
abstract public void apply(Pointer<? > instance);
|
||||
};
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
public static abstract class cleanup_callback extends Callback<cleanup_callback > {
|
||||
abstract public void apply(Pointer<? > instance);
|
||||
};
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
public static abstract class extension_data_callback extends Callback<extension_data_callback > {
|
||||
abstract public Pointer<? > apply(Pointer<Byte > uri);
|
||||
};
|
||||
public LV2_Descriptor(Pointer<? extends StructObject> pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
}
|
||||
60
src/main/java/com/bernard/sboard/bridj/LV2_Feature.java
Normal file
60
src/main/java/com/bernard/sboard/bridj/LV2_Feature.java
Normal file
@ -0,0 +1,60 @@
|
||||
package com.bernard.sboard.bridj;
|
||||
import org.bridj.Pointer;
|
||||
import org.bridj.StructObject;
|
||||
import org.bridj.ann.Field;
|
||||
import org.bridj.ann.Library;
|
||||
/**
|
||||
* <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i><br>
|
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
|
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
|
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> or <a href="http://bridj.googlecode.com/">BridJ</a> .
|
||||
*/
|
||||
@Library("lv2")
|
||||
public class LV2_Feature extends StructObject {
|
||||
public LV2_Feature() {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* A globally unique, case-sensitive identifier (URI) for this feature.<br>
|
||||
* This MUST be a valid URI string as defined by RFC 3986.<br>
|
||||
* C type : const char*
|
||||
*/
|
||||
@Field(0)
|
||||
public Pointer<Byte > URI() {
|
||||
return this.io.getPointerField(this, 0);
|
||||
}
|
||||
/**
|
||||
* A globally unique, case-sensitive identifier (URI) for this feature.<br>
|
||||
* This MUST be a valid URI string as defined by RFC 3986.<br>
|
||||
* C type : const char*
|
||||
*/
|
||||
@Field(0)
|
||||
public LV2_Feature URI(Pointer<Byte > URI) {
|
||||
this.io.setPointerField(this, 0, URI);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Pointer to arbitrary data.<br>
|
||||
* The format of this data is defined by the extension which describes the<br>
|
||||
* feature with the given `URI`.<br>
|
||||
* C type : void*
|
||||
*/
|
||||
@Field(1)
|
||||
public Pointer<? > data() {
|
||||
return this.io.getPointerField(this, 1);
|
||||
}
|
||||
/**
|
||||
* Pointer to arbitrary data.<br>
|
||||
* The format of this data is defined by the extension which describes the<br>
|
||||
* feature with the given `URI`.<br>
|
||||
* C type : void*
|
||||
*/
|
||||
@Field(1)
|
||||
public LV2_Feature data(Pointer<? > data) {
|
||||
this.io.setPointerField(this, 1, data);
|
||||
return this;
|
||||
}
|
||||
public LV2_Feature(Pointer<LV2_Feature> pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
}
|
||||
111
src/main/java/com/bernard/sboard/bridj/LV2_Lib_Descriptor.java
Normal file
111
src/main/java/com/bernard/sboard/bridj/LV2_Lib_Descriptor.java
Normal file
@ -0,0 +1,111 @@
|
||||
package com.bernard.sboard.bridj;
|
||||
import org.bridj.Callback;
|
||||
import org.bridj.Pointer;
|
||||
import org.bridj.StructObject;
|
||||
import org.bridj.ann.Field;
|
||||
import org.bridj.ann.Library;
|
||||
/**
|
||||
* <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i><br>
|
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
|
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
|
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> or <a href="http://bridj.googlecode.com/">BridJ</a> .
|
||||
*/
|
||||
@Library("lv2")
|
||||
public class LV2_Lib_Descriptor extends StructObject {
|
||||
public LV2_Lib_Descriptor() {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* Opaque library data which must be passed as the first parameter to all<br>
|
||||
* the methods of this struct.<br>
|
||||
* C type : LV2_Lib_Handle
|
||||
*/
|
||||
@Field(0)
|
||||
public Pointer<? > handle() {
|
||||
return this.io.getPointerField(this, 0);
|
||||
}
|
||||
/**
|
||||
* Opaque library data which must be passed as the first parameter to all<br>
|
||||
* the methods of this struct.<br>
|
||||
* C type : LV2_Lib_Handle
|
||||
*/
|
||||
@Field(0)
|
||||
public LV2_Lib_Descriptor handle(Pointer<? > handle) {
|
||||
this.io.setPointerField(this, 0, handle);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* The total size of this struct. This allows for this struct to be<br>
|
||||
* expanded in the future if necessary. This MUST be set by the library to<br>
|
||||
* sizeof(LV2_Lib_Descriptor). The host MUST NOT access any fields of this<br>
|
||||
* struct beyond get_plugin() unless this field indicates they are present.
|
||||
*/
|
||||
@Field(1)
|
||||
public int size() {
|
||||
return this.io.getIntField(this, 1);
|
||||
}
|
||||
/**
|
||||
* The total size of this struct. This allows for this struct to be<br>
|
||||
* expanded in the future if necessary. This MUST be set by the library to<br>
|
||||
* sizeof(LV2_Lib_Descriptor). The host MUST NOT access any fields of this<br>
|
||||
* struct beyond get_plugin() unless this field indicates they are present.
|
||||
*/
|
||||
@Field(1)
|
||||
public LV2_Lib_Descriptor size(int size) {
|
||||
this.io.setIntField(this, 1, size);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Destroy this library descriptor and free all related resources.<br>
|
||||
* C type : cleanup_callback
|
||||
*/
|
||||
@Field(2)
|
||||
public Pointer<LV2_Lib_Descriptor.cleanup_callback > cleanup() {
|
||||
return this.io.getPointerField(this, 2);
|
||||
}
|
||||
/**
|
||||
* Destroy this library descriptor and free all related resources.<br>
|
||||
* C type : cleanup_callback
|
||||
*/
|
||||
@Field(2)
|
||||
public LV2_Lib_Descriptor cleanup(Pointer<LV2_Lib_Descriptor.cleanup_callback > cleanup) {
|
||||
this.io.setPointerField(this, 2, cleanup);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Plugin accessor.<br>
|
||||
* Plugins are accessed by index using values from 0 upwards. Out of range<br>
|
||||
* indices MUST result in this function returning NULL, so the host can<br>
|
||||
* enumerate plugins by increasing `index` until NULL is returned.<br>
|
||||
* C type : get_plugin_callback
|
||||
*/
|
||||
@Field(3)
|
||||
public Pointer<LV2_Lib_Descriptor.get_plugin_callback > get_plugin() {
|
||||
return this.io.getPointerField(this, 3);
|
||||
}
|
||||
/**
|
||||
* Plugin accessor.<br>
|
||||
* Plugins are accessed by index using values from 0 upwards. Out of range<br>
|
||||
* indices MUST result in this function returning NULL, so the host can<br>
|
||||
* enumerate plugins by increasing `index` until NULL is returned.<br>
|
||||
* C type : get_plugin_callback
|
||||
*/
|
||||
@Field(3)
|
||||
public LV2_Lib_Descriptor get_plugin(Pointer<LV2_Lib_Descriptor.get_plugin_callback > get_plugin) {
|
||||
this.io.setPointerField(this, 3, get_plugin);
|
||||
return this;
|
||||
}
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
public static abstract class cleanup_callback extends Callback<cleanup_callback > {
|
||||
abstract public void apply(Pointer<? > handle);
|
||||
};
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
/// <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h</i>
|
||||
public static abstract class get_plugin_callback extends Callback<get_plugin_callback > {
|
||||
abstract public Pointer<LV2_Descriptor > apply(Pointer<? > handle, int index);
|
||||
};
|
||||
public LV2_Lib_Descriptor(Pointer<LV2_Lib_Descriptor> pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
}
|
||||
160
src/main/java/com/bernard/sboard/bridj/LibJack.java
Normal file
160
src/main/java/com/bernard/sboard/bridj/LibJack.java
Normal file
@ -0,0 +1,160 @@
|
||||
package com.bernard.sboard.bridj;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bridj.BridJ;
|
||||
import org.bridj.CRuntime;
|
||||
import org.bridj.Callback;
|
||||
import org.bridj.FlagSet;
|
||||
import org.bridj.IntValuedEnum;
|
||||
import org.bridj.Pointer;
|
||||
import org.bridj.ann.Library;
|
||||
import org.bridj.ann.Name;
|
||||
import org.bridj.ann.Runtime;
|
||||
|
||||
@Library("jack")
|
||||
@Runtime(CRuntime.class)
|
||||
public class LibJack {
|
||||
static {
|
||||
BridJ.register();
|
||||
}
|
||||
|
||||
public native static int jack_client_close(Pointer<?> client);
|
||||
|
||||
public native static int jack_activate(Pointer<?> client);
|
||||
|
||||
public native static int jack_get_buffer_size(Pointer<?> client);
|
||||
|
||||
public native static Pointer<Byte> jack_midi_event_reserve(Pointer<?> port_buffer, int time, int data_size);
|
||||
|
||||
public native static void jack_midi_clear_buffer(Pointer<?> port_buffer);
|
||||
|
||||
public native static Pointer<?> jack_port_get_buffer(Pointer<?> output_port, int nframes);
|
||||
|
||||
public native static Pointer<?> jack_port_register(Pointer<?> client, Pointer<Byte> port_name, Pointer<Byte> port_type, long flags, long buffer_size);
|
||||
|
||||
public native static Pointer<?> jack_client_open(Pointer<Byte> client_name, int options, Pointer<JackStatus> status);
|
||||
|
||||
@Name("jack_set_process_callback")
|
||||
native public static int jackSetProcessCallback(Pointer<?> client, Pointer<LibJack.JackProcessCallback > process_callback, Pointer<? > arg);
|
||||
|
||||
public static abstract class JackProcessCallback extends Callback<JackProcessCallback> {
|
||||
abstract public int apply(int nframes, Pointer<? > arg);
|
||||
}
|
||||
|
||||
public enum JackStatus implements IntValuedEnum<JackStatus> {
|
||||
/// Overall operation failed.
|
||||
JackFailure(1),
|
||||
/// The operation contained an invalid or unsupported option.
|
||||
JackInvalidOption(2),
|
||||
/**
|
||||
* The desired client name was not unique. With the @ref<br>
|
||||
* JackUseExactName option this situation is fatal. Otherwise,<br>
|
||||
* the name was modified by appending a dash and a two-digit<br>
|
||||
* number in the range "-01" to "-99". The<br>
|
||||
* jack_get_client_name() function will return the exact string<br>
|
||||
* that was used. If the specified @a client_name plus these<br>
|
||||
* extra characters would be too long, the open fails instead.
|
||||
*/
|
||||
JackNameNotUnique(4),
|
||||
/**
|
||||
* The JACK server was started as a result of this operation.<br>
|
||||
* Otherwise, it was running already. In either case the caller<br>
|
||||
* is now connected to jackd, so there is no race condition.<br>
|
||||
* When the server shuts down, the client will find out.
|
||||
*/
|
||||
JackServerStarted(8),
|
||||
/// Unable to connect to the JACK server.
|
||||
JackServerFailed(16),
|
||||
/// Communication error with the JACK server.
|
||||
JackServerError(32),
|
||||
/// Requested client does not exist.
|
||||
JackNoSuchClient(64),
|
||||
/// Unable to load internal client
|
||||
JackLoadFailure(128),
|
||||
/// Unable to initialize client
|
||||
JackInitFailure(256),
|
||||
/// Unable to access shared memory
|
||||
JackShmFailure(512),
|
||||
/// Client's protocol version does not match
|
||||
JackVersionError(1024),
|
||||
/// Backend error
|
||||
JackBackendError(2048),
|
||||
/// Client zombified failure
|
||||
JackClientZombie(4096);
|
||||
JackStatus(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
public final long value;
|
||||
public long value() {
|
||||
return this.value;
|
||||
}
|
||||
public Iterator<JackStatus > iterator() {
|
||||
return Collections.singleton(this).iterator();
|
||||
}
|
||||
public static IntValuedEnum<JackStatus > fromValue(int value) {
|
||||
return FlagSet.fromValue(value, values());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* enum values<br>
|
||||
* <i>native declaration : line 8</i>
|
||||
*/
|
||||
public enum JackPortFlags implements IntValuedEnum<JackPortFlags > {
|
||||
/**
|
||||
* if JackPortIsInput is set, then the port can receive<br>
|
||||
* data.
|
||||
*/
|
||||
JackPortIsInput(1),
|
||||
/**
|
||||
* if JackPortIsOutput is set, then data can be read from<br>
|
||||
* the port.
|
||||
*/
|
||||
JackPortIsOutput(2),
|
||||
/**
|
||||
* if JackPortIsPhysical is set, then the port corresponds<br>
|
||||
* to some kind of physical I/O connector.
|
||||
*/
|
||||
JackPortIsPhysical(4),
|
||||
/**
|
||||
* if JackPortCanMonitor is set, then a call to<br>
|
||||
* jack_port_request_monitor() makes sense.<br>
|
||||
* * Precisely what this means is dependent on the client. A typical<br>
|
||||
* result of it being called with TRUE as the second argument is<br>
|
||||
* that data that would be available from an output port (with<br>
|
||||
* JackPortIsPhysical set) is sent to a physical output connector<br>
|
||||
* as well, so that it can be heard/seen/whatever.<br>
|
||||
* * Clients that do not control physical interfaces<br>
|
||||
* should never create ports with this bit set.
|
||||
*/
|
||||
JackPortCanMonitor(8),
|
||||
/**
|
||||
* JackPortIsTerminal means:<br>
|
||||
* * for an input port: the data received by the port<br>
|
||||
* will not be passed on or made<br>
|
||||
* available at any other port<br>
|
||||
* * for an output port: the data available at the port<br>
|
||||
* does not originate from any other port<br>
|
||||
* * Audio synthesizers, I/O hardware interface clients, HDR<br>
|
||||
* systems are examples of clients that would set this flag for<br>
|
||||
* their ports.
|
||||
*/
|
||||
JackPortIsTerminal(16);
|
||||
JackPortFlags(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
public final long value;
|
||||
public long value() {
|
||||
return this.value;
|
||||
}
|
||||
public Iterator<JackPortFlags > iterator() {
|
||||
return Collections.singleton(this).iterator();
|
||||
}
|
||||
public static IntValuedEnum<JackPortFlags > fromValue(int value) {
|
||||
return FlagSet.fromValue(value, values());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
2137
src/main/java/com/bernard/sboard/bridj/LibLilv.java
Normal file
2137
src/main/java/com/bernard/sboard/bridj/LibLilv.java
Normal file
File diff suppressed because it is too large
Load Diff
250
src/main/java/com/bernard/sboard/bridj/LibLv2.java
Normal file
250
src/main/java/com/bernard/sboard/bridj/LibLv2.java
Normal file
@ -0,0 +1,250 @@
|
||||
package com.bernard.sboard.bridj;
|
||||
import org.bridj.BridJ;
|
||||
import org.bridj.CRuntime;
|
||||
import org.bridj.Callback;
|
||||
import org.bridj.Pointer;
|
||||
import org.bridj.Pointer.Releaser;
|
||||
import org.bridj.ann.Library;
|
||||
import org.bridj.ann.Name;
|
||||
import org.bridj.ann.Ptr;
|
||||
import org.bridj.ann.Runtime;
|
||||
/**
|
||||
* Wrapper for library <b>lv2</b><br>
|
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
|
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
|
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> or <a href="http://bridj.googlecode.com/">BridJ</a> .
|
||||
*/
|
||||
@Library("lv2")
|
||||
@Runtime(CRuntime.class)
|
||||
public class LibLv2 {
|
||||
static {
|
||||
BridJ.register();
|
||||
}
|
||||
|
||||
public static final Releaser noReleaser = new Pointer.Releaser() {
|
||||
|
||||
@Override
|
||||
public void release(Pointer<?> p) {
|
||||
// Doing nothing
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static final String LV2_CORE_PREFIX = "http://lv2plug.in/ns/lv2core#"; ///< http://lv2plug.in/ns/lv2core#
|
||||
|
||||
public static final String LV2_CORE__AllpassPlugin = LV2_CORE_PREFIX + "AllpassPlugin"; ///< http://lv2plug.in/ns/lv2core#AllpassPlugin
|
||||
public static final String LV2_CORE__AmplifierPlugin = LV2_CORE_PREFIX + "AmplifierPlugin"; ///< http://lv2plug.in/ns/lv2core#AmplifierPlugin
|
||||
public static final String LV2_CORE__AnalyserPlugin = LV2_CORE_PREFIX + "AnalyserPlugin"; ///< http://lv2plug.in/ns/lv2core#AnalyserPlugin
|
||||
public static final String LV2_CORE__AudioPort = LV2_CORE_PREFIX + "AudioPort"; ///< http://lv2plug.in/ns/lv2core#AudioPort
|
||||
public static final String LV2_CORE__BandpassPlugin = LV2_CORE_PREFIX + "BandpassPlugin"; ///< http://lv2plug.in/ns/lv2core#BandpassPlugin
|
||||
public static final String LV2_CORE__CVPort = LV2_CORE_PREFIX + "CVPort"; ///< http://lv2plug.in/ns/lv2core#CVPort
|
||||
public static final String LV2_CORE__ChorusPlugin = LV2_CORE_PREFIX + "ChorusPlugin"; ///< http://lv2plug.in/ns/lv2core#ChorusPlugin
|
||||
public static final String LV2_CORE__CombPlugin = LV2_CORE_PREFIX + "CombPlugin"; ///< http://lv2plug.in/ns/lv2core#CombPlugin
|
||||
public static final String LV2_CORE__CompressorPlugin = LV2_CORE_PREFIX + "CompressorPlugin"; ///< http://lv2plug.in/ns/lv2core#CompressorPlugin
|
||||
public static final String LV2_CORE__ConstantPlugin = LV2_CORE_PREFIX + "ConstantPlugin"; ///< http://lv2plug.in/ns/lv2core#ConstantPlugin
|
||||
public static final String LV2_CORE__ControlPort = LV2_CORE_PREFIX + "ControlPort"; ///< http://lv2plug.in/ns/lv2core#ControlPort
|
||||
public static final String LV2_CORE__ConverterPlugin = LV2_CORE_PREFIX + "ConverterPlugin"; ///< http://lv2plug.in/ns/lv2core#ConverterPlugin
|
||||
public static final String LV2_CORE__DelayPlugin = LV2_CORE_PREFIX + "DelayPlugin"; ///< http://lv2plug.in/ns/lv2core#DelayPlugin
|
||||
public static final String LV2_CORE__DistortionPlugin = LV2_CORE_PREFIX + "DistortionPlugin"; ///< http://lv2plug.in/ns/lv2core#DistortionPlugin
|
||||
public static final String LV2_CORE__DynamicsPlugin = LV2_CORE_PREFIX + "DynamicsPlugin"; ///< http://lv2plug.in/ns/lv2core#DynamicsPlugin
|
||||
public static final String LV2_CORE__EQPlugin = LV2_CORE_PREFIX + "EQPlugin"; ///< http://lv2plug.in/ns/lv2core#EQPlugin
|
||||
public static final String LV2_CORE__EnvelopePlugin = LV2_CORE_PREFIX + "EnvelopePlugin"; ///< http://lv2plug.in/ns/lv2core#EnvelopePlugin
|
||||
public static final String LV2_CORE__ExpanderPlugin = LV2_CORE_PREFIX + "ExpanderPlugin"; ///< http://lv2plug.in/ns/lv2core#ExpanderPlugin
|
||||
public static final String LV2_CORE__ExtensionData = LV2_CORE_PREFIX + "ExtensionData"; ///< http://lv2plug.in/ns/lv2core#ExtensionData
|
||||
public static final String LV2_CORE__Feature = LV2_CORE_PREFIX + "Feature"; ///< http://lv2plug.in/ns/lv2core#Feature
|
||||
public static final String LV2_CORE__FilterPlugin = LV2_CORE_PREFIX + "FilterPlugin"; ///< http://lv2plug.in/ns/lv2core#FilterPlugin
|
||||
public static final String LV2_CORE__FlangerPlugin = LV2_CORE_PREFIX + "FlangerPlugin"; ///< http://lv2plug.in/ns/lv2core#FlangerPlugin
|
||||
public static final String LV2_CORE__FunctionPlugin = LV2_CORE_PREFIX + "FunctionPlugin"; ///< http://lv2plug.in/ns/lv2core#FunctionPlugin
|
||||
public static final String LV2_CORE__GatePlugin = LV2_CORE_PREFIX + "GatePlugin"; ///< http://lv2plug.in/ns/lv2core#GatePlugin
|
||||
public static final String LV2_CORE__GeneratorPlugin = LV2_CORE_PREFIX + "GeneratorPlugin"; ///< http://lv2plug.in/ns/lv2core#GeneratorPlugin
|
||||
public static final String LV2_CORE__HighpassPlugin = LV2_CORE_PREFIX + "HighpassPlugin"; ///< http://lv2plug.in/ns/lv2core#HighpassPlugin
|
||||
public static final String LV2_CORE__InputPort = LV2_CORE_PREFIX + "InputPort"; ///< http://lv2plug.in/ns/lv2core#InputPort
|
||||
public static final String LV2_CORE__InstrumentPlugin = LV2_CORE_PREFIX + "InstrumentPlugin"; ///< http://lv2plug.in/ns/lv2core#InstrumentPlugin
|
||||
public static final String LV2_CORE__LimiterPlugin = LV2_CORE_PREFIX + "LimiterPlugin"; ///< http://lv2plug.in/ns/lv2core#LimiterPlugin
|
||||
public static final String LV2_CORE__LowpassPlugin = LV2_CORE_PREFIX + "LowpassPlugin"; ///< http://lv2plug.in/ns/lv2core#LowpassPlugin
|
||||
public static final String LV2_CORE__MixerPlugin = LV2_CORE_PREFIX + "MixerPlugin"; ///< http://lv2plug.in/ns/lv2core#MixerPlugin
|
||||
public static final String LV2_CORE__ModulatorPlugin = LV2_CORE_PREFIX + "ModulatorPlugin"; ///< http://lv2plug.in/ns/lv2core#ModulatorPlugin
|
||||
public static final String LV2_CORE__MultiEQPlugin = LV2_CORE_PREFIX + "MultiEQPlugin"; ///< http://lv2plug.in/ns/lv2core#MultiEQPlugin
|
||||
public static final String LV2_CORE__OscillatorPlugin = LV2_CORE_PREFIX + "OscillatorPlugin"; ///< http://lv2plug.in/ns/lv2core#OscillatorPlugin
|
||||
public static final String LV2_CORE__OutputPort = LV2_CORE_PREFIX + "OutputPort"; ///< http://lv2plug.in/ns/lv2core#OutputPort
|
||||
public static final String LV2_CORE__ParaEQPlugin = LV2_CORE_PREFIX + "ParaEQPlugin"; ///< http://lv2plug.in/ns/lv2core#ParaEQPlugin
|
||||
public static final String LV2_CORE__PhaserPlugin = LV2_CORE_PREFIX + "PhaserPlugin"; ///< http://lv2plug.in/ns/lv2core#PhaserPlugin
|
||||
public static final String LV2_CORE__PitchPlugin = LV2_CORE_PREFIX + "PitchPlugin"; ///< http://lv2plug.in/ns/lv2core#PitchPlugin
|
||||
public static final String LV2_CORE__Plugin = LV2_CORE_PREFIX + "Plugin"; ///< http://lv2plug.in/ns/lv2core#Plugin
|
||||
public static final String LV2_CORE__PluginBase = LV2_CORE_PREFIX + "PluginBase"; ///< http://lv2plug.in/ns/lv2core#PluginBase
|
||||
public static final String LV2_CORE__Point = LV2_CORE_PREFIX + "Point"; ///< http://lv2plug.in/ns/lv2core#Point
|
||||
public static final String LV2_CORE__Port = LV2_CORE_PREFIX + "Port"; ///< http://lv2plug.in/ns/lv2core#Port
|
||||
public static final String LV2_CORE__PortProperty = LV2_CORE_PREFIX + "PortProperty"; ///< http://lv2plug.in/ns/lv2core#PortProperty
|
||||
public static final String LV2_CORE__Resource = LV2_CORE_PREFIX + "Resource"; ///< http://lv2plug.in/ns/lv2core#Resource
|
||||
public static final String LV2_CORE__ReverbPlugin = LV2_CORE_PREFIX + "ReverbPlugin"; ///< http://lv2plug.in/ns/lv2core#ReverbPlugin
|
||||
public static final String LV2_CORE__ScalePoint = LV2_CORE_PREFIX + "ScalePoint"; ///< http://lv2plug.in/ns/lv2core#ScalePoint
|
||||
public static final String LV2_CORE__SimulatorPlugin = LV2_CORE_PREFIX + "SimulatorPlugin"; ///< http://lv2plug.in/ns/lv2core#SimulatorPlugin
|
||||
public static final String LV2_CORE__SpatialPlugin = LV2_CORE_PREFIX + "SpatialPlugin"; ///< http://lv2plug.in/ns/lv2core#SpatialPlugin
|
||||
public static final String LV2_CORE__Specification = LV2_CORE_PREFIX + "Specification"; ///< http://lv2plug.in/ns/lv2core#Specification
|
||||
public static final String LV2_CORE__SpectralPlugin = LV2_CORE_PREFIX + "SpectralPlugin"; ///< http://lv2plug.in/ns/lv2core#SpectralPlugin
|
||||
public static final String LV2_CORE__UtilityPlugin = LV2_CORE_PREFIX + "UtilityPlugin"; ///< http://lv2plug.in/ns/lv2core#UtilityPlugin
|
||||
public static final String LV2_CORE__WaveshaperPlugin = LV2_CORE_PREFIX + "WaveshaperPlugin"; ///< http://lv2plug.in/ns/lv2core#WaveshaperPlugin
|
||||
public static final String LV2_CORE__appliesTo = LV2_CORE_PREFIX + "appliesTo"; ///< http://lv2plug.in/ns/lv2core#appliesTo
|
||||
public static final String LV2_CORE__binary = LV2_CORE_PREFIX + "binary"; ///< http://lv2plug.in/ns/lv2core#binary
|
||||
public static final String LV2_CORE__connectionOptional= LV2_CORE_PREFIX + "connectionOptional"; ///< http://lv2plug.in/ns/lv2core#connectionOptional
|
||||
public static final String LV2_CORE__control = LV2_CORE_PREFIX + "control"; ///< http://lv2plug.in/ns/lv2core#control
|
||||
public static final String LV2_CORE__default = LV2_CORE_PREFIX + "default"; ///< http://lv2plug.in/ns/lv2core#default
|
||||
public static final String LV2_CORE__designation = LV2_CORE_PREFIX + "designation"; ///< http://lv2plug.in/ns/lv2core#designation
|
||||
public static final String LV2_CORE__documentation = LV2_CORE_PREFIX + "documentation"; ///< http://lv2plug.in/ns/lv2core#documentation
|
||||
public static final String LV2_CORE__enabled = LV2_CORE_PREFIX + "enabled"; ///< http://lv2plug.in/ns/lv2core#enabled
|
||||
public static final String LV2_CORE__enumeration = LV2_CORE_PREFIX + "enumeration"; ///< http://lv2plug.in/ns/lv2core#enumeration
|
||||
public static final String LV2_CORE__extensionData = LV2_CORE_PREFIX + "extensionData"; ///< http://lv2plug.in/ns/lv2core#extensionData
|
||||
public static final String LV2_CORE__freeWheeling = LV2_CORE_PREFIX + "freeWheeling"; ///< http://lv2plug.in/ns/lv2core#freeWheeling
|
||||
public static final String LV2_CORE__hardRTCapable = LV2_CORE_PREFIX + "hardRTCapable"; ///< http://lv2plug.in/ns/lv2core#hardRTCapable
|
||||
public static final String LV2_CORE__inPlaceBroken = LV2_CORE_PREFIX + "inPlaceBroken"; ///< http://lv2plug.in/ns/lv2core#inPlaceBroken
|
||||
public static final String LV2_CORE__index = LV2_CORE_PREFIX + "index"; ///< http://lv2plug.in/ns/lv2core#index
|
||||
public static final String LV2_CORE__integer = LV2_CORE_PREFIX + "integer"; ///< http://lv2plug.in/ns/lv2core#integer
|
||||
public static final String LV2_CORE__isLive = LV2_CORE_PREFIX + "isLive"; ///< http://lv2plug.in/ns/lv2core#isLive
|
||||
public static final String LV2_CORE__latency = LV2_CORE_PREFIX + "latency"; ///< http://lv2plug.in/ns/lv2core#latency
|
||||
public static final String LV2_CORE__maximum = LV2_CORE_PREFIX + "maximum"; ///< http://lv2plug.in/ns/lv2core#maximum
|
||||
public static final String LV2_CORE__microVersion = LV2_CORE_PREFIX + "microVersion"; ///< http://lv2plug.in/ns/lv2core#microVersion
|
||||
public static final String LV2_CORE__minimum = LV2_CORE_PREFIX + "minimum"; ///< http://lv2plug.in/ns/lv2core#minimum
|
||||
public static final String LV2_CORE__minorVersion = LV2_CORE_PREFIX + "minorVersion"; ///< http://lv2plug.in/ns/lv2core#minorVersion
|
||||
public static final String LV2_CORE__name = LV2_CORE_PREFIX + "name"; ///< http://lv2plug.in/ns/lv2core#name
|
||||
public static final String LV2_CORE__optionalFeature = LV2_CORE_PREFIX + "optionalFeature"; ///< http://lv2plug.in/ns/lv2core#optionalFeature
|
||||
public static final String LV2_CORE__port = LV2_CORE_PREFIX + "port"; ///< http://lv2plug.in/ns/lv2core#port
|
||||
public static final String LV2_CORE__portProperty = LV2_CORE_PREFIX + "portProperty"; ///< http://lv2plug.in/ns/lv2core#portProperty
|
||||
public static final String LV2_CORE__project = LV2_CORE_PREFIX + "project"; ///< http://lv2plug.in/ns/lv2core#project
|
||||
public static final String LV2_CORE__prototype = LV2_CORE_PREFIX + "prototype"; ///< http://lv2plug.in/ns/lv2core#prototype
|
||||
public static final String LV2_CORE__reportsLatency = LV2_CORE_PREFIX + "reportsLatency"; ///< http://lv2plug.in/ns/lv2core#reportsLatency
|
||||
public static final String LV2_CORE__requiredFeature = LV2_CORE_PREFIX + "requiredFeature"; ///< http://lv2plug.in/ns/lv2core#requiredFeature
|
||||
public static final String LV2_CORE__sampleRate = LV2_CORE_PREFIX + "sampleRate"; ///< http://lv2plug.in/ns/lv2core#sampleRate
|
||||
public static final String LV2_CORE__scalePoint = LV2_CORE_PREFIX + "scalePoint"; ///< http://lv2plug.in/ns/lv2core#scalePoint
|
||||
public static final String LV2_CORE__symbol = LV2_CORE_PREFIX + "symbol"; ///< http://lv2plug.in/ns/lv2core#symbol
|
||||
public static final String LV2_CORE__toggled = LV2_CORE_PREFIX + "toggled"; ///< http://lv2plug.in/ns/lv2core#toggled
|
||||
|
||||
public static final String LV2_PRESETS_PREFIX = "http://lv2plug.in/ns/ext/presets#"; ///< http://lv2plug.in/ns/ext/presets#
|
||||
|
||||
public static final String LV2_PRESETS__Bank = LV2_PRESETS_PREFIX + "Bank"; ///< http://lv2plug.in/ns/ext/presets#Bank
|
||||
public static final String LV2_PRESETS__Preset = LV2_PRESETS_PREFIX + "Preset"; ///< http://lv2plug.in/ns/ext/presets#Preset
|
||||
public static final String LV2_PRESETS__bank = LV2_PRESETS_PREFIX + "bank"; ///< http://lv2plug.in/ns/ext/presets#bank
|
||||
public static final String LV2_PRESETS__preset = LV2_PRESETS_PREFIX + "preset"; ///< http://lv2plug.in/ns/ext/presets#preset
|
||||
public static final String LV2_PRESETS__value = LV2_PRESETS_PREFIX + "value"; ///< http://lv2plug.in/ns/ext/presets#value
|
||||
|
||||
public static final String LV2_EVENT_PREFIX = "http://lv2plug.in/ns/ext/event#" ; ///< http://lv2plug.in/ns/ext/event#
|
||||
|
||||
public static final String LV2_EVENT__Event = LV2_EVENT_PREFIX + "Event"; ///< http://lv2plug.in/ns/ext/event#Event
|
||||
public static final String LV2_EVENT__EventPort = LV2_EVENT_PREFIX + "EventPort"; ///< http://lv2plug.in/ns/ext/event#EventPort
|
||||
public static final String LV2_EVENT__FrameStamp = LV2_EVENT_PREFIX + "FrameStamp"; ///< http://lv2plug.in/ns/ext/event#FrameStamp
|
||||
public static final String LV2_EVENT__TimeStamp = LV2_EVENT_PREFIX + "TimeStamp"; ///< http://lv2plug.in/ns/ext/event#TimeStamp
|
||||
public static final String LV2_EVENT__generatesTimeStamp = LV2_EVENT_PREFIX + "generatesTimeStamp"; ///< http://lv2plug.in/ns/ext/event#generatesTimeStamp
|
||||
public static final String LV2_EVENT__generic = LV2_EVENT_PREFIX + "generic"; ///< http://lv2plug.in/ns/ext/event#generic
|
||||
public static final String LV2_EVENT__inheritsEvent = LV2_EVENT_PREFIX + "inheritsEvent"; ///< http://lv2plug.in/ns/ext/event#inheritsEvent
|
||||
public static final String LV2_EVENT__inheritsTimeStamp = LV2_EVENT_PREFIX + "inheritsTimeStamp"; ///< http://lv2plug.in/ns/ext/event#inheritsTimeStamp
|
||||
public static final String LV2_EVENT__supportsEvent = LV2_EVENT_PREFIX + "supportsEvent"; ///< http://lv2plug.in/ns/ext/event#supportsEvent
|
||||
public static final String LV2_EVENT__supportsTimeStamp = LV2_EVENT_PREFIX + "supportsTimeStamp"; ///< http://lv2plug.in/ns/ext/event#supportsTimeStamp
|
||||
|
||||
public static final String LV2_PORT_GROUPS_PREFIX = "http://lv2plug.in/ns/ext/port-groups#"; ///< http://lv2plug.in/ns/ext/port-groups#
|
||||
|
||||
public static final String LV2_PORT_GROUPS__DiscreteGroup = LV2_PORT_GROUPS_PREFIX + "DiscreteGroup"; ///< http://lv2plug.in/ns/ext/port-groups#DiscreteGroup
|
||||
public static final String LV2_PORT_GROUPS__Element = LV2_PORT_GROUPS_PREFIX + "Element"; ///< http://lv2plug.in/ns/ext/port-groups#Element
|
||||
public static final String LV2_PORT_GROUPS__FivePointOneGroup = LV2_PORT_GROUPS_PREFIX + "FivePointOneGroup"; ///< http://lv2plug.in/ns/ext/port-groups#FivePointOneGroup
|
||||
public static final String LV2_PORT_GROUPS__FivePointZeroGroup = LV2_PORT_GROUPS_PREFIX + "FivePointZeroGroup"; ///< http://lv2plug.in/ns/ext/port-groups#FivePointZeroGroup
|
||||
public static final String LV2_PORT_GROUPS__FourPointZeroGroup = LV2_PORT_GROUPS_PREFIX + "FourPointZeroGroup"; ///< http://lv2plug.in/ns/ext/port-groups#FourPointZeroGroup
|
||||
public static final String LV2_PORT_GROUPS__Group = LV2_PORT_GROUPS_PREFIX + "Group"; ///< http://lv2plug.in/ns/ext/port-groups#Group
|
||||
public static final String LV2_PORT_GROUPS__InputGroup = LV2_PORT_GROUPS_PREFIX + "InputGroup"; ///< http://lv2plug.in/ns/ext/port-groups#InputGroup
|
||||
public static final String LV2_PORT_GROUPS__MidSideGroup = LV2_PORT_GROUPS_PREFIX + "MidSideGroup"; ///< http://lv2plug.in/ns/ext/port-groups#MidSideGroup
|
||||
public static final String LV2_PORT_GROUPS__MonoGroup = LV2_PORT_GROUPS_PREFIX + "MonoGroup"; ///< http://lv2plug.in/ns/ext/port-groups#MonoGroup
|
||||
public static final String LV2_PORT_GROUPS__OutputGroup = LV2_PORT_GROUPS_PREFIX + "OutputGroup"; ///< http://lv2plug.in/ns/ext/port-groups#OutputGroup
|
||||
public static final String LV2_PORT_GROUPS__SevenPointOneGroup = LV2_PORT_GROUPS_PREFIX + "SevenPointOneGroup"; ///< http://lv2plug.in/ns/ext/port-groups#SevenPointOneGroup
|
||||
public static final String LV2_PORT_GROUPS__SevenPointOneWideGroup = LV2_PORT_GROUPS_PREFIX + "SevenPointOneWideGroup"; ///< http://lv2plug.in/ns/ext/port-groups#SevenPointOneWideGroup
|
||||
public static final String LV2_PORT_GROUPS__SixPointOneGroup = LV2_PORT_GROUPS_PREFIX + "SixPointOneGroup"; ///< http://lv2plug.in/ns/ext/port-groups#SixPointOneGroup
|
||||
public static final String LV2_PORT_GROUPS__StereoGroup = LV2_PORT_GROUPS_PREFIX + "StereoGroup"; ///< http://lv2plug.in/ns/ext/port-groups#StereoGroup
|
||||
public static final String LV2_PORT_GROUPS__ThreePointZeroGroup = LV2_PORT_GROUPS_PREFIX + "ThreePointZeroGroup"; ///< http://lv2plug.in/ns/ext/port-groups#ThreePointZeroGroup
|
||||
public static final String LV2_PORT_GROUPS__center = LV2_PORT_GROUPS_PREFIX + "center"; ///< http://lv2plug.in/ns/ext/port-groups#center
|
||||
public static final String LV2_PORT_GROUPS__centerLeft = LV2_PORT_GROUPS_PREFIX + "centerLeft"; ///< http://lv2plug.in/ns/ext/port-groups#centerLeft
|
||||
public static final String LV2_PORT_GROUPS__centerRight = LV2_PORT_GROUPS_PREFIX + "centerRight"; ///< http://lv2plug.in/ns/ext/port-groups#centerRight
|
||||
public static final String LV2_PORT_GROUPS__element = LV2_PORT_GROUPS_PREFIX + "element"; ///< http://lv2plug.in/ns/ext/port-groups#element
|
||||
public static final String LV2_PORT_GROUPS__group = LV2_PORT_GROUPS_PREFIX + "group"; ///< http://lv2plug.in/ns/ext/port-groups#group
|
||||
public static final String LV2_PORT_GROUPS__left = LV2_PORT_GROUPS_PREFIX + "left"; ///< http://lv2plug.in/ns/ext/port-groups#left
|
||||
public static final String LV2_PORT_GROUPS__lowFrequencyEffects = LV2_PORT_GROUPS_PREFIX + "lowFrequencyEffects"; ///< http://lv2plug.in/ns/ext/port-groups#lowFrequencyEffects
|
||||
public static final String LV2_PORT_GROUPS__mainInput = LV2_PORT_GROUPS_PREFIX + "mainInput"; ///< http://lv2plug.in/ns/ext/port-groups#mainInput
|
||||
public static final String LV2_PORT_GROUPS__mainOutput = LV2_PORT_GROUPS_PREFIX + "mainOutput"; ///< http://lv2plug.in/ns/ext/port-groups#mainOutput
|
||||
public static final String LV2_PORT_GROUPS__rearCenter = LV2_PORT_GROUPS_PREFIX + "rearCenter"; ///< http://lv2plug.in/ns/ext/port-groups#rearCenter
|
||||
public static final String LV2_PORT_GROUPS__rearLeft = LV2_PORT_GROUPS_PREFIX + "rearLeft"; ///< http://lv2plug.in/ns/ext/port-groups#rearLeft
|
||||
public static final String LV2_PORT_GROUPS__rearRight = LV2_PORT_GROUPS_PREFIX + "rearRight"; ///< http://lv2plug.in/ns/ext/port-groups#rearRight
|
||||
public static final String LV2_PORT_GROUPS__right = LV2_PORT_GROUPS_PREFIX + "right"; ///< http://lv2plug.in/ns/ext/port-groups#right
|
||||
public static final String LV2_PORT_GROUPS__side = LV2_PORT_GROUPS_PREFIX + "side"; ///< http://lv2plug.in/ns/ext/port-groups#side
|
||||
public static final String LV2_PORT_GROUPS__sideChainOf = LV2_PORT_GROUPS_PREFIX + "sideChainOf"; ///< http://lv2plug.in/ns/ext/port-groups#sideChainOf
|
||||
public static final String LV2_PORT_GROUPS__sideLeft = LV2_PORT_GROUPS_PREFIX + "sideLeft"; ///< http://lv2plug.in/ns/ext/port-groups#sideLeft
|
||||
public static final String LV2_PORT_GROUPS__sideRight = LV2_PORT_GROUPS_PREFIX + "sideRight"; ///< http://lv2plug.in/ns/ext/port-groups#sideRight
|
||||
public static final String LV2_PORT_GROUPS__source = LV2_PORT_GROUPS_PREFIX + "source"; ///< http://lv2plug.in/ns/ext/port-groups#source
|
||||
public static final String LV2_PORT_GROUPS__subGroupOf = LV2_PORT_GROUPS_PREFIX + "subGroupOf"; ///< http://lv2plug.in/ns/ext/port-groups#subGroupOf
|
||||
|
||||
|
||||
/**
|
||||
* Type of the lv2_descriptor() function in a library (old discovery API).<br>
|
||||
* <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h:405</i>
|
||||
*/
|
||||
/**
|
||||
* Type of the lv2_descriptor() function in a library (old discovery API).<br>
|
||||
* <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h:405</i>
|
||||
*/
|
||||
public static abstract class LV2_Descriptor_Function extends Callback<LV2_Descriptor_Function > {
|
||||
abstract public Pointer<LV2_Descriptor > apply(int index);
|
||||
};
|
||||
/**
|
||||
* Type of the lv2_lib_descriptor() function in an LV2 library.<br>
|
||||
* <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h:471</i>
|
||||
*/
|
||||
/**
|
||||
* Type of the lv2_lib_descriptor() function in an LV2 library.<br>
|
||||
* <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h:471</i>
|
||||
*/
|
||||
public static abstract class LV2_Lib_Descriptor_Function extends Callback<LV2_Lib_Descriptor_Function > {
|
||||
abstract public Pointer<LV2_Lib_Descriptor > apply(Pointer<Byte > bundle_path, Pointer<Pointer<LV2_Feature > > features);
|
||||
};
|
||||
/**
|
||||
* Prototype for plugin accessor function.<br>
|
||||
* Plugins are discovered by hosts using RDF data (not by loading libraries).<br>
|
||||
* See http://lv2plug.in for details on the discovery process, though most<br>
|
||||
* hosts should use an existing library to implement this functionality.<br>
|
||||
* This is the simple plugin discovery API, suitable for most statically<br>
|
||||
* defined plugins. Advanced plugins that need access to their bundle during<br>
|
||||
* discovery can use lv2_lib_descriptor() instead. Plugin libraries MUST<br>
|
||||
* include a function called "lv2_descriptor" or "lv2_lib_descriptor" with<br>
|
||||
* C-style linkage, but SHOULD provide "lv2_descriptor" wherever possible.<br>
|
||||
* When it is time to load a plugin (designated by its URI), the host loads the<br>
|
||||
* plugin's library, gets the lv2_descriptor() function from it, and uses this<br>
|
||||
* function to find the LV2_Descriptor for the desired plugin. Plugins are<br>
|
||||
* accessed by index using values from 0 upwards. This function MUST return<br>
|
||||
* NULL for out of range indices, so the host can enumerate plugins by<br>
|
||||
* increasing `index` until NULL is returned.<br>
|
||||
* Note that `index` has no meaning, hosts MUST NOT depend on it remaining<br>
|
||||
* consistent between loads of the plugin library.<br>
|
||||
* Original signature : <code>LV2_Descriptor* lv2_descriptor(uint32_t)</code><br>
|
||||
* <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h:398</i>
|
||||
*/
|
||||
public static Pointer<LV2_Descriptor > lv2_descriptor(int index) {
|
||||
return Pointer.pointerToAddress(lv2_descriptor$2(index), LV2_Descriptor.class, noReleaser);
|
||||
}
|
||||
@Ptr
|
||||
@Name("lv2_descriptor")
|
||||
protected native static long lv2_descriptor$2(int index);
|
||||
/**
|
||||
* Prototype for library accessor function.<br>
|
||||
* This is the more advanced discovery API, which allows plugin libraries to<br>
|
||||
* access their bundles during discovery, which makes it possible for plugins to<br>
|
||||
* be dynamically defined by files in their bundle. This API also has an<br>
|
||||
* explicit cleanup function, removing any need for non-portable shared library<br>
|
||||
* destructors. Simple plugins that do not require these features may use<br>
|
||||
* lv2_descriptor() instead.<br>
|
||||
* This is the entry point for a plugin library. Hosts load this symbol from<br>
|
||||
* the library and call this function to obtain a library descriptor which can<br>
|
||||
* be used to access all the contained plugins. The returned object must not<br>
|
||||
* be destroyed (using LV2_Lib_Descriptor::cleanup()) until all plugins loaded<br>
|
||||
* from that library have been destroyed.<br>
|
||||
* Original signature : <code>LV2_Lib_Descriptor* lv2_lib_descriptor(const char*, const const LV2_Feature**)</code><br>
|
||||
* <i>native declaration : /usr/lib/lv2/core.lv2/lv2.h:464</i>
|
||||
*/
|
||||
public static Pointer<LV2_Lib_Descriptor > lv2_lib_descriptor(Pointer<Byte > bundle_path, Pointer<Pointer<LV2_Feature > > features) {
|
||||
return Pointer.pointerToAddress(lv2_lib_descriptor(Pointer.getPeer(bundle_path), Pointer.getPeer(features)), LV2_Lib_Descriptor.class,noReleaser);
|
||||
}
|
||||
@Ptr
|
||||
protected native static long lv2_lib_descriptor(@Ptr long bundle_path, @Ptr long features);
|
||||
}
|
||||
59
src/main/java/com/bernard/sboard/bridj/LilvInstanceImpl.java
Normal file
59
src/main/java/com/bernard/sboard/bridj/LilvInstanceImpl.java
Normal file
@ -0,0 +1,59 @@
|
||||
package com.bernard.sboard.bridj;
|
||||
import org.bridj.Pointer;
|
||||
import org.bridj.StructObject;
|
||||
import org.bridj.ann.Field;
|
||||
import org.bridj.ann.Library;
|
||||
/**
|
||||
* Instance of a plugin.<br>
|
||||
* This is exposed in the ABI to allow inlining of performance critical<br>
|
||||
* functions like lilv_instance_run() (simple wrappers of functions in lv2.h).<br>
|
||||
* This is for performance reasons, user code should not use this definition<br>
|
||||
* in any way (which is why it is not machine documented).<br>
|
||||
* Truly private implementation details are hidden via `pimpl`.<br>
|
||||
* <i>native declaration : /opt/kxstudio/include/lilv-0/lilv/lilv.h:1624</i><br>
|
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
|
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
|
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> or <a href="http://bridj.googlecode.com/">BridJ</a> .
|
||||
*/
|
||||
@Library("lilv-0")
|
||||
public class LilvInstanceImpl extends StructObject {
|
||||
public LilvInstanceImpl() {
|
||||
super();
|
||||
}
|
||||
/// C type : LV2_Handle
|
||||
@Field(0)
|
||||
public Pointer<LV2_Descriptor> lv2_descriptor() {
|
||||
return this.io.getPointerField(this, 0);
|
||||
}
|
||||
/// C type : LV2_Handle
|
||||
@Field(0)
|
||||
public LilvInstanceImpl lv2_descriptor(Pointer<? > lv2_descriptor) {
|
||||
this.io.setPointerField(this, 0, lv2_descriptor);
|
||||
return this;
|
||||
}
|
||||
/// C type : LV2_Handle
|
||||
@Field(1)
|
||||
public Pointer<? > lv2_handle() {
|
||||
return this.io.getPointerField(this, 1);
|
||||
}
|
||||
/// C type : LV2_Handle
|
||||
@Field(1)
|
||||
public LilvInstanceImpl lv2_handle(Pointer<? > lv2_handle) {
|
||||
this.io.setPointerField(this, 1, lv2_handle);
|
||||
return this;
|
||||
}
|
||||
/// C type : void*
|
||||
@Field(2)
|
||||
public Pointer<? > pimpl() {
|
||||
return this.io.getPointerField(this, 2);
|
||||
}
|
||||
/// C type : void*
|
||||
@Field(2)
|
||||
public LilvInstanceImpl pimpl(Pointer<? > pimpl) {
|
||||
this.io.setPointerField(this, 2, pimpl);
|
||||
return this;
|
||||
}
|
||||
public LilvInstanceImpl(Pointer<?> pointer) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.bernard.sboard.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EffectsBoxConfig {
|
||||
|
||||
public Map<String,PluginLayoutConfig> layouts = new HashMap<>();
|
||||
|
||||
public String inputPointName = "input";
|
||||
public String outputPointName = "output";
|
||||
|
||||
public String defaultLayout = "default";
|
||||
|
||||
public int bufferDefaultSampleCount = 128;
|
||||
}
|
||||
14
src/main/java/com/bernard/sboard/config/OscConfig.java
Normal file
14
src/main/java/com/bernard/sboard/config/OscConfig.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.bernard.sboard.config;
|
||||
|
||||
import com.illposed.osc.transport.NetworkProtocol;
|
||||
|
||||
public class OscConfig {
|
||||
|
||||
// Every 100ms
|
||||
public long frequentUpdatePeriod = 100;
|
||||
|
||||
public NetworkProtocol networkProtocol = NetworkProtocol.UDP;
|
||||
|
||||
public int inputport = 8775;
|
||||
public int outputport = 8776;
|
||||
}
|
||||
15
src/main/java/com/bernard/sboard/config/PluginConfig.java
Normal file
15
src/main/java/com/bernard/sboard/config/PluginConfig.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.bernard.sboard.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PluginConfig {
|
||||
|
||||
public String name;
|
||||
public String displayName;
|
||||
public String uri;
|
||||
|
||||
// map port symbol -> point name
|
||||
public Map<String,String> inputConnections;
|
||||
public Map<String,String> outputConnections;
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.bernard.sboard.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PluginLayoutConfig {
|
||||
|
||||
public String name;
|
||||
public String displayName;
|
||||
public List<PluginConfig> plugins;
|
||||
|
||||
public static final boolean validateLayout() {
|
||||
//TODO: Verifier qu'il n'y a pas de boucle
|
||||
//TODO: Verifier que l'ordre des connections ne contredit pas l'ordre des plugins
|
||||
//TODO: Verifier qu'à un point est toujours attaché au plus un pluginOutput
|
||||
return false;
|
||||
}
|
||||
}
|
||||
25
src/main/java/com/bernard/sboard/config/SBoardConfig.java
Normal file
25
src/main/java/com/bernard/sboard/config/SBoardConfig.java
Normal file
@ -0,0 +1,25 @@
|
||||
package com.bernard.sboard.config;
|
||||
|
||||
public class SBoardConfig {
|
||||
|
||||
public String jackControllerName = "SBoard";
|
||||
|
||||
public String micPortName = "mic";
|
||||
public String computerInPortName = "computer";
|
||||
|
||||
public String effectsMicPortName = "effectsMic";
|
||||
public String soundsPortName = "sounds";
|
||||
public String repeatedMicName = "repeatedMic";
|
||||
|
||||
public String fakeMicPortName = "fakeMic";
|
||||
public String earLoopbackPortName = "earLoopback";
|
||||
|
||||
public String jackAudioType = "32 bit float mono audio";
|
||||
|
||||
//TODO: Verifier que la fréquence audio de la config correspond à celle de jack.
|
||||
public float soundFrequency = 48_000f;
|
||||
|
||||
public EffectsBoxConfig effects = new EffectsBoxConfig();
|
||||
|
||||
public OscConfig osc = new OscConfig();
|
||||
}
|
||||
217
src/main/java/com/bernard/sboard/effects/EffectsBox.java
Normal file
217
src/main/java/com/bernard/sboard/effects/EffectsBox.java
Normal file
@ -0,0 +1,217 @@
|
||||
package com.bernard.sboard.effects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bridj.BridJ;
|
||||
import org.bridj.Pointer;
|
||||
|
||||
import com.bernard.sboard.SBoard;
|
||||
import com.bernard.sboard.bridj.LibLilv;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvPlugin;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvWorld;
|
||||
import com.bernard.sboard.config.EffectsBoxConfig;
|
||||
import com.bernard.sboard.config.PluginConfig;
|
||||
import com.bernard.sboard.config.PluginLayoutConfig;
|
||||
import com.bernard.sboard.lv2.LV2Plugin;
|
||||
import com.bernard.sboard.lv2.LV2Port;
|
||||
import com.bernard.sboard.lv2.LV2Preset;
|
||||
import com.bernard.sboard.lv2.LV2Ui;
|
||||
import com.bernard.sboard.osc.OscUtils;
|
||||
import com.bernard.sboard.osc.SOscMessage;
|
||||
|
||||
public class EffectsBox {
|
||||
|
||||
SBoard sboard;
|
||||
EffectsBoxConfig config;
|
||||
|
||||
Logger log = LogManager.getLogger(EffectsBox.class);
|
||||
|
||||
Pointer<LilvWorld> world;
|
||||
|
||||
List<LV2Plugin> plugins;
|
||||
Pointer<LibLilv.LilvPlugins> pluginsObject;
|
||||
|
||||
Map<String, LoadedPlugin> loadedPlugins;
|
||||
PluginLayoutConfig plc;
|
||||
|
||||
Pointer<Float> inBlankBuffer=null, outRandBuffer=null;
|
||||
|
||||
int pointSize = 0;
|
||||
Map<String, Pointer<Float>> points;
|
||||
|
||||
public EffectsBox(SBoard sboard, EffectsBoxConfig config) {
|
||||
this.config = config;
|
||||
this.sboard = sboard;
|
||||
this.loadedPlugins = new HashMap<>();
|
||||
this.points = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
public void setup() {
|
||||
this.world = LibLilv.lilv_world_new();
|
||||
|
||||
LibLilv.lilv_world_load_all(world);
|
||||
|
||||
this.plugins = new ArrayList<>();
|
||||
pluginsObject = LibLilv.lilv_world_get_all_plugins(world);
|
||||
for (Pointer<LibLilv.LilvIter> i = LibLilv.lilv_plugins_begin(pluginsObject);
|
||||
!LibLilv.lilv_plugins_is_end(pluginsObject, i);
|
||||
i = LibLilv.lilv_plugins_next(pluginsObject, i)) {
|
||||
Pointer<LilvPlugin> plugin = LibLilv.lilv_plugins_get(pluginsObject, i);
|
||||
this.plugins.add(new LV2Plugin(world,plugin));
|
||||
}
|
||||
|
||||
inBlankBuffer = Pointer.allocateArray(Float.class, config.bufferDefaultSampleCount);
|
||||
outRandBuffer = Pointer.allocateArray(Float.class, config.bufferDefaultSampleCount);
|
||||
|
||||
// Now loading default layout
|
||||
PluginLayoutConfig plc = config.layouts.get(config.defaultLayout);
|
||||
if(plc==null)
|
||||
log.error("Could not load find default plugin layout «"+config.defaultLayout+"»");
|
||||
else
|
||||
setupPlugins(plc);
|
||||
}
|
||||
|
||||
public void setupPlugins(PluginLayoutConfig plc) {
|
||||
for(PluginConfig pc : plc.plugins) {
|
||||
this.loadedPlugins.put(pc.name, new LoadedPlugin(this, sboard.config.soundFrequency, pc));
|
||||
}
|
||||
setupConnections(plc, config.bufferDefaultSampleCount);
|
||||
}
|
||||
|
||||
public void setupConnections(PluginLayoutConfig plc, int sampleCount) {
|
||||
if(inBlankBuffer==null)inBlankBuffer = Pointer.allocateArray(Float.class, sampleCount);
|
||||
if(outRandBuffer==null)outRandBuffer = Pointer.allocateArray(Float.class, sampleCount);
|
||||
for(PluginConfig pc : plc.plugins) {
|
||||
for(Entry<String,String> e : pc.inputConnections.entrySet()) {
|
||||
log.debug("Connecting "+e.getKey()+" to "+e.getValue());
|
||||
if(!points.containsKey(e.getValue())) {
|
||||
Pointer<Float> newpoint = Pointer.allocateArray(Float.class,sampleCount);
|
||||
if(newpoint==null)throw new RuntimeException("Coud not instanciate a point");
|
||||
points.put(e.getValue(), newpoint);
|
||||
}
|
||||
Pointer<Float> point = points.get(e.getValue());
|
||||
if(!loadedPlugins.get(pc.name).connectInputPort(e.getKey(), point))
|
||||
log.error("The requested port is not an input port");
|
||||
}
|
||||
for(Entry<String,String> e : pc.outputConnections.entrySet()) {
|
||||
log.debug("Connecting "+e.getKey()+" to "+e.getValue());
|
||||
if(!points.containsKey(e.getValue())) {
|
||||
Pointer<Float> newpoint = Pointer.allocateArray(Float.class,sampleCount);
|
||||
if(newpoint==null)throw new RuntimeException("Coud not instanciate a point");
|
||||
points.put(e.getValue(), newpoint);
|
||||
}
|
||||
Pointer<Float> point = points.get(e.getValue());
|
||||
if(!loadedPlugins.get(pc.name).connectOutputPort(e.getKey(), point))
|
||||
log.error("The requested port is not an output port");
|
||||
}
|
||||
|
||||
}
|
||||
pointSize = sampleCount;
|
||||
this.plc = plc;
|
||||
}
|
||||
|
||||
public void applyEffects(int nframes, Pointer<Float> inBuffer, Pointer<Float> outBuffer) {
|
||||
if(plc==null) {
|
||||
inBuffer.moveBytesTo(outBuffer, nframes*BridJ.sizeOf(Float.class));
|
||||
return;
|
||||
}
|
||||
if(pointSize < nframes) {
|
||||
inBlankBuffer = null;
|
||||
outRandBuffer = null;
|
||||
// Reallocation de tous les points
|
||||
for(String pname : points.keySet())
|
||||
points.get(pname).release();
|
||||
points.clear();
|
||||
setupConnections(plc, nframes);
|
||||
}
|
||||
// On copie tous l'entrée dans le inbuffer
|
||||
if(points.containsKey(config.inputPointName))
|
||||
inBuffer.moveBytesTo(points.get(config.inputPointName), nframes*BridJ.sizeOf(Float.class));
|
||||
// On lance maintenant tous les plugins
|
||||
for(PluginConfig p : plc.plugins)
|
||||
loadedPlugins.get(p.name).run(nframes);
|
||||
// Enfin, on copie dans le outbuffer
|
||||
if(points.containsKey(config.outputPointName))
|
||||
points.get(config.outputPointName).moveBytesTo(outBuffer, nframes*BridJ.sizeOf(Float.class));
|
||||
}
|
||||
|
||||
public void receiveOscMessage(SOscMessage message) {
|
||||
if(OscUtils.addrMatch(message.getContainer(1), "plugins")) {
|
||||
for(String s : OscUtils.allAddrMatch(message.getContainer(2), loadedPlugins.keySet()))
|
||||
loadedPlugins.get(s).receiveOscMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
||||
LibLilv.lilv_world_free(world);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void lv2info(LV2Plugin e) {
|
||||
|
||||
System.out.println("Présentation du plugin "+e.getUri());
|
||||
System.out.println("| Nom : "+e.getName());
|
||||
System.out.println("| Classe : "+e.getPluginClass());
|
||||
System.out.println("| Author : "+e.getAuthorName());
|
||||
System.out.println("| Author email : "+e.getAuthorEmail());
|
||||
System.out.println("| Author website : "+e.getAuthorHomepage());
|
||||
System.out.println("| Has latency : "+e.hasLatency());
|
||||
System.out.println("| Latency port : "+e.getLatencyPort());
|
||||
System.out.println("| Bundle uri : "+e.getBundleUri());
|
||||
System.out.println("| Binary uri : "+e.getBinaryUri());
|
||||
for(LV2Ui ui : e.getPluginUIs()) {
|
||||
System.out.println("| Ui : "+ui.getUri());
|
||||
for(String clazz : ui.getClassesUris())
|
||||
System.out.println("| | Class : "+clazz);
|
||||
System.out.println("| | Binary : "+ui.getBinary());
|
||||
System.out.println("| | Bundle : "+ui.getBundleUri());
|
||||
}
|
||||
System.out.println("| Data URIs :");
|
||||
for(String dataUri : e.getDataUris())
|
||||
System.out.println("| | "+dataUri);
|
||||
System.out.println("| Required Features :");
|
||||
for(String requiredFeature : e.getRequiredFeatures())
|
||||
System.out.println("| | "+requiredFeature);
|
||||
System.out.println("| Extension Features :");
|
||||
for(String extensionData : e.getExtensionData())
|
||||
System.out.println("| | "+extensionData);
|
||||
System.out.println("| Presets :");
|
||||
for(LV2Preset preset : e.getPresets())
|
||||
System.out.println("| | "+preset.getFirstTitle() + " (" + preset.getUri() + ")");
|
||||
System.out.println("| Ports :");
|
||||
for(LV2Port port : e.getPorts()) {
|
||||
System.out.println("| | Port #"+port.getIndex());
|
||||
System.out.println("| | | Minimum : "+port.getMinVal());
|
||||
System.out.println("| | | Maximum : "+port.getMaxVal());
|
||||
System.out.println("| | | Défaut : "+port.getDefaultVal());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Pointer<Float> getInBlankBuffer() {
|
||||
return inBlankBuffer;
|
||||
}
|
||||
public Pointer<Float> getOutRandBuffer() {
|
||||
return outRandBuffer;
|
||||
}
|
||||
|
||||
public Pointer<LilvWorld> getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public Pointer<LibLilv.LilvPlugins> getPluginsObject() {
|
||||
return pluginsObject;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
225
src/main/java/com/bernard/sboard/effects/LoadedPlugin.java
Normal file
225
src/main/java/com/bernard/sboard/effects/LoadedPlugin.java
Normal file
@ -0,0 +1,225 @@
|
||||
package com.bernard.sboard.effects;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bridj.BridJ;
|
||||
import org.bridj.Pointer;
|
||||
|
||||
import com.bernard.sboard.bridj.LibLilv;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvNode;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvPort;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvWorld;
|
||||
import com.bernard.sboard.bridj.LibLv2;
|
||||
import com.bernard.sboard.bridj.LilvInstanceImpl;
|
||||
import com.bernard.sboard.config.PluginConfig;
|
||||
import com.bernard.sboard.osc.OscRemoteController;
|
||||
import com.bernard.sboard.osc.OscUtils;
|
||||
import com.bernard.sboard.osc.SOscMessage;
|
||||
import com.illposed.osc.OSCMessage;
|
||||
|
||||
public class LoadedPlugin {
|
||||
|
||||
String uri;
|
||||
|
||||
String name;
|
||||
|
||||
Logger log;
|
||||
|
||||
Pointer<LilvWorld> world;
|
||||
|
||||
Pointer<LibLilv.LilvPlugin> plugin;
|
||||
|
||||
Pointer<LilvInstanceImpl> instance;
|
||||
|
||||
public Pointer<Float> controls;
|
||||
|
||||
Map<String, Integer> controlPortsIndexes;
|
||||
Set<String> inputControlPorts;
|
||||
Set<String> outputControlPorts;
|
||||
|
||||
public static Pointer<LibLilv.LilvNode> lv2_ControlPort = null;
|
||||
public static Pointer<LibLilv.LilvNode> lv2_AudioPort = null;
|
||||
public static Pointer<LibLilv.LilvNode> lv2_InputPort = null;
|
||||
public static Pointer<LibLilv.LilvNode> lv2_OutputPort = null;
|
||||
|
||||
public LoadedPlugin(EffectsBox ebox, float frequency, PluginConfig pconfig) {
|
||||
this.log = ebox.log;
|
||||
if(lv2_ControlPort == null)
|
||||
lv2_ControlPort = LibLilv.lilv_new_uri(ebox.getWorld(), Pointer.pointerToCString(LibLv2.LV2_CORE__ControlPort));
|
||||
if(lv2_AudioPort == null)
|
||||
lv2_AudioPort = LibLilv.lilv_new_uri(ebox.getWorld(), Pointer.pointerToCString(LibLv2.LV2_CORE__AudioPort));
|
||||
if(lv2_InputPort == null)
|
||||
lv2_InputPort = LibLilv.lilv_new_uri(ebox.getWorld(), Pointer.pointerToCString(LibLv2.LV2_CORE__InputPort));
|
||||
if(lv2_OutputPort == null)
|
||||
lv2_OutputPort = LibLilv.lilv_new_uri(ebox.getWorld(), Pointer.pointerToCString(LibLv2.LV2_CORE__OutputPort));
|
||||
log.debug("Loaded URIs");
|
||||
this.world = ebox.getWorld();
|
||||
this.name = pconfig.name;
|
||||
|
||||
Pointer<LibLilv.LilvNode> plugin_uri = LibLilv.lilv_new_uri(ebox.getWorld(), Pointer.pointerToCString(pconfig.uri));
|
||||
|
||||
plugin = LibLilv.lilv_plugins_get_by_uri(ebox.getPluginsObject(), plugin_uri);
|
||||
log.debug("Trying to instanciated plugin");
|
||||
instance = LibLilv.lilv_plugin_instantiate(plugin, frequency, null);
|
||||
log.debug("Plugin instanciated");
|
||||
|
||||
int pcount = LibLilv.lilv_plugin_get_num_ports(plugin);
|
||||
controlPortsIndexes = new HashMap<>();
|
||||
inputControlPorts = new HashSet<>();
|
||||
outputControlPorts = new HashSet<>();
|
||||
controls = Pointer.allocateArray(Float.class, pcount);
|
||||
Pointer<Float> maxes = Pointer.allocateArray(Float.class, pcount);
|
||||
Pointer<Float> mins = Pointer.allocateArray(Float.class, pcount);
|
||||
|
||||
for (int i = 0; i < pcount; i++) {
|
||||
Pointer<LilvPort> port = LibLilv.lilv_plugin_get_port_by_index(plugin, i);
|
||||
String pname = LibLilv.lilv_node_as_string(LibLilv.lilv_port_get_symbol(plugin, port)).getCString();
|
||||
LibLilv.lilv_plugin_get_port_ranges_float(plugin, mins, maxes, controls);
|
||||
if (LibLilv.lilv_port_is_a(plugin, port, lv2_ControlPort)) {
|
||||
controlPortsIndexes.put(pname, i);
|
||||
if (Float.isNaN(controls.getFloatAtIndex(i))) {
|
||||
if (!Float.isNaN(mins.getFloatAtIndex(i)))
|
||||
controls.setFloatAtIndex(i, mins.getFloatAtIndex(i));
|
||||
else if (!Float.isNaN(maxes.getFloatAtIndex(i)))
|
||||
controls.setFloatAtIndex(i, maxes.getFloatAtIndex(i));
|
||||
else
|
||||
controls.setFloatAtIndex(i, 0.0f);
|
||||
}
|
||||
if(LibLilv.lilv_port_is_a(plugin, port, lv2_InputPort)) {
|
||||
inputControlPorts.add(pname);
|
||||
} else if(LibLilv.lilv_port_is_a(plugin, port, lv2_OutputPort)) {
|
||||
outputControlPorts.add(pname);
|
||||
} else {
|
||||
log.error("Control port is neither a input or an output port");
|
||||
}
|
||||
LibLilv.lilv_instance_connect_port(instance, i, Pointer.pointerToAddress(controls.getPeer() + i*BridJ.sizeOf(Float.class), Float.class, p -> {}));
|
||||
} else if (LibLilv.lilv_port_is_a(plugin, port, lv2_AudioPort)){
|
||||
if(LibLilv.lilv_port_is_a(plugin, port, lv2_InputPort)) {
|
||||
log.debug("Connecting input to blank buffer");
|
||||
LibLilv.lilv_instance_connect_port(instance, i, ebox.getInBlankBuffer());
|
||||
} else if(LibLilv.lilv_port_is_a(plugin, port, lv2_OutputPort)) {
|
||||
log.debug("Connecting output to rand buffer");
|
||||
LibLilv.lilv_instance_connect_port(instance, i, ebox.getOutRandBuffer());
|
||||
} else {
|
||||
log.error("Audio port is neither a input or an output port");
|
||||
}
|
||||
} else {
|
||||
log.error("The port is neither audio nor control");
|
||||
}
|
||||
}
|
||||
|
||||
LibLilv.lilv_instance_activate(instance);
|
||||
}
|
||||
|
||||
private boolean connectPortIf(String psymbol, Pointer<Float> point, Pointer<LilvNode> portClass) {
|
||||
Pointer<LilvPort> port = LibLilv.lilv_plugin_get_port_by_symbol(
|
||||
plugin,
|
||||
LibLilv.lilv_new_string(world, Pointer.pointerToCString(psymbol))
|
||||
);
|
||||
int index = LibLilv.lilv_port_get_index(plugin, port);
|
||||
|
||||
if(!LibLilv.lilv_port_is_a(plugin, port, lv2_AudioPort) || !LibLilv.lilv_port_is_a(plugin, port, portClass))
|
||||
return false;
|
||||
log.info("Size safe: "+point.getValidBytes());
|
||||
LibLilv.lilv_instance_connect_port(instance, index, point);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean connectInputPort(String psymbol, Pointer<Float> point) {
|
||||
return connectPortIf(psymbol, point, lv2_InputPort);
|
||||
}
|
||||
public boolean connectOutputPort(String psymbol, Pointer<Float> point) {
|
||||
return connectPortIf(psymbol, point, lv2_OutputPort);
|
||||
}
|
||||
|
||||
public void run(int sampleCount) {
|
||||
LibLilv.lilv_instance_run(instance, sampleCount);
|
||||
}
|
||||
|
||||
public Pointer<LilvInstanceImpl> getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
Map<String, Set<OscRemoteController>> portListeners;
|
||||
|
||||
public void receiveOscMessage(SOscMessage message) {
|
||||
if(OscUtils.addrMatch(message.getContainer(3), "ports")) {
|
||||
for(String p : OscUtils.allAddrMatch(message.getContainer(4), controlPortsIndexes.keySet())) {
|
||||
if(OscUtils.addrMatch(message.getContainer(5), "listen")) {
|
||||
// LISTEN [uid]
|
||||
if(outputControlPorts.contains(p)) {
|
||||
message.getServer().declareFrequentUpdate(getPortAddress(p)+"/value", () -> controls.getFloatAtIndex(controlPortsIndexes.get(p)), message.getServer().getSender((int) message.getArguments().get(0)));
|
||||
} else if (inputControlPorts.contains(p)){
|
||||
portListeners.putIfAbsent(p, new HashSet<>());
|
||||
portListeners.get(p).add(message.getServer().getSender((int) message.getArguments().get(0)));
|
||||
} else {
|
||||
//Error
|
||||
}
|
||||
}
|
||||
if(OscUtils.addrMatch(message.getContainer(5), "ignore")) {
|
||||
// IGNORE [uid]
|
||||
if(outputControlPorts.contains(p)) {
|
||||
message.getServer().removeRegularListen(getPortAddress(p)+"/value", message.getServer().getSender((int) message.getArguments().get(0)));
|
||||
} else if (inputControlPorts.contains(p)){
|
||||
if(portListeners.containsKey(p))
|
||||
portListeners.get(p).remove(message.getServer().getSender((int) message.getArguments().get(0)));
|
||||
} else {
|
||||
//Error
|
||||
}
|
||||
}
|
||||
if(OscUtils.addrMatch(message.getContainer(5), "set")) {
|
||||
// SET [newValue]
|
||||
log.debug("La settagation a été effectuée");
|
||||
Float value = (Float) message.getArguments().get(0);
|
||||
controls.setFloatAtIndex(controlPortsIndexes.get(p), value);
|
||||
}
|
||||
if(OscUtils.addrMatch(message.getContainer(5), "get")) {
|
||||
// GET [uid]
|
||||
OSCMessage oscm = new OSCMessage(getPortAddress(p)+"/value", List.of(controls.getFloatAtIndex(controlPortsIndexes.get(p))));
|
||||
message.getServer().getSender((int) message.getArguments().get(0)).send(oscm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getPortAddress(String portName) {
|
||||
return "/effectbox/plugins/"+name+"/ports/"+portName;
|
||||
}
|
||||
|
||||
public void notifyOfPortUpdate(String p) {
|
||||
if(portListeners.containsKey(p))
|
||||
for(OscRemoteController orc : portListeners.get(p)) {
|
||||
OSCMessage oscm = new OSCMessage(getPortAddress(p)+"/value",List.of(controls.getFloatAtIndex(controlPortsIndexes.get(p))));
|
||||
orc.send(oscm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
175
src/main/java/com/bernard/sboard/lv2/LV2Plugin.java
Normal file
175
src/main/java/com/bernard/sboard/lv2/LV2Plugin.java
Normal file
@ -0,0 +1,175 @@
|
||||
package com.bernard.sboard.lv2;
|
||||
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilvNodesToList;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilvUIsToList;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_node_as_string;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_node_as_uri;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_node_free;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_nodes_free;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_class_get_label;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_author_email;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_author_homepage;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_author_name;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_bundle_uri;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_class;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_data_uris;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_extension_data;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_latency_port_index;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_library_uri;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_name;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_num_ports;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_optional_features;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_port_ranges_float;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_related;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_required_features;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_get_uis;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_plugin_has_latency;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_uis_free;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bridj.Pointer;
|
||||
|
||||
import com.bernard.sboard.bridj.LibLilv;
|
||||
import com.bernard.sboard.bridj.LibLv2;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvNode;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvNodes;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvPlugin;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvPluginClass;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvUIs;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvWorld;
|
||||
|
||||
|
||||
|
||||
public class LV2Plugin {
|
||||
|
||||
Pointer<LilvWorld> world;
|
||||
Pointer<LilvPlugin> p;
|
||||
|
||||
public LV2Plugin(Pointer<LilvWorld> world, Pointer<LilvPlugin> p) {
|
||||
this.world = world;
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return lilv_node_as_uri(LibLilv.lilv_plugin_get_uri(p)).getCString();
|
||||
}
|
||||
|
||||
public String getPluginClass() {
|
||||
Pointer<LilvPluginClass> pclass = lilv_plugin_get_class(p);
|
||||
Pointer<LilvNode> class_label = lilv_plugin_class_get_label(pclass);
|
||||
if (class_label!=null && class_label.getPeer()!=0) {
|
||||
return lilv_node_as_string(class_label).getCString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String stringNodeGetter(Pointer<LilvNode> val) {
|
||||
String out = null;
|
||||
if (val!=null && val.getPeer()!=0) {
|
||||
out = lilv_node_as_string(val).getCString();
|
||||
lilv_node_free(val);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return stringNodeGetter(lilv_plugin_get_name(p));
|
||||
}
|
||||
public String getAuthorName() {
|
||||
return stringNodeGetter(lilv_plugin_get_author_name(p));
|
||||
}
|
||||
public String getAuthorEmail() {
|
||||
return stringNodeGetter(lilv_plugin_get_author_email(p));
|
||||
}
|
||||
public String getAuthorHomepage() {
|
||||
return stringNodeGetter(lilv_plugin_get_author_homepage(p));
|
||||
}
|
||||
|
||||
public boolean hasLatency() {
|
||||
return lilv_plugin_has_latency(p);
|
||||
}
|
||||
public int getLatencyPort() {
|
||||
if (lilv_plugin_has_latency(p))
|
||||
return lilv_plugin_get_latency_port_index(p);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String getBundleUri() {
|
||||
return lilv_node_as_uri(lilv_plugin_get_bundle_uri(p)).getCString();
|
||||
|
||||
}
|
||||
|
||||
public String getBinaryUri() {
|
||||
Pointer<LilvNode> binary_uri = lilv_plugin_get_library_uri(p);
|
||||
if (binary_uri!=null && binary_uri.getPeer()!=0) {
|
||||
return lilv_node_as_uri(lilv_plugin_get_library_uri(p)).getCString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<LV2Ui> getPluginUIs() {
|
||||
Pointer<LilvUIs> uis = lilv_plugin_get_uis(p);
|
||||
List<LV2Ui> out = lilvUIsToList(lilv_plugin_get_uis(p)).stream().map(n -> new LV2Ui(world, n)).toList();
|
||||
lilv_uis_free(uis);
|
||||
return out;
|
||||
}
|
||||
|
||||
public List<String> getDataUris() {
|
||||
return lilvNodesToList(lilv_plugin_get_data_uris(p)).stream().map(LibLilv::lilv_node_as_uri).map(Pointer::getCString).toList();
|
||||
}
|
||||
|
||||
public List<String> getRequiredFeatures() {
|
||||
Pointer<LilvNodes> features = lilv_plugin_get_required_features(p);
|
||||
if(features!=null && features.getPeer()==0)
|
||||
return null;
|
||||
List<String> out = lilvNodesToList(features).stream().map(LibLilv::lilv_node_as_uri).map(Pointer::getCString).toList();
|
||||
lilv_nodes_free(features);
|
||||
return out;
|
||||
}
|
||||
|
||||
public Object getOptionalFeatures() {
|
||||
Pointer<LilvNodes> features = lilv_plugin_get_optional_features(p);
|
||||
if(features!=null && features.getPeer()==0)
|
||||
return null;
|
||||
List<String> out = lilvNodesToList(features).stream().map(LibLilv::lilv_node_as_uri).map(Pointer::getCString).toList();
|
||||
lilv_nodes_free(features);
|
||||
return out;
|
||||
}
|
||||
|
||||
public List<String> getExtensionData() {
|
||||
Pointer<LilvNodes> features = lilv_plugin_get_extension_data(p);
|
||||
if(features!=null && features.getPeer()==0)
|
||||
return null;
|
||||
List<String> out = lilvNodesToList(features).stream().map(LibLilv::lilv_node_as_uri).map(Pointer::getCString).toList();
|
||||
lilv_nodes_free(features);
|
||||
return out;
|
||||
}
|
||||
|
||||
public List<LV2Preset> getPresets() {
|
||||
Pointer<LilvNode> preset_class = LibLilv.lilv_new_uri(world, Pointer.pointerToCString(LibLv2.LV2_PRESETS__Preset));
|
||||
Pointer<LilvNodes> presets = lilv_plugin_get_related(p, preset_class);
|
||||
if(presets==null)return List.of();
|
||||
List<LV2Preset> out = lilvNodesToList(presets).stream().map(n -> new LV2Preset(world,n)).toList();
|
||||
System.out.println(out);
|
||||
//lilv_nodes_free(presets);
|
||||
return out;
|
||||
}
|
||||
|
||||
public List<LV2Port> getPorts() {
|
||||
int num_ports = lilv_plugin_get_num_ports(p);
|
||||
Pointer<Float> mins = Pointer.allocateArray(Float.class, num_ports);
|
||||
Pointer<Float> maxes = Pointer.allocateArray(Float.class, num_ports);
|
||||
Pointer<Float> defaults = Pointer.allocateArray(Float.class, num_ports);
|
||||
lilv_plugin_get_port_ranges_float(p, mins, maxes, defaults);
|
||||
|
||||
List<LV2Port> ports = new ArrayList<>();
|
||||
for (int i = 0; i < num_ports; ++i) {
|
||||
ports.add(new LV2Port(i,mins.getFloatAtIndex(i), maxes.getFloatAtIndex(i), defaults.getFloatAtIndex(i)));
|
||||
}
|
||||
return ports;
|
||||
}
|
||||
|
||||
}
|
||||
33
src/main/java/com/bernard/sboard/lv2/LV2Port.java
Normal file
33
src/main/java/com/bernard/sboard/lv2/LV2Port.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.bernard.sboard.lv2;
|
||||
|
||||
public class LV2Port {
|
||||
|
||||
int index;
|
||||
float minVal,maxVal,defaultVal;
|
||||
|
||||
public LV2Port(int index, float minVal, float maxVal, float defaultVal) {
|
||||
this.index = index;
|
||||
this.minVal = minVal;
|
||||
this.maxVal = maxVal;
|
||||
this.defaultVal = defaultVal;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public float getMinVal() {
|
||||
return minVal;
|
||||
}
|
||||
|
||||
public float getMaxVal() {
|
||||
return maxVal;
|
||||
}
|
||||
|
||||
public float getDefaultVal() {
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
46
src/main/java/com/bernard/sboard/lv2/LV2Preset.java
Normal file
46
src/main/java/com/bernard/sboard/lv2/LV2Preset.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.bernard.sboard.lv2;
|
||||
|
||||
import org.bridj.Pointer;
|
||||
|
||||
import com.bernard.sboard.bridj.LibLilv;
|
||||
|
||||
import static com.bernard.sboard.bridj.LibLilv.*;
|
||||
|
||||
public class LV2Preset {
|
||||
|
||||
Pointer<LilvWorld> world;
|
||||
Pointer<LilvNode> preset;
|
||||
|
||||
boolean loaded = false;
|
||||
|
||||
public LV2Preset(Pointer<LilvWorld> world, Pointer<LilvNode> preset) {
|
||||
this.world = world;
|
||||
this.preset = preset;
|
||||
|
||||
System.out.println(lilv_node_is_uri(preset));
|
||||
}
|
||||
|
||||
public boolean loadResource() {
|
||||
if(!loaded)
|
||||
if(lilv_world_load_resource(world, preset)!=0)
|
||||
System.err.println("Illegal preset "+lilv_node_as_uri(preset).getCString());
|
||||
else
|
||||
this.loaded = true;
|
||||
return loaded;
|
||||
}
|
||||
|
||||
public String getFirstTitle() {
|
||||
if(!loadResource())return "No Resource";
|
||||
Pointer<LilvNode> labelUri = LibLilv.lilv_new_uri(world, Pointer.pointerToCString(LibLilv.LILV_NS_RDFS + "label"));
|
||||
if(!lilv_world_ask(world, preset, labelUri, null))
|
||||
return "No Title";
|
||||
Pointer<LilvNode> title = lilv_world_get(world,preset,labelUri,null);
|
||||
return lilv_node_as_string(title).getCString();
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return lilv_node_as_uri(preset).getCString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
46
src/main/java/com/bernard/sboard/lv2/LV2Ui.java
Normal file
46
src/main/java/com/bernard/sboard/lv2/LV2Ui.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.bernard.sboard.lv2;
|
||||
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilvNodesToList;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_node_as_uri;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_ui_get_binary_uri;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_ui_get_bundle_uri;
|
||||
import static com.bernard.sboard.bridj.LibLilv.lilv_ui_get_classes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bridj.Pointer;
|
||||
|
||||
import com.bernard.sboard.bridj.LibLilv;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvUI;
|
||||
import com.bernard.sboard.bridj.LibLilv.LilvWorld;
|
||||
|
||||
public class LV2Ui {
|
||||
|
||||
Pointer<LilvWorld> world;
|
||||
Pointer<LilvUI> ui;
|
||||
|
||||
public LV2Ui(Pointer<LilvWorld> world, Pointer<LilvUI> ui) {
|
||||
this.world = world;
|
||||
this.ui = ui;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return lilv_node_as_uri(lilv_ui_get_bundle_uri(ui)).getCString();
|
||||
}
|
||||
|
||||
public String getBinary() {
|
||||
Pointer<Byte> val = lilv_node_as_uri(lilv_ui_get_binary_uri(ui));
|
||||
if(val.getPeer()!=0)
|
||||
return val.getCString();
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getBundleUri() {
|
||||
return lilv_node_as_uri(lilv_ui_get_bundle_uri(ui)).getCString();
|
||||
}
|
||||
|
||||
public List<String> getClassesUris() {
|
||||
return lilvNodesToList(lilv_ui_get_classes(ui)).stream().map(LibLilv::lilv_node_as_uri).map(Pointer::getCString).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.bernard.sboard.osc;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.illposed.osc.OSCPacket;
|
||||
import com.illposed.osc.OSCSerializeException;
|
||||
import com.illposed.osc.transport.OSCPortOut;
|
||||
|
||||
public class OscRemoteController {
|
||||
|
||||
int uid;
|
||||
OSCPortOut outport;
|
||||
OscServer server;
|
||||
String name;
|
||||
|
||||
|
||||
|
||||
public OscRemoteController(OscServer server, int uid, String name, OSCPortOut outport) {
|
||||
this.uid = uid;
|
||||
this.name = name;
|
||||
this.outport = outport;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public void send(OSCPacket packet) {
|
||||
try {
|
||||
outport.send(packet);
|
||||
} catch (IOException e) {
|
||||
server.log.warn("Could not send osc packet to recipient", e);
|
||||
} catch (OSCSerializeException e) {
|
||||
server.log.error("Tried to send malformed osc packet", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
outport.close();
|
||||
}
|
||||
|
||||
}
|
||||
216
src/main/java/com/bernard/sboard/osc/OscServer.java
Normal file
216
src/main/java/com/bernard/sboard/osc/OscServer.java
Normal file
@ -0,0 +1,216 @@
|
||||
package com.bernard.sboard.osc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.bernard.sboard.SBoard;
|
||||
import com.bernard.sboard.config.OscConfig;
|
||||
import com.illposed.osc.OSCBadDataEvent;
|
||||
import com.illposed.osc.OSCBundle;
|
||||
import com.illposed.osc.OSCMessage;
|
||||
import com.illposed.osc.OSCPacket;
|
||||
import com.illposed.osc.OSCPacketDispatcher;
|
||||
import com.illposed.osc.OSCPacketEvent;
|
||||
import com.illposed.osc.OSCPacketListener;
|
||||
import com.illposed.osc.transport.OSCPortIn;
|
||||
import com.illposed.osc.transport.OSCPortInBuilder;
|
||||
import com.illposed.osc.transport.OSCPortOut;
|
||||
import com.illposed.osc.transport.OSCPortOutBuilder;
|
||||
|
||||
public class OscServer implements OSCPacketListener{
|
||||
|
||||
Logger log = LogManager.getLogger(OscServer.class);
|
||||
|
||||
SBoard sboard;
|
||||
|
||||
OscConfig config;
|
||||
|
||||
OSCPortIn inport;
|
||||
|
||||
Map<Integer,OscRemoteController> controllers;
|
||||
|
||||
Timer globalTimer;
|
||||
|
||||
OSCPacketDispatcher opd;
|
||||
|
||||
Timer oscDispacher;
|
||||
Lock oscLock;
|
||||
|
||||
Map<OscRemoteController,Set<FrequentListener<?>>> frequentListeners;
|
||||
|
||||
public OscServer(SBoard sboard, OscConfig config) {
|
||||
this.sboard = sboard;
|
||||
this.config = config;
|
||||
this.frequentListeners = new HashMap<>();
|
||||
this.controllers = new HashMap<>();
|
||||
this.oscLock = new ReentrantLock();
|
||||
}
|
||||
|
||||
public void setup() throws IOException {
|
||||
|
||||
oscDispacher = new Timer();
|
||||
inport = new OSCPortInBuilder()
|
||||
.setNetworkProtocol(config.networkProtocol)
|
||||
.setLocalPort(config.inputport)
|
||||
.setPacketListener(this)
|
||||
.build();
|
||||
|
||||
inport.startListening();
|
||||
|
||||
globalTimer = new Timer();
|
||||
globalTimer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateFrequentListeners();
|
||||
}
|
||||
}, config.frequentUpdatePeriod, config.frequentUpdatePeriod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(OSCPacketEvent event) {
|
||||
oscLock.lock();
|
||||
recursivePacketDispach(event.getPacket());
|
||||
oscLock.unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void handleBadData(OSCBadDataEvent event) {
|
||||
log.warn("OSC Message not understood", event.getException());
|
||||
}
|
||||
private void dispachMessageToSBoard(OSCMessage message) {
|
||||
SOscMessage smessage = new SOscMessage(this, message);
|
||||
log.debug("Received OSC message: "+message.getAddress()+" "+message.getArguments());
|
||||
if(OscUtils.addrMatch(smessage.getContainer(0),"sboard") && OscUtils.addrMatch(smessage.getContainer(1),"osc")) {
|
||||
// Alors, le message nous est nous est destiné
|
||||
if(OscUtils.addrMatch(smessage.getContainer(1), "register")) {
|
||||
// REGISTER [ int int int int UUID, string Name, string IPAddr, int port ]
|
||||
UUID regUUID = new UUID(
|
||||
((int)smessage.getArguments().get(0))*0xFFFFL + ((int)smessage.getArguments().get(1)),
|
||||
((int)smessage.getArguments().get(2))*0xFFFFL + ((int)smessage.getArguments().get(3)));
|
||||
String name = (String)smessage.getArguments().get(4);
|
||||
SocketAddress address = new InetSocketAddress((String)smessage.getArguments().get(5), (int)smessage.getArguments().get(6));
|
||||
int newuid = 0;
|
||||
do {
|
||||
newuid = sboard.random.nextInt();
|
||||
} while (!controllers.containsKey(newuid));
|
||||
OSCPortOut opo;
|
||||
try {
|
||||
opo = new OSCPortOutBuilder()
|
||||
.setRemotePort((int)smessage.getArguments().get(6))
|
||||
.setRemoteSocketAddress(address)
|
||||
.setNetworkProtocol(config.networkProtocol)
|
||||
.build();
|
||||
OscRemoteController orc = new OscRemoteController(this, newuid, name, opo);
|
||||
OSCMessage answer = new OSCMessage("/sboard/osc/registered", List.of(
|
||||
(int)(regUUID.getLeastSignificantBits()>>32),
|
||||
(int)(regUUID.getLeastSignificantBits()&0xFFFF),
|
||||
(int)(regUUID.getMostSignificantBits()>>32),
|
||||
(int)(regUUID.getMostSignificantBits()&0xFFFF),
|
||||
newuid));
|
||||
controllers.put(newuid, orc);
|
||||
orc.send(answer);
|
||||
} catch (IOException e) {
|
||||
log.error("Could not register OSC reciever", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sboard.dispatchOscMessage(smessage);
|
||||
}
|
||||
}
|
||||
// Le synchronized permet de forcer les messages dans un même bundle à être executés sequentiellement.
|
||||
private void recursivePacketDispach(OSCPacket packet) {
|
||||
if(packet instanceof OSCMessage) {
|
||||
dispachMessageToSBoard((OSCMessage)packet);
|
||||
} else if (packet instanceof OSCBundle) {
|
||||
OSCBundle bundle = (OSCBundle) packet;
|
||||
if(!bundle.getTimestamp().isImmediate()) {
|
||||
Date dispachDate = bundle.getTimestamp().toDate(Date.from(Instant.now()));
|
||||
if(!dispachDate.before(Date.from(Instant.now()))) {
|
||||
oscDispacher.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
oscLock.lock();
|
||||
recursivePacketDispach(packet);
|
||||
oscLock.unlock();
|
||||
}
|
||||
}, dispachDate);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// At this point, we should dispach the message immediatly
|
||||
for(OSCPacket oscp : bundle.getPackets())
|
||||
recursivePacketDispach(oscp);
|
||||
}
|
||||
}
|
||||
|
||||
public OscRemoteController getSender(int uid) {
|
||||
return controllers.get(uid);
|
||||
}
|
||||
|
||||
public void close() throws IOException{
|
||||
inport.close();
|
||||
for(OscRemoteController ctrl : controllers.values())
|
||||
ctrl.close();
|
||||
}
|
||||
|
||||
/* Values Listeners */
|
||||
|
||||
public <T> void declareFrequentUpdate(String address, Supplier<T> getter, OscRemoteController controller) {
|
||||
synchronized(frequentListeners) {
|
||||
frequentListeners.putIfAbsent(controller, new HashSet<>());
|
||||
frequentListeners.get(controller).add(new FrequentListener<>(address, getter, controller));
|
||||
}
|
||||
}
|
||||
public void removeRegularListen(String address, OscRemoteController controller) {
|
||||
synchronized(frequentListeners) {
|
||||
if(frequentListeners.containsKey(controller))
|
||||
frequentListeners.get(controller).removeIf(fl -> fl.address.equals(address));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateFrequentListeners() {
|
||||
synchronized(frequentListeners) {
|
||||
for(OscRemoteController ctrl : frequentListeners.keySet()) {
|
||||
OSCBundle bundle = new OSCBundle();
|
||||
for(FrequentListener<?> fl : frequentListeners.get(ctrl)) {
|
||||
OSCMessage toSend = new OSCMessage(fl.address,List.of(fl.getter.get()));
|
||||
bundle.addPacket(toSend);
|
||||
}
|
||||
ctrl.send(bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected class FrequentListener<T> {
|
||||
String address;
|
||||
Supplier<T> getter;
|
||||
OscRemoteController controller;
|
||||
public FrequentListener(String address, Supplier<T> getter, OscRemoteController controller) {
|
||||
this.address = address;
|
||||
this.getter = getter;
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
30
src/main/java/com/bernard/sboard/osc/OscUtils.java
Normal file
30
src/main/java/com/bernard/sboard/osc/OscUtils.java
Normal file
@ -0,0 +1,30 @@
|
||||
package com.bernard.sboard.osc;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class OscUtils {
|
||||
|
||||
/**
|
||||
* Returns true if the address part given as a parameter matches as
|
||||
* an OSC address.
|
||||
*
|
||||
* If str is invalid (i.e. contains invalid characters)
|
||||
* the output of this function should not be used.
|
||||
* @param addr The address with matching characters
|
||||
* @param str the string against which should the addr be matched
|
||||
* @return true iff the address should match str
|
||||
*/
|
||||
public static boolean addrMatch(String addr, String str) {
|
||||
if(str.equals(addr))return true;
|
||||
//TODO: Rajouter le parse, avec les ?,*,{},[], ...
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Set<String> allAddrMatch(String addr, Set<String> keys) {
|
||||
System.out.println(addr+"<-->"+keys);
|
||||
if(keys.contains(addr))return Set.of(addr);
|
||||
//TODO: Rajouter le parse, avec les ?,*,{},[], ...
|
||||
return Set.of();
|
||||
}
|
||||
|
||||
}
|
||||
46
src/main/java/com/bernard/sboard/osc/SOscMessage.java
Normal file
46
src/main/java/com/bernard/sboard/osc/SOscMessage.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.bernard.sboard.osc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.illposed.osc.OSCMessage;
|
||||
import com.illposed.osc.OSCMessageInfo;
|
||||
|
||||
public class SOscMessage {
|
||||
|
||||
OscServer server;
|
||||
|
||||
OSCMessage message;
|
||||
|
||||
String[] address = null;
|
||||
|
||||
public SOscMessage(OscServer server, OSCMessage message) {
|
||||
this.server = server;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public OscServer getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public OSCMessage getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getContainer(int i) {
|
||||
if(address==null) address = message.getAddress().substring(1).split("/");
|
||||
return address[i];
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return message.getAddress();
|
||||
}
|
||||
|
||||
public List<Object> getArguments(){
|
||||
return message.getArguments();
|
||||
}
|
||||
|
||||
public OSCMessageInfo getInfo() {
|
||||
return message.getInfo();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.bernard.sboard.saddr;
|
||||
|
||||
public interface CheckableSaddr<T> extends SAddr<T> {
|
||||
|
||||
boolean check();
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.bernard.sboard.saddr;
|
||||
|
||||
public class ContinuousFloatSType implements SType<Float>{
|
||||
|
||||
float minValue, maxValue;
|
||||
boolean enforceValues;
|
||||
|
||||
@Override
|
||||
public boolean validate(Float o) {
|
||||
return !enforceValues || (minValue < o && o < maxValue);
|
||||
}
|
||||
|
||||
}
|
||||
38
src/main/java/com/bernard/sboard/saddr/PointerSAddr.java
Normal file
38
src/main/java/com/bernard/sboard/saddr/PointerSAddr.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.bernard.sboard.saddr;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.bridj.Pointer;
|
||||
|
||||
public abstract class PointerSAddr<T> implements SAddr<T>, ReadableSAddr<T>, WritableSAddr<T>{
|
||||
|
||||
String address;
|
||||
Pointer<T> pointer;
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
return pointer!=Pointer.NULL;// Il n'y a aucun moyen de savoir si un pointeur a été free
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setValue(T value) {
|
||||
pointer.set(value);
|
||||
return true; // If something has gone wrong, the program will segfault
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return pointer.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<Capability> getCapabilities() {
|
||||
return EnumSet.of(Capability.CHECK, Capability.READ, Capability.WRITE);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.bernard.sboard.saddr;
|
||||
|
||||
public interface ReadableSAddr<T> extends CheckableSaddr<T> {
|
||||
|
||||
T getValue();
|
||||
|
||||
}
|
||||
18
src/main/java/com/bernard/sboard/saddr/SAddr.java
Normal file
18
src/main/java/com/bernard/sboard/saddr/SAddr.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.bernard.sboard.saddr;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public interface SAddr<T> {
|
||||
|
||||
String getAddress();
|
||||
|
||||
SType<T> getType();
|
||||
|
||||
EnumSet<Capability> getCapabilities();
|
||||
|
||||
public static enum Capability{
|
||||
READ, // We can request to read the value
|
||||
WRITE, // We can request to set the value
|
||||
CHECK; // We can request to check if this address contains any data
|
||||
}
|
||||
}
|
||||
13
src/main/java/com/bernard/sboard/saddr/SType.java
Normal file
13
src/main/java/com/bernard/sboard/saddr/SType.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.bernard.sboard.saddr;
|
||||
|
||||
public interface SType<T> {
|
||||
|
||||
/**
|
||||
* Checks wether the object is valid for this type, i.e. it checks all the constrains
|
||||
*
|
||||
* @param o The object to check
|
||||
* @return true iff the object is valid
|
||||
*/
|
||||
boolean validate(T o);
|
||||
|
||||
}
|
||||
13
src/main/java/com/bernard/sboard/saddr/SwitchFloatSType.java
Normal file
13
src/main/java/com/bernard/sboard/saddr/SwitchFloatSType.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.bernard.sboard.saddr;
|
||||
|
||||
public class SwitchFloatSType implements SType<Float>{
|
||||
|
||||
float valueOn = 1.0f;
|
||||
float valueOff = 0.0f;
|
||||
|
||||
@Override
|
||||
public boolean validate(Float o) {
|
||||
return o == valueOn || o == valueOff;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.bernard.sboard.saddr;
|
||||
|
||||
public interface WritableSAddr<T> extends SAddr<T> {
|
||||
|
||||
boolean setValue(T value);
|
||||
|
||||
}
|
||||
13
src/test/java/com/bernard/sboard/AppTest.java
Normal file
13
src/test/java/com/bernard/sboard/AppTest.java
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This Java source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package com.bernard.sboard;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class AppTest {
|
||||
@Test public void appHasAGreeting() {
|
||||
assertNotNull("app should have a greeting", true);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user