[sample - 10/10] make and implement crate
parent
bdd8f43ac3
commit
74b2344e99
12
README.md
12
README.md
|
@ -67,6 +67,7 @@ the following is the current list of plugins
|
|||
- `panera`: pan individual notes differently
|
||||
- `velociter`: random velocity setter
|
||||
- `opiate`: spectral morphing between two audio signals
|
||||
- `sample - 10/10`: sample rate changer
|
||||
|
||||
there's a bit of an explanation of each of the plugins below, but it's not a thorough documentation or a manual, it's just a bunch of notes i've written and a short description of the parameters
|
||||
|
||||
|
@ -323,6 +324,17 @@ params:
|
|||
|
||||
if `morph` is set to 0, only audio 1 will play. if it's set to 1, only audio 2 will play. values in between will morph between the two audio signals
|
||||
|
||||
### sample - 10/10
|
||||
|
||||
simple (not accurate) sample rate changer
|
||||
|
||||
params:
|
||||
- `repeats`: how many times to repeat a sample
|
||||
|
||||
repeats a sample as many times as you tell it to, so if `repeats == 2.0`, and the inputs are `[0.0, 1.0, 0.5, 0.3, 0.4, 0.6, 0.7]`, it will play `[0.0, 0.0, 0.0, 0.3, 0.3, 0.3, 0.7]`. basically, `repeats == n` divides the sample rate by `n`
|
||||
|
||||
it's not doing any actual resampling of audio
|
||||
|
||||
## contributing
|
||||
|
||||
issues and prs are welcome, but please open an issue before making any big pr, i don't wanna have to reject a pr where you have put a lot of effort on. if you are fine with that, ig go ahead i'm not your mum
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "sample10_10"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
baseplug = { git = "https://github.com/wrl/baseplug.git", rev = "9cec68f31cca9c0c7a1448379f75d92bbbc782a8" }
|
||||
serde = "1.0.126"
|
||||
utils = { path = "../utils" }
|
|
@ -0,0 +1,67 @@
|
|||
#![allow(incomplete_features)]
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
use baseplug::{Plugin, ProcessContext};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
baseplug::model! {
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct Sample1010Model {
|
||||
#[model(min = 0.0, max = 200.0)]
|
||||
#[parameter(name = "repeats")]
|
||||
repeats: f32,
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Sample1010Model {
|
||||
fn default() -> Self {
|
||||
Self { repeats: 1.0 }
|
||||
}
|
||||
}
|
||||
|
||||
struct Sample1010 {
|
||||
last: (f32, f32),
|
||||
counter: usize,
|
||||
}
|
||||
|
||||
impl Plugin for Sample1010 {
|
||||
const NAME: &'static str = "sample - 10/10";
|
||||
const PRODUCT: &'static str = "sample - 10/10";
|
||||
const VENDOR: &'static str = "unnieversal";
|
||||
|
||||
const INPUT_CHANNELS: usize = 2;
|
||||
const OUTPUT_CHANNELS: usize = 2;
|
||||
|
||||
type Model = Sample1010Model;
|
||||
|
||||
#[inline]
|
||||
fn new(_sample_rate: f32, _model: &Sample1010Model) -> Self {
|
||||
Self {
|
||||
last: (0.0, 0.0),
|
||||
counter: 0,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn process(&mut self, model: &Sample1010ModelProcess, ctx: &mut ProcessContext<Self>) {
|
||||
let input = &ctx.inputs[0].buffers;
|
||||
let output = &mut ctx.outputs[0].buffers;
|
||||
|
||||
for i in 0..ctx.nframes {
|
||||
if (self.counter as f32) < model.repeats[i] {
|
||||
output[0][i] = self.last.0;
|
||||
output[1][i] = self.last.1;
|
||||
|
||||
self.counter += 1;
|
||||
} else {
|
||||
output[0][i] = input[0][i];
|
||||
output[1][i] = input[1][i];
|
||||
|
||||
self.counter = 0;
|
||||
self.last = (input[0][i], input[1][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
baseplug::vst2!(Sample1010, b"1010");
|
Loading…
Reference in New Issue