diff options
52 files changed, 3364 insertions, 5145 deletions
diff --git a/omins.lv2/adenv.ttl b/omins.lv2/adenv.ttl new file mode 100644 index 0000000..807e8dc --- /dev/null +++ b/omins.lv2/adenv.ttl @@ -0,0 +1,59 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix units: <http://lv2plug.in/ns/extensions/units#> . + +<http://drobilla.net/plugins/omins/adenv> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Gate" ; + lv2:symbol "port0" ; + a lv2:AudioPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Trigger" ; + lv2:symbol "port1" ; + a lv2:AudioPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 0 ; + lv2:index 2 ; + lv2:minimum 0 ; + lv2:name "Attack Time" ; + lv2:symbol "port2" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:default 0 ; + lv2:index 3 ; + lv2:minimum 0 ; + lv2:name "Decay Time" ; + lv2:symbol "port3" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:index 4 ; + lv2:name "Envelope Out" ; + lv2:symbol "port4" ; + a lv2:AudioPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Loki Davison <ltdav1[at]student.monash.edu.au>" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Percussive AD Envelope" ; + a lv2:Plugin . diff --git a/omins.lv2/adenv_lvl.ttl b/omins.lv2/adenv_lvl.ttl new file mode 100644 index 0000000..0971fd2 --- /dev/null +++ b/omins.lv2/adenv_lvl.ttl @@ -0,0 +1,92 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix units: <http://lv2plug.in/ns/extensions/units#> . + +<http://drobilla.net/plugins/omins/adenv_lvl> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Gate" ; + lv2:symbol "port0" ; + a lv2:CVPort , + lv2:InputPort + ] , [ + lv2:index 1 ; + lv2:name "Trigger" ; + lv2:symbol "port1" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 0 ; + lv2:index 2 ; + lv2:minimum 0 ; + lv2:name "Initial Level" ; + lv2:symbol "port2" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 1 ; + lv2:index 3 ; + lv2:minimum 0 ; + lv2:name "Attack to Level" ; + lv2:symbol "port3" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 0 ; + lv2:index 4 ; + lv2:minimum 0 ; + lv2:name "Decay to Level" ; + lv2:symbol "port4" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + units:unit units:s ; + lv2:default 0 ; + lv2:index 5 ; + lv2:minimum 0 ; + lv2:name "Attack Time" ; + lv2:symbol "port5" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + units:unit units:s ; + lv2:default 0 ; + lv2:index 6 ; + lv2:minimum 0 ; + lv2:name "Decay Time" ; + lv2:symbol "port6" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 7 ; + lv2:name "Envelope Out" ; + lv2:symbol "port7" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] , [ + lv2:index 8 ; + lv2:name "Reset Level" ; + lv2:symbol "port8" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Loki Davison <ltdav1[at]student.monash.edu.au>" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Percussive AD Envelope with levels" ; + a lv2:Plugin . diff --git a/omins.lv2/comparison.ttl b/omins.lv2/comparison.ttl new file mode 100644 index 0000000..61dc7ae --- /dev/null +++ b/omins.lv2/comparison.ttl @@ -0,0 +1,60 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/comparison> + lv2:binary <file:///usr/local/lib/lv2/naspro-ladspa.lv2/ladspa.so> ; + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "A" ; + lv2:symbol "port0" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "B" ; + lv2:symbol "port1" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 2 ; + lv2:name "Larger" ; + lv2:symbol "port2" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] , [ + lv2:index 3 ; + lv2:name "Smaller" ; + lv2:symbol "port3" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] , [ + lv2:index 4 ; + lv2:name "A > B" ; + lv2:symbol "port4" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] , [ + lv2:index 5 ; + lv2:name "A = B" ; + lv2:symbol "port5" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Thorsten Wilms" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Comparison" ; + a lv2:Plugin . diff --git a/omins.lv2/dahdsr_fexp.ttl b/omins.lv2/dahdsr_fexp.ttl new file mode 100644 index 0000000..bebdeda --- /dev/null +++ b/omins.lv2/dahdsr_fexp.ttl @@ -0,0 +1,99 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix units: <http://lv2plug.in/ns/extensions/units#> . + +<http://drobilla.net/plugins/omins/dahdsr_fexp> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Gate" ; + lv2:symbol "port0" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Trigger" ; + lv2:symbol "port1" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 0 ; + lv2:index 2 ; + lv2:minimum 0 ; + lv2:name "Delay Time" ; + lv2:symbol "port2" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:default 0 ; + lv2:index 3 ; + lv2:minimum 0 ; + lv2:name "Attack Time" ; + lv2:symbol "port3" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:default 0 ; + lv2:index 4 ; + lv2:minimum 0 ; + lv2:name "Hold Time" ; + lv2:symbol "port4" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:default 0 ; + lv2:index 5 ; + lv2:minimum 0 ; + lv2:name "Decay Time" ; + lv2:symbol "port5" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:default 1 ; + lv2:index 6 ; + lv2:maximum 1 ; + lv2:minimum 0 ; + lv2:name "Sustain Level" ; + lv2:symbol "port6" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 0 ; + lv2:index 7 ; + lv2:minimum 0 ; + lv2:name "Release Time" ; + lv2:symbol "port7" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:index 8 ; + lv2:name "Envelope Out" ; + lv2:symbol "port8" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Loki Davison <ltdav1[at]student.monash.edu.au>" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Exponential DAHDSR Envelope" ; + a lv2:Plugin . diff --git a/omins.lv2/dahdsr_hexp.ttl b/omins.lv2/dahdsr_hexp.ttl new file mode 100644 index 0000000..d2ddc8f --- /dev/null +++ b/omins.lv2/dahdsr_hexp.ttl @@ -0,0 +1,99 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix units: <http://lv2plug.in/ns/extensions/units#> . + +<http://drobilla.net/plugins/omins/dahdsr_hexp> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Gate" ; + lv2:symbol "port0" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Trigger" ; + lv2:symbol "port1" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 0 ; + lv2:index 2 ; + lv2:minimum 0 ; + lv2:name "Delay Time" ; + lv2:symbol "port2" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:default 0 ; + lv2:index 3 ; + lv2:minimum 0 ; + lv2:name "Attack Time" ; + lv2:symbol "port3" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:default 0 ; + lv2:index 4 ; + lv2:minimum 0 ; + lv2:name "Hold Time" ; + lv2:symbol "port4" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:default 0 ; + lv2:index 5 ; + lv2:minimum 0 ; + lv2:name "Decay Time" ; + lv2:symbol "port5" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:default 1 ; + lv2:index 6 ; + lv2:maximum 1 ; + lv2:minimum 0 ; + lv2:name "Sustain Level" ; + lv2:symbol "port6" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 0 ; + lv2:index 7 ; + lv2:minimum 0 ; + lv2:name "Release Time" ; + lv2:symbol "port7" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:index 8 ; + lv2:name "Envelope Out" ; + lv2:symbol "port8" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Loki Davison <ltdav1[at]student.monash.edu.au>" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "DAHDSR Envelope (Linear A, Exponential DR)" ; + a lv2:Plugin . diff --git a/omins.lv2/fast_crossfade.ttl b/omins.lv2/fast_crossfade.ttl new file mode 100644 index 0000000..5710b05 --- /dev/null +++ b/omins.lv2/fast_crossfade.ttl @@ -0,0 +1,45 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/fast_crossfade> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Level" ; + lv2:symbol "port0" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "A" ; + lv2:symbol "port1" ; + a lv2:AudioPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 2 ; + lv2:name "B" ; + lv2:symbol "port2" ; + a lv2:AudioPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 3 ; + lv2:name "Output" ; + lv2:symbol "port3" ; + a lv2:AudioPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Thorsten Wilms" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Fast Crossfade" ; + a lv2:Plugin . diff --git a/omins.lv2/formant_filter.ttl b/omins.lv2/formant_filter.ttl new file mode 100644 index 0000000..191779e --- /dev/null +++ b/omins.lv2/formant_filter.ttl @@ -0,0 +1,41 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/formant_filter> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:default 0 ; + lv2:index 0 ; + lv2:maximum 4 ; + lv2:minimum 0 ; + lv2:name "Vowel" ; + lv2:symbol "port0" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Input" ; + lv2:symbol "port1" ; + a lv2:AudioPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 2 ; + lv2:name "Output" ; + lv2:symbol "port2" ; + a lv2:AudioPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "David Robillard" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Formant Filter" ; + a lv2:Plugin . diff --git a/omins.lv2/hz_voct.ttl b/omins.lv2/hz_voct.ttl new file mode 100644 index 0000000..8960c8b --- /dev/null +++ b/omins.lv2/hz_voct.ttl @@ -0,0 +1,31 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/hz_voct> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Input" ; + lv2:symbol "port0" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Output" ; + lv2:symbol "port1" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "David Robillard" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Hz to V/Oct" ; + a lv2:Plugin . diff --git a/omins.lv2/manifest.ttl.in b/omins.lv2/manifest.ttl.in new file mode 100644 index 0000000..8fd0dba --- /dev/null +++ b/omins.lv2/manifest.ttl.in @@ -0,0 +1,87 @@ +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . + +<http://drobilla.net/plugins/omins/adenv_lvl> + a lv2:Plugin ; + rdfs:seeAlso <adenv_lvl.ttl> ; + lv2:binary <adenv_lvl@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/adenv> + a lv2:Plugin ; + rdfs:seeAlso <adenv.ttl> ; + lv2:binary <adenv@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/comparison> + a lv2:Plugin ; + rdfs:seeAlso <comparison.ttl> ; + lv2:binary <comparison@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/dahdsr_fexp> + a lv2:Plugin ; + rdfs:seeAlso <dahdsr_fexp.ttl> ; + lv2:binary <dahdsr_fexp@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/dahdsr_hexp> + a lv2:Plugin ; + rdfs:seeAlso <dahdsr_hexp.ttl> ; + lv2:binary <dahdsr_hexp@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/fast_crossfade> + a lv2:Plugin ; + rdfs:seeAlso <fast_crossfade.ttl> ; + lv2:binary <fast_crossfade@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/formant_filter> + a lv2:Plugin ; + rdfs:seeAlso <formant_filter.ttl> ; + lv2:binary <formant_filter@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/hz_voct> + a lv2:Plugin ; + rdfs:seeAlso <hz_voct.ttl> ; + lv2:binary <hz_voct@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/masher> + a lv2:Plugin ; + rdfs:seeAlso <masher.ttl> ; + lv2:binary <masher@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/multiplexer> + a lv2:Plugin ; + rdfs:seeAlso <multiplexer.ttl> ; + lv2:binary <multiplexer@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/prob_switch> + a lv2:Plugin ; + rdfs:seeAlso <prob_switch.ttl> ; + lv2:binary <prob_switch@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/range_trans> + a lv2:Plugin ; + rdfs:seeAlso <range_trans.ttl> ; + lv2:binary <range_trans@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/sample_and_hold> + a lv2:Plugin ; + rdfs:seeAlso <sample_and_hold.ttl> ; + lv2:binary <sample_and_hold@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/signal_abs> + a lv2:Plugin ; + rdfs:seeAlso <signal_abs.ttl> ; + lv2:binary <signal_abs@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/slew_limiter> + a lv2:Plugin ; + rdfs:seeAlso <slew_limiter.ttl> ; + lv2:binary <slew_limiter@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/slide> + a lv2:Plugin ; + rdfs:seeAlso <slide.ttl> ; + lv2:binary <slide@LIB_EXT@> . + +<http://drobilla.net/plugins/omins/waveguide_mesh> + a lv2:Plugin ; + rdfs:seeAlso <waveguide_mesh.ttl> ; + lv2:binary <waveguide_mesh@LIB_EXT@> . diff --git a/omins.lv2/masher.ttl b/omins.lv2/masher.ttl new file mode 100644 index 0000000..b174249 --- /dev/null +++ b/omins.lv2/masher.ttl @@ -0,0 +1,51 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/masher> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Input" ; + lv2:symbol "port0" ; + a lv2:AudioPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 1 ; + lv2:index 1 ; + lv2:maximum 10 ; + lv2:minimum 1 ; + lv2:name "Grain Pitch" ; + lv2:symbol "port1" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 400 ; + lv2:index 2 ; + lv2:maximum 800 ; + lv2:minimum 0 ; + lv2:name "Density" ; + lv2:symbol "port2" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 3 ; + lv2:name "Output" ; + lv2:symbol "port3" ; + a lv2:AudioPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Dave Griffiths" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Masher" ; + a lv2:Plugin . diff --git a/omins.lv2/multiplexer.ttl b/omins.lv2/multiplexer.ttl new file mode 100644 index 0000000..fe8b3b4 --- /dev/null +++ b/omins.lv2/multiplexer.ttl @@ -0,0 +1,39 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/multiplexer> + a lv2:Plugin ; + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + a lv2:CVPort , + lv2:InputPort ; + lv2:index 0 ; + lv2:name "Gate" ; + lv2:symbol "gate" ; + ] , [ + a lv2:CVPort , + lv2:InputPort ; + lv2:index 1 ; + lv2:name "Off" ; + lv2:symbol "off" ; + ] , [ + a lv2:CVPort , + lv2:InputPort ; + lv2:index 2 ; + lv2:name "On" ; + lv2:symbol "on" ; + ] , [ + a lv2:CVPort , + lv2:OutputPort ; + lv2:index 3 ; + lv2:name "Output" ; + lv2:symbol "output" ; + ] ; + doap:name "Multiplexer" . diff --git a/omins.lv2/prob_switch.ttl b/omins.lv2/prob_switch.ttl new file mode 100644 index 0000000..d422cff --- /dev/null +++ b/omins.lv2/prob_switch.ttl @@ -0,0 +1,45 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/prob_switch> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Input 1" ; + lv2:symbol "port0" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Input 2" ; + lv2:symbol "port1" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 2 ; + lv2:name "Probability" ; + lv2:symbol "port2" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 3 ; + lv2:name "Output" ; + lv2:symbol "port3" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Loki Davison" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Probability Switch" ; + a lv2:Plugin . diff --git a/omins.lv2/range_trans.ttl b/omins.lv2/range_trans.ttl new file mode 100644 index 0000000..f9ee544 --- /dev/null +++ b/omins.lv2/range_trans.ttl @@ -0,0 +1,63 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/range_trans> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:default 0 ; + lv2:index 0 ; + lv2:name "Input Min" ; + lv2:symbol "port0" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 1 ; + lv2:index 1 ; + lv2:name "Input Max" ; + lv2:symbol "port1" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 0 ; + lv2:index 2 ; + lv2:name "Output Min" ; + lv2:symbol "port2" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 1 ; + lv2:index 3 ; + lv2:name "Output Max" ; + lv2:symbol "port3" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 4 ; + lv2:name "Input" ; + lv2:symbol "port4" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 5 ; + lv2:name "Output" ; + lv2:symbol "port5" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "David Robillard" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Range Translator" ; + a lv2:Plugin . diff --git a/omins.lv2/sample_and_hold.ttl b/omins.lv2/sample_and_hold.ttl new file mode 100644 index 0000000..89e2a55 --- /dev/null +++ b/omins.lv2/sample_and_hold.ttl @@ -0,0 +1,53 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/sample_and_hold> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Input" ; + lv2:symbol "in" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Trigger" ; + lv2:symbol "trigger" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 2 ; + lv2:name "Threshold" ; + lv2:symbol "threshold" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 3 ; + lv2:name "Continuous Triggering" ; + lv2:portProperty lv2:toggled ; + lv2:symbol "continuous" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 4 ; + lv2:name "Output" ; + lv2:symbol "out" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Thorsten Wilms" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Sample and Hold" ; + a lv2:Plugin . diff --git a/omins.lv2/signal_abs.ttl b/omins.lv2/signal_abs.ttl new file mode 100644 index 0000000..8914f2d --- /dev/null +++ b/omins.lv2/signal_abs.ttl @@ -0,0 +1,40 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/signal_abs> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Input" ; + lv2:symbol "port0" ; + a lv2:AudioPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 1 ; + lv2:index 1 ; + lv2:name "Sign" ; + lv2:portProperty lv2:toggled ; + lv2:symbol "port1" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 2 ; + lv2:name "Output" ; + lv2:symbol "port2" ; + a lv2:AudioPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Loki Davison" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Signed Absolute Value" ; + a lv2:Plugin . diff --git a/omins.lv2/slew_limiter.ttl b/omins.lv2/slew_limiter.ttl new file mode 100644 index 0000000..c3ee33f --- /dev/null +++ b/omins.lv2/slew_limiter.ttl @@ -0,0 +1,48 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix units: <http://lv2plug.in/ns/extensions/units#> . + +<http://drobilla.net/plugins/omins/slew_limiter> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Input" ; + lv2:symbol "in" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Rise rate" ; + lv2:symbol "rise_rate" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port ; + units:unit units:hz + ] , [ + lv2:index 2 ; + lv2:name "Fall rate" ; + lv2:symbol "fall_rate" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port ; + units:unit units:hz + ] , [ + lv2:index 3 ; + lv2:name "Output" ; + lv2:symbol "out" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Lars Luthman <larsl@users.sourceforge.net>" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Slew Limiter" ; + a lv2:Plugin . diff --git a/omins.lv2/slide.ttl b/omins.lv2/slide.ttl new file mode 100644 index 0000000..9c23af2 --- /dev/null +++ b/omins.lv2/slide.ttl @@ -0,0 +1,48 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix units: <http://lv2plug.in/ns/extensions/units#> . + +<http://drobilla.net/plugins/omins/slide> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Input" ; + lv2:symbol "in" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Rise time" ; + lv2:symbol "rise_time" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:index 2 ; + lv2:name "Fall time" ; + lv2:symbol "fall_time" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port ; + units:unit units:s + ] , [ + lv2:index 3 ; + lv2:name "Output" ; + lv2:symbol "out" ; + a lv2:CVPort , + lv2:OutputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Lars Luthman <larsl@users.sourceforge.net>" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Slide" ; + a lv2:Plugin . diff --git a/omins.lv2/waveguide_mesh.ttl b/omins.lv2/waveguide_mesh.ttl new file mode 100644 index 0000000..54f4189 --- /dev/null +++ b/omins.lv2/waveguide_mesh.ttl @@ -0,0 +1,70 @@ +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://drobilla.net/plugins/omins/waveguide_mesh> + lv2:microVersion 0 ; + lv2:minorVersion 0 ; + lv2:optionalFeature lv2:hardRTCapable ; + lv2:port [ + lv2:index 0 ; + lv2:name "Trigger" ; + lv2:symbol "port0" ; + a lv2:CVPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 1 ; + lv2:name "Output" ; + lv2:symbol "port1" ; + a lv2:AudioPort , + lv2:OutputPort , + lv2:Port + ] , [ + lv2:default 0.11005 ; + lv2:index 2 ; + lv2:maximum 0.22 ; + lv2:minimum 0.0001 ; + lv2:name "Tension" ; + lv2:symbol "port2" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:index 3 ; + lv2:name "Power" ; + lv2:symbol "port3" ; + a lv2:AudioPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 1 ; + lv2:index 4 ; + lv2:maximum 7.01 ; + lv2:minimum 0.95 ; + lv2:name "Excitation X" ; + lv2:portProperty lv2:integer ; + lv2:symbol "port4" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] , [ + lv2:default 1 ; + lv2:index 5 ; + lv2:maximum 7.01 ; + lv2:minimum 0.95 ; + lv2:name "Excitation Y" ; + lv2:portProperty lv2:integer ; + lv2:symbol "port5" ; + a lv2:ControlPort , + lv2:InputPort , + lv2:Port + ] ; + <http://purl.org/dc/elements/1.1/creator> "Loki Davison" ; + <http://purl.org/dc/elements/1.1/rights> "GPL" ; + doap:name "Simple Waveguide Mesh" ; + a lv2:Plugin . diff --git a/src/SConstruct b/src/SConstruct deleted file mode 100644 index 7749ebf..0000000 --- a/src/SConstruct +++ /dev/null @@ -1,7 +0,0 @@ -import glob - -env = Environment(); -env.Append(LINKFLAGS="-nostartfiles") - -for i in glob.glob("*.c"): - env.SharedLibrary(i[:-2], i) diff --git a/src/adenv.c b/src/adenv.c index 1c75688..81b54f4 100644 --- a/src/adenv.c +++ b/src/adenv.c @@ -1,5 +1,5 @@ /* - adenv.c - A LADSPA plugin to generate percussive (i.e no sustain time), linear AD envelopes. + adenv.c - A LV2 plugin to generate percussive (i.e no sustain time), linear AD envelopes. Copyright 2005 Loki Davison based on ADENV by Mike Rawes @@ -21,20 +21,11 @@ #define _XOPEN_SOURCE 500 /* strdup */ #include <stdlib.h> -#include <ladspa.h> +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> #include <stdio.h> #include <math.h> -#ifdef ENABLE_NLS -# include <locale.h> -# define G_(s) gettext(s) -#else -# define G_(s) (s) -#endif -#define G_NOP(s) s - #define ADENV_BASE_ID 2661 -#define ADENV_VARIANT_COUNT 1 #define ADENV_GATE 0 #define ADENV_TRIGGER 1 @@ -42,7 +33,7 @@ #define ADENV_DECAY 3 #define ADENV_OUTPUT 4 -LADSPA_Descriptor **dahdsr_descriptors = 0; +LV2_Descriptor **dahdsr_descriptors = 0; typedef enum { IDLE, @@ -51,39 +42,31 @@ typedef enum { } ADENVState; typedef struct { - LADSPA_Data *gate; - LADSPA_Data *trigger; - LADSPA_Data *attack; - LADSPA_Data *decay; - LADSPA_Data *output; - LADSPA_Data srate; - LADSPA_Data inv_srate; - LADSPA_Data last_gate; - LADSPA_Data last_trigger; - LADSPA_Data from_level; - LADSPA_Data level; + float *gate; + float *trigger; + float *attack; + float *decay; + float *output; + float srate; + float inv_srate; + float last_gate; + float last_trigger; + float from_level; + float level; ADENVState state; unsigned long samples; } Dahdsr; -const LADSPA_Descriptor * -ladspa_descriptor(unsigned long index) -{ - if (index < ADENV_VARIANT_COUNT) - return dahdsr_descriptors[index]; - - return 0; -} - -void -cleanupDahdsr(LADSPA_Handle instance) +static void +cleanup(LV2_Handle instance) { free(instance); } -void -connectPortDahdsr(LADSPA_Handle instance, - unsigned long port, LADSPA_Data * data) +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* data) { Dahdsr *plugin = (Dahdsr *) instance; @@ -106,20 +89,22 @@ connectPortDahdsr(LADSPA_Handle instance, } } -LADSPA_Handle -instantiateDahdsr(const LADSPA_Descriptor * descriptor, - unsigned long sample_rate) +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) { Dahdsr *plugin = (Dahdsr *) malloc(sizeof(Dahdsr)); - plugin->srate = (LADSPA_Data) sample_rate; + plugin->srate = (float) sample_rate; plugin->inv_srate = 1.0f / plugin->srate; - return (LADSPA_Handle) plugin; + return (LV2_Handle) plugin; } -void -activateDahdsr(LADSPA_Handle instance) +static void +activate(LV2_Handle instance) { Dahdsr *plugin = (Dahdsr *) instance; @@ -131,38 +116,38 @@ activateDahdsr(LADSPA_Handle instance) plugin->samples = 0; } -void -runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) +static void +run(LV2_Handle instance, uint32_t sample_count) { Dahdsr *plugin = (Dahdsr *) instance; /* Gate */ - LADSPA_Data *gate = plugin->gate; + float *gate = plugin->gate; /* Trigger */ - LADSPA_Data *trigger = plugin->trigger; + float *trigger = plugin->trigger; /* Attack Time (s) */ - LADSPA_Data attack = *(plugin->attack); + float attack = *(plugin->attack); /* Decay Time (s) */ - LADSPA_Data decay = *(plugin->decay); + float decay = *(plugin->decay); /* Envelope Out */ - LADSPA_Data *output = plugin->output; + float *output = plugin->output; /* Instance Data */ - LADSPA_Data srate = plugin->srate; - LADSPA_Data inv_srate = plugin->inv_srate; - LADSPA_Data last_gate = plugin->last_gate; - LADSPA_Data last_trigger = plugin->last_trigger; - LADSPA_Data from_level = plugin->from_level; - LADSPA_Data level = plugin->level; + float srate = plugin->srate; + float inv_srate = plugin->inv_srate; + float last_gate = plugin->last_gate; + float last_trigger = plugin->last_trigger; + float from_level = plugin->from_level; + float level = plugin->level; ADENVState state = plugin->state; unsigned long samples = plugin->samples; - LADSPA_Data gat, trg, att, dec; - LADSPA_Data elapsed; + float gat, trg, att, dec; + float elapsed; unsigned long s; /* Convert times into rates */ @@ -174,7 +159,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) * while (currentSample < endSample) Level += Level * ReleaseCoeff; */ - LADSPA_Data ReleaseCoeff = log(0.001) / (decay * srate); + float ReleaseCoeff = log(0.001) / (decay * srate); for (s = 0; s < sample_count; s++) { gat = gate[s]; @@ -201,7 +186,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case ATTACK: samples++; - elapsed = (LADSPA_Data) samples *att; + elapsed = (float) samples *att; if (elapsed > 1.0f) { state = DECAY; @@ -213,7 +198,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case DECAY: samples++; - elapsed = (LADSPA_Data) samples *dec; + elapsed = (float) samples *dec; if (elapsed > 1.0f) { state = IDLE; @@ -244,131 +229,22 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) plugin->samples = samples; } -void -_init(void) -{ - static const unsigned long ids[] = { ADENV_BASE_ID }; - static const char *labels[] = { "adenv" }; - static const char *names[] = { G_NOP("Percussive AD Envelope") }; - char **port_names; - LADSPA_PortDescriptor *port_descriptors; - LADSPA_PortRangeHint *port_range_hints; - LADSPA_Descriptor *descriptor; - - LADSPA_PortDescriptor gate_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor trigger_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor attack_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor decay_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor output_port_descriptors[] = - { LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO }; - - void (*run_functions[]) (LADSPA_Handle, unsigned long) = { - runDahdsr_Control}; - -#ifdef ENABLE_NLS - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); -#endif - - dahdsr_descriptors = - (LADSPA_Descriptor **) calloc(ADENV_VARIANT_COUNT, - sizeof(LADSPA_Descriptor)); - - if (dahdsr_descriptors) { - int i = 0; - - dahdsr_descriptors[i] = - (LADSPA_Descriptor *) malloc(sizeof(LADSPA_Descriptor)); - descriptor = dahdsr_descriptors[i]; - if (descriptor) { - descriptor->UniqueID = ids[i]; - descriptor->Label = labels[i]; - descriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - descriptor->Name = G_(names[i]); - descriptor->Maker = - "Loki Davison <ltdav1[at]student.monash.edu.au>"; - descriptor->Copyright = "GPL"; - - descriptor->PortCount = 5; - - port_descriptors = - (LADSPA_PortDescriptor *) calloc(5, - sizeof - (LADSPA_PortDescriptor)); - descriptor->PortDescriptors = - (const LADSPA_PortDescriptor *)port_descriptors; - - port_range_hints = - (LADSPA_PortRangeHint *) calloc(5, - sizeof(LADSPA_PortRangeHint)); - descriptor->PortRangeHints = - (const LADSPA_PortRangeHint *)port_range_hints; - - port_names = (char **)calloc(5, sizeof(char *)); - descriptor->PortNames = (const char **)port_names; - - /* Parameters for Gate */ - port_descriptors[ADENV_GATE] = gate_port_descriptors[i]; - port_names[ADENV_GATE] = G_("Gate"); - port_range_hints[ADENV_GATE].HintDescriptor = - LADSPA_HINT_TOGGLED; - - /* Parameters for Trigger */ - port_descriptors[ADENV_TRIGGER] = trigger_port_descriptors[i]; - port_names[ADENV_TRIGGER] = G_("Trigger"); - port_range_hints[ADENV_TRIGGER].HintDescriptor = - LADSPA_HINT_TOGGLED; - - /* Parameters for Attack Time (s) */ - port_descriptors[ADENV_ATTACK] = attack_port_descriptors[i]; - port_names[ADENV_ATTACK] = G_("Attack Time (s)"); - port_range_hints[ADENV_ATTACK].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[ADENV_ATTACK].LowerBound = 0.0f; - - /* Parameters for Decay Time (s) */ - port_descriptors[ADENV_DECAY] = decay_port_descriptors[i]; - port_names[ADENV_DECAY] = G_("Decay Time (s)"); - port_range_hints[ADENV_DECAY].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[ADENV_DECAY].LowerBound = 0.0f; - - /* Parameters for Envelope Out */ - port_descriptors[ADENV_OUTPUT] = output_port_descriptors[i]; - port_names[ADENV_OUTPUT] = G_("Envelope Out"); - port_range_hints[ADENV_OUTPUT].HintDescriptor = 0; - - descriptor->activate = activateDahdsr; - descriptor->cleanup = cleanupDahdsr; - descriptor->connect_port = connectPortDahdsr; - descriptor->deactivate = NULL; - descriptor->instantiate = instantiateDahdsr; - descriptor->run = run_functions[i]; - descriptor->run_adding = NULL; - descriptor->set_run_adding_gain = NULL; - } - } - -} - -void -_fini(void) +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/adenv", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) { - LADSPA_Descriptor *descriptor; - - if (dahdsr_descriptors) { - descriptor = dahdsr_descriptors[0]; - if (descriptor) { - free((LADSPA_PortDescriptor *) descriptor->PortDescriptors); - free((char **)descriptor->PortNames); - free((LADSPA_PortRangeHint *) descriptor->PortRangeHints); - free(descriptor); - } - free(dahdsr_descriptors); + switch (index) { + case 0: return &descriptor; + default: return NULL; } } diff --git a/src/adenv_lvl.c b/src/adenv_lvl.c index 1ba2a26..2c57530 100644 --- a/src/adenv_lvl.c +++ b/src/adenv_lvl.c @@ -1,5 +1,5 @@ /* - adenv.c - A LADSPA plugin to generate percussive (i.e no sustain time), linear AD envelopes. + adenv.c - A LV2 plugin to generate percussive (i.e no sustain time), linear AD envelopes. This one takes in levels to make filter sweeps/etc easier. Copyright 2005 Loki Davison @@ -22,18 +22,10 @@ #define _XOPEN_SOURCE 500 /* strdup */ #include <stdlib.h> -#include <ladspa.h> +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> #include <stdio.h> #include <math.h> -#ifdef ENABLE_NLS -# include <locale.h> -# define G_(s) gettext(s) -#else -# define G_(s) (s) -#endif -#define G_NOP(s) s - #define ADENVLVL_BASE_ID 2662 #define ADENVLVL_VARIANT_COUNT 1 @@ -47,8 +39,6 @@ #define ADENVLVL_OUTPUT 7 #define ADENVLVL_RESET 8 -LADSPA_Descriptor **dahdsr_descriptors = 0; - typedef enum { IDLE, ATTACK, @@ -56,43 +46,34 @@ typedef enum { } ADENVLVLState; typedef struct { - LADSPA_Data *gate; - LADSPA_Data *trigger; - LADSPA_Data *attack; - LADSPA_Data *reset; - LADSPA_Data *decay; - LADSPA_Data *start_level; - LADSPA_Data *attack_level; - LADSPA_Data *decay_level; - LADSPA_Data *output; - LADSPA_Data srate; - LADSPA_Data inv_srate; - LADSPA_Data last_gate; - LADSPA_Data last_trigger; - LADSPA_Data last_reset; - LADSPA_Data level; + float *gate; + float *trigger; + float *attack; + float *reset; + float *decay; + float *start_level; + float *attack_level; + float *decay_level; + float *output; + float srate; + float inv_srate; + float last_gate; + float last_trigger; + float last_reset; + float level; ADENVLVLState state; unsigned long samples; } Dahdsr; -const LADSPA_Descriptor * -ladspa_descriptor(unsigned long index) -{ - if (index < ADENVLVL_VARIANT_COUNT) - return dahdsr_descriptors[index]; - - return 0; -} - -void -cleanupDahdsr(LADSPA_Handle instance) +static void +cleanup(LV2_Handle instance) { free(instance); } -void -connectPortDahdsr(LADSPA_Handle instance, - unsigned long port, LADSPA_Data * data) +static void +connect_port(LV2_Handle instance, + uint32_t port, void * data) { Dahdsr *plugin = (Dahdsr *) instance; @@ -127,20 +108,22 @@ connectPortDahdsr(LADSPA_Handle instance, } } -LADSPA_Handle -instantiateDahdsr(const LADSPA_Descriptor * descriptor, - unsigned long sample_rate) +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) { Dahdsr *plugin = (Dahdsr *) malloc(sizeof(Dahdsr)); - plugin->srate = (LADSPA_Data) sample_rate; + plugin->srate = (float) sample_rate; plugin->inv_srate = 1.0f / plugin->srate; - return (LADSPA_Handle) plugin; + return (LV2_Handle) plugin; } -void -activateDahdsr(LADSPA_Handle instance) +static void +activate(LV2_Handle instance) { Dahdsr *plugin = (Dahdsr *) instance; @@ -152,50 +135,50 @@ activateDahdsr(LADSPA_Handle instance) plugin->samples = 0; } -void -runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) +static void +run(LV2_Handle instance, uint32_t sample_count) { Dahdsr *plugin = (Dahdsr *) instance; /* Gate */ - LADSPA_Data *gate = plugin->gate; + float *gate = plugin->gate; /* Trigger */ - LADSPA_Data *trigger = plugin->trigger; + float *trigger = plugin->trigger; /* Reset */ - LADSPA_Data *reset = plugin->reset; + float *reset = plugin->reset; /* Start Level */ - LADSPA_Data start_level = *(plugin->start_level); + float start_level = *(plugin->start_level); /* Attack Level */ - LADSPA_Data attack_level = *(plugin->attack_level); + float attack_level = *(plugin->attack_level); /* Decay Level */ - LADSPA_Data decay_level = *(plugin->decay_level); + float decay_level = *(plugin->decay_level); /* Attack Time (s) */ - LADSPA_Data attack = *(plugin->attack); + float attack = *(plugin->attack); /* Decay Time (s) */ - LADSPA_Data decay = *(plugin->decay); + float decay = *(plugin->decay); /* Envelope Out */ - LADSPA_Data *output = plugin->output; + float *output = plugin->output; /* Instance Data */ - LADSPA_Data srate = plugin->srate; - LADSPA_Data inv_srate = plugin->inv_srate; - LADSPA_Data last_gate = plugin->last_gate; - LADSPA_Data last_trigger = plugin->last_trigger; - LADSPA_Data last_reset = plugin->last_reset; - LADSPA_Data level = plugin->level; + float srate = plugin->srate; + float inv_srate = plugin->inv_srate; + float last_gate = plugin->last_gate; + float last_trigger = plugin->last_trigger; + float last_reset = plugin->last_reset; + float level = plugin->level; ADENVLVLState state = plugin->state; unsigned long samples = plugin->samples; - LADSPA_Data gat, trg, att, dec; - LADSPA_Data elapsed; + float gat, trg, att, dec; + float elapsed; unsigned long s; /* Convert times into rates */ @@ -216,9 +199,9 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) if (decay_level == 0) { decay_level = 0.0000001; } - LADSPA_Data ReleaseCoeff_att = + float ReleaseCoeff_att = (log(attack_level) - log(start_level)) / (attack * srate); - LADSPA_Data ReleaseCoeff_dec = + float ReleaseCoeff_dec = (log(decay_level) - log(attack_level)) / (decay * srate); for (s = 0; s < sample_count; s++) { @@ -253,7 +236,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) level = start_level; } samples++; - elapsed = (LADSPA_Data) samples *att; + elapsed = (float) samples *att; if (elapsed > 1.0f) { state = DECAY; @@ -265,7 +248,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case DECAY: samples++; - elapsed = (LADSPA_Data) samples *dec; + elapsed = (float) samples *dec; if (elapsed > 1.0f) { //fprintf(stderr, "finished decay, RC %f , level %f decay_level %f start %f\n", ReleaseCoeff_dec, level, decay_level, start_level); @@ -295,167 +278,22 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) plugin->samples = samples; } -void -_init(void) +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/adenv_lvl", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) { - static const unsigned long ids[] = { ADENVLVL_BASE_ID }; - static const char *labels[] = { "adenv_lvl" }; - static const char *names[] = - { G_NOP("Percussive AD Envelope with levels") }; - char **port_names; - LADSPA_PortDescriptor *port_descriptors; - LADSPA_PortRangeHint *port_range_hints; - LADSPA_Descriptor *descriptor; - - LADSPA_PortDescriptor gate_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor trigger_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor start_level_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor attack_level_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor decay_level_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor attack_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor decay_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor output_port_descriptors[] = - { LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO }; - - void (*run_functions[]) (LADSPA_Handle, unsigned long) = { - runDahdsr_Control}; - -#ifdef ENABLE_NLS - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); -#endif - - dahdsr_descriptors = - (LADSPA_Descriptor **) calloc(ADENVLVL_VARIANT_COUNT, - sizeof(LADSPA_Descriptor)); - - if (dahdsr_descriptors) { - int i = 0; - - dahdsr_descriptors[i] = - (LADSPA_Descriptor *) malloc(sizeof(LADSPA_Descriptor)); - descriptor = dahdsr_descriptors[i]; - if (descriptor) { - descriptor->UniqueID = ids[i]; - descriptor->Label = labels[i]; - descriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - descriptor->Name = G_(names[i]); - descriptor->Maker = - "Loki Davison <ltdav1[at]student.monash.edu.au>"; - descriptor->Copyright = "GPL"; - - descriptor->PortCount = 9; - - port_descriptors = - (LADSPA_PortDescriptor *) calloc(9, - sizeof - (LADSPA_PortDescriptor)); - descriptor->PortDescriptors = - (const LADSPA_PortDescriptor *)port_descriptors; - - port_range_hints = - (LADSPA_PortRangeHint *) calloc(9, - sizeof(LADSPA_PortRangeHint)); - descriptor->PortRangeHints = - (const LADSPA_PortRangeHint *)port_range_hints; - - port_names = (char **)calloc(9, sizeof(char *)); - descriptor->PortNames = (const char **)port_names; - - /* Parameters for Gate */ - port_descriptors[ADENVLVL_GATE] = gate_port_descriptors[i]; - port_names[ADENVLVL_GATE] = G_("Gate"); - port_range_hints[ADENVLVL_GATE].HintDescriptor = - LADSPA_HINT_TOGGLED; - - /* Parameters for Trigger */ - port_descriptors[ADENVLVL_TRIGGER] = trigger_port_descriptors[i]; - port_names[ADENVLVL_TRIGGER] = G_("Trigger"); - port_range_hints[ADENVLVL_TRIGGER].HintDescriptor = - LADSPA_HINT_TOGGLED; - /* Parameters for Reset */ - port_descriptors[ADENVLVL_RESET] = trigger_port_descriptors[i]; - port_names[ADENVLVL_RESET] = G_("Reset Level"); - port_range_hints[ADENVLVL_RESET].HintDescriptor = - LADSPA_HINT_TOGGLED; - - /* Parameters for Attack Time (s) */ - port_descriptors[ADENVLVL_ATTACK] = attack_port_descriptors[i]; - port_names[ADENVLVL_ATTACK] = G_("Attack Time (s)"); - port_range_hints[ADENVLVL_ATTACK].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[ADENVLVL_ATTACK].LowerBound = 0.0f; - - /* Parameters for Start Level */ - port_descriptors[ADENVLVL_START_LEVEL] = - start_level_port_descriptors[i]; - port_names[ADENVLVL_START_LEVEL] = G_("Initial Level"); - port_range_hints[ADENVLVL_START_LEVEL].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[ADENVLVL_START_LEVEL].LowerBound = 0.0f; - - /* Parameters for Attack to level (s) */ - port_descriptors[ADENVLVL_ATTACK_LEVEL] = - attack_level_port_descriptors[i]; - port_names[ADENVLVL_ATTACK_LEVEL] = G_("Attack to Level"); - port_range_hints[ADENVLVL_ATTACK_LEVEL].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_1; - port_range_hints[ADENVLVL_ATTACK_LEVEL].LowerBound = 0.0f; - - /* Parameters for Decay to level (s) */ - port_descriptors[ADENVLVL_DECAY_LEVEL] = - decay_level_port_descriptors[i]; - port_names[ADENVLVL_DECAY_LEVEL] = G_("Decay to Level"); - port_range_hints[ADENVLVL_DECAY_LEVEL].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[ADENVLVL_DECAY_LEVEL].LowerBound = 0.0f; - - /* Parameters for Decay Time (s) */ - port_descriptors[ADENVLVL_DECAY] = decay_port_descriptors[i]; - port_names[ADENVLVL_DECAY] = G_("Decay Time (s)"); - port_range_hints[ADENVLVL_DECAY].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[ADENVLVL_DECAY].LowerBound = 0.0f; - - /* Parameters for Envelope Out */ - port_descriptors[ADENVLVL_OUTPUT] = output_port_descriptors[i]; - port_names[ADENVLVL_OUTPUT] = G_("Envelope Out"); - port_range_hints[ADENVLVL_OUTPUT].HintDescriptor = 0; - - descriptor->activate = activateDahdsr; - descriptor->cleanup = cleanupDahdsr; - descriptor->connect_port = connectPortDahdsr; - descriptor->deactivate = NULL; - descriptor->instantiate = instantiateDahdsr; - descriptor->run = run_functions[i]; - descriptor->run_adding = NULL; - descriptor->set_run_adding_gain = NULL; - } - } - -} - -void -_fini(void) -{ - LADSPA_Descriptor *descriptor; - - if (dahdsr_descriptors) { - descriptor = dahdsr_descriptors[0]; - if (descriptor) { - free((LADSPA_PortDescriptor *) descriptor->PortDescriptors); - free((char **)descriptor->PortNames); - free((LADSPA_PortRangeHint *) descriptor->PortRangeHints); - free(descriptor); - } - free(dahdsr_descriptors); + switch (index) { + case 0: return &descriptor; + default: return NULL; } } diff --git a/src/comparison.c b/src/comparison.c new file mode 100644 index 0000000..ea8c97d --- /dev/null +++ b/src/comparison.c @@ -0,0 +1,142 @@ +/* Comparison plugin. + * Copyright 2005 Thorsten Wilms. + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#include "lv2.h" + +#define COMP_BASE_ID 4440 + +#define COMP_NUM_PORTS 6 + +/* Port Numbers */ +#define COMP_A 0 +#define COMP_B 1 +#define COMP_LARGER 2 +#define COMP_SMALLER 3 +#define COMP_A_LARGER 4 +#define COMP_EQUAL 5 + +/* All state information for plugin */ +typedef struct { + /* Ports */ + float *a_buffer; + float *b_buffer; + float *larger_buffer; + float *smaller_buffer; + float *a_larger_buffer; + float *equal_buffer; +} Comp; + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + Comp* plugin = malloc(sizeof(Comp)); + plugin->a_buffer = NULL; + plugin->b_buffer = NULL; + plugin->larger_buffer = NULL; + plugin->smaller_buffer = NULL; + plugin->a_larger_buffer = NULL; + plugin->equal_buffer = NULL; + return (LV2_Handle)plugin; +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* location) +{ + Comp* plugin; + + plugin = (Comp*)instance; + switch (port) { + case COMP_A: + plugin->a_buffer = location; + break; + case COMP_B: + plugin->b_buffer = location; + break; + case COMP_LARGER: + plugin->larger_buffer = location; + break; + case COMP_SMALLER: + plugin->smaller_buffer = location; + break; + case COMP_A_LARGER: + plugin->a_larger_buffer = location; + break; + case COMP_EQUAL: + plugin->equal_buffer = location; + break; + } +} + +static void +run(LV2_Handle instance, uint32_t nframes) +{ + Comp* const plugin = (Comp*)instance; + const float* const a = plugin->a_buffer; + const float* const b = plugin->b_buffer; + float* const larger = plugin->larger_buffer; + float* const smaller = plugin->smaller_buffer; + float* const a_larger = plugin->a_larger_buffer; + float* const equal = plugin->equal_buffer; + unsigned long i; + + for (i = 0; i < nframes; i++) { + equal[i] = (a[i] == b[i]) ? 1.0 : 0.0; + larger[i] = (a[i] > b[i]) ? a[i] : b[i]; + smaller[i] = (a[i] < b[i]) ? a[i] : b[i]; + a_larger[i] = (a[i] > b[i]) ? 1.0 : 0.0; + } +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/comparison", + instantiate, + connect_port, + NULL, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/comparison_4440.c b/src/comparison_4440.c deleted file mode 100644 index e26aea1..0000000 --- a/src/comparison_4440.c +++ /dev/null @@ -1,282 +0,0 @@ -/* Comparison plugin. - * Copyright 2005 Thorsten Wilms. - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> - -#include "ladspa.h" - -#define COMP_BASE_ID 4440 - -#define COMP_NUM_PORTS 6 - -/* Port Numbers */ -#define COMP_A 0 -#define COMP_B 1 -#define COMP_LARGER 2 -#define COMP_SMALLER 3 -#define COMP_A_LARGER 4 -#define COMP_EQUAL 5 - -/* All state information for plugin */ -typedef struct { - /* Ports */ - LADSPA_Data *a_buffer; - LADSPA_Data *b_buffer; - LADSPA_Data *larger_buffer; - LADSPA_Data *smaller_buffer; - LADSPA_Data *a_larger_buffer; - LADSPA_Data *equal_buffer; -} Comp; - -/* Construct a new plugin instance */ -LADSPA_Handle -comp_instantiate(const LADSPA_Descriptor* descriptor, - unsigned long srate) -{ - Comp* plugin = malloc(sizeof(Comp)); - plugin->a_buffer = NULL; - plugin->b_buffer = NULL; - plugin->larger_buffer = NULL; - plugin->smaller_buffer = NULL; - plugin->a_larger_buffer = NULL; - plugin->equal_buffer = NULL; - return (LADSPA_Handle)plugin; -} - -/* Connect a port to a data location */ -void -comp_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - Comp* plugin; - - plugin = (Comp*)instance; - switch (port) { - case COMP_A: - plugin->a_buffer = location; - break; - case COMP_B: - plugin->b_buffer = location; - break; - case COMP_LARGER: - plugin->larger_buffer = location; - break; - case COMP_SMALLER: - plugin->smaller_buffer = location; - break; - case COMP_A_LARGER: - plugin->a_larger_buffer = location; - break; - case COMP_EQUAL: - plugin->equal_buffer = location; - break; - } -} - -void -comp_run_ac(LADSPA_Handle instance, unsigned long nframes) -{ - Comp* const plugin = (Comp*)instance; - const LADSPA_Data* const a = plugin->a_buffer; - const LADSPA_Data const b = *plugin->b_buffer; - LADSPA_Data* const larger = plugin->larger_buffer; - LADSPA_Data* const smaller = plugin->smaller_buffer; - LADSPA_Data* const a_larger = plugin->a_larger_buffer; - LADSPA_Data* const equal = plugin->equal_buffer; - unsigned long i; - - for (i = 0; i < nframes; i++) { - equal[i] = (a[i] == b) ? 1.0 : 0.0; - larger[i] = (a[i] > b) ? a[i] : b; - smaller[i] = (a[i] < b) ? a[i] : b; - a_larger[i] = (a[i] > b) ? 1.0 : 0.0; - } -} - -void -comp_run_aa(LADSPA_Handle instance, unsigned long nframes) -{ - Comp* const plugin = (Comp*)instance; - const LADSPA_Data* const a = plugin->a_buffer; - const LADSPA_Data* const b = plugin->b_buffer; - LADSPA_Data* const larger = plugin->larger_buffer; - LADSPA_Data* const smaller = plugin->smaller_buffer; - LADSPA_Data* const a_larger = plugin->a_larger_buffer; - LADSPA_Data* const equal = plugin->equal_buffer; - unsigned long i; - - for (i = 0; i < nframes; i++) { - equal[i] = (a[i] == b[i]) ? 1.0 : 0.0; - larger[i] = (a[i] > b[i]) ? a[i] : b[i]; - smaller[i] = (a[i] < b[i]) ? a[i] : b[i]; - a_larger[i] = (a[i] > b[i]) ? 1.0 : 0.0; - } -} - -void -comp_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* comp_ac_desc = NULL; -LADSPA_Descriptor* comp_aa_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - comp_ac_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - comp_aa_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (comp_ac_desc) { - - comp_ac_desc->UniqueID = COMP_BASE_ID; - comp_ac_desc->Label = strdup("comp_ac"); - comp_ac_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - comp_ac_desc->Name = strdup("Comparison (AC)"); - comp_ac_desc->Maker = strdup("Thorsten Wilms"); - comp_ac_desc->Copyright = strdup("GPL"); - comp_ac_desc->PortCount = COMP_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(COMP_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - comp_ac_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[COMP_A] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[COMP_B] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[COMP_LARGER] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_descriptors[COMP_SMALLER] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_descriptors[COMP_A_LARGER] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_descriptors[COMP_EQUAL] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(COMP_NUM_PORTS, sizeof(char*)); - comp_ac_desc->PortNames = (const char**)port_names; - port_names[COMP_A] = strdup("A"); - port_names[COMP_B] = strdup("B"); - port_names[COMP_LARGER] = strdup("Larger"); - port_names[COMP_SMALLER] = strdup("Smaller"); - port_names[COMP_A_LARGER] = strdup("A > B"); - port_names[COMP_EQUAL] = strdup("A = B"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(COMP_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - comp_ac_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[COMP_A].HintDescriptor = 0; - port_range_hints[COMP_B].HintDescriptor = 0; - port_range_hints[COMP_LARGER].HintDescriptor = 0; - port_range_hints[COMP_SMALLER].HintDescriptor = 0; - port_range_hints[COMP_A_LARGER].HintDescriptor = 0; - port_range_hints[COMP_EQUAL].HintDescriptor = 0; - comp_ac_desc->instantiate = comp_instantiate; - comp_ac_desc->connect_port = comp_connect_port; - comp_ac_desc->activate = NULL; - comp_ac_desc->run = comp_run_ac; - comp_ac_desc->run_adding = NULL; - comp_ac_desc->set_run_adding_gain = NULL; - comp_ac_desc->deactivate = NULL; - comp_ac_desc->cleanup = comp_cleanup; - } - - if (comp_aa_desc) { - - comp_aa_desc->UniqueID = COMP_BASE_ID+1; - comp_aa_desc->Label = strdup("comp_aa"); - comp_aa_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - comp_aa_desc->Name = strdup("Comparison (AA)"); - comp_aa_desc->Maker = strdup("Thorsten Wilms"); - comp_aa_desc->Copyright = strdup("GPL"); - comp_aa_desc->PortCount = COMP_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(COMP_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - comp_aa_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[COMP_A] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[COMP_B] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[COMP_LARGER] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_descriptors[COMP_SMALLER] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_descriptors[COMP_A_LARGER] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_descriptors[COMP_EQUAL] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(COMP_NUM_PORTS, sizeof(char*)); - comp_aa_desc->PortNames = (const char**)port_names; - port_names[COMP_A] = strdup("A"); - port_names[COMP_B] = strdup("B"); - port_names[COMP_LARGER] = strdup("Larger"); - port_names[COMP_SMALLER] = strdup("Smaller"); - port_names[COMP_A_LARGER] = strdup("A > B"); - port_names[COMP_EQUAL] = strdup("A = B"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(COMP_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - comp_aa_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[COMP_A].HintDescriptor = 0; - port_range_hints[COMP_B].HintDescriptor = 0; - port_range_hints[COMP_LARGER].HintDescriptor = 0; - port_range_hints[COMP_SMALLER].HintDescriptor = 0; - port_range_hints[COMP_A_LARGER].HintDescriptor = 0; - port_range_hints[COMP_EQUAL].HintDescriptor = 0; - comp_aa_desc->instantiate = comp_instantiate; - comp_aa_desc->connect_port = comp_connect_port; - comp_aa_desc->activate = NULL; - comp_aa_desc->run = comp_run_aa; - comp_aa_desc->run_adding = NULL; - comp_aa_desc->set_run_adding_gain = NULL; - comp_aa_desc->deactivate = NULL; - comp_aa_desc->cleanup = comp_cleanup; - } -} - -void -comp_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - comp_delete_descriptor(comp_ac_desc); - comp_delete_descriptor(comp_aa_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return comp_ac_desc; - case 1: - return comp_aa_desc; - default: - return NULL; - } -} - diff --git a/src/dahdsr_fexp.c b/src/dahdsr_fexp.c index 960d8e8..116316b 100644 --- a/src/dahdsr_fexp.c +++ b/src/dahdsr_fexp.c @@ -1,5 +1,5 @@ /* - dahdsr_fexp.c - A LADSPA plugin to generate DAHDSR envelopes + dahdsr_fexp.c - A LV2 plugin to generate DAHDSR envelopes exponential attack, decay and release version. Copyright 2005 Loki Davison, based on DAHDSR by Mike Rawes @@ -20,19 +20,9 @@ #define _XOPEN_SOURCE 500 /* strdup */ #include <stdlib.h> -#include <ladspa.h> +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> #include <math.h> -#ifdef ENABLE_NLS -# include <locale.h> -# define G_(s) gettext(s) -#else -# define G_(s) (s) -#endif -#define G_NOP(s) s - -#define DAHDSR_VARIANT_COUNT 1 - #define DAHDSR_GATE 0 #define DAHDSR_TRIGGER 1 #define DAHDSR_DELAY 2 @@ -43,8 +33,6 @@ #define DAHDSR_RELEASE 7 #define DAHDSR_OUTPUT 8 -LADSPA_Descriptor **dahdsr_descriptors = 0; - typedef enum { IDLE, DELAY, @@ -56,43 +44,34 @@ typedef enum { } DAHDSRState; typedef struct { - LADSPA_Data *gate; - LADSPA_Data *trigger; - LADSPA_Data *delay; - LADSPA_Data *attack; - LADSPA_Data *hold; - LADSPA_Data *decay; - LADSPA_Data *sustain; - LADSPA_Data *release; - LADSPA_Data *output; - LADSPA_Data srate; - LADSPA_Data inv_srate; - LADSPA_Data last_gate; - LADSPA_Data last_trigger; - LADSPA_Data from_level; - LADSPA_Data level; + float *gate; + float *trigger; + float *delay; + float *attack; + float *hold; + float *decay; + float *sustain; + float *release; + float *output; + float srate; + float inv_srate; + float last_gate; + float last_trigger; + float from_level; + float level; DAHDSRState state; unsigned long samples; } Dahdsr; -const LADSPA_Descriptor * -ladspa_descriptor(unsigned long index) -{ - if (index < DAHDSR_VARIANT_COUNT) - return dahdsr_descriptors[index]; - - return 0; -} - -void -cleanupDahdsr(LADSPA_Handle instance) +static void +cleanup(LV2_Handle instance) { free(instance); } -void -connectPortDahdsr(LADSPA_Handle instance, - unsigned long port, LADSPA_Data * data) +static void +connect_port(LV2_Handle instance, + uint32_t port, void* data) { Dahdsr *plugin = (Dahdsr *) instance; @@ -127,20 +106,22 @@ connectPortDahdsr(LADSPA_Handle instance, } } -LADSPA_Handle -instantiateDahdsr(const LADSPA_Descriptor * descriptor, - unsigned long sample_rate) +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) { Dahdsr *plugin = (Dahdsr *) malloc(sizeof(Dahdsr)); - plugin->srate = (LADSPA_Data) sample_rate; + plugin->srate = (float) sample_rate; plugin->inv_srate = 1.0f / plugin->srate; - return (LADSPA_Handle) plugin; + return (LV2_Handle) plugin; } -void -activateDahdsr(LADSPA_Handle instance) +static void +activate(LV2_Handle instance) { Dahdsr *plugin = (Dahdsr *) instance; @@ -152,50 +133,50 @@ activateDahdsr(LADSPA_Handle instance) plugin->samples = 0; } -void -runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) +static void +run(LV2_Handle instance, uint32_t sample_count) { Dahdsr *plugin = (Dahdsr *) instance; /* Gate */ - LADSPA_Data *gate = plugin->gate; + float *gate = plugin->gate; /* Trigger */ - LADSPA_Data *trigger = plugin->trigger; + float *trigger = plugin->trigger; /* Delay Time (s) */ - LADSPA_Data delay = *(plugin->delay); + float delay = *(plugin->delay); /* Attack Time (s) */ - LADSPA_Data attack = *(plugin->attack); + float attack = *(plugin->attack); /* Hold Time (s) */ - LADSPA_Data hold = *(plugin->hold); + float hold = *(plugin->hold); /* Decay Time (s) */ - LADSPA_Data decay = *(plugin->decay); + float decay = *(plugin->decay); /* Sustain Level */ - LADSPA_Data sustain = *(plugin->sustain); + float sustain = *(plugin->sustain); /* Release Time (s) */ - LADSPA_Data release = *(plugin->release); + float release = *(plugin->release); /* Envelope Out */ - LADSPA_Data *output = plugin->output; + float *output = plugin->output; /* Instance Data */ - LADSPA_Data srate = plugin->srate; - LADSPA_Data inv_srate = plugin->inv_srate; - LADSPA_Data last_gate = plugin->last_gate; - LADSPA_Data last_trigger = plugin->last_trigger; - LADSPA_Data from_level = plugin->from_level; - LADSPA_Data level = plugin->level; + float srate = plugin->srate; + float inv_srate = plugin->inv_srate; + float last_gate = plugin->last_gate; + float last_trigger = plugin->last_trigger; + float from_level = plugin->from_level; + float level = plugin->level; DAHDSRState state = plugin->state; unsigned long samples = plugin->samples; - LADSPA_Data gat, trg, del, att, hld, dec, sus, rel; - LADSPA_Data elapsed; + float gat, trg, del, att, hld, dec, sus, rel; + float elapsed; unsigned long s; /* Convert times into rates */ @@ -213,9 +194,9 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) sus = 1.0f; } - LADSPA_Data ReleaseCoeff_att = (0 - log(0.001)) / (attack * srate); - LADSPA_Data ReleaseCoeff_dec = (log(sus)) / (decay * srate); - LADSPA_Data ReleaseCoeff_rel = + float ReleaseCoeff_att = (0 - log(0.001)) / (attack * srate); + float ReleaseCoeff_dec = (log(sus)) / (decay * srate); + float ReleaseCoeff_rel = (log(0.001) - log(sus)) / (release * srate); for (s = 0; s < sample_count; s++) { @@ -257,7 +238,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case DELAY: samples++; - elapsed = (LADSPA_Data) samples *del; + elapsed = (float) samples *del; if (elapsed > 1.0f) { state = att < srate ? ATTACK @@ -270,7 +251,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case ATTACK: samples++; - elapsed = (LADSPA_Data) samples *att; + elapsed = (float) samples *att; if (elapsed > 1.0f) { state = hld < srate ? HOLD @@ -285,7 +266,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case HOLD: samples++; - elapsed = (LADSPA_Data) samples *hld; + elapsed = (float) samples *hld; if (elapsed > 1.0f) { state = dec < srate ? DECAY @@ -295,7 +276,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case DECAY: samples++; - elapsed = (LADSPA_Data) samples *dec; + elapsed = (float) samples *dec; if (elapsed > 1.0f) { state = gat > 0.0f ? SUSTAIN : (rel < srate ? RELEASE : IDLE); @@ -310,7 +291,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case RELEASE: samples++; - elapsed = (LADSPA_Data) samples *rel; + elapsed = (float) samples *rel; if (elapsed > 1.0f) { state = IDLE; @@ -339,172 +320,22 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) plugin->samples = samples; } -void -_init(void) +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/dahdsr_fexp", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) { - static const unsigned long ids[] = { 2664 }; - static const char *labels[] = { "dahdsr_fexp" }; - static const char *names[] = { G_NOP("DAHDSR Envelope full exp, adr") }; - char **port_names; - LADSPA_PortDescriptor *port_descriptors; - LADSPA_PortRangeHint *port_range_hints; - LADSPA_Descriptor *descriptor; - - LADSPA_PortDescriptor gate_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor trigger_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor delay_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor attack_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor hold_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor decay_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor sustain_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor release_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor output_port_descriptors[] = - { LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO }; - - void (*run_functions[]) (LADSPA_Handle, unsigned long) = { - runDahdsr_Control}; - -#ifdef ENABLE_NLS - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); -#endif - - dahdsr_descriptors = - (LADSPA_Descriptor **) calloc(DAHDSR_VARIANT_COUNT, - sizeof(LADSPA_Descriptor)); - - if (dahdsr_descriptors) { - int i = 0; - - dahdsr_descriptors[i] = - (LADSPA_Descriptor *) malloc(sizeof(LADSPA_Descriptor)); - descriptor = dahdsr_descriptors[i]; - if (descriptor) { - descriptor->UniqueID = ids[i]; - descriptor->Label = labels[i]; - descriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - descriptor->Name = G_(names[i]); - descriptor->Maker = - "Loki Davison <ltdav1[at]student.monash.edu.au>"; - descriptor->Copyright = "GPL"; - - descriptor->PortCount = 9; - - port_descriptors = - (LADSPA_PortDescriptor *) calloc(9, - sizeof - (LADSPA_PortDescriptor)); - descriptor->PortDescriptors = - (const LADSPA_PortDescriptor *)port_descriptors; - - port_range_hints = - (LADSPA_PortRangeHint *) calloc(9, - sizeof(LADSPA_PortRangeHint)); - descriptor->PortRangeHints = - (const LADSPA_PortRangeHint *)port_range_hints; - - port_names = (char **)calloc(9, sizeof(char *)); - descriptor->PortNames = (const char **)port_names; - - /* Parameters for Gate */ - port_descriptors[DAHDSR_GATE] = gate_port_descriptors[i]; - port_names[DAHDSR_GATE] = G_("Gate"); - port_range_hints[DAHDSR_GATE].HintDescriptor = - LADSPA_HINT_TOGGLED; - - /* Parameters for Trigger */ - port_descriptors[DAHDSR_TRIGGER] = trigger_port_descriptors[i]; - port_names[DAHDSR_TRIGGER] = G_("Trigger"); - port_range_hints[DAHDSR_TRIGGER].HintDescriptor = - LADSPA_HINT_TOGGLED; - - /* Parameters for Delay Time (s) */ - port_descriptors[DAHDSR_DELAY] = delay_port_descriptors[i]; - port_names[DAHDSR_DELAY] = G_("Delay Time (s)"); - port_range_hints[DAHDSR_DELAY].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_DELAY].LowerBound = 0.0f; - - /* Parameters for Attack Time (s) */ - port_descriptors[DAHDSR_ATTACK] = attack_port_descriptors[i]; - port_names[DAHDSR_ATTACK] = G_("Attack Time (s)"); - port_range_hints[DAHDSR_ATTACK].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_ATTACK].LowerBound = 0.0f; - - /* Parameters for Hold Time (s) */ - port_descriptors[DAHDSR_HOLD] = hold_port_descriptors[i]; - port_names[DAHDSR_HOLD] = G_("Hold Time (s)"); - port_range_hints[DAHDSR_HOLD].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_HOLD].LowerBound = 0.0f; - - /* Parameters for Decay Time (s) */ - port_descriptors[DAHDSR_DECAY] = decay_port_descriptors[i]; - port_names[DAHDSR_DECAY] = G_("Decay Time (s)"); - port_range_hints[DAHDSR_DECAY].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_DECAY].LowerBound = 0.0f; - - /* Parameters for Sustain Level */ - port_descriptors[DAHDSR_SUSTAIN] = sustain_port_descriptors[i]; - port_names[DAHDSR_SUSTAIN] = G_("Sustain Level"); - port_range_hints[DAHDSR_SUSTAIN].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | - LADSPA_HINT_DEFAULT_MAXIMUM; - port_range_hints[DAHDSR_SUSTAIN].LowerBound = 0.0f; - port_range_hints[DAHDSR_SUSTAIN].UpperBound = 1.0f; - - /* Parameters for Release Time (s) */ - port_descriptors[DAHDSR_RELEASE] = release_port_descriptors[i]; - port_names[DAHDSR_RELEASE] = G_("Release Time (s)"); - port_range_hints[DAHDSR_RELEASE].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_RELEASE].LowerBound = 0.0f; - - /* Parameters for Envelope Out */ - port_descriptors[DAHDSR_OUTPUT] = output_port_descriptors[i]; - port_names[DAHDSR_OUTPUT] = G_("Envelope Out"); - port_range_hints[DAHDSR_OUTPUT].HintDescriptor = 0; - - descriptor->activate = activateDahdsr; - descriptor->cleanup = cleanupDahdsr; - descriptor->connect_port = connectPortDahdsr; - descriptor->deactivate = NULL; - descriptor->instantiate = instantiateDahdsr; - descriptor->run = run_functions[i]; - descriptor->run_adding = NULL; - descriptor->set_run_adding_gain = NULL; - - } - } -} - -void -_fini(void) -{ - LADSPA_Descriptor *descriptor; - int i; - - if (dahdsr_descriptors) { - for (i = 0; i < DAHDSR_VARIANT_COUNT; i++) { - descriptor = dahdsr_descriptors[i]; - if (descriptor) { - free((LADSPA_PortDescriptor *) descriptor->PortDescriptors); - free((char **)descriptor->PortNames); - free((LADSPA_PortRangeHint *) descriptor->PortRangeHints); - free(descriptor); - } - } - free(dahdsr_descriptors); + switch (index) { + case 0: return &descriptor; + default: return NULL; } } diff --git a/src/dahdsr_hexp.c b/src/dahdsr_hexp.c index e0147e4..32e9dec 100644 --- a/src/dahdsr_hexp.c +++ b/src/dahdsr_hexp.c @@ -1,5 +1,5 @@ /* - dahdsr.so.c - A LADSPA plugin to generate DAHDSR envelopes + dahdsr.so.c - A LV2 plugin to generate DAHDSR envelopes linear attack, exponential decay and release version. Copyright 2005 Loki Davison, based on DAHDSR by Mike Rawes @@ -20,19 +20,9 @@ #define _XOPEN_SOURCE 500 /* strdup */ #include <stdlib.h> -#include <ladspa.h> +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> #include <math.h> -#ifdef ENABLE_NLS -# include <locale.h> -# define G_(s) gettext(s) -#else -# define G_(s) (s) -#endif -#define G_NOP(s) s - -#define DAHDSR_VARIANT_COUNT 1 - #define DAHDSR_GATE 0 #define DAHDSR_TRIGGER 1 #define DAHDSR_DELAY 2 @@ -43,7 +33,7 @@ #define DAHDSR_RELEASE 7 #define DAHDSR_OUTPUT 8 -LADSPA_Descriptor **dahdsr_descriptors = 0; +LV2_Descriptor **dahdsr_descriptors = 0; typedef enum { IDLE, @@ -56,43 +46,35 @@ typedef enum { } DAHDSRState; typedef struct { - LADSPA_Data *gate; - LADSPA_Data *trigger; - LADSPA_Data *delay; - LADSPA_Data *attack; - LADSPA_Data *hold; - LADSPA_Data *decay; - LADSPA_Data *sustain; - LADSPA_Data *release; - LADSPA_Data *output; - LADSPA_Data srate; - LADSPA_Data inv_srate; - LADSPA_Data last_gate; - LADSPA_Data last_trigger; - LADSPA_Data from_level; - LADSPA_Data level; + float *gate; + float *trigger; + float *delay; + float *attack; + float *hold; + float *decay; + float *sustain; + float *release; + float *output; + float srate; + float inv_srate; + float last_gate; + float last_trigger; + float from_level; + float level; DAHDSRState state; unsigned long samples; } Dahdsr; -const LADSPA_Descriptor * -ladspa_descriptor(unsigned long index) -{ - if (index < DAHDSR_VARIANT_COUNT) - return dahdsr_descriptors[index]; - - return 0; -} - -void -cleanupDahdsr(LADSPA_Handle instance) +static void +cleanup(LV2_Handle instance) { free(instance); } -void -connectPortDahdsr(LADSPA_Handle instance, - unsigned long port, LADSPA_Data * data) +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* data) { Dahdsr *plugin = (Dahdsr *) instance; @@ -127,20 +109,22 @@ connectPortDahdsr(LADSPA_Handle instance, } } -LADSPA_Handle -instantiateDahdsr(const LADSPA_Descriptor * descriptor, - unsigned long sample_rate) +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) { Dahdsr *plugin = (Dahdsr *) malloc(sizeof(Dahdsr)); - plugin->srate = (LADSPA_Data) sample_rate; + plugin->srate = (float) sample_rate; plugin->inv_srate = 1.0f / plugin->srate; - return (LADSPA_Handle) plugin; + return (LV2_Handle) plugin; } -void -activateDahdsr(LADSPA_Handle instance) +static void +activate(LV2_Handle instance) { Dahdsr *plugin = (Dahdsr *) instance; @@ -152,50 +136,50 @@ activateDahdsr(LADSPA_Handle instance) plugin->samples = 0; } -void -runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) +static void +run(LV2_Handle instance, uint32_t sample_count) { Dahdsr *plugin = (Dahdsr *) instance; /* Gate */ - LADSPA_Data *gate = plugin->gate; + float *gate = plugin->gate; /* Trigger */ - LADSPA_Data *trigger = plugin->trigger; + float *trigger = plugin->trigger; /* Delay Time (s) */ - LADSPA_Data delay = *(plugin->delay); + float delay = *(plugin->delay); /* Attack Time (s) */ - LADSPA_Data attack = *(plugin->attack); + float attack = *(plugin->attack); /* Hold Time (s) */ - LADSPA_Data hold = *(plugin->hold); + float hold = *(plugin->hold); /* Decay Time (s) */ - LADSPA_Data decay = *(plugin->decay); + float decay = *(plugin->decay); /* Sustain Level */ - LADSPA_Data sustain = *(plugin->sustain); + float sustain = *(plugin->sustain); /* Release Time (s) */ - LADSPA_Data release = *(plugin->release); + float release = *(plugin->release); /* Envelope Out */ - LADSPA_Data *output = plugin->output; + float *output = plugin->output; /* Instance Data */ - LADSPA_Data srate = plugin->srate; - LADSPA_Data inv_srate = plugin->inv_srate; - LADSPA_Data last_gate = plugin->last_gate; - LADSPA_Data last_trigger = plugin->last_trigger; - LADSPA_Data from_level = plugin->from_level; - LADSPA_Data level = plugin->level; + float srate = plugin->srate; + float inv_srate = plugin->inv_srate; + float last_gate = plugin->last_gate; + float last_trigger = plugin->last_trigger; + float from_level = plugin->from_level; + float level = plugin->level; DAHDSRState state = plugin->state; unsigned long samples = plugin->samples; - LADSPA_Data gat, trg, del, att, hld, dec, sus, rel; - LADSPA_Data elapsed; + float gat, trg, del, att, hld, dec, sus, rel; + float elapsed; unsigned long s; /* Convert times into rates */ @@ -213,9 +197,9 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) sus = 1.0f; } - //LADSPA_Data ReleaseCoeff_att = (0 - log(0.001)) / (attack * srate); - LADSPA_Data ReleaseCoeff_dec = (log(sus)) / (decay * srate); - LADSPA_Data ReleaseCoeff_rel = + //float ReleaseCoeff_att = (0 - log(0.001)) / (attack * srate); + float ReleaseCoeff_dec = (log(sus)) / (decay * srate); + float ReleaseCoeff_rel = (log(0.001) - log(sus)) / (release * srate); for (s = 0; s < sample_count; s++) { @@ -257,7 +241,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case DELAY: samples++; - elapsed = (LADSPA_Data) samples *del; + elapsed = (float) samples *del; if (elapsed > 1.0f) { state = att < srate ? ATTACK @@ -270,7 +254,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case ATTACK: samples++; - elapsed = (LADSPA_Data) samples *att; + elapsed = (float) samples *att; if (elapsed > 1.0f) { state = hld < srate ? HOLD @@ -285,7 +269,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case HOLD: samples++; - elapsed = (LADSPA_Data) samples *hld; + elapsed = (float) samples *hld; if (elapsed > 1.0f) { state = dec < srate ? DECAY @@ -295,7 +279,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case DECAY: samples++; - elapsed = (LADSPA_Data) samples *dec; + elapsed = (float) samples *dec; if (elapsed > 1.0f) { state = gat > 0.0f ? SUSTAIN : (rel < srate ? RELEASE : IDLE); @@ -310,7 +294,7 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) break; case RELEASE: samples++; - elapsed = (LADSPA_Data) samples *rel; + elapsed = (float) samples *rel; if (elapsed > 1.0f) { state = IDLE; @@ -339,173 +323,22 @@ runDahdsr_Control(LADSPA_Handle instance, unsigned long sample_count) plugin->samples = samples; } -void -_init(void) -{ - static const unsigned long ids[] = { 2663 }; - static const char *labels[] = { "dahdsr_hexp" }; - static const char *names[] = - { G_NOP("DAHDSR Envelope linear attack exp dr") }; - char **port_names; - LADSPA_PortDescriptor *port_descriptors; - LADSPA_PortRangeHint *port_range_hints; - LADSPA_Descriptor *descriptor; - - LADSPA_PortDescriptor gate_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor trigger_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor delay_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor attack_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor hold_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor decay_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor sustain_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor release_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor output_port_descriptors[] = - { LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO }; - - void (*run_functions[]) (LADSPA_Handle, unsigned long) = { - runDahdsr_Control}; - -#ifdef ENABLE_NLS - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); -#endif - - dahdsr_descriptors = - (LADSPA_Descriptor **) calloc(DAHDSR_VARIANT_COUNT, - sizeof(LADSPA_Descriptor)); - - if (dahdsr_descriptors) { - int i = 0; - - dahdsr_descriptors[i] = - (LADSPA_Descriptor *) malloc(sizeof(LADSPA_Descriptor)); - descriptor = dahdsr_descriptors[i]; - if (descriptor) { - descriptor->UniqueID = ids[i]; - descriptor->Label = labels[i]; - descriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - descriptor->Name = G_(names[i]); - descriptor->Maker = - "Loki Davison <ltdav1[at]student.monash.edu.au>"; - descriptor->Copyright = "GPL"; - - descriptor->PortCount = 9; - - port_descriptors = - (LADSPA_PortDescriptor *) calloc(9, - sizeof - (LADSPA_PortDescriptor)); - descriptor->PortDescriptors = - (const LADSPA_PortDescriptor *)port_descriptors; - - port_range_hints = - (LADSPA_PortRangeHint *) calloc(9, - sizeof(LADSPA_PortRangeHint)); - descriptor->PortRangeHints = - (const LADSPA_PortRangeHint *)port_range_hints; - - port_names = (char **)calloc(9, sizeof(char *)); - descriptor->PortNames = (const char **)port_names; - - /* Parameters for Gate */ - port_descriptors[DAHDSR_GATE] = gate_port_descriptors[i]; - port_names[DAHDSR_GATE] = G_("Gate"); - port_range_hints[DAHDSR_GATE].HintDescriptor = - LADSPA_HINT_TOGGLED; - - /* Parameters for Trigger */ - port_descriptors[DAHDSR_TRIGGER] = trigger_port_descriptors[i]; - port_names[DAHDSR_TRIGGER] = G_("Trigger"); - port_range_hints[DAHDSR_TRIGGER].HintDescriptor = - LADSPA_HINT_TOGGLED; - - /* Parameters for Delay Time (s) */ - port_descriptors[DAHDSR_DELAY] = delay_port_descriptors[i]; - port_names[DAHDSR_DELAY] = G_("Delay Time (s)"); - port_range_hints[DAHDSR_DELAY].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_DELAY].LowerBound = 0.0f; - - /* Parameters for Attack Time (s) */ - port_descriptors[DAHDSR_ATTACK] = attack_port_descriptors[i]; - port_names[DAHDSR_ATTACK] = G_("Attack Time (s)"); - port_range_hints[DAHDSR_ATTACK].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_ATTACK].LowerBound = 0.0f; - - /* Parameters for Hold Time (s) */ - port_descriptors[DAHDSR_HOLD] = hold_port_descriptors[i]; - port_names[DAHDSR_HOLD] = G_("Hold Time (s)"); - port_range_hints[DAHDSR_HOLD].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_HOLD].LowerBound = 0.0f; - - /* Parameters for Decay Time (s) */ - port_descriptors[DAHDSR_DECAY] = decay_port_descriptors[i]; - port_names[DAHDSR_DECAY] = G_("Decay Time (s)"); - port_range_hints[DAHDSR_DECAY].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_DECAY].LowerBound = 0.0f; - - /* Parameters for Sustain Level */ - port_descriptors[DAHDSR_SUSTAIN] = sustain_port_descriptors[i]; - port_names[DAHDSR_SUSTAIN] = G_("Sustain Level"); - port_range_hints[DAHDSR_SUSTAIN].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | - LADSPA_HINT_DEFAULT_MAXIMUM; - port_range_hints[DAHDSR_SUSTAIN].LowerBound = 0.0f; - port_range_hints[DAHDSR_SUSTAIN].UpperBound = 1.0f; - - /* Parameters for Release Time (s) */ - port_descriptors[DAHDSR_RELEASE] = release_port_descriptors[i]; - port_names[DAHDSR_RELEASE] = G_("Release Time (s)"); - port_range_hints[DAHDSR_RELEASE].HintDescriptor = - LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM; - port_range_hints[DAHDSR_RELEASE].LowerBound = 0.0f; - - /* Parameters for Envelope Out */ - port_descriptors[DAHDSR_OUTPUT] = output_port_descriptors[i]; - port_names[DAHDSR_OUTPUT] = G_("Envelope Out"); - port_range_hints[DAHDSR_OUTPUT].HintDescriptor = 0; - - descriptor->activate = activateDahdsr; - descriptor->cleanup = cleanupDahdsr; - descriptor->connect_port = connectPortDahdsr; - descriptor->deactivate = NULL; - descriptor->instantiate = instantiateDahdsr; - descriptor->run = run_functions[i]; - descriptor->run_adding = NULL; - descriptor->set_run_adding_gain = NULL; - - } - } -} - -void -_fini(void) +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/dahdsr_hexp", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) { - LADSPA_Descriptor *descriptor; - int i; - - if (dahdsr_descriptors) { - for (i = 0; i < DAHDSR_VARIANT_COUNT; i++) { - descriptor = dahdsr_descriptors[i]; - if (descriptor) { - free((LADSPA_PortDescriptor *) descriptor->PortDescriptors); - free((char **)descriptor->PortNames); - free((LADSPA_PortRangeHint *) descriptor->PortRangeHints); - free(descriptor); - } - } - free(dahdsr_descriptors); + switch (index) { + case 0: return &descriptor; + default: return NULL; } } diff --git a/src/fast_crossfade.c b/src/fast_crossfade.c new file mode 100644 index 0000000..228efb4 --- /dev/null +++ b/src/fast_crossfade.c @@ -0,0 +1,138 @@ +/* Crossfade with AR Level plugin. + * Copyright 2005 Thorsten Wilms. + * + * Based on David Robillard's "Hz to AMS style V/Oct" plugin for the skeleton. + * Thanks to Florian Schmidt for explaining how to calculate the scale values + * before I could work it out myself! ;-) + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#define XFADE_LEVEL_ID 4410 + +#define XFADE_NUM_PORTS 4 + +/* Port Numbers */ +#define XFADE_LEVEL 0 +#define XFADE_A 1 +#define XFADE_B 2 +#define XFADE_OUTPUT 3 + +/* All state information for plugin */ +typedef struct { + /* Ports */ + float *level_buffer; + float *a_buffer; + float *b_buffer; + float *output_buffer; +} XFADE; + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + return (LV2_Handle)malloc(sizeof(XFADE)); +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, void* location) +{ + XFADE* plugin; + + plugin = (XFADE*) instance; + switch (port) { + case XFADE_LEVEL: + plugin->level_buffer = location; + break; + case XFADE_A: + plugin->a_buffer = location; + break; + case XFADE_B: + plugin->b_buffer = location; + break; + case XFADE_OUTPUT: + plugin->output_buffer = location; + break; + } +} + +static void +run(LV2_Handle instance, uint32_t nframes) +{ + float* level; + float* a; + float* b; + float* output; + XFADE* plugin; + unsigned long i; + float l; + + plugin = (XFADE*)instance; + + level = plugin->level_buffer; + a = plugin->a_buffer; + b = plugin->b_buffer; + output = plugin->output_buffer; + + for (i = 0; i < nframes; i++) { + /* transfer multiplication value to 0 to 1 range */ + if (level[i] < -1) { + l = 0; + } else if (level[i] > 1) { + l = 1; + } else { + l = (level[i] + 1) / 2; + } + + output[i] = a[i] * l + b[i] * (1 - l); + } +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/fast_crossfade", + instantiate, + connect_port, + NULL, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/fast_crossfade_4410.c b/src/fast_crossfade_4410.c deleted file mode 100644 index 37376ba..0000000 --- a/src/fast_crossfade_4410.c +++ /dev/null @@ -1,209 +0,0 @@ -/* Crossfade with AR Level plugin. - * Copyright 2005 Thorsten Wilms. - * - * Based on David Robillard's "Hz to AMS style V/Oct" plugin for the skeleton. - * Thanks to Florian Schmidt for explaining how to calculate the scale values - * before I could work it out myself! ;-) - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> - -#include "ladspa.h" - -#define XFADE_LEVEL_ID 4410 - -#define XFADE_NUM_PORTS 4 - -/* Port Numbers */ -#define XFADE_LEVEL 0 -#define XFADE_A 1 -#define XFADE_B 2 -#define XFADE_OUTPUT 3 - -/* All state information for plugin */ -typedef struct { - /* Ports */ - LADSPA_Data *level_buffer; - LADSPA_Data *a_buffer; - LADSPA_Data *b_buffer; - LADSPA_Data *output_buffer; -} XFADE; - -/* Construct a new plugin instance */ -LADSPA_Handle -XFADE_instantiate(const LADSPA_Descriptor * descriptor, unsigned long srate) -{ - return (LADSPA_Handle)malloc(sizeof(XFADE)); -} - -/* Connect a port to a data location */ -void -XFADE_connect_port(LADSPA_Handle instance, - unsigned long port, LADSPA_Data * location) -{ - XFADE* plugin; - - plugin = (XFADE*) instance; - switch (port) { - case XFADE_LEVEL: - plugin->level_buffer = location; - break; - case XFADE_A: - plugin->a_buffer = location; - break; - case XFADE_B: - plugin->b_buffer = location; - break; - case XFADE_OUTPUT: - plugin->output_buffer = location; - break; - } -} - -void -XFADE_run_ar(LADSPA_Handle instance, unsigned long nframes) -{ - LADSPA_Data* level; - LADSPA_Data* a; - LADSPA_Data* b; - LADSPA_Data* output; - XFADE* plugin; - unsigned long i; - float l; - - plugin = (XFADE*)instance; - - level = plugin->level_buffer; - a = plugin->a_buffer; - b = plugin->b_buffer; - output = plugin->output_buffer; - - for (i = 0; i < nframes; i++) { - /* transfer multiplication value to 0 to 1 range */ - if (level[i] < -1) { - l = 0; - } else if (level[i] > 1) { - l = 1; - } else { - l = (level[i] + 1) / 2; - } - - output[i] = a[i] * l + b[i] * (1 - l); - } -} - -void -XFADE_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor *xfade_descriptor = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char **port_names; - LADSPA_PortDescriptor *port_descriptors; - LADSPA_PortRangeHint *port_range_hints; - - xfade_descriptor = - (LADSPA_Descriptor *) malloc(sizeof(LADSPA_Descriptor)); - - if (xfade_descriptor) { - xfade_descriptor->UniqueID = XFADE_LEVEL_ID; - xfade_descriptor->Label = strdup("fast_xfade"); - xfade_descriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - xfade_descriptor->Name = strdup("Fast Crossfade"); - xfade_descriptor->Maker = strdup("Thorsten Wilms"); - xfade_descriptor->Copyright = strdup("GPL"); - xfade_descriptor->PortCount = XFADE_NUM_PORTS; - port_descriptors = - (LADSPA_PortDescriptor *) calloc(XFADE_NUM_PORTS, - sizeof(LADSPA_PortDescriptor)); - xfade_descriptor->PortDescriptors = - (const LADSPA_PortDescriptor *)port_descriptors; - port_descriptors[XFADE_LEVEL] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[XFADE_A] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[XFADE_B] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[XFADE_OUTPUT] = - LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char **)calloc(XFADE_NUM_PORTS, sizeof(char *)); - xfade_descriptor->PortNames = (const char **)port_names; - port_names[XFADE_LEVEL] = strdup("Level"); - port_names[XFADE_A] = strdup("A"); - port_names[XFADE_B] = strdup("B"); - port_names[XFADE_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(XFADE_NUM_PORTS, - sizeof(LADSPA_PortRangeHint))); - xfade_descriptor->PortRangeHints = - (const LADSPA_PortRangeHint *)port_range_hints; - port_range_hints[XFADE_LEVEL].HintDescriptor = 0; - port_range_hints[XFADE_A].HintDescriptor = 0; - port_range_hints[XFADE_B].HintDescriptor = 0; - port_range_hints[XFADE_OUTPUT].HintDescriptor = 0; - xfade_descriptor->instantiate = XFADE_instantiate; - xfade_descriptor->connect_port = XFADE_connect_port; - xfade_descriptor->activate = NULL; - xfade_descriptor->run = XFADE_run_ar; - xfade_descriptor->run_adding = NULL; - xfade_descriptor->set_run_adding_gain = NULL; - xfade_descriptor->deactivate = NULL; - xfade_descriptor->cleanup = XFADE_cleanup; - } - -} - -void -XFADE_delete_descriptors(LADSPA_Descriptor * psdescriptors) -{ - unsigned long lIndex; - - if (psdescriptors) { - free((char *)psdescriptors->Label); - free((char *)psdescriptors->Name); - free((char *)psdescriptors->Maker); - free((char *)psdescriptors->Copyright); - free((LADSPA_PortDescriptor *) psdescriptors->PortDescriptors); - for (lIndex = 0; lIndex < psdescriptors->PortCount; lIndex++) - free((char *)(psdescriptors->PortNames[lIndex])); - free((char **)psdescriptors->PortNames); - free((LADSPA_PortRangeHint *) psdescriptors->PortRangeHints); - free(psdescriptors); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - XFADE_delete_descriptors(xfade_descriptor); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor * -ladspa_descriptor(unsigned long index) -{ - if (index == 0) - return xfade_descriptor; - return 0; -} - diff --git a/src/formant_filter.c b/src/formant_filter.c new file mode 100644 index 0000000..ac851be --- /dev/null +++ b/src/formant_filter.c @@ -0,0 +1,215 @@ +/* Formant filter plugin. Copyright 2005-2011 David Robillard. + * + * Based on SSM formant filter, + * Copyright 2001 David Griffiths <dave@pawfal.org> + * + * Based on public domain code from alex@smartelectronix.com + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#define FORMANT_BASE_ID 4300 + +#define FORMANT_NUM_PORTS 3 + +/* Port Numbers */ +#define FORMANT_VOWEL 0 +#define FORMANT_INPUT 1 +#define FORMANT_OUTPUT 2 + +/* Vowel Coefficients */ +const double coeff[5][11] = { + { /* A */ 8.11044e-06, + 8.943665402, -36.83889529, 92.01697887, -154.337906, 181.6233289, + -151.8651235, 89.09614114, -35.10298511, 8.388101016, -0.923313471 + }, + { /* E */ 4.36215e-06, + 8.90438318, -36.55179099, 91.05750846, -152.422234, 179.1170248, + -149.6496211, 87.78352223, -34.60687431, 8.282228154, -0.914150747 + }, + { /* I */ 3.33819e-06, + 8.893102966, -36.49532826, 90.96543286, -152.4545478, 179.4835618, + -150.315433, 88.43409371, -34.98612086, 8.407803364, -0.932568035 + }, + { /* O */ 1.13572e-06, + 8.994734087, -37.2084849, 93.22900521, -156.6929844, 184.596544, + -154.3755513, 90.49663749, -35.58964535, 8.478996281, -0.929252233 + }, + { /* U */ 4.09431e-07, + 8.997322763, -37.20218544, 93.11385476, -156.2530937, 183.7080141, + -153.2631681, 89.59539726, -35.12454591, 8.338655623, -0.910251753 + } +}; + +/* All state information for plugin */ +typedef struct +{ + /* Ports */ + float* vowel; + float* input; + float* output; + + double memory[5][10]; +} Formant; + +/* Linear interpolation */ +inline static float +linear(float bot, float top, float pos, float val1, float val2) +{ + float t = (pos - bot) / (top - bot); + return val1 * t + val2 * (1.0f - t); +} + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + return (LV2_Handle)malloc(sizeof(Formant)); +} + +/** Activate an instance */ +static void +activate(LV2_Handle instance) +{ + Formant* plugin = (Formant*)instance; + int i, j; + + for (i = 0; i < 5; ++i) + for (j = 0; j < 10; ++j) + plugin->memory[i][j] = 0.0; +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* location) +{ + Formant* plugin; + + plugin = (Formant*)instance; + switch (port) { + case FORMANT_VOWEL: + plugin->vowel = location; + break; + case FORMANT_INPUT: + plugin->input = location; + break; + case FORMANT_OUTPUT: + plugin->output = location; + break; + } +} + +static void +run(LV2_Handle instance, uint32_t nframes) +{ + Formant* plugin = (Formant*)instance; + float vowel; + float in; + float* out; + float res; + float o[5]; + size_t n, v; + + for (n=0; n < nframes; ++n) { + vowel = plugin->vowel[0]; + in = plugin->input[n]; + out = plugin->output; + + for (v=0; v < 5; ++v) { + res = (float) (coeff[v][0] * (in * 0.1f) + + coeff[v][1] * plugin->memory[v][0] + + coeff[v][2] * plugin->memory[v][1] + + coeff[v][3] * plugin->memory[v][2] + + coeff[v][4] * plugin->memory[v][3] + + coeff[v][5] * plugin->memory[v][4] + + coeff[v][6] * plugin->memory[v][5] + + coeff[v][7] * plugin->memory[v][6] + + coeff[v][8] * plugin->memory[v][7] + + coeff[v][9] * plugin->memory[v][8] + + coeff[v][10] * plugin->memory[v][9] ); + + plugin->memory[v][9] = plugin->memory[v][8]; + plugin->memory[v][8] = plugin->memory[v][7]; + plugin->memory[v][7] = plugin->memory[v][6]; + plugin->memory[v][6] = plugin->memory[v][5]; + plugin->memory[v][5] = plugin->memory[v][4]; + plugin->memory[v][4] = plugin->memory[v][3]; + plugin->memory[v][3] = plugin->memory[v][2]; + plugin->memory[v][2] = plugin->memory[v][1]; + plugin->memory[v][1] = plugin->memory[v][0]; + plugin->memory[v][0] = (double)res; + + o[v] = res; + } + + // Mix between formants + if (vowel <= 0) + out[n] = o[0]; + else if (vowel > 0 && vowel < 1) + out[n] = linear(0.0f, 1.0f, vowel, o[1], o[0]); + else if (vowel == 1) + out[n] = o[1]; + else if (vowel > 1 && vowel < 2) + out[n] = linear(0.0f, 1.0f, vowel - 1.0f, o[2], o[1]); + else if (vowel == 2) + out[n] = o[2]; + else if (vowel > 2 && vowel < 3) + out[n] = linear(0.0f, 1.0f, vowel - 2.0f, o[3], o[2]); + else if (vowel == 3) + out[n] = o[3]; + else if (vowel > 3 && vowel < 4) + out[n] = linear(0.0f, 1.0f, vowel - 3.0f, o[4], o[3]); + else //if (vowel >= 4) + out[n] = o[4]; + } +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/formant_filter", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/formant_filter_4300.c b/src/formant_filter_4300.c deleted file mode 100644 index a361978..0000000 --- a/src/formant_filter_4300.c +++ /dev/null @@ -1,331 +0,0 @@ -/* Formant filter plugin. Copyright 2005-2011 David Robillard. - * - * Based on SSM formant filter, - * Copyright 2001 David Griffiths <dave@pawfal.org> - * - * Based on public domain code from alex@smartelectronix.com - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "ladspa.h" - -#define FORMANT_BASE_ID 4300 - -#define FORMANT_NUM_PORTS 3 - -/* Port Numbers */ -#define FORMANT_VOWEL 0 -#define FORMANT_INPUT 1 -#define FORMANT_OUTPUT 2 - -/* Vowel Coefficients */ -const double coeff[5][11] = { - { /* A */ 8.11044e-06, - 8.943665402, -36.83889529, 92.01697887, -154.337906, 181.6233289, - -151.8651235, 89.09614114, -35.10298511, 8.388101016, -0.923313471 - }, - { /* E */ 4.36215e-06, - 8.90438318, -36.55179099, 91.05750846, -152.422234, 179.1170248, - -149.6496211, 87.78352223, -34.60687431, 8.282228154, -0.914150747 - }, - { /* I */ 3.33819e-06, - 8.893102966, -36.49532826, 90.96543286, -152.4545478, 179.4835618, - -150.315433, 88.43409371, -34.98612086, 8.407803364, -0.932568035 - }, - { /* O */ 1.13572e-06, - 8.994734087, -37.2084849, 93.22900521, -156.6929844, 184.596544, - -154.3755513, 90.49663749, -35.58964535, 8.478996281, -0.929252233 - }, - { /* U */ 4.09431e-07, - 8.997322763, -37.20218544, 93.11385476, -156.2530937, 183.7080141, - -153.2631681, 89.59539726, -35.12454591, 8.338655623, -0.910251753 - } -}; - -/* All state information for plugin */ -typedef struct -{ - /* Ports */ - LADSPA_Data* vowel; - LADSPA_Data* input; - LADSPA_Data* output; - - double memory[5][10]; -} Formant; - -/* Linear interpolation */ -inline static float -linear(float bot, float top, float pos, float val1, float val2) -{ - float t = (pos - bot) / (top - bot); - return val1 * t + val2 * (1.0f - t); -} - -/* Construct a new plugin instance */ -LADSPA_Handle -formant_instantiate(const LADSPA_Descriptor* descriptor, - unsigned long srate) -{ - return (LADSPA_Handle)malloc(sizeof(Formant)); -} - -/** Activate an instance */ -void -formant_activate(LADSPA_Handle instance) -{ - Formant* plugin = (Formant*)instance; - int i, j; - - for (i = 0; i < 5; ++i) - for (j = 0; j < 10; ++j) - plugin->memory[i][j] = 0.0; -} - -/* Connect a port to a data location */ -void -formant_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - Formant* plugin; - - plugin = (Formant*)instance; - switch (port) { - case FORMANT_VOWEL: - plugin->vowel = location; - break; - case FORMANT_INPUT: - plugin->input = location; - break; - case FORMANT_OUTPUT: - plugin->output = location; - break; - } -} - -void -formant_run_vc(LADSPA_Handle instance, unsigned long nframes) -{ - Formant* plugin = (Formant*)instance; - LADSPA_Data vowel; - LADSPA_Data in; - LADSPA_Data* out; - LADSPA_Data res; - LADSPA_Data o[5]; - size_t n, v; - - for (n=0; n < nframes; ++n) { - vowel = plugin->vowel[0]; - in = plugin->input[n]; - out = plugin->output; - - for (v=0; v < 5; ++v) { - res = (float) (coeff[v][0] * (in * 0.1f) + - coeff[v][1] * plugin->memory[v][0] + - coeff[v][2] * plugin->memory[v][1] + - coeff[v][3] * plugin->memory[v][2] + - coeff[v][4] * plugin->memory[v][3] + - coeff[v][5] * plugin->memory[v][4] + - coeff[v][6] * plugin->memory[v][5] + - coeff[v][7] * plugin->memory[v][6] + - coeff[v][8] * plugin->memory[v][7] + - coeff[v][9] * plugin->memory[v][8] + - coeff[v][10] * plugin->memory[v][9] ); - - plugin->memory[v][9] = plugin->memory[v][8]; - plugin->memory[v][8] = plugin->memory[v][7]; - plugin->memory[v][7] = plugin->memory[v][6]; - plugin->memory[v][6] = plugin->memory[v][5]; - plugin->memory[v][5] = plugin->memory[v][4]; - plugin->memory[v][4] = plugin->memory[v][3]; - plugin->memory[v][3] = plugin->memory[v][2]; - plugin->memory[v][2] = plugin->memory[v][1]; - plugin->memory[v][1] = plugin->memory[v][0]; - plugin->memory[v][0] = (double)res; - - o[v] = res; - } - - // Mix between formants - if (vowel <= 0) - out[n] = o[0]; - else if (vowel > 0 && vowel < 1) - out[n] = linear(0.0f, 1.0f, vowel, o[1], o[0]); - else if (vowel == 1) - out[n] = o[1]; - else if (vowel > 1 && vowel < 2) - out[n] = linear(0.0f, 1.0f, vowel - 1.0f, o[2], o[1]); - else if (vowel == 2) - out[n] = o[2]; - else if (vowel > 2 && vowel < 3) - out[n] = linear(0.0f, 1.0f, vowel - 2.0f, o[3], o[2]); - else if (vowel == 3) - out[n] = o[3]; - else if (vowel > 3 && vowel < 4) - out[n] = linear(0.0f, 1.0f, vowel - 3.0f, o[4], o[3]); - else //if (vowel >= 4) - out[n] = o[4]; - } -} - -/* -void -formant_run_va(LADSPA_Handle instance, unsigned long nframes) -{ - LADSPA_Data* input; - LADSPA_Data* output; - Formant* plugin = (Formant*)instance; -}*/ - -void -formant_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* formant_vc_desc = NULL; -//LADSPA_Descriptor* formant_va_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - formant_vc_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - //formant_va_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (formant_vc_desc) { - - formant_vc_desc->UniqueID = FORMANT_BASE_ID; - formant_vc_desc->Label = strdup("formant_vc"); - formant_vc_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - formant_vc_desc->Name = strdup("Formant Filter (CR vowel)"); - formant_vc_desc->Maker = strdup("David Robillard"); - formant_vc_desc->Copyright = strdup("GPL"); - formant_vc_desc->PortCount = FORMANT_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(FORMANT_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - formant_vc_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[FORMANT_VOWEL] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[FORMANT_INPUT] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[FORMANT_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(FORMANT_NUM_PORTS, sizeof(char*)); - formant_vc_desc->PortNames = (const char**)port_names; - port_names[FORMANT_VOWEL] = strdup("Vowel"); - port_names[FORMANT_INPUT] = strdup("Input"); - port_names[FORMANT_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(FORMANT_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - formant_vc_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[FORMANT_VOWEL].LowerBound = 0.0f; - port_range_hints[FORMANT_VOWEL].UpperBound = 4.0f; - port_range_hints[FORMANT_VOWEL].HintDescriptor = - LADSPA_HINT_DEFAULT_0 | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; - port_range_hints[FORMANT_INPUT].HintDescriptor = 0; - port_range_hints[FORMANT_OUTPUT].HintDescriptor = 0; - formant_vc_desc->instantiate = formant_instantiate; - formant_vc_desc->connect_port = formant_connect_port; - formant_vc_desc->activate = formant_activate; - formant_vc_desc->run = formant_run_vc; - formant_vc_desc->run_adding = NULL; - formant_vc_desc->set_run_adding_gain = NULL; - formant_vc_desc->deactivate = NULL; - formant_vc_desc->cleanup = formant_cleanup; - } - - /*if (formant_va_desc) { - - formant_va_desc->UniqueID = FORMANT_BASE_ID+1; - formant_va_desc->Label = strdup("formant_va"); - formant_va_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - formant_va_desc->Name = strdup("Formant Filter (AR vowel)"); - formant_va_desc->Maker = strdup("David Robillard"); - formant_va_desc->Copyright = strdup("GPL"); - formant_va_desc->PortCount = FORMANT_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(FORMANT_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - formant_va_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[FORMANT_VOWEL] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[FORMANT_INPUT] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[FORMANT_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(FORMANT_NUM_PORTS, sizeof(char*)); - formant_va_desc->PortNames = (const char**)port_names; - port_names[FORMANT_VOWEL] = strdup("Vowel"); - port_names[FORMANT_INPUT] = strdup("Input"); - port_names[FORMANT_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(FORMANT_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - formant_va_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[FORMANT_VOWEL].HintDescriptor = 0; - port_range_hints[FORMANT_INPUT].HintDescriptor = 0; - port_range_hints[FORMANT_OUTPUT].HintDescriptor = 0; - formant_va_desc->instantiate = formant_instantiate; - formant_va_desc->connect_port = formant_connect_port; - formant_va_desc->activate = formant_activate; - formant_va_desc->run = formant_run_va; - formant_va_desc->run_adding = NULL; - formant_va_desc->set_run_adding_gain = NULL; - formant_va_desc->deactivate = NULL; - formant_va_desc->cleanup = formant_cleanup; - }*/ -} - -void -formant_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor*)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint*)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - formant_delete_descriptor(formant_vc_desc); - //formant_delete_descriptor(formant_va_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return formant_vc_desc; - //case 1: - // return formant_va_desc; - default: - return NULL; - } -} - diff --git a/src/hz_voct.c b/src/hz_voct.c new file mode 100644 index 0000000..2d1409f --- /dev/null +++ b/src/hz_voct.c @@ -0,0 +1,119 @@ +/* Hz to AMS style V/Oct plugin. Copyright 2005-2011 David Robillard. + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#define HZVOCT_BASE_ID 4200 + +#define HZVOCT_NUM_PORTS 2 + +/* Port Numbers */ +#define HZVOCT_INPUT 0 +#define HZVOCT_OUTPUT 1 + +/* All state information for plugin */ +typedef struct +{ + /* Ports */ + float* input_buffer; + float* output_buffer; +} HzVoct; + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + HzVoct* plugin = malloc(sizeof(HzVoct)); + plugin->input_buffer = NULL; + plugin->output_buffer = NULL; + return (LV2_Handle)plugin; +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* location) +{ + HzVoct* plugin; + + plugin = (HzVoct*)instance; + switch (port) { + case HZVOCT_INPUT: + plugin->input_buffer = location; + break; + case HZVOCT_OUTPUT: + plugin->output_buffer = location; + break; + } +} + +static void +run(LV2_Handle instance, uint32_t nframes) +{ + float* input; + float* output; + HzVoct* plugin; + unsigned long i; + float log2inv; + float eighth = 1.0f/8.0f; + const float offset = 5.0313842; // + octave, ... -1, 0, 1 ... + + plugin = (HzVoct*)instance; + log2inv = 1.0f/logf(2.0); + + input = plugin->input_buffer; + output = plugin->output_buffer; + + // Inverse of the formula used in AMS's converter module (except the 1/8 part) + for (i = 0; i < nframes; i++) + *output++ = logf((*input++) * eighth) * log2inv - offset; +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/hz_voct", + instantiate, + connect_port, + NULL, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/hz_voct_4200.c b/src/hz_voct_4200.c deleted file mode 100644 index 744338f..0000000 --- a/src/hz_voct_4200.c +++ /dev/null @@ -1,231 +0,0 @@ -/* Hz to AMS style V/Oct plugin. Copyright 2005-2011 David Robillard. - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "ladspa.h" - -#define HZVOCT_BASE_ID 4200 - -#define HZVOCT_NUM_PORTS 2 - -/* Port Numbers */ -#define HZVOCT_INPUT 0 -#define HZVOCT_OUTPUT 1 - -/* All state information for plugin */ -typedef struct -{ - /* Ports */ - LADSPA_Data* input_buffer; - LADSPA_Data* output_buffer; -} HzVoct; - -/* Construct a new plugin instance */ -LADSPA_Handle -hzvoct_instantiate(const LADSPA_Descriptor* descriptor, - unsigned long srate) -{ - HzVoct* plugin = malloc(sizeof(HzVoct)); - plugin->input_buffer = NULL; - plugin->output_buffer = NULL; - return (LADSPA_Handle)plugin; -} - -/* Connect a port to a data location */ -void -hzvoct_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - HzVoct* plugin; - - plugin = (HzVoct*)instance; - switch (port) { - case HZVOCT_INPUT: - plugin->input_buffer = location; - break; - case HZVOCT_OUTPUT: - plugin->output_buffer = location; - break; - } -} - -void -hzvoct_run_cr(LADSPA_Handle instance, unsigned long nframes) -{ - HzVoct* plugin; - float log2inv; - float eighth = 1.0f/8.0f; - const float offset = 2.0313842f; // + octave, ... -1, 0, 1 ... - - plugin = (HzVoct*)instance; - log2inv = 1.0f/logf(2.0f); - - *plugin->output_buffer = logf(*plugin->input_buffer * eighth) * log2inv - offset; -} - -void -hzvoct_run_ar(LADSPA_Handle instance, unsigned long nframes) -{ - LADSPA_Data* input; - LADSPA_Data* output; - HzVoct* plugin; - unsigned long i; - float log2inv; - float eighth = 1.0f/8.0f; - const float offset = 5.0313842; // + octave, ... -1, 0, 1 ... - - plugin = (HzVoct*)instance; - log2inv = 1.0f/logf(2.0); - - input = plugin->input_buffer; - output = plugin->output_buffer; - - // Inverse of the formula used in AMS's converter module (except the 1/8 part) - for (i = 0; i < nframes; i++) - *output++ = logf((*input++) * eighth) * log2inv - offset; -} - -void -hzvoct_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* hz_voct_cr_desc = NULL; -LADSPA_Descriptor* hz_voct_ar_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - hz_voct_cr_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - hz_voct_ar_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (hz_voct_cr_desc) { - - hz_voct_cr_desc->UniqueID = HZVOCT_BASE_ID; - hz_voct_cr_desc->Label = strdup("hz_voct_cr"); - hz_voct_cr_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - hz_voct_cr_desc->Name = strdup("Hz to V/Oct Converter (CR)"); - hz_voct_cr_desc->Maker = strdup("David Robillard"); - hz_voct_cr_desc->Copyright = strdup("GPL"); - hz_voct_cr_desc->PortCount = HZVOCT_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(HZVOCT_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - hz_voct_cr_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[HZVOCT_INPUT] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[HZVOCT_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL; - port_names = (char**)calloc(HZVOCT_NUM_PORTS, sizeof(char*)); - hz_voct_cr_desc->PortNames = (const char**)port_names; - port_names[HZVOCT_INPUT] = strdup("Input"); - port_names[HZVOCT_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(HZVOCT_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - hz_voct_cr_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[HZVOCT_INPUT].HintDescriptor = 0; - port_range_hints[HZVOCT_OUTPUT].HintDescriptor = 0; - hz_voct_cr_desc->instantiate = hzvoct_instantiate; - hz_voct_cr_desc->connect_port = hzvoct_connect_port; - hz_voct_cr_desc->activate = NULL; - hz_voct_cr_desc->run = hzvoct_run_cr; - hz_voct_cr_desc->run_adding = NULL; - hz_voct_cr_desc->set_run_adding_gain = NULL; - hz_voct_cr_desc->deactivate = NULL; - hz_voct_cr_desc->cleanup = hzvoct_cleanup; - } - - if (hz_voct_ar_desc) { - - hz_voct_ar_desc->UniqueID = HZVOCT_BASE_ID+1; - hz_voct_ar_desc->Label = strdup("hz_voct_ar"); - hz_voct_ar_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - hz_voct_ar_desc->Name = strdup("Hz to V/Oct Converter (AR)"); - hz_voct_ar_desc->Maker = strdup("David Robillard"); - hz_voct_ar_desc->Copyright = strdup("GPL"); - hz_voct_ar_desc->PortCount = HZVOCT_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(HZVOCT_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - hz_voct_ar_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[HZVOCT_INPUT] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[HZVOCT_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(HZVOCT_NUM_PORTS, sizeof(char*)); - hz_voct_ar_desc->PortNames = (const char**)port_names; - port_names[HZVOCT_INPUT] = strdup("Input"); - port_names[HZVOCT_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(HZVOCT_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - hz_voct_ar_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[HZVOCT_INPUT].HintDescriptor = 0; - port_range_hints[HZVOCT_OUTPUT].HintDescriptor = 0; - hz_voct_ar_desc->instantiate = hzvoct_instantiate; - hz_voct_ar_desc->connect_port = hzvoct_connect_port; - hz_voct_ar_desc->activate = NULL; - hz_voct_ar_desc->run = hzvoct_run_ar; - hz_voct_ar_desc->run_adding = NULL; - hz_voct_ar_desc->set_run_adding_gain = NULL; - hz_voct_ar_desc->deactivate = NULL; - hz_voct_ar_desc->cleanup = hzvoct_cleanup; - } -} - -void -hzvoct_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - hzvoct_delete_descriptor(hz_voct_cr_desc); - hzvoct_delete_descriptor(hz_voct_ar_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return hz_voct_cr_desc; - case 1: - return hz_voct_ar_desc; - default: - return NULL; - } -} - diff --git a/src/ladspa.h b/src/ladspa.h deleted file mode 100644 index b1a9c4e..0000000 --- a/src/ladspa.h +++ /dev/null @@ -1,603 +0,0 @@ -/* ladspa.h - - Linux Audio Developer's Simple Plugin API Version 1.1[LGPL]. - Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis, - Stefan Westerfeld. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License - as published by the Free Software Foundation; either version 2.1 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. */ - -#ifndef LADSPA_INCLUDED -#define LADSPA_INCLUDED - -#define LADSPA_VERSION "1.1" -#define LADSPA_VERSION_MAJOR 1 -#define LADSPA_VERSION_MINOR 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************************/ - -/* Overview: - - There is a large number of synthesis packages in use or development - on the Linux platform at this time. This API (`The Linux Audio - Developer's Simple Plugin API') attempts to give programmers the - ability to write simple `plugin' audio processors in C/C++ and link - them dynamically (`plug') into a range of these packages (`hosts'). - It should be possible for any host and any plugin to communicate - completely through this interface. - - This API is deliberately short and simple. To achieve compatibility - with a range of promising Linux sound synthesis packages it - attempts to find the `greatest common divisor' in their logical - behaviour. Having said this, certain limiting decisions are - implicit, notably the use of a fixed type (LADSPA_Data) for all - data transfer and absence of a parameterised `initialisation' - phase. See below for the LADSPA_Data typedef. - - Plugins are expected to distinguish between control and audio - data. Plugins have `ports' that are inputs or outputs for audio or - control data and each plugin is `run' for a `block' corresponding - to a short time interval measured in samples. Audio data is - communicated using arrays of LADSPA_Data, allowing a block of audio - to be processed by the plugin in a single pass. Control data is - communicated using single LADSPA_Data values. Control data has a - single value at the start of a call to the `run()' or `run_adding()' - function, and may be considered to remain this value for its - duration. The plugin may assume that all its input and output ports - have been connected to the relevant data location (see the - `connect_port()' function below) before it is asked to run. - - Plugins will reside in shared object files suitable for dynamic - linking by dlopen() and family. The file will provide a number of - `plugin types' that can be used to instantiate actual plugins - (sometimes known as `plugin instances') that can be connected - together to perform tasks. - - This API contains very limited error-handling. */ - -/*****************************************************************************/ - -/* Fundamental data type passed in and out of plugin. This data type - is used to communicate audio samples and control values. It is - assumed that the plugin will work sensibly given any numeric input - value although it may have a preferred range (see hints below). - - For audio it is generally assumed that 1.0f is the `0dB' reference - amplitude and is a `normal' signal level. */ - -typedef float LADSPA_Data; - -/*****************************************************************************/ - -/* Special Plugin Properties: - - Optional features of the plugin type are encapsulated in the - LADSPA_Properties type. This is assembled by ORing individual - properties together. */ - -typedef int LADSPA_Properties; - -/* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a - real-time dependency (e.g. listens to a MIDI device) and so its - output must not be cached or subject to significant latency. */ -#define LADSPA_PROPERTY_REALTIME 0x1 - -/* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin - may cease to work correctly if the host elects to use the same data - location for both input and output (see connect_port()). This - should be avoided as enabling this flag makes it impossible for - hosts to use the plugin to process audio `in-place.' */ -#define LADSPA_PROPERTY_INPLACE_BROKEN 0x2 - -/* Property LADSPA_PROPERTY_HARD_RT_CAPABLE indicates that the plugin - is capable of running not only in a conventional host but also in a - `hard real-time' environment. To qualify for this the plugin must - satisfy all of the following: - - (1) The plugin must not use malloc(), free() or other heap memory - management within its run() or run_adding() functions. All new - memory used in run() must be managed via the stack. These - restrictions only apply to the run() function. - - (2) The plugin will not attempt to make use of any library - functions with the exceptions of functions in the ANSI standard C - and C maths libraries, which the host is expected to provide. - - (3) The plugin will not access files, devices, pipes, sockets, IPC - or any other mechanism that might result in process or thread - blocking. - - (4) The plugin will take an amount of time to execute a run() or - run_adding() call approximately of form (A+B*SampleCount) where A - and B depend on the machine and host in use. This amount of time - may not depend on input signals or plugin state. The host is left - the responsibility to perform timings to estimate upper bounds for - A and B. */ -#define LADSPA_PROPERTY_HARD_RT_CAPABLE 0x4 - -#define LADSPA_IS_REALTIME(x) ((x) & LADSPA_PROPERTY_REALTIME) -#define LADSPA_IS_INPLACE_BROKEN(x) ((x) & LADSPA_PROPERTY_INPLACE_BROKEN) -#define LADSPA_IS_HARD_RT_CAPABLE(x) ((x) & LADSPA_PROPERTY_HARD_RT_CAPABLE) - -/*****************************************************************************/ - -/* Plugin Ports: - - Plugins have `ports' that are inputs or outputs for audio or - data. Ports can communicate arrays of LADSPA_Data (for audio - inputs/outputs) or single LADSPA_Data values (for control - input/outputs). This information is encapsulated in the - LADSPA_PortDescriptor type which is assembled by ORing individual - properties together. - - Note that a port must be an input or an output port but not both - and that a port must be a control or audio port but not both. */ - -typedef int LADSPA_PortDescriptor; - -/* Property LADSPA_PORT_INPUT indicates that the port is an input. */ -#define LADSPA_PORT_INPUT 0x1 - -/* Property LADSPA_PORT_OUTPUT indicates that the port is an output. */ -#define LADSPA_PORT_OUTPUT 0x2 - -/* Property LADSPA_PORT_CONTROL indicates that the port is a control - port. */ -#define LADSPA_PORT_CONTROL 0x4 - -/* Property LADSPA_PORT_AUDIO indicates that the port is a audio - port. */ -#define LADSPA_PORT_AUDIO 0x8 - -#define LADSPA_IS_PORT_INPUT(x) ((x) & LADSPA_PORT_INPUT) -#define LADSPA_IS_PORT_OUTPUT(x) ((x) & LADSPA_PORT_OUTPUT) -#define LADSPA_IS_PORT_CONTROL(x) ((x) & LADSPA_PORT_CONTROL) -#define LADSPA_IS_PORT_AUDIO(x) ((x) & LADSPA_PORT_AUDIO) - -/*****************************************************************************/ - -/* Plugin Port Range Hints: - - The host may wish to provide a representation of data entering or - leaving a plugin (e.g. to generate a GUI automatically). To make - this more meaningful, the plugin should provide `hints' to the host - describing the usual values taken by the data. - - Note that these are only hints. The host may ignore them and the - plugin must not assume that data supplied to it is meaningful. If - the plugin receives invalid input data it is expected to continue - to run without failure and, where possible, produce a sensible - output (e.g. a high-pass filter given a negative cutoff frequency - might switch to an all-pass mode). - - Hints are meaningful for all input and output ports but hints for - input control ports are expected to be particularly useful. - - More hint information is encapsulated in the - LADSPA_PortRangeHintDescriptor type which is assembled by ORing - individual hint types together. Hints may require further - LowerBound and UpperBound information. - - All the hint information for a particular port is aggregated in the - LADSPA_PortRangeHint structure. */ - -typedef int LADSPA_PortRangeHintDescriptor; - -/* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field - of the LADSPA_PortRangeHint should be considered meaningful. The - value in this field should be considered the (inclusive) lower - bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also - specified then the value of LowerBound should be multiplied by the - sample rate. */ -#define LADSPA_HINT_BOUNDED_BELOW 0x1 - -/* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field - of the LADSPA_PortRangeHint should be considered meaningful. The - value in this field should be considered the (inclusive) upper - bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also - specified then the value of UpperBound should be multiplied by the - sample rate. */ -#define LADSPA_HINT_BOUNDED_ABOVE 0x2 - -/* Hint LADSPA_HINT_TOGGLED indicates that the data item should be - considered a Boolean toggle. Data less than or equal to zero should - be considered `off' or `false,' and data above zero should be - considered `on' or `true.' LADSPA_HINT_TOGGLED may not be used in - conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or - LADSPA_HINT_DEFAULT_1. */ -#define LADSPA_HINT_TOGGLED 0x4 - -/* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified - should be interpreted as multiples of the sample rate. For - instance, a frequency range from 0Hz to the Nyquist frequency (half - the sample rate) could be requested by this hint in conjunction - with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds - at all must support this hint to retain meaning. */ -#define LADSPA_HINT_SAMPLE_RATE 0x8 - -/* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the - user will find it more intuitive to view values using a logarithmic - scale. This is particularly useful for frequencies and gains. */ -#define LADSPA_HINT_LOGARITHMIC 0x10 - -/* Hint LADSPA_HINT_INTEGER indicates that a user interface would - probably wish to provide a stepped control taking only integer - values. Any bounds set should be slightly wider than the actual - integer range required to avoid floating point rounding errors. For - instance, the integer set {0,1,2,3} might be described as [-0.1, - 3.1]. */ -#define LADSPA_HINT_INTEGER 0x20 - -/* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal' - value for the port that is sensible as a default. For instance, - this value is suitable for use as an initial value in a user - interface or as a value the host might assign to a control port - when the user has not provided one. Defaults are encoded using a - mask so only one default may be specified for a port. Some of the - hints make use of lower and upper bounds, in which case the - relevant bound or bounds must be available and - LADSPA_HINT_SAMPLE_RATE must be applied as usual. The resulting - default must be rounded if LADSPA_HINT_INTEGER is present. Default - values were introduced in LADSPA v1.1. */ -#define LADSPA_HINT_DEFAULT_MASK 0x3C0 - -/* This default values indicates that no default is provided. */ -#define LADSPA_HINT_DEFAULT_NONE 0x0 - -/* This default hint indicates that the suggested lower bound for the - port should be used. */ -#define LADSPA_HINT_DEFAULT_MINIMUM 0x40 - -/* This default hint indicates that a low value between the suggested - lower and upper bounds should be chosen. For ports with - LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 + - log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper - * 0.25). */ -#define LADSPA_HINT_DEFAULT_LOW 0x80 - -/* This default hint indicates that a middle value between the - suggested lower and upper bounds should be chosen. For ports with - LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 + - log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper * - 0.5). */ -#define LADSPA_HINT_DEFAULT_MIDDLE 0xC0 - -/* This default hint indicates that a high value between the suggested - lower and upper bounds should be chosen. For ports with - LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 + - log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper - * 0.75). */ -#define LADSPA_HINT_DEFAULT_HIGH 0x100 - -/* This default hint indicates that the suggested upper bound for the - port should be used. */ -#define LADSPA_HINT_DEFAULT_MAXIMUM 0x140 - -/* This default hint indicates that the number 0 should be used. Note - that this default may be used in conjunction with - LADSPA_HINT_TOGGLED. */ -#define LADSPA_HINT_DEFAULT_0 0x200 - -/* This default hint indicates that the number 1 should be used. Note - that this default may be used in conjunction with - LADSPA_HINT_TOGGLED. */ -#define LADSPA_HINT_DEFAULT_1 0x240 - -/* This default hint indicates that the number 100 should be used. */ -#define LADSPA_HINT_DEFAULT_100 0x280 - -/* This default hint indicates that the Hz frequency of `concert A' - should be used. This will be 440 unless the host uses an unusual - tuning convention, in which case it may be within a few Hz. */ -#define LADSPA_HINT_DEFAULT_440 0x2C0 - -#define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW) -#define LADSPA_IS_HINT_BOUNDED_ABOVE(x) ((x) & LADSPA_HINT_BOUNDED_ABOVE) -#define LADSPA_IS_HINT_TOGGLED(x) ((x) & LADSPA_HINT_TOGGLED) -#define LADSPA_IS_HINT_SAMPLE_RATE(x) ((x) & LADSPA_HINT_SAMPLE_RATE) -#define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC) -#define LADSPA_IS_HINT_INTEGER(x) ((x) & LADSPA_HINT_INTEGER) - -#define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK) -#define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_MINIMUM) -#define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_LOW) -#define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_MIDDLE) -#define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_HIGH) -#define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_MAXIMUM) -#define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_0) -#define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_1) -#define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_100) -#define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_440) - -typedef struct _LADSPA_PortRangeHint { - - /* Hints about the port. */ - LADSPA_PortRangeHintDescriptor HintDescriptor; - - /* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When - LADSPA_HINT_SAMPLE_RATE is also active then this value should be - multiplied by the relevant sample rate. */ - LADSPA_Data LowerBound; - - /* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When - LADSPA_HINT_SAMPLE_RATE is also active then this value should be - multiplied by the relevant sample rate. */ - LADSPA_Data UpperBound; - -} LADSPA_PortRangeHint; - -/*****************************************************************************/ - -/* Plugin Handles: - - This plugin handle indicates a particular instance of the plugin - concerned. It is valid to compare this to NULL (0 for C++) but - otherwise the host should not attempt to interpret it. The plugin - may use it to reference internal instance data. */ - -typedef void * LADSPA_Handle; - -/*****************************************************************************/ - -/* Descriptor for a Type of Plugin: - - This structure is used to describe a plugin type. It provides a - number of functions to examine the type, instantiate it, link it to - buffers and workspaces and to run it. */ - -typedef struct _LADSPA_Descriptor { - - /* This numeric identifier indicates the plugin type - uniquely. Plugin programmers may reserve ranges of IDs from a - central body to avoid clashes. Hosts may assume that IDs are - below 0x1000000. */ - unsigned long UniqueID; - - /* This identifier can be used as a unique, case-sensitive - identifier for the plugin type within the plugin file. Plugin - types should be identified by file and label rather than by index - or plugin name, which may be changed in new plugin - versions. Labels must not contain white-space characters. */ - const char * Label; - - /* This indicates a number of properties of the plugin. */ - LADSPA_Properties Properties; - - /* This member points to the null-terminated name of the plugin - (e.g. "Sine Oscillator"). */ - const char * Name; - - /* This member points to the null-terminated string indicating the - maker of the plugin. This can be an empty string but not NULL. */ - const char * Maker; - - /* This member points to the null-terminated string indicating any - copyright applying to the plugin. If no Copyright applies the - string "None" should be used. */ - const char * Copyright; - - /* This indicates the number of ports (input AND output) present on - the plugin. */ - unsigned long PortCount; - - /* This member indicates an array of port descriptors. Valid indices - vary from 0 to PortCount-1. */ - const LADSPA_PortDescriptor * PortDescriptors; - - /* This member indicates an array of null-terminated strings - describing ports (e.g. "Frequency (Hz)"). Valid indices vary from - 0 to PortCount-1. */ - const char * const * PortNames; - - /* This member indicates an array of range hints for each port (see - above). Valid indices vary from 0 to PortCount-1. */ - const LADSPA_PortRangeHint * PortRangeHints; - - /* This may be used by the plugin developer to pass any custom - implementation data into an instantiate call. It must not be used - or interpreted by the host. It is expected that most plugin - writers will not use this facility as LADSPA_Handle should be - used to hold instance data. */ - void * ImplementationData; - - /* This member is a function pointer that instantiates a plugin. A - handle is returned indicating the new plugin instance. The - instantiation function accepts a sample rate as a parameter. The - plugin descriptor from which this instantiate function was found - must also be passed. This function must return NULL if - instantiation fails. - - Note that instance initialisation should generally occur in - activate() rather than here. */ - LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor, - unsigned long SampleRate); - - /* This member is a function pointer that connects a port on an - instantiated plugin to a memory location at which a block of data - for the port will be read/written. The data location is expected - to be an array of LADSPA_Data for audio ports or a single - LADSPA_Data value for control ports. Memory issues will be - managed by the host. The plugin must read/write the data at these - locations every time run() or run_adding() is called and the data - present at the time of this connection call should not be - considered meaningful. - - connect_port() may be called more than once for a plugin instance - to allow the host to change the buffers that the plugin is - reading or writing. These calls may be made before or after - activate() or deactivate() calls. - - connect_port() must be called at least once for each port before - run() or run_adding() is called. When working with blocks of - LADSPA_Data the plugin should pay careful attention to the block - size passed to the run function as the block allocated may only - just be large enough to contain the block of samples. - - Plugin writers should be aware that the host may elect to use the - same buffer for more than one port and even use the same buffer - for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN). - However, overlapped buffers or use of a single buffer for both - audio and control data may result in unexpected behaviour. */ - void (*connect_port)(LADSPA_Handle Instance, - unsigned long Port, - LADSPA_Data * DataLocation); - - /* This member is a function pointer that initialises a plugin - instance and activates it for use. This is separated from - instantiate() to aid real-time support and so that hosts can - reinitialise a plugin instance by calling deactivate() and then - activate(). In this case the plugin instance must reset all state - information dependent on the history of the plugin instance - except for any data locations provided by connect_port() and any - gain set by set_run_adding_gain(). If there is nothing for - activate() to do then the plugin writer may provide a NULL rather - than an empty function. - - When present, hosts must call this function once before run() (or - run_adding()) is called for the first time. This call should be - made as close to the run() call as possible and indicates to - real-time plugins that they are now live. Plugins should not rely - on a prompt call to run() after activate(). activate() may not be - called again unless deactivate() is called first. Note that - connect_port() may be called before or after a call to - activate(). */ - void (*activate)(LADSPA_Handle Instance); - - /* This method is a function pointer that runs an instance of a - plugin for a block. Two parameters are required: the first is a - handle to the particular instance to be run and the second - indicates the block size (in samples) for which the plugin - instance may run. - - Note that if an activate() function exists then it must be called - before run() or run_adding(). If deactivate() is called for a - plugin instance then the plugin instance may not be reused until - activate() has been called again. - - If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE - then there are various things that the plugin should not do - within the run() or run_adding() functions (see above). */ - void (*run)(LADSPA_Handle Instance, - unsigned long SampleCount); - - /* This method is a function pointer that runs an instance of a - plugin for a block. This has identical behaviour to run() except - in the way data is output from the plugin. When run() is used, - values are written directly to the memory areas associated with - the output ports. However when run_adding() is called, values - must be added to the values already present in the memory - areas. Furthermore, output values written must be scaled by the - current gain set by set_run_adding_gain() (see below) before - addition. - - run_adding() is optional. When it is not provided by a plugin, - this function pointer must be set to NULL. When it is provided, - the function set_run_adding_gain() must be provided also. */ - void (*run_adding)(LADSPA_Handle Instance, - unsigned long SampleCount); - - /* This method is a function pointer that sets the output gain for - use when run_adding() is called (see above). If this function is - never called the gain is assumed to default to 1. Gain - information should be retained when activate() or deactivate() - are called. - - This function should be provided by the plugin if and only if the - run_adding() function is provided. When it is absent this - function pointer must be set to NULL. */ - void (*set_run_adding_gain)(LADSPA_Handle Instance, - LADSPA_Data Gain); - - /* This is the counterpart to activate() (see above). If there is - nothing for deactivate() to do then the plugin writer may provide - a NULL rather than an empty function. - - Hosts must deactivate all activated units after they have been - run() (or run_adding()) for the last time. This call should be - made as close to the last run() call as possible and indicates to - real-time plugins that they are no longer live. Plugins should - not rely on prompt deactivation. Note that connect_port() may be - called before or after a call to deactivate(). - - Deactivation is not similar to pausing as the plugin instance - will be reinitialised when activate() is called to reuse it. */ - void (*deactivate)(LADSPA_Handle Instance); - - /* Once an instance of a plugin has been finished with it can be - deleted using the following function. The instance handle passed - ceases to be valid after this call. - - If activate() was called for a plugin instance then a - corresponding call to deactivate() must be made before cleanup() - is called. */ - void (*cleanup)(LADSPA_Handle Instance); - -} LADSPA_Descriptor; - -/**********************************************************************/ - -/* Accessing a Plugin: */ - -/* The exact mechanism by which plugins are loaded is host-dependent, - however all most hosts will need to know is the name of shared - object file containing the plugin types. To allow multiple hosts to - share plugin types, hosts may wish to check for environment - variable LADSPA_PATH. If present, this should contain a - colon-separated path indicating directories that should be searched - (in order) when loading plugin types. - - A plugin programmer must include a function called - "ladspa_descriptor" with the following function prototype within - the shared object file. This function will have C-style linkage (if - you are using C++ this is taken care of by the `extern "C"' clause - at the top of the file). - - A host will find the plugin shared object file by one means or - another, find the ladspa_descriptor() function, call it, and - proceed from there. - - Plugin types are accessed by index (not ID) using values from 0 - upwards. Out of range indexes must result in this function - returning NULL, so the plugin count can be determined by checking - for the least index that results in NULL being returned. */ - -const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index); - -/* Datatype corresponding to the ladspa_descriptor() function. */ -typedef const LADSPA_Descriptor * -(*LADSPA_Descriptor_Function)(unsigned long Index); - -/**********************************************************************/ - -#ifdef __cplusplus -} -#endif - -#endif /* LADSPA_INCLUDED */ - -/* EOF */ diff --git a/src/masher_4310.c b/src/masher.c index 23763dc..d7e84ea 100644 --- a/src/masher_4310.c +++ b/src/masher.c @@ -1,6 +1,6 @@ /* Masher * Copyright 2001 David Griffiths <dave@pawfal.org> - * LADSPAfication 2005 David Robillard <drobilla@connect.carelton.ca> + * LV2fication 2005 David Robillard <drobilla@connect.carelton.ca> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ #include <string.h> #include <stdbool.h> -#include "ladspa.h" +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> #define MASHER_BASE_ID 4310 @@ -43,7 +43,7 @@ #define MAX_GRAIN_SIZE 2048 typedef struct { - LADSPA_Data* data; + float* data; size_t length; } Sample; @@ -55,10 +55,10 @@ typedef struct { /* All state information for plugin */ typedef struct { /* Ports */ - LADSPA_Data *input; - LADSPA_Data *grain_pitch; - LADSPA_Data *density; - LADSPA_Data *output; + float *input; + float *grain_pitch; + float *density; + float *output; Sample grain_store[GRAINSTORE_SIZE]; GrainDesc overlaps[OVERLAPS_SIZE]; @@ -67,22 +67,25 @@ typedef struct { size_t write_grain; } Masher; -float +static inline float rand_range(float l, float h) { return ((rand() % 10000 / 10000.0f) * (h - l)) + l; } /* Construct a new plugin instance */ -LADSPA_Handle -masher_instantiate(const LADSPA_Descriptor * descriptor, unsigned long srate) +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) { - return (LADSPA_Handle)malloc(sizeof(Masher)); + return (LV2_Handle)malloc(sizeof(Masher)); } /** Activate an instance */ -void -masher_activate(LADSPA_Handle instance) +static void +activate(LV2_Handle instance) { Masher *plugin = (Masher*)instance; int i = 0; @@ -91,16 +94,16 @@ masher_activate(LADSPA_Handle instance) plugin->write_grain = 0; for (i=0; i < GRAINSTORE_SIZE; ++i) { - //plugin->grain_store[i].data = (LADSPA_Data*)calloc(MAX_GRAIN_SIZE, sizeof(LADSPA_Data)); - posix_memalign((void**)&plugin->grain_store[i].data, 16, MAX_GRAIN_SIZE * sizeof(LADSPA_Data)); + //plugin->grain_store[i].data = (float*)calloc(MAX_GRAIN_SIZE, sizeof(float)); + posix_memalign((void**)&plugin->grain_store[i].data, 16, MAX_GRAIN_SIZE * sizeof(float)); plugin->grain_store[i].length = 0; } } /* Connect a port to a data location */ -void -masher_connect_port(LADSPA_Handle instance, - unsigned long port, LADSPA_Data * location) +static void +connect_port(LV2_Handle instance, + uint32_t port, void * location) { Masher *plugin = (Masher *) instance; @@ -120,7 +123,7 @@ masher_connect_port(LADSPA_Handle instance, } } -void +static void mix_pitch(Sample* src, Sample* dst, size_t pos, float pitch) { float n = 0; @@ -133,8 +136,8 @@ mix_pitch(Sample* src, Sample* dst, size_t pos, float pitch) } } -void -masher_run(LADSPA_Handle instance, unsigned long nframes) +static void +run(LV2_Handle instance, uint32_t nframes) { Masher* plugin = (Masher*)instance; @@ -142,11 +145,11 @@ masher_run(LADSPA_Handle instance, unsigned long nframes) int read_grain = 0; // FIXME: what is this? int grain_store_size = 100; // FIXME: what is this? (max 1000) - const LADSPA_Data grain_pitch = *plugin->grain_pitch; - const LADSPA_Data density = *plugin->density; + const float grain_pitch = *plugin->grain_pitch; + const float density = *plugin->density; - const LADSPA_Data* const in = plugin->input; - LADSPA_Data* const out = plugin->output; + const float* const in = plugin->input; + float* const out = plugin->output; Sample out_sample = { out, nframes }; @@ -215,116 +218,29 @@ masher_run(LADSPA_Handle instance, unsigned long nframes) } } -void -masher_cleanup(LADSPA_Handle instance) +static void +cleanup(LV2_Handle instance) { free(instance); } -LADSPA_Descriptor *masher_desc = NULL; -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char **port_names; - LADSPA_PortDescriptor *port_descriptors; - LADSPA_PortRangeHint *port_range_hints; - - masher_desc = (LADSPA_Descriptor *) malloc(sizeof(LADSPA_Descriptor)); - - if (masher_desc) { - - masher_desc->UniqueID = MASHER_BASE_ID; - masher_desc->Label = strdup("ssm_masher"); - masher_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - masher_desc->Name = strdup("Masher"); - masher_desc->Maker = strdup("Dave Griffiths"); - masher_desc->Copyright = strdup("GPL"); - masher_desc->PortCount = MASHER_NUM_PORTS; - port_descriptors = - (LADSPA_PortDescriptor *) calloc(MASHER_NUM_PORTS, - sizeof(LADSPA_PortDescriptor)); - masher_desc->PortDescriptors = - (const LADSPA_PortDescriptor *)port_descriptors; - port_descriptors[MASHER_INPUT] = - LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[MASHER_GRAINPITCH] = - LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[MASHER_DENSITY] = - LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[MASHER_OUTPUT] = - LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char **)calloc(MASHER_NUM_PORTS, sizeof(char *)); - masher_desc->PortNames = (const char **)port_names; - port_names[MASHER_INPUT] = strdup("Input"); - port_names[MASHER_GRAINPITCH] = strdup("Grain Pitch"); - port_names[MASHER_DENSITY] = strdup("Density"); - port_names[MASHER_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(MASHER_NUM_PORTS, - sizeof(LADSPA_PortRangeHint))); - masher_desc->PortRangeHints = - (const LADSPA_PortRangeHint *)port_range_hints; - - port_range_hints[MASHER_GRAINPITCH].LowerBound = 1.0f; - port_range_hints[MASHER_GRAINPITCH].UpperBound = 10.0f; - port_range_hints[MASHER_GRAINPITCH].HintDescriptor = - LADSPA_HINT_DEFAULT_1 | LADSPA_HINT_BOUNDED_BELOW | - LADSPA_HINT_BOUNDED_ABOVE; - port_range_hints[MASHER_DENSITY].LowerBound = 0.0f; - port_range_hints[MASHER_DENSITY].UpperBound = 800.0f; - port_range_hints[MASHER_DENSITY].HintDescriptor = - LADSPA_HINT_DEFAULT_MIDDLE | LADSPA_HINT_BOUNDED_BELOW | - LADSPA_HINT_BOUNDED_ABOVE; - port_range_hints[MASHER_INPUT].HintDescriptor = 0; - port_range_hints[MASHER_OUTPUT].HintDescriptor = 0; - masher_desc->instantiate = masher_instantiate; - masher_desc->connect_port = masher_connect_port; - masher_desc->activate = masher_activate; - masher_desc->run = masher_run; - masher_desc->run_adding = NULL; - masher_desc->set_run_adding_gain = NULL; - masher_desc->deactivate = NULL; - masher_desc->cleanup = masher_cleanup; - } -} +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/masher", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; -void -masher_delete_descriptor(LADSPA_Descriptor * psDescriptor) +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) { - unsigned long lIndex; - - if (psDescriptor) { - free((char *)psDescriptor->Label); - free((char *)psDescriptor->Name); - free((char *)psDescriptor->Maker); - free((char *)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *) psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char *)(psDescriptor->PortNames[lIndex])); - free((char **)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *) psDescriptor->PortRangeHints); - free(psDescriptor); + switch (index) { + case 0: return &descriptor; + default: return NULL; } } - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - masher_delete_descriptor(masher_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor * -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return masher_desc; - default: - return NULL; - } -} - diff --git a/src/multiplexer.c b/src/multiplexer.c new file mode 100644 index 0000000..90f94fa --- /dev/null +++ b/src/multiplexer.c @@ -0,0 +1,120 @@ +/* Multiplxer plugin. + * Copyright 2005 Thorsten Wilms. + * Based on David Robillard's "Hz to AMS style V/Oct" plugin for the skeleton. + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#define MUX_GATE_ID 4420 + +#define MUX_NUM_PORTS 4 + +/* Port Numbers */ +#define MUX_GATE 0 +#define MUX_OFF 1 +#define MUX_ON 2 +#define MUX_OUTPUT 3 + +/* All state information for plugin */ +typedef struct +{ + /* Ports */ + float* gate_buffer; + float* off_buffer; + float* on_buffer; + float* output_buffer; +} MUX; + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + return (LV2_Handle)malloc(sizeof(MUX)); +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* location) +{ + MUX* plugin; + + plugin = (MUX*)instance; + switch (port) { + case MUX_GATE: + plugin->gate_buffer = location; + break; + case MUX_OFF: + plugin->off_buffer = location; + break; + case MUX_ON: + plugin->on_buffer = location; + break; + case MUX_OUTPUT: + plugin->output_buffer = location; + break; + } +} + +static void +run(LV2_Handle instance, uint32_t nframes) +{ + const MUX* const plugin = (MUX*)instance; + const float* const gate = plugin->gate_buffer; + const float* const off = plugin->off_buffer; + const float* const on = plugin->on_buffer; + float* const output = plugin->output_buffer; + unsigned long i; + + for (i = 0; i < nframes; i++) + output[i] = (gate[i] <= 0) ? off[i] : on[i]; +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/multiplexer", + instantiate, + connect_port, + NULL, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/multiplexer_4420.c b/src/multiplexer_4420.c deleted file mode 100644 index 772b26a..0000000 --- a/src/multiplexer_4420.c +++ /dev/null @@ -1,239 +0,0 @@ -/* Multiplxer plugin. - * Copyright 2005 Thorsten Wilms. - * GATEd on David Robillard's "Hz to AMS style V/Oct" plugin for the skeleton. - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "ladspa.h" - -#define MUX_GATE_ID 4420 - -#define MUX_NUM_PORTS 4 - -/* Port Numbers */ -#define MUX_GATE 0 -#define MUX_OFF 1 -#define MUX_ON 2 -#define MUX_OUTPUT 3 - -/* All state information for plugin */ -typedef struct -{ - /* Ports */ - LADSPA_Data* gate_buffer; - LADSPA_Data* off_buffer; - LADSPA_Data* on_buffer; - LADSPA_Data* output_buffer; -} MUX; - -/* Construct a new plugin instance */ -LADSPA_Handle -MUX_instantiate(const LADSPA_Descriptor* descriptor, - unsigned long srate) -{ - return (LADSPA_Handle)malloc(sizeof(MUX)); -} - -/* Connect a port to a data location */ -void -MUX_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - MUX* plugin; - - plugin = (MUX*)instance; - switch (port) { - case MUX_GATE: - plugin->gate_buffer = location; - break; - case MUX_OFF: - plugin->off_buffer = location; - break; - case MUX_ON: - plugin->on_buffer = location; - break; - case MUX_OUTPUT: - plugin->output_buffer = location; - break; - } -} - -void -MUX_run_cr(LADSPA_Handle instance, unsigned long nframes) -{ - const MUX* const plugin = (MUX*)instance; - - if (*plugin->gate_buffer <= 0) - *plugin->output_buffer = *plugin->off_buffer; - else - *plugin->output_buffer = *plugin->on_buffer; -} - -void -MUX_run_ar(LADSPA_Handle instance, unsigned long nframes) -{ - const MUX* const plugin = (MUX*)instance; - const LADSPA_Data* const gate = plugin->gate_buffer; - const LADSPA_Data* const off = plugin->off_buffer; - const LADSPA_Data* const on = plugin->on_buffer; - LADSPA_Data* const output = plugin->output_buffer; - unsigned long i; - - for (i = 0; i < nframes; i++) - output[i] = (gate[i] <= 0) ? off[i] : on[i]; -} - -void -MUX_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* MUX_cr_desc = NULL; -LADSPA_Descriptor* MUX_ar_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - MUX_cr_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - MUX_ar_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (MUX_cr_desc) { - MUX_cr_desc->UniqueID = MUX_GATE_ID; - MUX_cr_desc->Label = strdup("mux_cr"); - MUX_cr_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - MUX_cr_desc->Name = strdup("Multiplexer (CR)"); - MUX_cr_desc->Maker = strdup("Thorsten Wilms"); - MUX_cr_desc->Copyright = strdup("GPL"); - MUX_cr_desc->PortCount = MUX_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(MUX_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - MUX_cr_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[MUX_GATE] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[MUX_OFF] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[MUX_ON] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[MUX_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL; - port_names = (char**)calloc(MUX_NUM_PORTS, sizeof(char*)); - MUX_cr_desc->PortNames = (const char**)port_names; - port_names[MUX_GATE] = strdup("Gate"); - port_names[MUX_OFF] = strdup("Off"); - port_names[MUX_ON] = strdup("On"); - port_names[MUX_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(MUX_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - MUX_cr_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[MUX_GATE].HintDescriptor = 0; - port_range_hints[MUX_OFF].HintDescriptor = 0; - port_range_hints[MUX_ON].HintDescriptor = 0; - port_range_hints[MUX_OUTPUT].HintDescriptor = 0; - MUX_cr_desc->instantiate = MUX_instantiate; - MUX_cr_desc->connect_port = MUX_connect_port; - MUX_cr_desc->activate = NULL; - MUX_cr_desc->run = MUX_run_cr; - MUX_cr_desc->run_adding = NULL; - MUX_cr_desc->set_run_adding_gain = NULL; - MUX_cr_desc->deactivate = NULL; - MUX_cr_desc->cleanup = MUX_cleanup; - } - - if (MUX_ar_desc) { - MUX_ar_desc->UniqueID = MUX_GATE_ID+1; - MUX_ar_desc->Label = strdup("mux_ar"); - MUX_ar_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - MUX_ar_desc->Name = strdup("Multiplexer (AR)"); - MUX_ar_desc->Maker = strdup("Thorsten Wilms"); - MUX_ar_desc->Copyright = strdup("GPL"); - MUX_ar_desc->PortCount = MUX_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(MUX_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - MUX_ar_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[MUX_GATE] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[MUX_OFF] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[MUX_ON] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[MUX_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(MUX_NUM_PORTS, sizeof(char*)); - MUX_ar_desc->PortNames = (const char**)port_names; - port_names[MUX_GATE] = strdup("Gate"); - port_names[MUX_OFF] = strdup("Off"); - port_names[MUX_ON] = strdup("On"); - port_names[MUX_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(MUX_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - MUX_ar_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[MUX_GATE].HintDescriptor = 0; - port_range_hints[MUX_OFF].HintDescriptor = 0; - port_range_hints[MUX_ON].HintDescriptor = 0; - port_range_hints[MUX_OUTPUT].HintDescriptor = 0; - MUX_ar_desc->instantiate = MUX_instantiate; - MUX_ar_desc->connect_port = MUX_connect_port; - MUX_ar_desc->activate = NULL; - MUX_ar_desc->run = MUX_run_ar; - MUX_ar_desc->run_adding = NULL; - MUX_ar_desc->set_run_adding_gain = NULL; - MUX_ar_desc->deactivate = NULL; - MUX_ar_desc->cleanup = MUX_cleanup; - } -} - -void -MUX_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - MUX_delete_descriptor(MUX_cr_desc); - MUX_delete_descriptor(MUX_ar_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return MUX_cr_desc; - case 1: - return MUX_ar_desc; - default: - return NULL; - } -} - diff --git a/src/power_4400.c b/src/power_4400.c deleted file mode 100644 index 95bf1bf..0000000 --- a/src/power_4400.c +++ /dev/null @@ -1,228 +0,0 @@ -/* Base to the power of Exponent plugin. - * Copyright 2005 Thorsten Wilms. - * - * Based on David Robillard's "Hz to AMS style V/Oct" plugin for the skeleton, - * and there's not much else in here :). - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "ladspa.h" - -#define POWER_BASE_ID 4400 - -#define POWER_NUM_PORTS 3 - -/* Port Numbers */ -#define POWER_BASE 0 -#define POWER_EXPONENT 1 -#define POWER_RESULT 2 - -/* All state information for plugin */ -typedef struct -{ - /* Ports */ - LADSPA_Data* base_buffer; - LADSPA_Data* exponent_buffer; - LADSPA_Data* result_buffer; -} POWER; - -/* Construct a new plugin instance */ -LADSPA_Handle -POWER_instantiate(const LADSPA_Descriptor* descriptor, - unsigned long srate) -{ - return (LADSPA_Handle)malloc(sizeof(POWER)); -} - -/* Connect a port to a data location */ -void -POWER_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - POWER* plugin; - - plugin = (POWER*)instance; - switch (port) { - case POWER_BASE: - plugin->base_buffer = location; - break; - case POWER_EXPONENT: - plugin->exponent_buffer = location; - break; - case POWER_RESULT: - plugin->result_buffer = location; - break; - } -} - -void -POWER_run_cr(LADSPA_Handle instance, unsigned long nframes) -{ - POWER* plugin = (POWER*)instance; - - *plugin->result_buffer = powf(*plugin->base_buffer, *plugin->exponent_buffer); -} - -void -POWER_run_ar(LADSPA_Handle instance, unsigned long nframes) -{ - const POWER* const plugin = (POWER*)instance; - const LADSPA_Data* const base = plugin->base_buffer; - const LADSPA_Data* const exponent = plugin->exponent_buffer; - LADSPA_Data* const result = plugin->result_buffer; - unsigned long i; - - for (i = 0; i < nframes; ++i) - result[i] = powf(base[i], exponent[i]); -} - -void -POWER_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* power_cr_desc = NULL; -LADSPA_Descriptor* power_ar_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - power_cr_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - power_ar_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (power_cr_desc) { - - power_cr_desc->UniqueID = POWER_BASE_ID; - power_cr_desc->Label = strdup("power_cr"); - power_cr_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - power_cr_desc->Name = strdup("Power (CR)"); - power_cr_desc->Maker = strdup("Thorsten Wilms"); - power_cr_desc->Copyright = strdup("GPL"); - power_cr_desc->PortCount = POWER_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(POWER_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - power_cr_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[POWER_BASE] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[POWER_EXPONENT] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[POWER_RESULT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL; - port_names = (char**)calloc(POWER_NUM_PORTS, sizeof(char*)); - power_cr_desc->PortNames = (const char**)port_names; - port_names[POWER_BASE] = strdup("Base"); - port_names[POWER_EXPONENT] = strdup("Exponent"); - port_names[POWER_RESULT] = strdup("Result"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(POWER_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - power_cr_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[POWER_BASE].HintDescriptor = 0; - port_range_hints[POWER_EXPONENT].HintDescriptor = 0; - port_range_hints[POWER_RESULT].HintDescriptor = 0; - power_cr_desc->instantiate = POWER_instantiate; - power_cr_desc->connect_port = POWER_connect_port; - power_cr_desc->activate = NULL; - power_cr_desc->run = POWER_run_cr; - power_cr_desc->run_adding = NULL; - power_cr_desc->set_run_adding_gain = NULL; - power_cr_desc->deactivate = NULL; - power_cr_desc->cleanup = POWER_cleanup; - } - - if (power_ar_desc) { - - power_ar_desc->UniqueID = POWER_BASE_ID+1; - power_ar_desc->Label = strdup("power"); - power_ar_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - power_ar_desc->Name = strdup("Power (AR)"); - power_ar_desc->Maker = strdup("Thorsten Wilms"); - power_ar_desc->Copyright = strdup("GPL"); - power_ar_desc->PortCount = POWER_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(POWER_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - power_ar_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[POWER_BASE] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[POWER_EXPONENT] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[POWER_RESULT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(POWER_NUM_PORTS, sizeof(char*)); - power_ar_desc->PortNames = (const char**)port_names; - port_names[POWER_BASE] = strdup("Base"); - port_names[POWER_EXPONENT] = strdup("Exponent"); - port_names[POWER_RESULT] = strdup("Result"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(POWER_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - power_ar_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[POWER_BASE].HintDescriptor = 0; - port_range_hints[POWER_EXPONENT].HintDescriptor = 0; - port_range_hints[POWER_RESULT].HintDescriptor = 0; - power_ar_desc->instantiate = POWER_instantiate; - power_ar_desc->connect_port = POWER_connect_port; - power_ar_desc->activate = NULL; - power_ar_desc->run = POWER_run_ar; - power_ar_desc->run_adding = NULL; - power_ar_desc->set_run_adding_gain = NULL; - power_ar_desc->deactivate = NULL; - power_ar_desc->cleanup = POWER_cleanup; - } -} - -void -POWER_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - POWER_delete_descriptor(power_cr_desc); - POWER_delete_descriptor(power_ar_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return power_cr_desc; - case 1: - return power_ar_desc; - default: - return NULL; - } -} - diff --git a/src/prob_switch.c b/src/prob_switch.c new file mode 100644 index 0000000..1f97a23 --- /dev/null +++ b/src/prob_switch.c @@ -0,0 +1,130 @@ +/* This file is an audio plugin. + * Copyright 2005 Loki Davison. + * + * Probability parameter is the prob of input 1 being the output value. + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#define PROBSWITCH_BASE_ID 2667 + +#define PROBSWITCH_NUM_PORTS 4 + +/* Port Numbers */ +#define PROBSWITCH_INPUT1 0 +#define PROBSWITCH_INPUT2 1 +#define PROBSWITCH_PROB 2 +#define PROBSWITCH_OUTPUT 3 + +/* All state information for plugin */ +typedef struct +{ + /* Ports */ + float* input2; + float* prob; + float* input1; + float* output; +} ProbSwitch; + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + return (LV2_Handle)malloc(sizeof(ProbSwitch)); +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* location) +{ + ProbSwitch* plugin; + + plugin = (ProbSwitch*)instance; + switch (port) { + case PROBSWITCH_INPUT2: + plugin->input2 = location; + break; + case PROBSWITCH_PROB: + plugin->prob = location; + break; + case PROBSWITCH_INPUT1: + plugin->input1 = location; + break; + case PROBSWITCH_OUTPUT: + plugin->output = location; + break; + } +} + +static void +run(LV2_Handle instance, uint32_t nframes) +{ + ProbSwitch* plugin = (ProbSwitch*)instance; + float* input2 = plugin->input2; + float* prob = plugin->prob; + float* input1 = plugin->input1; + float* output = plugin->output; + size_t i; + + for (i = 0; i < nframes; ++i) + { + if((rand()/RAND_MAX) <= prob[i]) + { + output[i] = input1[i]; + } + else + { + output[i] = input2[i]; + } + } +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/prob_switch", + instantiate, + connect_port, + NULL, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/prob_switch_2667.c b/src/prob_switch_2667.c deleted file mode 100644 index d310dd5..0000000 --- a/src/prob_switch_2667.c +++ /dev/null @@ -1,266 +0,0 @@ -/* This file is an audio plugin. - * Copyright 2005 Loki Davison. - * - * Probability parameter is the prob of input 1 being the output value. - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "ladspa.h" - -#define PROBSWITCH_BASE_ID 2667 - -#define PROBSWITCH_NUM_PORTS 4 - -/* Port Numbers */ -#define PROBSWITCH_INPUT1 0 -#define PROBSWITCH_INPUT2 1 -#define PROBSWITCH_PROB 2 -#define PROBSWITCH_OUTPUT 3 - -/* All state information for plugin */ -typedef struct -{ - /* Ports */ - LADSPA_Data* input2; - LADSPA_Data* prob; - LADSPA_Data* input1; - LADSPA_Data* output; -} ProbSwitch; - -/* Construct a new plugin instance */ -LADSPA_Handle -probswitch_instantiate(const LADSPA_Descriptor* descriptor, - unsigned long srate) -{ - return (LADSPA_Handle)malloc(sizeof(ProbSwitch)); -} - -/* Connect a port to a data location */ -void -probswitch_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - ProbSwitch* plugin; - - plugin = (ProbSwitch*)instance; - switch (port) { - case PROBSWITCH_INPUT2: - plugin->input2 = location; - break; - case PROBSWITCH_PROB: - plugin->prob = location; - break; - case PROBSWITCH_INPUT1: - plugin->input1 = location; - break; - case PROBSWITCH_OUTPUT: - plugin->output = location; - break; - } -} - -void -probswitch_run_cr(LADSPA_Handle instance, unsigned long nframes) -{ - ProbSwitch* plugin = (ProbSwitch*)instance; - LADSPA_Data* input1 = plugin->input1; - LADSPA_Data* input2 = plugin->input2; - LADSPA_Data* output = plugin->output; - LADSPA_Data prob = * (plugin->prob); - size_t i; - LADSPA_Data temp; - - for (i = 0; i < nframes; ++i) - { - temp = rand(); - if((temp/RAND_MAX) <= prob) - { - output[i] = input1[i]; - } - else - { - output[i] = input2[i]; - } - } - -} - -void -probswitch_run_ar(LADSPA_Handle instance, unsigned long nframes) -{ - ProbSwitch* plugin = (ProbSwitch*)instance; - LADSPA_Data* input2 = plugin->input2; - LADSPA_Data* prob = plugin->prob; - LADSPA_Data* input1 = plugin->input1; - LADSPA_Data* output = plugin->output; - size_t i; - - for (i = 0; i < nframes; ++i) - { - if((rand()/RAND_MAX) <= prob[i]) - { - output[i] = input1[i]; - } - else - { - output[i] = input2[i]; - } - } -} - -void -probswitch_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* prob_switch_cr_desc = NULL; -LADSPA_Descriptor* prob_switch_ar_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - prob_switch_cr_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - prob_switch_ar_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (prob_switch_cr_desc) { - - prob_switch_cr_desc->UniqueID = PROBSWITCH_BASE_ID; - prob_switch_cr_desc->Label = strdup("prob_switch_cr"); - prob_switch_cr_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - prob_switch_cr_desc->Name = strdup("Probability Switch (CR Controls)"); - prob_switch_cr_desc->Maker = strdup("Loki Davison"); - prob_switch_cr_desc->Copyright = strdup("GPL"); - prob_switch_cr_desc->PortCount = PROBSWITCH_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(PROBSWITCH_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - prob_switch_cr_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[PROBSWITCH_INPUT2] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[PROBSWITCH_PROB] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[PROBSWITCH_INPUT1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[PROBSWITCH_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(PROBSWITCH_NUM_PORTS, sizeof(char*)); - prob_switch_cr_desc->PortNames = (const char**)port_names; - port_names[PROBSWITCH_INPUT2] = strdup("Input 2"); - port_names[PROBSWITCH_PROB] = strdup("Probability"); - port_names[PROBSWITCH_INPUT1] = strdup("Input 1"); - port_names[PROBSWITCH_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(PROBSWITCH_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - prob_switch_cr_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[PROBSWITCH_INPUT2].HintDescriptor = 0; - port_range_hints[PROBSWITCH_PROB].HintDescriptor = LADSPA_HINT_DEFAULT_1; - port_range_hints[PROBSWITCH_INPUT1].HintDescriptor = 0; - port_range_hints[PROBSWITCH_OUTPUT].HintDescriptor = 0; - prob_switch_cr_desc->instantiate = probswitch_instantiate; - prob_switch_cr_desc->connect_port = probswitch_connect_port; - prob_switch_cr_desc->activate = NULL; - prob_switch_cr_desc->run = probswitch_run_cr; - prob_switch_cr_desc->run_adding = NULL; - prob_switch_cr_desc->set_run_adding_gain = NULL; - prob_switch_cr_desc->deactivate = NULL; - prob_switch_cr_desc->cleanup = probswitch_cleanup; - } - - if (prob_switch_ar_desc) { - - prob_switch_ar_desc->UniqueID = PROBSWITCH_BASE_ID+1; - prob_switch_ar_desc->Label = strdup("prob_switch_ar"); - prob_switch_ar_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - prob_switch_ar_desc->Name = strdup("Probability Switch (AR Controls)"); - prob_switch_ar_desc->Maker = strdup("Loki Davison"); - prob_switch_ar_desc->Copyright = strdup("GPL"); - prob_switch_ar_desc->PortCount = PROBSWITCH_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(PROBSWITCH_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - prob_switch_ar_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[PROBSWITCH_INPUT2] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[PROBSWITCH_PROB] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[PROBSWITCH_INPUT1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[PROBSWITCH_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(PROBSWITCH_NUM_PORTS, sizeof(char*)); - prob_switch_ar_desc->PortNames = (const char**)port_names; - port_names[PROBSWITCH_INPUT2] = strdup("Input 2"); - port_names[PROBSWITCH_PROB] = strdup("Probability"); - port_names[PROBSWITCH_INPUT1] = strdup("Input 1"); - port_names[PROBSWITCH_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(PROBSWITCH_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - prob_switch_ar_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[PROBSWITCH_INPUT2].HintDescriptor = 0; - port_range_hints[PROBSWITCH_PROB].HintDescriptor = 0; - port_range_hints[PROBSWITCH_INPUT1].HintDescriptor = 0; - port_range_hints[PROBSWITCH_OUTPUT].HintDescriptor = 0; - prob_switch_ar_desc->instantiate = probswitch_instantiate; - prob_switch_ar_desc->connect_port = probswitch_connect_port; - prob_switch_ar_desc->activate = NULL; - prob_switch_ar_desc->run = probswitch_run_ar; - prob_switch_ar_desc->run_adding = NULL; - prob_switch_ar_desc->set_run_adding_gain = NULL; - prob_switch_ar_desc->deactivate = NULL; - prob_switch_ar_desc->cleanup = probswitch_cleanup; - } -} - -void -probswitch_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - probswitch_delete_descriptor(prob_switch_cr_desc); - probswitch_delete_descriptor(prob_switch_ar_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return prob_switch_cr_desc; - case 1: - return prob_switch_ar_desc; - default: - return NULL; - } -} - diff --git a/src/range_trans.c b/src/range_trans.c new file mode 100644 index 0000000..5c32d91 --- /dev/null +++ b/src/range_trans.c @@ -0,0 +1,131 @@ +/* This file is an audio plugin. Copyright 2005-2011 David Robillard. + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#define RANGETRANS_BASE_ID 4210 + +#define RANGETRANS_NUM_PORTS 6 + +/* Port Numbers */ +#define RANGETRANS_IN_MIN 0 +#define RANGETRANS_IN_MAX 1 +#define RANGETRANS_OUT_MIN 2 +#define RANGETRANS_OUT_MAX 3 +#define RANGETRANS_INPUT 4 +#define RANGETRANS_OUTPUT 5 + +/* All state information for plugin */ +typedef struct +{ + /* Ports */ + float* in_min; + float* in_max; + float* out_min; + float* out_max; + float* input; + float* output; +} RangeTrans; + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + return (LV2_Handle)malloc(sizeof(RangeTrans)); +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* location) +{ + RangeTrans* plugin; + + plugin = (RangeTrans*)instance; + switch (port) { + case RANGETRANS_IN_MIN: + plugin->in_min = location; + break; + case RANGETRANS_IN_MAX: + plugin->in_max = location; + break; + case RANGETRANS_OUT_MIN: + plugin->out_min = location; + break; + case RANGETRANS_OUT_MAX: + plugin->out_max = location; + break; + case RANGETRANS_INPUT: + plugin->input = location; + break; + case RANGETRANS_OUTPUT: + plugin->output = location; + break; + } +} + +static void +run(LV2_Handle instance, uint32_t nframes) +{ + const RangeTrans* const plugin = (RangeTrans*)instance; + const float* const in_min = plugin->in_min; + const float* const in_max = plugin->in_max; + const float* const out_min = plugin->out_min; + const float* const out_max = plugin->out_max; + const float* const input = plugin->input; + float* const output = plugin->output; + unsigned long i; + + for (i = 0; i < nframes; ++i) + output[i] = ((input[i] - in_min[i]) / (in_max[i] - in_min[i])) + * (out_max[i] - out_min[i]) + out_min[i]; +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/range_trans", + instantiate, + connect_port, + NULL, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/range_trans_4210.c b/src/range_trans_4210.c deleted file mode 100644 index 9598908..0000000 --- a/src/range_trans_4210.c +++ /dev/null @@ -1,270 +0,0 @@ -/* This file is an audio plugin. Copyright 2005-2011 David Robillard. - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "ladspa.h" - -#define RANGETRANS_BASE_ID 4210 - -#define RANGETRANS_NUM_PORTS 6 - -/* Port Numbers */ -#define RANGETRANS_IN_MIN 0 -#define RANGETRANS_IN_MAX 1 -#define RANGETRANS_OUT_MIN 2 -#define RANGETRANS_OUT_MAX 3 -#define RANGETRANS_INPUT 4 -#define RANGETRANS_OUTPUT 5 - -/* All state information for plugin */ -typedef struct -{ - /* Ports */ - LADSPA_Data* in_min; - LADSPA_Data* in_max; - LADSPA_Data* out_min; - LADSPA_Data* out_max; - LADSPA_Data* input; - LADSPA_Data* output; -} RangeTrans; - -/* Construct a new plugin instance */ -LADSPA_Handle -rangetrans_instantiate(const LADSPA_Descriptor* descriptor, - unsigned long srate) -{ - return (LADSPA_Handle)malloc(sizeof(RangeTrans)); -} - -/* Connect a port to a data location */ -void -rangetrans_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - RangeTrans* plugin; - - plugin = (RangeTrans*)instance; - switch (port) { - case RANGETRANS_IN_MIN: - plugin->in_min = location; - break; - case RANGETRANS_IN_MAX: - plugin->in_max = location; - break; - case RANGETRANS_OUT_MIN: - plugin->out_min = location; - break; - case RANGETRANS_OUT_MAX: - plugin->out_max = location; - break; - case RANGETRANS_INPUT: - plugin->input = location; - break; - case RANGETRANS_OUTPUT: - plugin->output = location; - break; - } -} - -void -rangetrans_run_cr(LADSPA_Handle instance, unsigned long nframes) -{ - const RangeTrans* const plugin = (RangeTrans*)instance; - const LADSPA_Data in_min = *plugin->in_min; - const LADSPA_Data in_max = *plugin->in_max; - const LADSPA_Data out_min = *plugin->out_min; - const LADSPA_Data out_max = *plugin->out_max; - const LADSPA_Data* const input = plugin->input; - LADSPA_Data* const output = plugin->output; - unsigned long i; - - for (i = 0; i < nframes; ++i) - output[i] = ((input[i] - in_min) / (in_max - in_min)) - * (out_max - out_min) + out_min; -} - -void -rangetrans_run_ar(LADSPA_Handle instance, unsigned long nframes) -{ - const RangeTrans* const plugin = (RangeTrans*)instance; - const LADSPA_Data* const in_min = plugin->in_min; - const LADSPA_Data* const in_max = plugin->in_max; - const LADSPA_Data* const out_min = plugin->out_min; - const LADSPA_Data* const out_max = plugin->out_max; - const LADSPA_Data* const input = plugin->input; - LADSPA_Data* const output = plugin->output; - unsigned long i; - - for (i = 0; i < nframes; ++i) - output[i] = ((input[i] - in_min[i]) / (in_max[i] - in_min[i])) - * (out_max[i] - out_min[i]) + out_min[i]; -} - -void -rangetrans_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* range_trans_cr_desc = NULL; -LADSPA_Descriptor* range_trans_ar_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - range_trans_cr_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - range_trans_ar_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (range_trans_cr_desc) { - - range_trans_cr_desc->UniqueID = RANGETRANS_BASE_ID; - range_trans_cr_desc->Label = strdup("range_trans_cr"); - range_trans_cr_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - range_trans_cr_desc->Name = strdup("Range Translator (CR Controls)"); - range_trans_cr_desc->Maker = strdup("David Robillard"); - range_trans_cr_desc->Copyright = strdup("GPL"); - range_trans_cr_desc->PortCount = RANGETRANS_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(RANGETRANS_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - range_trans_cr_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[RANGETRANS_IN_MIN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[RANGETRANS_IN_MAX] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[RANGETRANS_OUT_MIN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[RANGETRANS_OUT_MAX] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[RANGETRANS_INPUT] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[RANGETRANS_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(RANGETRANS_NUM_PORTS, sizeof(char*)); - range_trans_cr_desc->PortNames = (const char**)port_names; - port_names[RANGETRANS_IN_MIN] = strdup("Input Min"); - port_names[RANGETRANS_IN_MAX] = strdup("Input Max"); - port_names[RANGETRANS_OUT_MIN] = strdup("Output Min"); - port_names[RANGETRANS_OUT_MAX] = strdup("Output Max"); - port_names[RANGETRANS_INPUT] = strdup("Input"); - port_names[RANGETRANS_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(RANGETRANS_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - range_trans_cr_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[RANGETRANS_IN_MIN].HintDescriptor = LADSPA_HINT_DEFAULT_0; - port_range_hints[RANGETRANS_IN_MAX].HintDescriptor = LADSPA_HINT_DEFAULT_1; - port_range_hints[RANGETRANS_OUT_MIN].HintDescriptor = LADSPA_HINT_DEFAULT_0; - port_range_hints[RANGETRANS_OUT_MAX].HintDescriptor = LADSPA_HINT_DEFAULT_1; - port_range_hints[RANGETRANS_INPUT].HintDescriptor = 0; - port_range_hints[RANGETRANS_OUTPUT].HintDescriptor = 0; - range_trans_cr_desc->instantiate = rangetrans_instantiate; - range_trans_cr_desc->connect_port = rangetrans_connect_port; - range_trans_cr_desc->activate = NULL; - range_trans_cr_desc->run = rangetrans_run_cr; - range_trans_cr_desc->run_adding = NULL; - range_trans_cr_desc->set_run_adding_gain = NULL; - range_trans_cr_desc->deactivate = NULL; - range_trans_cr_desc->cleanup = rangetrans_cleanup; - } - - if (range_trans_ar_desc) { - - range_trans_ar_desc->UniqueID = RANGETRANS_BASE_ID+1; - range_trans_ar_desc->Label = strdup("range_trans_ar"); - range_trans_ar_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - range_trans_ar_desc->Name = strdup("Range Translator (AR Controls)"); - range_trans_ar_desc->Maker = strdup("David Robillard"); - range_trans_ar_desc->Copyright = strdup("GPL"); - range_trans_ar_desc->PortCount = RANGETRANS_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(RANGETRANS_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - range_trans_ar_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[RANGETRANS_IN_MIN] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[RANGETRANS_IN_MAX] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[RANGETRANS_OUT_MIN] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[RANGETRANS_OUT_MAX] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[RANGETRANS_INPUT] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[RANGETRANS_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(RANGETRANS_NUM_PORTS, sizeof(char*)); - range_trans_ar_desc->PortNames = (const char**)port_names; - port_names[RANGETRANS_IN_MIN] = strdup("Input Min"); - port_names[RANGETRANS_IN_MAX] = strdup("Input Max"); - port_names[RANGETRANS_OUT_MIN] = strdup("Output Min"); - port_names[RANGETRANS_OUT_MAX] = strdup("Output Max"); - port_names[RANGETRANS_INPUT] = strdup("Input"); - port_names[RANGETRANS_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(RANGETRANS_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - range_trans_ar_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[RANGETRANS_IN_MIN].HintDescriptor = 0; - port_range_hints[RANGETRANS_IN_MAX].HintDescriptor = 0; - port_range_hints[RANGETRANS_OUT_MIN].HintDescriptor = 0; - port_range_hints[RANGETRANS_OUT_MAX].HintDescriptor = 0; - port_range_hints[RANGETRANS_INPUT].HintDescriptor = 0; - port_range_hints[RANGETRANS_OUTPUT].HintDescriptor = 0; - range_trans_ar_desc->instantiate = rangetrans_instantiate; - range_trans_ar_desc->connect_port = rangetrans_connect_port; - range_trans_ar_desc->activate = NULL; - range_trans_ar_desc->run = rangetrans_run_ar; - range_trans_ar_desc->run_adding = NULL; - range_trans_ar_desc->set_run_adding_gain = NULL; - range_trans_ar_desc->deactivate = NULL; - range_trans_ar_desc->cleanup = rangetrans_cleanup; - } -} - -void -rangetrans_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - rangetrans_delete_descriptor(range_trans_cr_desc); - rangetrans_delete_descriptor(range_trans_ar_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return range_trans_cr_desc; - case 1: - return range_trans_ar_desc; - default: - return NULL; - } -} - diff --git a/src/sample_and_hold.c b/src/sample_and_hold.c new file mode 100644 index 0000000..2e01f5f --- /dev/null +++ b/src/sample_and_hold.c @@ -0,0 +1,150 @@ +/* Sample and Hold. + * Copyright 2005 Thorsten Wilms. + * Based on David Robillard's "Hz to AMS style V/Oct" plugin for the skeleton. + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#define ID 4430 + +#define NUM_PORTS 5 + +/* Port Numbers */ +#define INPUT 0 +#define TRIGGER 1 +#define THRESHOLD 2 +#define CONTINUOUS 3 +#define OUTPUT 4 + +/* All state information for plugin */ +typedef struct +{ + /* Ports */ + float* input_buffer; + float* trigger_buffer; + float* threshold_buffer; + float* continuous_buffer; + float* output_buffer; + + float hold; /* the value sampled and held */ + float last_trigger; /* trigger port value from the previous frame */ +} SH; + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + return (LV2_Handle)malloc(sizeof(SH)); +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* location) +{ + SH* plugin = (SH*)instance; + + switch (port) { + case INPUT: + plugin->input_buffer = location; + break; + case TRIGGER: + plugin->trigger_buffer = location; + break; + case THRESHOLD: + plugin->threshold_buffer = location; + break; + case CONTINUOUS: + plugin->continuous_buffer = location; + break; + case OUTPUT: + plugin->output_buffer = location; + break; + } +} + +static void +activate(LV2_Handle instance) +{ + SH* plugin = (SH*)instance; + + plugin->hold = 0; + plugin->last_trigger = 0; +} + +static void +run(LV2_Handle instance, uint32_t nframes) +{ + SH* const plugin = (SH*)instance; + const float* const input = plugin->input_buffer; + const float* const trigger = plugin->trigger_buffer; + const float* const threshold = plugin->threshold_buffer; + const float* const continuous = plugin->continuous_buffer; + float* const output = plugin->output_buffer; + + unsigned long i; + + for (i = 0; i < nframes; i++) { + if (continuous[0] != 0) { + /* Continuous triggering on (sample while trigger > threshold) */ + if (trigger[i] >= threshold[i]) + plugin->hold = input[i]; + } else { + /* Continuous triggering off + * (only sample on first frame with trigger > threshold) */ + if (plugin->last_trigger < threshold[i] && trigger[i] >= threshold[i]) + plugin->hold = input[i]; + } + + plugin->last_trigger = trigger[i]; + output[i] = plugin->hold; + } +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/sample_and_hold", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/sample_and_hold_4430.c b/src/sample_and_hold_4430.c deleted file mode 100644 index b8a8958..0000000 --- a/src/sample_and_hold_4430.c +++ /dev/null @@ -1,296 +0,0 @@ -/* Sample and Hold. - * Copyright 2005 Thorsten Wilms. - * Based on David Robillard's "Hz to AMS style V/Oct" plugin for the skeleton. - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> - -#include "ladspa.h" - -#define SH_ID 4430 - -#define SH_NUM_PORTS 5 - -/* Port Numbers */ -#define SH_INPUT 0 -#define SH_TRIGGER 1 -#define SH_THRESHOLD 2 -#define SH_CONTINUOUS 3 -#define SH_OUTPUT 4 - -/* All state information for plugin */ -typedef struct -{ - /* Ports */ - LADSPA_Data* input_buffer; - LADSPA_Data* trigger_buffer; - LADSPA_Data* threshold_buffer; - LADSPA_Data* continuous_buffer; - LADSPA_Data* output_buffer; - - float hold; /* the value sampled and held */ - float last_trigger; /* trigger port value from the previous frame */ -} SH; - -/* Construct a new plugin instance */ -LADSPA_Handle -SH_instantiate(const LADSPA_Descriptor * descriptor, unsigned long srate) -{ - return (LADSPA_Handle)malloc(sizeof(SH)); -} - -/* Connect a port to a data location */ -void -SH_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - SH* plugin = (SH*)instance; - - switch (port) { - case SH_INPUT: - plugin->input_buffer = location; - break; - case SH_TRIGGER: - plugin->trigger_buffer = location; - break; - case SH_THRESHOLD: - plugin->threshold_buffer = location; - break; - case SH_CONTINUOUS: - plugin->continuous_buffer = location; - break; - case SH_OUTPUT: - plugin->output_buffer = location; - break; - } -} - -void -SH_activate(LADSPA_Handle instance) -{ - SH* plugin = (SH*)instance; - - plugin->hold = 0; - plugin->last_trigger = 0; -} - -void -SH_run_cr(LADSPA_Handle instance, unsigned long nframes) -{ - SH* const plugin = (SH*)instance; - const LADSPA_Data* const input = plugin->input_buffer; - const LADSPA_Data* const trigger = plugin->trigger_buffer; - const LADSPA_Data threshold = *plugin->threshold_buffer; - const LADSPA_Data continuous = *plugin->continuous_buffer; - LADSPA_Data* const output = plugin->output_buffer; - - unsigned long i; - - /* Continuous triggering on (sample while trigger > threshold) */ - if (continuous != 0.0f) { - for (i = 0; i < nframes; i++) { - if (trigger[i] >= threshold) - plugin->hold = input[i]; - plugin->last_trigger = trigger[i]; - output[i] = plugin->hold; - } - - /* Continuous triggering off - * (only sample on first frame with trigger > threshold) */ - } else { - for (i = 0; i < nframes; i++) { - if (plugin->last_trigger < threshold && trigger[i] >= threshold) - plugin->hold = input[i]; - plugin->last_trigger = trigger[i]; - output[i] = plugin->hold; - } - } -} - -void -SH_run_ar(LADSPA_Handle instance, unsigned long nframes) -{ - SH* const plugin = (SH*)instance; - const LADSPA_Data* const input = plugin->input_buffer; - const LADSPA_Data* const trigger = plugin->trigger_buffer; - const LADSPA_Data* const threshold = plugin->threshold_buffer; - const LADSPA_Data* const continuous = plugin->continuous_buffer; - LADSPA_Data* const output = plugin->output_buffer; - - unsigned long i; - - for (i = 0; i < nframes; i++) { - if (continuous[0] != 0) { - /* Continuous triggering on (sample while trigger > threshold) */ - if (trigger[i] >= threshold[i]) - plugin->hold = input[i]; - } else { - /* Continuous triggering off - * (only sample on first frame with trigger > threshold) */ - if (plugin->last_trigger < threshold[i] && trigger[i] >= threshold[i]) - plugin->hold = input[i]; - } - - plugin->last_trigger = trigger[i]; - output[i] = plugin->hold; - } -} - -void -SH_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* SH_cr_desc = NULL; -LADSPA_Descriptor* SH_ar_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - SH_cr_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - SH_ar_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (SH_cr_desc) { - SH_cr_desc->UniqueID = SH_ID; - SH_cr_desc->Label = strdup("sh_cr"); - SH_cr_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - SH_cr_desc->Name = strdup("Sample and Hold (CR Threshold)"); - SH_cr_desc->Maker = strdup("Thorsten Wilms"); - SH_cr_desc->Copyright = strdup("GPL"); - SH_cr_desc->PortCount = SH_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(SH_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - SH_cr_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[SH_INPUT] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[SH_TRIGGER] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[SH_THRESHOLD] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[SH_CONTINUOUS] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[SH_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(SH_NUM_PORTS, sizeof(char*)); - SH_cr_desc->PortNames = (const char**)port_names; - port_names[SH_INPUT] = strdup("Input"); - port_names[SH_TRIGGER] = strdup("Trigger"); - port_names[SH_THRESHOLD] = strdup("Threshold"); - port_names[SH_CONTINUOUS] = strdup("Continuous Triggering"); - port_names[SH_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(SH_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - SH_cr_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[SH_INPUT].HintDescriptor = 0; - port_range_hints[SH_TRIGGER].HintDescriptor = 0; - port_range_hints[SH_THRESHOLD].HintDescriptor = 0; - port_range_hints[SH_CONTINUOUS].HintDescriptor = LADSPA_HINT_TOGGLED; - port_range_hints[SH_OUTPUT].HintDescriptor = 0; - SH_cr_desc->instantiate = SH_instantiate; - SH_cr_desc->connect_port = SH_connect_port; - SH_cr_desc->activate = SH_activate; - SH_cr_desc->run = SH_run_cr; - SH_cr_desc->run_adding = NULL; - SH_cr_desc->set_run_adding_gain = NULL; - SH_cr_desc->deactivate = NULL; - SH_cr_desc->cleanup = SH_cleanup; - } - - if (SH_ar_desc) { - SH_ar_desc->UniqueID = SH_ID+1; - SH_ar_desc->Label = strdup("sh_ar"); - SH_ar_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - SH_ar_desc->Name = strdup("Sample and Hold (AR Threshold)"); - SH_ar_desc->Maker = strdup("Thorsten Wilms"); - SH_ar_desc->Copyright = strdup("GPL"); - SH_ar_desc->PortCount = SH_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(SH_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - SH_ar_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[SH_INPUT] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[SH_TRIGGER] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[SH_THRESHOLD] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[SH_CONTINUOUS] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[SH_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(SH_NUM_PORTS, sizeof(char*)); - SH_ar_desc->PortNames = (const char**)port_names; - port_names[SH_INPUT] = strdup("Input"); - port_names[SH_TRIGGER] = strdup("Trigger"); - port_names[SH_THRESHOLD] = strdup("Threshold"); - port_names[SH_CONTINUOUS] = strdup("Continuous Triggering"); - port_names[SH_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(SH_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - SH_ar_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[SH_INPUT].HintDescriptor = 0; - port_range_hints[SH_TRIGGER].HintDescriptor = 0; - port_range_hints[SH_THRESHOLD].HintDescriptor = 0; - port_range_hints[SH_CONTINUOUS].HintDescriptor = LADSPA_HINT_TOGGLED; - port_range_hints[SH_OUTPUT].HintDescriptor = 0; - SH_ar_desc->instantiate = SH_instantiate; - SH_ar_desc->connect_port = SH_connect_port; - SH_ar_desc->activate = SH_activate; - SH_ar_desc->run = SH_run_ar; - SH_ar_desc->run_adding = NULL; - SH_ar_desc->set_run_adding_gain = NULL; - SH_ar_desc->deactivate = NULL; - SH_ar_desc->cleanup = SH_cleanup; - } -} - -void -SH_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - SH_delete_descriptor(SH_cr_desc); - SH_delete_descriptor(SH_ar_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return SH_cr_desc; - case 1: - return SH_ar_desc; - default: - return NULL; - } -} - diff --git a/src/signal_abs.c b/src/signal_abs.c new file mode 100644 index 0000000..a81b282 --- /dev/null +++ b/src/signal_abs.c @@ -0,0 +1,124 @@ +/* Absolute value audio plugin. + * Copyright 2005 Loki Davison. + * + * Sign parameter is the sign of the output, 0 being negative and >0 begin positive. + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#define SIGNAL_ABS_BASE_ID 2669 + +#define SIGNAL_ABS_NUM_PORTS 3 + +/* Port Numbers */ +#define SIGNAL_ABS_INPUT1 0 +#define SIGNAL_ABS_SIGN 1 +#define SIGNAL_ABS_OUTPUT 2 + +/* All state information for plugin */ +typedef struct +{ + /* Ports */ + float* sign; + float* input1; + float* output; +} SignalAbs; + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + return (LV2_Handle)malloc(sizeof(SignalAbs)); +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* location) +{ + SignalAbs* plugin; + + plugin = (SignalAbs*)instance; + switch (port) { + case SIGNAL_ABS_SIGN: + plugin->sign = location; + break; + case SIGNAL_ABS_INPUT1: + plugin->input1 = location; + break; + case SIGNAL_ABS_OUTPUT: + plugin->output = location; + break; + } +} + +static void +run_ar(LV2_Handle instance, uint32_t nframes) +{ + SignalAbs* plugin = (SignalAbs*)instance; + float* sign = plugin->sign; + float* input1 = plugin->input1; + float* output = plugin->output; + size_t i; + + for (i = 0; i < nframes; ++i) + { + if(sign[i] > 0.5) + { + output[i] = fabs(input1[i]); + } + else + { + output[i] = fabs(input1[i]) * -1; + } + } +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/signal_abs", + instantiate, + connect_port, + NULL, + run_ar, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/signal_abs_2669.c b/src/signal_abs_2669.c deleted file mode 100644 index d158cd0..0000000 --- a/src/signal_abs_2669.c +++ /dev/null @@ -1,251 +0,0 @@ -/* Absolute value audio plugin. - * Copyright 2005 Loki Davison. - * - * Sign parameter is the sign of the output, 0 being negative and >0 begin positive. - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "ladspa.h" - -#define SIGNAL_ABS_BASE_ID 2669 - -#define SIGNAL_ABS_NUM_PORTS 3 - -/* Port Numbers */ -#define SIGNAL_ABS_INPUT1 0 -#define SIGNAL_ABS_SIGN 1 -#define SIGNAL_ABS_OUTPUT 2 - -/* All state information for plugin */ -typedef struct -{ - /* Ports */ - LADSPA_Data* sign; - LADSPA_Data* input1; - LADSPA_Data* output; -} SignalAbs; - -/* Construct a new plugin instance */ -LADSPA_Handle -signalabs_instantiate(const LADSPA_Descriptor* descriptor, - unsigned long srate) -{ - return (LADSPA_Handle)malloc(sizeof(SignalAbs)); -} - -/* Connect a port to a data location */ -void -signalabs_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - SignalAbs* plugin; - - plugin = (SignalAbs*)instance; - switch (port) { - case SIGNAL_ABS_SIGN: - plugin->sign = location; - break; - case SIGNAL_ABS_INPUT1: - plugin->input1 = location; - break; - case SIGNAL_ABS_OUTPUT: - plugin->output = location; - break; - } -} - -void -signalabs_run_cr(LADSPA_Handle instance, unsigned long nframes) -{ - SignalAbs* plugin = (SignalAbs*)instance; - LADSPA_Data* input1 = plugin->input1; - LADSPA_Data* output = plugin->output; - LADSPA_Data sign = * (plugin->sign); - size_t i; - - for (i = 0; i < nframes; ++i) - { - if(sign > 0) - { - output[i] = fabs(input1[i]); - } - else - { - output[i] = fabs(input1[i]) * -1; - } - } - -} - -void -signalabs_run_ar(LADSPA_Handle instance, unsigned long nframes) -{ - SignalAbs* plugin = (SignalAbs*)instance; - LADSPA_Data* sign = plugin->sign; - LADSPA_Data* input1 = plugin->input1; - LADSPA_Data* output = plugin->output; - size_t i; - - for (i = 0; i < nframes; ++i) - { - if(sign[i] > 0.5) - { - output[i] = fabs(input1[i]); - } - else - { - output[i] = fabs(input1[i]) * -1; - } - } -} - -void -signalabs_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* signal_abs_cr_desc = NULL; -LADSPA_Descriptor* signal_abs_ar_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - signal_abs_cr_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - signal_abs_ar_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (signal_abs_cr_desc) { - - signal_abs_cr_desc->UniqueID = SIGNAL_ABS_BASE_ID; - signal_abs_cr_desc->Label = strdup("signal_abs_cr"); - signal_abs_cr_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - signal_abs_cr_desc->Name = strdup("Signal Absolute value, negative or positive (CR Controls)"); - signal_abs_cr_desc->Maker = strdup("Loki Davison"); - signal_abs_cr_desc->Copyright = strdup("GPL"); - signal_abs_cr_desc->PortCount = SIGNAL_ABS_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(SIGNAL_ABS_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - signal_abs_cr_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[SIGNAL_ABS_SIGN] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[SIGNAL_ABS_INPUT1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[SIGNAL_ABS_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(SIGNAL_ABS_NUM_PORTS, sizeof(char*)); - signal_abs_cr_desc->PortNames = (const char**)port_names; - port_names[SIGNAL_ABS_SIGN] = strdup("Sign"); - port_names[SIGNAL_ABS_INPUT1] = strdup("Input"); - port_names[SIGNAL_ABS_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(SIGNAL_ABS_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - signal_abs_cr_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[SIGNAL_ABS_SIGN].HintDescriptor = LADSPA_HINT_DEFAULT_1 | LADSPA_HINT_TOGGLED; - port_range_hints[SIGNAL_ABS_INPUT1].HintDescriptor = 0; - port_range_hints[SIGNAL_ABS_OUTPUT].HintDescriptor = 0; - signal_abs_cr_desc->instantiate = signalabs_instantiate; - signal_abs_cr_desc->connect_port = signalabs_connect_port; - signal_abs_cr_desc->activate = NULL; - signal_abs_cr_desc->run = signalabs_run_cr; - signal_abs_cr_desc->run_adding = NULL; - signal_abs_cr_desc->set_run_adding_gain = NULL; - signal_abs_cr_desc->deactivate = NULL; - signal_abs_cr_desc->cleanup = signalabs_cleanup; - } - - if (signal_abs_ar_desc) { - - signal_abs_ar_desc->UniqueID = SIGNAL_ABS_BASE_ID+1; - signal_abs_ar_desc->Label = strdup("signal_abs_ar"); - signal_abs_ar_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - signal_abs_ar_desc->Name = strdup("Signal Absolute value, negative or positive (AR Controls)"); - signal_abs_ar_desc->Maker = strdup("Loki Davison"); - signal_abs_ar_desc->Copyright = strdup("GPL"); - signal_abs_ar_desc->PortCount = SIGNAL_ABS_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(SIGNAL_ABS_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - signal_abs_ar_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[SIGNAL_ABS_SIGN] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[SIGNAL_ABS_INPUT1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[SIGNAL_ABS_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names = (char**)calloc(SIGNAL_ABS_NUM_PORTS, sizeof(char*)); - signal_abs_ar_desc->PortNames = (const char**)port_names; - port_names[SIGNAL_ABS_SIGN] = strdup("Sign"); - port_names[SIGNAL_ABS_INPUT1] = strdup("Input 1"); - port_names[SIGNAL_ABS_OUTPUT] = strdup("Output"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(SIGNAL_ABS_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - signal_abs_ar_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[SIGNAL_ABS_SIGN].HintDescriptor = 0; - port_range_hints[SIGNAL_ABS_INPUT1].HintDescriptor = 0; - port_range_hints[SIGNAL_ABS_OUTPUT].HintDescriptor = 0; - signal_abs_ar_desc->instantiate = signalabs_instantiate; - signal_abs_ar_desc->connect_port = signalabs_connect_port; - signal_abs_ar_desc->activate = NULL; - signal_abs_ar_desc->run = signalabs_run_ar; - signal_abs_ar_desc->run_adding = NULL; - signal_abs_ar_desc->set_run_adding_gain = NULL; - signal_abs_ar_desc->deactivate = NULL; - signal_abs_ar_desc->cleanup = signalabs_cleanup; - } -} - -void -signalabs_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - signalabs_delete_descriptor(signal_abs_cr_desc); - signalabs_delete_descriptor(signal_abs_ar_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return signal_abs_cr_desc; - case 1: - return signal_abs_ar_desc; - default: - return NULL; - } -} - diff --git a/src/slew_limiter.c b/src/slew_limiter.c new file mode 100644 index 0000000..c663543 --- /dev/null +++ b/src/slew_limiter.c @@ -0,0 +1,149 @@ +/* slew_limiter - A LV2 plugin that limits the rate of change of a + * signal. Increases and decreases in the signal can be + * limited separately. + * + * Copyright 2005 Lars Luthman + * LV2 skeleton code taken from dahdsr_fexp.c by Loki Davison + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> +#include <math.h> + +/* These are the port numbers */ +#define SLIM_INPUT 0 +#define SLIM_MAXRISE 1 +#define SLIM_MAXFALL 2 +#define SLIM_OUTPUT 3 + +/* This is an array pointer to the descriptors of the different variants */ +LV2_Descriptor** slim_descriptors = 0; + +/* This is the data for a single instance of the plugin */ +typedef struct +{ + float* input; + float* maxrise; + float* maxfall; + float* reset; + float* output; + float srate; + float last_output; +} +SLim; + +/* Clean up after a plugin instance */ +static void cleanup (LV2_Handle instance) +{ + free(instance); +} + +/* This is called when the hosts connects a port to a buffer */ +static void connect_port(LV2_Handle instance, + uint32_t port, void* data) +{ + SLim* plugin = (SLim *)instance; + + switch (port) { + case SLIM_INPUT: + plugin->input = data; + break; + case SLIM_MAXRISE: + plugin->maxrise = data; + break; + case SLIM_MAXFALL: + plugin->maxfall = data; + break; + case SLIM_OUTPUT: + plugin->output = data; + break; + } +} + +/* The host uses this function to create an instance of a plugin */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + SLim* plugin = (SLim*)calloc(1, sizeof(SLim)); + plugin->srate = (float)sample_rate; + return (LV2_Handle)plugin; +} + +/* This is called before the hosts starts to use the plugin instance */ +static void activate(LV2_Handle instance) +{ + SLim* plugin = (SLim*)instance; + plugin->last_output = 0; +} + +/* The run function! */ +static void run(LV2_Handle instance, uint32_t sample_count) +{ + SLim* plugin = (SLim*)instance; + + if (plugin->input && plugin->output) { + unsigned long i; + float maxrise, maxfall; + for (i = 0; i < sample_count; ++i) { + + if (plugin->maxrise) + maxrise = plugin->maxrise[i]; + else + maxrise = 0; + + if (plugin->maxfall) + maxfall = plugin->maxfall[i]; + else + maxfall = 0; + + float maxinc = maxrise / plugin->srate; + float maxdec = maxfall / plugin->srate; + float increment = plugin->input[i] - plugin->last_output; + if (increment > maxinc) + increment = maxinc; + else if (increment < -maxdec) + increment = -maxdec; + + plugin->output[i] = plugin->last_output + increment; + plugin->last_output = plugin->output[i]; + } + } +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/slew_limiter", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/slew_limiter_2743.c b/src/slew_limiter_2743.c deleted file mode 100644 index b612f1d..0000000 --- a/src/slew_limiter_2743.c +++ /dev/null @@ -1,259 +0,0 @@ -/* slew_limiter - A LADSPA plugin that limits the rate of change of a - * signal. Increases and decreases in the signal can be - * limited separately. - * - * Copyright 2005 Lars Luthman - * LADSPA skeleton code taken from dahdsr_fexp.c by Loki Davison - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <ladspa.h> -#include <math.h> - -/* This defines the number of "variants", i.e. the number of separate plugins - in this file */ -#define SLIM_VARIANT_COUNT 2 - -/* These are the port numbers */ -#define SLIM_INPUT 0 -#define SLIM_MAXRISE 1 -#define SLIM_MAXFALL 2 -#define SLIM_OUTPUT 3 - -/* This is an array pointer to the descriptors of the different variants */ -LADSPA_Descriptor** slim_descriptors = 0; - -/* This is the data for a single instance of the plugin */ -typedef struct -{ - LADSPA_Data* input; - LADSPA_Data* maxrise; - LADSPA_Data* maxfall; - LADSPA_Data* reset; - LADSPA_Data* output; - LADSPA_Data srate; - LADSPA_Data last_output; -} -SLim; - -/* LADSPA hosts use this function to get the plugin descriptors */ -const LADSPA_Descriptor* ladspa_descriptor(unsigned long index) -{ - if (index < SLIM_VARIANT_COUNT) - return slim_descriptors[index]; - return 0; -} - -/* Clean up after a plugin instance */ -void cleanupSLim (LADSPA_Handle instance) -{ - free(instance); -} - -/* This is called when the hosts connects a port to a buffer */ -void connectPortSLim(LADSPA_Handle instance, - unsigned long port, LADSPA_Data* data) -{ - SLim* plugin = (SLim *)instance; - - switch (port) { - case SLIM_INPUT: - plugin->input = data; - break; - case SLIM_MAXRISE: - plugin->maxrise = data; - break; - case SLIM_MAXFALL: - plugin->maxfall = data; - break; - case SLIM_OUTPUT: - plugin->output = data; - break; - } -} - -/* The host uses this function to create an instance of a plugin */ -LADSPA_Handle instantiateSLim(const LADSPA_Descriptor * descriptor, - unsigned long sample_rate) -{ - SLim* plugin = (SLim*)calloc(1, sizeof(SLim)); - plugin->srate = (LADSPA_Data)sample_rate; - return (LADSPA_Handle)plugin; -} - -/* This is called before the hosts starts to use the plugin instance */ -void activateSLim(LADSPA_Handle instance) -{ - SLim* plugin = (SLim*)instance; - plugin->last_output = 0; -} - -/* The run function! */ -void runSLim(LADSPA_Handle instance, unsigned long sample_count, int variant) -{ - SLim* plugin = (SLim*)instance; - - if (plugin->input && plugin->output) { - unsigned long i; - LADSPA_Data maxrise, maxfall; - for (i = 0; i < sample_count; ++i) { - - if (plugin->maxrise && variant == 0) - maxrise = plugin->maxrise[i]; - else if (plugin->maxrise && variant == 1) - maxrise = plugin->maxrise[0]; - else - maxrise = 0; - - if (plugin->maxfall && variant == 0) - maxfall = plugin->maxfall[i]; - else if (plugin->maxfall && variant == 1) - maxfall = plugin->maxfall[0]; - else - maxfall = 0; - - LADSPA_Data maxinc = maxrise / plugin->srate; - LADSPA_Data maxdec = maxfall / plugin->srate; - LADSPA_Data increment = plugin->input[i] - plugin->last_output; - if (increment > maxinc) - increment = maxinc; - else if (increment < -maxdec) - increment = -maxdec; - - plugin->output[i] = plugin->last_output + increment; - plugin->last_output = plugin->output[i]; - } - } -} - -void runSLim_audio(LADSPA_Handle instance, unsigned long sample_count) -{ - runSLim(instance, sample_count, 0); -} - -void runSLim_control(LADSPA_Handle instance, unsigned long sample_count) -{ - runSLim(instance, sample_count, 1); -} - -/* Called automagically by the dynamic linker - set up global stuff here */ -void _init(void) -{ - static const unsigned long ids[] = { 2743, 2744 }; - static const char * labels[] = { "slew_limiter_ra", "slew_limiter_rc" }; - static const char * names[] = { "Slew limiter (RA)", "Slew limiter (RC)" }; - - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - LADSPA_Descriptor* descriptor; - - LADSPA_PortDescriptor input_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, - LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor maxrise_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, - LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor maxfall_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, - LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor output_port_descriptors[] = - { LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO, - LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO }; - - void (*run_functions[]) (LADSPA_Handle, unsigned long) = { runSLim_audio, - runSLim_control }; - - slim_descriptors = (LADSPA_Descriptor**)calloc(SLIM_VARIANT_COUNT, - sizeof(LADSPA_Descriptor)); - - if (slim_descriptors) { - int i; - for (i = 0; i < SLIM_VARIANT_COUNT; ++i) { - slim_descriptors[i] = - (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - descriptor = slim_descriptors[i]; - if (descriptor) { - descriptor->UniqueID = ids[i]; - descriptor->Label = labels[i]; - descriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - descriptor->Name = names[i]; - descriptor->Maker = "Lars Luthman <larsl@users.sourceforge.net>"; - descriptor->Copyright = "GPL"; - descriptor->PortCount = 4; - - port_descriptors = - (LADSPA_PortDescriptor*)calloc(4, sizeof(LADSPA_PortDescriptor)); - descriptor->PortDescriptors = - (const LADSPA_PortDescriptor*)port_descriptors; - port_range_hints = - (LADSPA_PortRangeHint*)calloc(4, sizeof(LADSPA_PortRangeHint)); - descriptor->PortRangeHints = - (const LADSPA_PortRangeHint*)port_range_hints; - - port_names = (char**)calloc(9, sizeof (char*)); - descriptor->PortNames = (const char**)port_names; - - /* Parameters for Input */ - port_descriptors[SLIM_INPUT] = input_port_descriptors[i]; - port_names[SLIM_INPUT] = "Input"; - - /* Parameters for Rise rate */ - port_descriptors[SLIM_MAXRISE] = maxrise_port_descriptors[i]; - port_names[SLIM_MAXRISE] = "Rise rate (1/s)"; - - /* Parameters for Fall rate */ - port_descriptors[SLIM_MAXFALL] = maxfall_port_descriptors[i]; - port_names[SLIM_MAXFALL] = "Fall rate (1/s)"; - - /* Parameters for Output*/ - port_descriptors[SLIM_OUTPUT] = output_port_descriptors[i]; - port_names[SLIM_OUTPUT] = "Output"; - - descriptor->activate = activateSLim; - descriptor->cleanup = cleanupSLim; - descriptor->connect_port = connectPortSLim; - descriptor->deactivate = NULL; - descriptor->instantiate = instantiateSLim; - descriptor->run = run_functions[i]; - descriptor->run_adding = NULL; - descriptor->set_run_adding_gain = NULL; - } - } - } -} - -/* Called automagically by the dynamic linker - free global stuff here */ -void _fini(void) -{ - LADSPA_Descriptor* descriptor; - int i; - - if (slim_descriptors) { - for (i = 0; i < SLIM_VARIANT_COUNT; i++) { - descriptor = slim_descriptors[i]; - if (descriptor) { - free((LADSPA_PortDescriptor*)descriptor->PortDescriptors); - free((char**)descriptor->PortNames); - free((LADSPA_PortRangeHint*)descriptor->PortRangeHints); - free(descriptor); - } - } - free(slim_descriptors); - } -} diff --git a/src/slide.c b/src/slide.c new file mode 100644 index 0000000..125c96a --- /dev/null +++ b/src/slide.c @@ -0,0 +1,170 @@ +/* slide.c - A LV2 plugin that "slides" the output signal between + * the current and the previous input value, taking the given + * number of seconds to reach the current input value. + * + * Copyright 2005 Lars Luthman + * LV2 skeleton code taken from dahdsr_fexp.c by Loki Davison + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> +#include <math.h> + +/* These are the port numbers */ +#define SLIDE_INPUT 0 +#define SLIDE_RISETIME 1 +#define SLIDE_FALLTIME 2 +#define SLIDE_OUTPUT 3 + +/* This is the data for a single instance of the plugin */ +typedef struct +{ + float* input; + float* risetime; + float* falltime; + float* output; + float srate; + float from; + float to; + float last_output; +} Slide; + +/* Clean up after a plugin instance */ +static void cleanup (LV2_Handle instance) +{ + free(instance); +} + +/* This is called when the hosts connects a port to a buffer */ +static void connect_port(LV2_Handle instance, + uint32_t port, void* data) +{ + Slide* plugin = (Slide *)instance; + + switch (port) { + case SLIDE_INPUT: + plugin->input = data; + break; + case SLIDE_RISETIME: + plugin->risetime = data; + break; + case SLIDE_FALLTIME: + plugin->falltime = data; + break; + case SLIDE_OUTPUT: + plugin->output = data; + break; + } +} + +/* The host uses this function to create an instance of a plugin */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + Slide* plugin = (Slide*)calloc(1, sizeof(Slide)); + plugin->srate = (float)sample_rate; + return (LV2_Handle)plugin; +} + +/* This is called before the hosts starts to use the plugin instance */ +static void activate(LV2_Handle instance) +{ + Slide* plugin = (Slide*)instance; + plugin->last_output = 0; + plugin->from = 0; + plugin->to = 0; +} + +/* The run function! */ +static void run(LV2_Handle instance, uint32_t sample_count) +{ + Slide* plugin = (Slide*)instance; + + if (plugin->input && plugin->output) { + unsigned long i; + float risetime, falltime; + for (i = 0; i < sample_count; ++i) { + + if (plugin->risetime) + risetime = plugin->risetime[i]; + else + risetime = 0; + + if (plugin->falltime) + falltime = plugin->falltime[i]; + else + falltime = 0; + + /* If the signal changed, start sliding to the new value */ + if (plugin->input[i] != plugin->to) { + plugin->from = plugin->last_output; + plugin->to = plugin->input[i]; + } + + float time; + int rising; + if (plugin->to > plugin->from) { + time = risetime; + rising = 1; + } else { + time = falltime; + rising = 0; + } + + /* If the rise/fall time is 0, just copy the input to the output */ + if (time == 0) + plugin->output[i] = plugin->input[i]; + + /* Otherwise, do the portamento */ + else { + float increment = + (plugin->to - plugin->from) / (time * plugin->srate); + plugin->output[i] = plugin->last_output + increment; + if ((plugin->output[i] > plugin->to && rising) || + (plugin->output[i] < plugin->to && !rising)) { + plugin->output[i] = plugin->to; + } + } + + plugin->last_output = plugin->output[i]; + } + } +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/slide", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/slide_2741.c b/src/slide_2741.c deleted file mode 100644 index 759e439..0000000 --- a/src/slide_2741.c +++ /dev/null @@ -1,284 +0,0 @@ -/* slide.c - A LADSPA plugin that "slides" the output signal between - * the current and the previous input value, taking the given - * number of seconds to reach the current input value. - * - * Copyright 2005 Lars Luthman - * LADSPA skeleton code taken from dahdsr_fexp.c by Loki Davison - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <ladspa.h> -#include <math.h> - -/* This defines the number of "variants", i.e. the number of separate plugins - in this library */ -#define SLIDE_VARIANT_COUNT 2 - -/* These are the port numbers */ -#define SLIDE_INPUT 0 -#define SLIDE_RISETIME 1 -#define SLIDE_FALLTIME 2 -#define SLIDE_OUTPUT 3 - -/* This is an array pointer to the descriptors of the different variants */ -LADSPA_Descriptor** slide_descriptors = 0; - -/* This is the data for a single instance of the plugin */ -typedef struct -{ - LADSPA_Data* input; - LADSPA_Data* risetime; - LADSPA_Data* falltime; - LADSPA_Data* output; - LADSPA_Data srate; - LADSPA_Data from; - LADSPA_Data to; - LADSPA_Data last_output; -} Slide; - -/* LADSPA hosts use this function to get the plugin descriptors */ -const LADSPA_Descriptor* ladspa_descriptor(unsigned long index) -{ - if (index < SLIDE_VARIANT_COUNT) - return slide_descriptors[index]; - return 0; -} - -/* Clean up after a plugin instance */ -void cleanupSlide (LADSPA_Handle instance) -{ - free(instance); -} - -/* This is called when the hosts connects a port to a buffer */ -void connectPortSlide(LADSPA_Handle instance, - unsigned long port, LADSPA_Data* data) -{ - Slide* plugin = (Slide *)instance; - - switch (port) { - case SLIDE_INPUT: - plugin->input = data; - break; - case SLIDE_RISETIME: - plugin->risetime = data; - break; - case SLIDE_FALLTIME: - plugin->falltime = data; - break; - case SLIDE_OUTPUT: - plugin->output = data; - break; - } -} - -/* The host uses this function to create an instance of a plugin */ -LADSPA_Handle instantiateSlide(const LADSPA_Descriptor * descriptor, - unsigned long sample_rate) -{ - Slide* plugin = (Slide*)calloc(1, sizeof(Slide)); - plugin->srate = (LADSPA_Data)sample_rate; - return (LADSPA_Handle)plugin; -} - -/* This is called before the hosts starts to use the plugin instance */ -void activateSlide(LADSPA_Handle instance) -{ - Slide* plugin = (Slide*)instance; - plugin->last_output = 0; - plugin->from = 0; - plugin->to = 0; -} - -/* The run function! */ -void runSlide(LADSPA_Handle instance, unsigned long sample_count, int variant) -{ - Slide* plugin = (Slide*)instance; - - if (plugin->input && plugin->output) { - unsigned long i; - LADSPA_Data risetime, falltime; - for (i = 0; i < sample_count; ++i) { - - if (plugin->risetime && variant == 0) - risetime = plugin->risetime[i]; - else if (plugin->risetime && variant == 1) - risetime = plugin->risetime[0]; - else - risetime = 0; - - if (plugin->falltime) - falltime = plugin->falltime[i]; - else if (plugin->falltime && variant == 1) - falltime = plugin->falltime[0]; - else - falltime = 0; - - /* If the signal changed, start sliding to the new value */ - if (plugin->input[i] != plugin->to) { - plugin->from = plugin->last_output; - plugin->to = plugin->input[i]; - } - - LADSPA_Data time; - int rising; - if (plugin->to > plugin->from) { - time = risetime; - rising = 1; - } else { - time = falltime; - rising = 0; - } - - /* If the rise/fall time is 0, just copy the input to the output */ - if (time == 0) - plugin->output[i] = plugin->input[i]; - - /* Otherwise, do the portamento */ - else { - LADSPA_Data increment = - (plugin->to - plugin->from) / (time * plugin->srate); - plugin->output[i] = plugin->last_output + increment; - if ((plugin->output[i] > plugin->to && rising) || - (plugin->output[i] < plugin->to && !rising)) { - plugin->output[i] = plugin->to; - } - } - - plugin->last_output = plugin->output[i]; - } - } -} - -void runSlide_audio(LADSPA_Handle instance, unsigned long sample_count) -{ - runSlide(instance, sample_count, 0); -} - -void runSlide_control(LADSPA_Handle instance, unsigned long sample_count) -{ - runSlide(instance, sample_count, 1); -} - -/* Called automagically by the dynamic linker - set up global stuff here */ -void _init(void) -{ - static const unsigned long ids[] = { 2741, 2742 }; - static const char * labels[] = { "slide_ta", "slide_tc" }; - static const char * names[] = { "Slide (TA)", "Slide (TC)" }; - - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - LADSPA_Descriptor* descriptor; - - LADSPA_PortDescriptor input_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, - LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO }; - LADSPA_PortDescriptor risetime_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, - LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor falltime_port_descriptors[] = - { LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, - LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL }; - LADSPA_PortDescriptor output_port_descriptors[] = - { LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO, - LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO }; - - void (*run_functions[])(LADSPA_Handle, unsigned long) = - { runSlide_audio, runSlide_control }; - - slide_descriptors = (LADSPA_Descriptor**)calloc(SLIDE_VARIANT_COUNT, - sizeof(LADSPA_Descriptor)); - - if (slide_descriptors) { - int i; - for (i = 0; i < SLIDE_VARIANT_COUNT; ++i) { - slide_descriptors[i] = - (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - descriptor = slide_descriptors[i]; - if (descriptor) { - descriptor->UniqueID = ids[i]; - descriptor->Label = labels[i]; - descriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - descriptor->Name = names[i]; - descriptor->Maker = "Lars Luthman <larsl@users.sourceforge.net>"; - descriptor->Copyright = "GPL"; - descriptor->PortCount = 4; - - port_descriptors = - (LADSPA_PortDescriptor*)calloc(4, sizeof(LADSPA_PortDescriptor)); - descriptor->PortDescriptors = - (const LADSPA_PortDescriptor*)port_descriptors; - port_range_hints = - (LADSPA_PortRangeHint*)calloc(4, sizeof(LADSPA_PortRangeHint)); - descriptor->PortRangeHints = - (const LADSPA_PortRangeHint*)port_range_hints; - - port_names = (char **) calloc (9, sizeof (char*)); - descriptor->PortNames = (const char **) port_names; - - /* Parameters for Input */ - port_descriptors[SLIDE_INPUT] = input_port_descriptors[i]; - port_names[SLIDE_INPUT] = "Input"; - - /* Parameters for Rise rate */ - port_descriptors[SLIDE_RISETIME] = risetime_port_descriptors[i]; - port_names[SLIDE_RISETIME] = "Rise time (s)"; - - /* Parameters for Fall rate */ - port_descriptors[SLIDE_FALLTIME] = falltime_port_descriptors[i]; - port_names[SLIDE_FALLTIME] = "Fall time (s)"; - - /* Parameters for Output*/ - port_descriptors[SLIDE_OUTPUT] = output_port_descriptors[i]; - port_names[SLIDE_OUTPUT] = "Output"; - - descriptor->activate = activateSlide; - descriptor->cleanup = cleanupSlide; - descriptor->connect_port = connectPortSlide; - descriptor->deactivate = NULL; - descriptor->instantiate = instantiateSlide; - descriptor->run = run_functions[i]; - descriptor->run_adding = NULL; - descriptor->set_run_adding_gain = NULL; - } - } - } -} - -/* Called automagically by the dynamic linker - free global stuff here */ -void _fini(void) -{ - LADSPA_Descriptor* descriptor; - int i; - - if (slide_descriptors) { - for (i = 0; i < SLIDE_VARIANT_COUNT; i++) { - descriptor = slide_descriptors[i]; - if (descriptor) { - free((LADSPA_PortDescriptor*)descriptor->PortDescriptors); - free((char**)descriptor->PortNames); - free((LADSPA_PortRangeHint*)descriptor->PortRangeHints); - free(descriptor); - } - } - free(slide_descriptors); - } -} - diff --git a/src/waveguide_mesh.c b/src/waveguide_mesh.c new file mode 100644 index 0000000..045a478 --- /dev/null +++ b/src/waveguide_mesh.c @@ -0,0 +1,274 @@ +/* This file is an audio plugin. + * Copyright 2005 Loki Davison. + * + * Based on code by Brook Eaton and a couple of papers... + * + * Implements a Waveguide Mesh drum. FIXME to be extended, to have rimguides, power normalisation and all + * manner of other goodies. + * + * Tension is well, drum tension + * power is how hard you hit it. + * + * + * This plugin is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This plugin is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define _XOPEN_SOURCE 500 /* strdup */ +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> + +#define MESH_BASE_ID 2670 + +#define MESH_NUM_PORTS 6 + +/* Port Numbers */ +#define MESH_INPUT1 0 +#define MESH_OUTPUT 1 +#define MESH_TENSION 2 +#define MESH_POWER 3 +#define MESH_EX_X 4 +#define MESH_EX_Y 5 + +#define LENGTH 8 // must be divisible by 4!! +#define WIDTH 8 +#define SIZE LENGTH*WIDTH // Size of mesh +#define INITIAL 0 // initial values stored at junctions +#define LOSS 0.2 // loss in wave propagation +#define INIT_DELTA 6 // initial values +#define INIT_T 0.1 // for the impedances +#define INIT_GAMMA 8 // +#define PORTS 8 //for the initialization of junction velocities from excitation + +// 2D array of junctions. +// The important function of the junction is to store +// the velocities of travelling waves so that adjacent junction's +// velocities can be calculated. +typedef struct _junction +{ + float v_junction; // junction velocity + float n_junction; // velocity heading north into junction + float s_junction; // velocity heading south into junction + float e_junction; // velocity heading east into junction + float w_junction; // velocity heading west into junction + float c_junction; // velocity heading back into the junction (delayed) + float s_temp; // these two 'temp' values are used because calculation + float e_temp; // of the mesh updates s/e values before they are used +} _junction; // to calculate north and south velocities! + +/* All state information for plugin */ + +typedef struct +{ + /* Ports */ + float* input1; + float* output; + float* tension; + float* power; + float* ex_x; + float* ex_y; + + /* vars */ + _junction mesh[LENGTH][WIDTH]; + float last_trigger; + +} WgMesh; + +/* Construct a new plugin instance */ +static LV2_Handle +instantiate(const LV2_Descriptor* descriptor, + double sample_rate, + const char* bundle_path, + const LV2_Feature* const* features) +{ + WgMesh * plugin = (WgMesh *) malloc (sizeof (WgMesh)); + + return (LV2_Handle)plugin; +} + +static void +activate(LV2_Handle instance) +{ + WgMesh * plugin = (WgMesh *) instance; + for (int i=0; i<LENGTH; i++) { + for (int j=0; j<WIDTH; j++) { + plugin->mesh[i][j].v_junction = INITIAL; + plugin->mesh[i][j].n_junction = INITIAL; + plugin->mesh[i][j].s_junction = INITIAL; + plugin->mesh[i][j].e_junction = INITIAL; + plugin->mesh[i][j].w_junction = INITIAL; + plugin->mesh[i][j].c_junction = INITIAL; + plugin->mesh[i][j].s_temp = INITIAL; + plugin->mesh[i][j].e_temp = INITIAL; + } + } + plugin->last_trigger = 0.0; +} + +/* Connect a port to a data location */ +static void +connect_port(LV2_Handle instance, + uint32_t port, + void* location) +{ + WgMesh* plugin; + + plugin = (WgMesh*)instance; + switch (port) { + case MESH_INPUT1: + plugin->input1 = location; + break; + case MESH_OUTPUT: + plugin->output = location; + break; + case MESH_TENSION: + plugin->tension = location; + break; + case MESH_POWER: + plugin->power = location; + break; + case MESH_EX_X: + plugin->ex_x = location; + break; + case MESH_EX_Y: + plugin->ex_y = location; + break; + } +} + +inline static void excite_mesh(WgMesh* plugin, float power, float ex_x, float ex_y) +{ + int i=ex_x,j=ex_y; + float temp; + float Yj; + + Yj = 2*(INIT_DELTA*INIT_DELTA/((INIT_T*INIT_T)*(INIT_GAMMA*INIT_GAMMA))); // junction admittance + temp = power*2/(LENGTH+WIDTH); + plugin->mesh[i][j].v_junction = plugin->mesh[i][j].v_junction + temp; + plugin->mesh[i][j].n_junction = plugin->mesh[i][j].n_junction + Yj*temp/PORTS; + // All velocities leaving the junction are equal to + plugin->mesh[i][j].s_junction = plugin->mesh[i][j].s_junction + Yj*temp/PORTS; + // the total velocity in the junction * the admittance + plugin->mesh[i][j].e_junction = plugin->mesh[i][j].e_junction + Yj*temp/PORTS; + // divided by the number of outgoing ports. + plugin->mesh[i][j].w_junction = plugin->mesh[i][j].w_junction + Yj*temp/PORTS; + //mesh[i][j].c_junction = 0; +} + +static void +run(LV2_Handle instance, uint32_t nframes) +{ + WgMesh* plugin = (WgMesh*)instance; + float tension = *(plugin->tension); + float ex_x = *(plugin->ex_x); + float ex_y = *(plugin->ex_y); + float* input = plugin->input1; + float* out = plugin->output; + float* power = plugin->power; + float last_trigger = plugin->last_trigger; + size_t i,j,k; + float filt, trg, oldfilt; + float Yc,Yj,tempN,tempS,tempE,tempW; + + // Set input variables // + oldfilt = plugin->mesh[LENGTH-LENGTH/4][WIDTH-WIDTH/4].v_junction; + + for (k=0; k<nframes; k++) { + if (tension==0) + tension=0.0001; + trg = input[k]; + + if (trg > 0.0f && !(last_trigger > 0.0f)) + { + //printf("got trigger, exciting mesh, %f \n", tension); + excite_mesh(plugin, power[k], ex_x, ex_y); + } + + //junction admitance + Yj = 2*INIT_DELTA*INIT_DELTA/(( (tension)*((tension) )*(INIT_GAMMA*INIT_GAMMA))); + Yc = Yj-4; // junction admittance (left shift is for multiply by 2!) + //plugin->v_power = power[k]; + + for (i=1; i<LENGTH-1; i++) { + // INNER MESH // + for (j=1; j<WIDTH-1; j++) { // to multiply by 2 - simply shift to the left by 1! + plugin->mesh[i][j].v_junction = 2.0*(plugin->mesh[i][j].n_junction + plugin->mesh[i][j].s_junction + + plugin->mesh[i][j].e_junction + plugin->mesh[i][j].w_junction + Yc*plugin->mesh[i][j].c_junction)/Yj; + + plugin->mesh[i][j+1].s_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].n_junction; + plugin->mesh[i][j-1].n_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].s_temp; + + plugin->mesh[i+1][j].e_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].w_junction; + plugin->mesh[i-1][j].w_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].e_temp; + + plugin->mesh[i][j].c_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].c_junction; + + plugin->mesh[i][j].s_temp = plugin->mesh[i][j].s_junction; // + plugin->mesh[i][j].e_temp = plugin->mesh[i][j].e_junction; // update current values in the temp slots! + } + // BOUNDARY // + tempS = plugin->mesh[i][0].s_junction; + plugin->mesh[i][0].s_junction = -plugin->mesh[i][0].n_junction; + plugin->mesh[i][1].s_junction = plugin->mesh[i][1].s_temp = tempS; + tempN = plugin->mesh[i][WIDTH-1].n_junction; + plugin->mesh[i][WIDTH-1].n_junction = -plugin->mesh[i][WIDTH-1].s_junction; + plugin->mesh[i][WIDTH-2].n_junction = tempN; + // 'i's in the neplugint few lines are really 'j's! + tempE = plugin->mesh[0][i].e_junction; + plugin->mesh[0][i].e_junction = -plugin->mesh[0][i].w_junction; + plugin->mesh[1][i].e_junction = plugin->mesh[1][i].e_temp = tempE; + tempW = plugin->mesh[WIDTH-1][i].w_junction; + plugin->mesh[WIDTH-1][i].w_junction = -plugin->mesh[WIDTH-1][i].e_junction; + plugin->mesh[WIDTH-2][i].w_junction = tempW; + } + + filt = LOSS*(plugin->mesh[LENGTH-LENGTH/4][WIDTH-WIDTH/4].v_junction + oldfilt); + oldfilt = plugin->mesh[LENGTH-LENGTH/4][WIDTH-WIDTH/4].v_junction; + plugin->mesh[LENGTH-LENGTH/4][WIDTH-WIDTH/4].v_junction = filt; + + out[k] = plugin->mesh[WIDTH/4][WIDTH/4-1].v_junction; + last_trigger = trg; + } + plugin->last_trigger = last_trigger; + +} + +static void +cleanup(LV2_Handle instance) +{ + free(instance); +} + +static const LV2_Descriptor descriptor = { + "http://drobilla.net/plugins/omins/waveguide_mesh", + instantiate, + connect_port, + activate, + run, + NULL, + cleanup, + NULL, +}; + +LV2_SYMBOL_EXPORT const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + switch (index) { + case 0: return &descriptor; + default: return NULL; + } +} diff --git a/src/waveguide_mesh_2670.c b/src/waveguide_mesh_2670.c deleted file mode 100644 index d767dce..0000000 --- a/src/waveguide_mesh_2670.c +++ /dev/null @@ -1,355 +0,0 @@ -/* This file is an audio plugin. - * Copyright 2005 Loki Davison. - * - * Based on code by Brook Eaton and a couple of papers... - * - * Implements a Waveguide Mesh drum. FIXME to be extended, to have rimguides, power normalisation and all - * manner of other goodies. - * - * Tension is well, drum tension - * power is how hard you hit it. - * - * - * This plugin is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This plugin is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define _XOPEN_SOURCE 500 /* strdup */ -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "ladspa.h" - -#define MESH_BASE_ID 2670 - -#define MESH_NUM_PORTS 6 - -/* Port Numbers */ -#define MESH_INPUT1 0 -#define MESH_OUTPUT 1 -#define MESH_TENSION 2 -#define MESH_POWER 3 -#define MESH_EX_X 4 -#define MESH_EX_Y 5 - -#define LENGTH 8 // must be divisible by 4!! -#define WIDTH 8 -#define SIZE LENGTH*WIDTH // Size of mesh -#define INITIAL 0 // initial values stored at junctions -#define LOSS 0.2 // loss in wave propagation -#define INIT_DELTA 6 // initial values -#define INIT_T 0.1 // for the impedances -#define INIT_GAMMA 8 // -#define PORTS 8 //for the initialization of junction velocities from excitation - -// 2D array of junctions. -// The important function of the junction is to store -// the velocities of travelling waves so that adjacent junction's -// velocities can be calculated. -typedef struct _junction -{ - LADSPA_Data v_junction; // junction velocity - LADSPA_Data n_junction; // velocity heading north into junction - LADSPA_Data s_junction; // velocity heading south into junction - LADSPA_Data e_junction; // velocity heading east into junction - LADSPA_Data w_junction; // velocity heading west into junction - LADSPA_Data c_junction; // velocity heading back into the junction (delayed) - LADSPA_Data s_temp; // these two 'temp' values are used because calculation - LADSPA_Data e_temp; // of the mesh updates s/e values before they are used -} _junction; // to calculate north and south velocities! - -/* All state information for plugin */ - -typedef struct -{ - /* Ports */ - LADSPA_Data* input1; - LADSPA_Data* output; - LADSPA_Data* tension; - LADSPA_Data* power; - LADSPA_Data* ex_x; - LADSPA_Data* ex_y; - - /* vars */ - _junction mesh[LENGTH][WIDTH]; - LADSPA_Data last_trigger; - -} WgMesh; - -/* Construct a new plugin instance */ -LADSPA_Handle -wgmesh_instantiate(const LADSPA_Descriptor* descriptor, - unsigned long srate) -{ - WgMesh * plugin = (WgMesh *) malloc (sizeof (WgMesh)); - int i, j; - - //// Init Mesh - for (i=0; i<LENGTH; i++) { - for (j=0; j<WIDTH; j++) { - plugin->mesh[i][j].v_junction = INITIAL; - plugin->mesh[i][j].n_junction = INITIAL; - plugin->mesh[i][j].s_junction = INITIAL; - plugin->mesh[i][j].e_junction = INITIAL; - plugin->mesh[i][j].w_junction = INITIAL; - plugin->mesh[i][j].c_junction = INITIAL; - plugin->mesh[i][j].s_temp = INITIAL; - plugin->mesh[i][j].e_temp = INITIAL; - } - } - plugin->last_trigger = 0.0; - return (LADSPA_Handle)plugin; -} - -/* Connect a port to a data location */ -void -wgmesh_connect_port(LADSPA_Handle instance, - unsigned long port, - LADSPA_Data* location) -{ - WgMesh* plugin; - - plugin = (WgMesh*)instance; - switch (port) { - case MESH_INPUT1: - plugin->input1 = location; - break; - case MESH_OUTPUT: - plugin->output = location; - break; - case MESH_TENSION: - plugin->tension = location; - break; - case MESH_POWER: - plugin->power = location; - break; - case MESH_EX_X: - plugin->ex_x = location; - break; - case MESH_EX_Y: - plugin->ex_y = location; - break; - } -} - -inline static void excite_mesh(WgMesh* plugin, LADSPA_Data power, LADSPA_Data ex_x, LADSPA_Data ex_y) -{ - int i=ex_x,j=ex_y; - LADSPA_Data temp; - LADSPA_Data Yj; - - Yj = 2*(INIT_DELTA*INIT_DELTA/((INIT_T*INIT_T)*(INIT_GAMMA*INIT_GAMMA))); // junction admittance - temp = power*2/(LENGTH+WIDTH); - plugin->mesh[i][j].v_junction = plugin->mesh[i][j].v_junction + temp; - plugin->mesh[i][j].n_junction = plugin->mesh[i][j].n_junction + Yj*temp/PORTS; - // All velocities leaving the junction are equal to - plugin->mesh[i][j].s_junction = plugin->mesh[i][j].s_junction + Yj*temp/PORTS; - // the total velocity in the junction * the admittance - plugin->mesh[i][j].e_junction = plugin->mesh[i][j].e_junction + Yj*temp/PORTS; - // divided by the number of outgoing ports. - plugin->mesh[i][j].w_junction = plugin->mesh[i][j].w_junction + Yj*temp/PORTS; - //mesh[i][j].c_junction = 0; -} - -void -wgmesh_run_cr(LADSPA_Handle instance, unsigned long nframes) -{ - WgMesh* plugin = (WgMesh*)instance; - LADSPA_Data tension = *(plugin->tension); - LADSPA_Data ex_x = *(plugin->ex_x); - LADSPA_Data ex_y = *(plugin->ex_y); - LADSPA_Data* input = plugin->input1; - LADSPA_Data* out = plugin->output; - LADSPA_Data* power = plugin->power; - LADSPA_Data last_trigger = plugin->last_trigger; - size_t i,j,k; - LADSPA_Data filt, trg, oldfilt; - LADSPA_Data Yc,Yj,tempN,tempS,tempE,tempW; - - // Set input variables // - oldfilt = plugin->mesh[LENGTH-LENGTH/4][WIDTH-WIDTH/4].v_junction; - - for (k=0; k<nframes; k++) { - if (tension==0) - tension=0.0001; - trg = input[k]; - - if (trg > 0.0f && !(last_trigger > 0.0f)) - { - //printf("got trigger, exciting mesh, %f \n", tension); - excite_mesh(plugin, power[k], ex_x, ex_y); - } - - //junction admitance - Yj = 2*INIT_DELTA*INIT_DELTA/(( (tension)*((tension) )*(INIT_GAMMA*INIT_GAMMA))); - Yc = Yj-4; // junction admittance (left shift is for multiply by 2!) - //plugin->v_power = power[k]; - - for (i=1; i<LENGTH-1; i++) { - // INNER MESH // - for (j=1; j<WIDTH-1; j++) { // to multiply by 2 - simply shift to the left by 1! - plugin->mesh[i][j].v_junction = 2.0*(plugin->mesh[i][j].n_junction + plugin->mesh[i][j].s_junction - + plugin->mesh[i][j].e_junction + plugin->mesh[i][j].w_junction + Yc*plugin->mesh[i][j].c_junction)/Yj; - - plugin->mesh[i][j+1].s_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].n_junction; - plugin->mesh[i][j-1].n_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].s_temp; - - plugin->mesh[i+1][j].e_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].w_junction; - plugin->mesh[i-1][j].w_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].e_temp; - - plugin->mesh[i][j].c_junction = plugin->mesh[i][j].v_junction - plugin->mesh[i][j].c_junction; - - plugin->mesh[i][j].s_temp = plugin->mesh[i][j].s_junction; // - plugin->mesh[i][j].e_temp = plugin->mesh[i][j].e_junction; // update current values in the temp slots! - } - // BOUNDARY // - tempS = plugin->mesh[i][0].s_junction; - plugin->mesh[i][0].s_junction = -plugin->mesh[i][0].n_junction; - plugin->mesh[i][1].s_junction = plugin->mesh[i][1].s_temp = tempS; - tempN = plugin->mesh[i][WIDTH-1].n_junction; - plugin->mesh[i][WIDTH-1].n_junction = -plugin->mesh[i][WIDTH-1].s_junction; - plugin->mesh[i][WIDTH-2].n_junction = tempN; - // 'i's in the neplugint few lines are really 'j's! - tempE = plugin->mesh[0][i].e_junction; - plugin->mesh[0][i].e_junction = -plugin->mesh[0][i].w_junction; - plugin->mesh[1][i].e_junction = plugin->mesh[1][i].e_temp = tempE; - tempW = plugin->mesh[WIDTH-1][i].w_junction; - plugin->mesh[WIDTH-1][i].w_junction = -plugin->mesh[WIDTH-1][i].e_junction; - plugin->mesh[WIDTH-2][i].w_junction = tempW; - } - - filt = LOSS*(plugin->mesh[LENGTH-LENGTH/4][WIDTH-WIDTH/4].v_junction + oldfilt); - oldfilt = plugin->mesh[LENGTH-LENGTH/4][WIDTH-WIDTH/4].v_junction; - plugin->mesh[LENGTH-LENGTH/4][WIDTH-WIDTH/4].v_junction = filt; - - out[k] = plugin->mesh[WIDTH/4][WIDTH/4-1].v_junction; - last_trigger = trg; - } - plugin->last_trigger = last_trigger; - -} - -void -wgmesh_cleanup(LADSPA_Handle instance) -{ - free(instance); -} - -LADSPA_Descriptor* wg_mesh_cr_desc = NULL; - -/* Called automatically when the plugin library is first loaded. */ -void -_init() -{ - char** port_names; - LADSPA_PortDescriptor* port_descriptors; - LADSPA_PortRangeHint* port_range_hints; - - wg_mesh_cr_desc = (LADSPA_Descriptor*)malloc(sizeof(LADSPA_Descriptor)); - - if (wg_mesh_cr_desc) { - - wg_mesh_cr_desc->UniqueID = MESH_BASE_ID; - wg_mesh_cr_desc->Label = strdup("wg_mesh_cr"); - wg_mesh_cr_desc->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - wg_mesh_cr_desc->Name = strdup("Simple waveguide mesh (CR Controls)"); - wg_mesh_cr_desc->Maker = strdup("Loki Davison"); - wg_mesh_cr_desc->Copyright = strdup("GPL"); - wg_mesh_cr_desc->PortCount = MESH_NUM_PORTS; - port_descriptors = (LADSPA_PortDescriptor*)calloc(MESH_NUM_PORTS, sizeof(LADSPA_PortDescriptor)); - wg_mesh_cr_desc->PortDescriptors = (const LADSPA_PortDescriptor*)port_descriptors; - port_descriptors[MESH_TENSION] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[MESH_POWER] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[MESH_INPUT1] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - port_descriptors[MESH_OUTPUT] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_descriptors[MESH_EX_X] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_descriptors[MESH_EX_Y] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - port_names = (char**)calloc(MESH_NUM_PORTS, sizeof(char*)); - wg_mesh_cr_desc->PortNames = (const char**)port_names; - port_names[MESH_TENSION] = strdup("Tension"); - port_names[MESH_POWER] = strdup("Power"); - port_names[MESH_INPUT1] = strdup("Trigger"); - port_names[MESH_OUTPUT] = strdup("Output"); - port_names[MESH_EX_X] = strdup("Excitation X"); - port_names[MESH_EX_Y] = strdup("Excitation Y"); - port_range_hints = ((LADSPA_PortRangeHint *) - calloc(MESH_NUM_PORTS, sizeof(LADSPA_PortRangeHint))); - wg_mesh_cr_desc->PortRangeHints = (const LADSPA_PortRangeHint*)port_range_hints; - port_range_hints[MESH_TENSION].HintDescriptor = LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE -| LADSPA_HINT_DEFAULT_MIDDLE; - port_range_hints[MESH_TENSION].LowerBound = 0.0001f; - port_range_hints[MESH_TENSION].UpperBound = 0.22f; - port_range_hints[MESH_POWER].HintDescriptor = LADSPA_HINT_DEFAULT_1 | LADSPA_HINT_BOUNDED_BELOW; - port_range_hints[MESH_POWER].LowerBound = 0.000f; - port_range_hints[MESH_POWER].UpperBound = 20.000f; - - port_range_hints[MESH_EX_X].HintDescriptor = LADSPA_HINT_DEFAULT_1 | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_INTEGER; - port_range_hints[MESH_EX_X].LowerBound = 0.950f; //1 - port_range_hints[MESH_EX_X].UpperBound = LENGTH-0.99;//length-1 ish - - port_range_hints[MESH_EX_Y].HintDescriptor = LADSPA_HINT_DEFAULT_1 | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_INTEGER; - port_range_hints[MESH_EX_Y].LowerBound = 0.950f; //1 - port_range_hints[MESH_EX_Y].UpperBound = LENGTH-0.99;//length-1 ish - - port_range_hints[MESH_INPUT1].HintDescriptor = 0; - port_range_hints[MESH_OUTPUT].HintDescriptor = 0; - wg_mesh_cr_desc->instantiate = wgmesh_instantiate; - wg_mesh_cr_desc->connect_port = wgmesh_connect_port; - wg_mesh_cr_desc->activate = NULL; - wg_mesh_cr_desc->run = wgmesh_run_cr; - wg_mesh_cr_desc->run_adding = NULL; - wg_mesh_cr_desc->set_run_adding_gain = NULL; - wg_mesh_cr_desc->deactivate = NULL; - wg_mesh_cr_desc->cleanup = wgmesh_cleanup; - } -} - -void -wgmesh_delete_descriptor(LADSPA_Descriptor* psDescriptor) -{ - unsigned long lIndex; - if (psDescriptor) { - free((char*)psDescriptor->Label); - free((char*)psDescriptor->Name); - free((char*)psDescriptor->Maker); - free((char*)psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++) - free((char*)(psDescriptor->PortNames[lIndex])); - free((char**)psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)psDescriptor->PortRangeHints); - free(psDescriptor); - } -} - -/* Called automatically when the library is unloaded. */ -void -_fini() -{ - wgmesh_delete_descriptor(wg_mesh_cr_desc); -} - -/* Return a descriptor of the requested plugin type. */ -const LADSPA_Descriptor* -ladspa_descriptor(unsigned long Index) -{ - switch (Index) { - case 0: - return wg_mesh_cr_desc; - default: - return NULL; - } -} - Binary files differ@@ -0,0 +1,104 @@ +#!/usr/bin/env python +import os +import shutil +import subprocess +from waflib.extras import autowaf as autowaf + +# Version of this package (even if built as a child) +OMINS_VERSION = '0.0.0' + +# Variables for 'waf dist' +APPNAME = 'omins.lv2' +VERSION = OMINS_VERSION + +# Mandatory variables +top = '.' +out = 'build' + +def options(opt): + opt.load('compiler_c') + autowaf.set_options(opt) + +def configure(conf): + conf.load('compiler_c') + autowaf.configure(conf) + autowaf.set_c99_mode(conf) + autowaf.display_header('Omins.LV2 Configuration') + + autowaf.check_pkg(conf, 'lv2', atleast_version='1.0.0', uselib_store='LV2') + + # Set env.pluginlib_PATTERN + pat = conf.env.cshlib_PATTERN + if pat[0:3] == 'lib': + pat = pat[3:] + conf.env.pluginlib_PATTERN = pat + conf.env.pluginlib_EXT = pat[pat.rfind('.'):] + + autowaf.display_msg(conf, "LV2 bundle directory", + conf.env.LV2DIR) + print('') + +def build_plugin(bld, lang, bundle, name, source, defines=None): + # Build plugin library + penv = bld.env.derive() + penv.cshlib_PATTERN = bld.env.pluginlib_PATTERN + obj = bld(features = '%s %sshlib' % (lang,lang), + env = penv, + source = source, + includes = ['.', 'src/include'], + name = name, + target = os.path.join(bundle, name), + uselib = ['LV2'], + install_path = '${LV2DIR}/' + bundle) + if defines != None: + obj.defines = defines + + # Install data file + data_file = '%s.ttl' % name + bld.install_files('${LV2DIR}/' + bundle, os.path.join(bundle, data_file)) + +def build(bld): + # Copy data files to build bundle (build/omins.lv2) + def do_copy(task): + src = task.inputs[0].abspath() + tgt = task.outputs[0].abspath() + return shutil.copy(src, tgt) + + for i in bld.path.ant_glob('omins.lv2/*.ttl'): + bld(features = 'subst', + is_copy = True, + source = i, + target = bld.path.get_bld().make_node('omins.lv2/%s' % i), + install_path = '${LV2DIR}/omins.lv2') + + bld(features = 'subst', + source = 'omins.lv2/manifest.ttl.in', + target = bld.path.get_bld().make_node('omins.lv2/manifest.ttl'), + LIB_EXT = bld.env.pluginlib_EXT, + install_path = '${LV2DIR}/omins.lv2') + + plugins = ['adenv', + 'adenv_lvl', + 'comparison', + 'dahdsr_fexp', + 'dahdsr_hexp', + 'fast_crossfade', + 'formant_filter', + 'hz_voct', + 'masher', + 'multiplexer', + 'prob_switch', + 'range_trans', + 'sample_and_hold', + 'signal_abs', + 'slew_limiter', + 'slide', + 'waveguide_mesh'] + + for i in plugins: + build_plugin(bld, 'c', 'omins.lv2', i, + ['src/%s.c' % i]) + +def lint(ctx): + subprocess.call('cpplint.py --filter=+whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-readability/todo,-build/include src/* serd/*', shell=True) + |