initial
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*.vst
|
||||
target/
|
||||
*.lock
|
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "rist"
|
||||
version = "0.0.1"
|
||||
authors = ["Veit Heller <veit@veitheller.de>"]
|
||||
|
||||
[dependencies]
|
||||
vst2 = "0.0.1"
|
||||
|
||||
[lib]
|
||||
name = "rist"
|
||||
crate-type = ["dylib"]
|
61
bundler.sh
Executable file
61
bundler.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Make sure we have the arguments we need
|
||||
if [[ -z $1 || -z $2 ]]; then
|
||||
echo "Generates a macOS bundle from a compiled dylib file"
|
||||
echo "Example:"
|
||||
echo -e "\t$0 Plugin target/release/plugin.dylib"
|
||||
echo -e "\tCreates a Plugin.vst bundle"
|
||||
else
|
||||
# Make the bundle folder
|
||||
mkdir -p "$1.vst/Contents/MacOS"
|
||||
|
||||
# Create the PkgInfo
|
||||
echo "BNDL????" > "$1.vst/Contents/PkgInfo"
|
||||
|
||||
#build the Info.Plist
|
||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
|
||||
<plist version=\"1.0\">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$1</string>
|
||||
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>vst</string>
|
||||
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.rust-vst2.$1</string>
|
||||
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
|
||||
<key>CFBundleName</key>
|
||||
<string>$1</string>
|
||||
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
|
||||
<key>CFBundleSignature</key>
|
||||
<string>$((RANDOM % 9999))</string>
|
||||
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<string></string>
|
||||
|
||||
</dict>
|
||||
</plist>" > "$1.vst/Contents/Info.plist"
|
||||
|
||||
# move the provided library to the correct location
|
||||
cp "$2" "$1.vst/Contents/MacOS/$1"
|
||||
|
||||
echo "Created bundle $1.vst"
|
||||
fi
|
76
src/lib.rs
Normal file
76
src/lib.rs
Normal file
@@ -0,0 +1,76 @@
|
||||
#[macro_use] extern crate vst2;
|
||||
|
||||
use vst2::buffer::AudioBuffer;
|
||||
use vst2::plugin::{Plugin, Info};
|
||||
|
||||
struct Rist {
|
||||
threshold: f32
|
||||
}
|
||||
|
||||
impl Default for Rist {
|
||||
fn default() -> Rist {
|
||||
Rist {
|
||||
threshold: 1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn with_default<T, F>(index: i32, mut fun: F, default: T) -> T where F: FnMut() -> T {
|
||||
match index {
|
||||
0 => fun(),
|
||||
_ => default,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Plugin for Rist {
|
||||
fn get_info(&self) -> Info {
|
||||
Info {
|
||||
name: "Rist".to_string(),
|
||||
vendor: "hellerve".to_string(),
|
||||
unique_id: 1004001,
|
||||
inputs: 2,
|
||||
outputs: 2,
|
||||
parameters: 1,
|
||||
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn get_parameter(&self, index: i32) -> f32 {
|
||||
with_default(index, || self.threshold, 0.0)
|
||||
}
|
||||
|
||||
fn set_parameter(&mut self, index: i32, value: f32) -> () {
|
||||
with_default(index, || self.threshold = value.max(0.001), ())
|
||||
}
|
||||
|
||||
fn get_parameter_name(&self, index: i32) -> String {
|
||||
with_default(index, || "Threshold", "").to_string()
|
||||
}
|
||||
|
||||
fn get_parameter_text(&self, index: i32) -> String {
|
||||
with_default(index, || format!("{}", self.threshold * 100.0), "".to_string())
|
||||
}
|
||||
|
||||
fn get_parameter_label(&self, index: i32) -> String {
|
||||
with_default(index, || "%", "").to_string()
|
||||
}
|
||||
|
||||
fn process(&mut self, buffer: AudioBuffer<f32>) {
|
||||
let (i, o) = buffer.split();
|
||||
|
||||
for (ib, ob) in i.iter().zip(o) {
|
||||
for (is, os) in ib.iter().zip(ob) {
|
||||
if *is < 0.0 {
|
||||
*os = is.max(-self.threshold) / self.threshold;
|
||||
} else {
|
||||
*os = is.min(self.threshold) / self.threshold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
plugin_main!(Rist);
|
Reference in New Issue
Block a user