standalone vst (oxymoron lol)

This commit is contained in:
Alex Janka 2023-03-07 08:51:12 +11:00
parent 28240c80c3
commit 066a8690ba
6 changed files with 125 additions and 34 deletions

126
Cargo.lock generated
View file

@ -86,15 +86,6 @@ dependencies = [
"libloading",
]
[[package]]
name = "assert_no_alloc"
version = "1.1.2"
source = "git+https://github.com/robbert-vdh/rust-assert-no-alloc.git?branch=feature/nested-permit-forbid#a6fb4f62b9624715291e320ea5f0f70e73b035cf"
dependencies = [
"backtrace",
"log",
]
[[package]]
name = "async-ringbuf"
version = "0.1.2"
@ -237,6 +228,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
[[package]]
name = "cache-padded"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]]
name = "cc"
version = "1.0.79"
@ -297,6 +294,7 @@ dependencies = [
"once_cell",
"strsim",
"termcolor",
"terminal_size",
]
[[package]]
@ -454,6 +452,26 @@ dependencies = [
"bindgen",
]
[[package]]
name = "coremidi"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a7847ca018a67204508b77cb9e6de670125075f7464fff5f673023378fa34f5"
dependencies = [
"core-foundation",
"core-foundation-sys 0.8.3",
"coremidi-sys",
]
[[package]]
name = "coremidi-sys"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79a6deed0c97b2d40abbab77e4c97f81d71e162600423382c277dd640019116c"
dependencies = [
"core-foundation-sys 0.8.3",
]
[[package]]
name = "cpal"
version = "0.15.0"
@ -772,7 +790,6 @@ dependencies = [
"itertools",
"once_cell",
"rand",
"samplerate",
]
[[package]]
@ -998,6 +1015,33 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
[[package]]
name = "jack"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e5a18a3c2aefb354fb77111ade228b20267bdc779de84e7a4ccf7ea96b9a6cd"
dependencies = [
"bitflags",
"jack-sys",
"lazy_static",
"libc",
"log",
]
[[package]]
name = "jack-sys"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6013b7619b95a22b576dfb43296faa4ecbe40abbdb97dfd22ead520775fc86ab"
dependencies = [
"bitflags",
"lazy_static",
"libc",
"libloading",
"log",
"pkg-config",
]
[[package]]
name = "jni"
version = "0.19.0"
@ -1098,15 +1142,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "libsamplerate-sys"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28853b399f78f8281cd88d333b54a63170c4275f6faea66726a2bea5cca72e0d"
dependencies = [
"cmake",
]
[[package]]
name = "libudev-sys"
version = "0.1.4"
@ -1204,6 +1239,22 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f2dd5c7f8aaf48a76e389068ab25ed80bdbc226b887f9013844c415698c9952"
[[package]]
name = "midir"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a456444d83e7ead06ae6a5c0a215ed70282947ff3897fb45fcb052b757284731"
dependencies = [
"alsa",
"bitflags",
"coremidi",
"js-sys",
"libc",
"wasm-bindgen",
"web-sys",
"windows 0.43.0",
]
[[package]]
name = "minifb"
version = "0.24.0"
@ -1312,24 +1363,29 @@ version = "0.0.0"
dependencies = [
"anyhow",
"anymap",
"assert_no_alloc",
"atomic_float",
"atomic_refcell",
"backtrace",
"baseview",
"bitflags",
"cfg-if",
"clap",
"clap-sys",
"core-foundation",
"cpal",
"crossbeam",
"jack",
"lazy_static",
"libc",
"log",
"midi-consts",
"midir",
"nih_log",
"nih_plug_derive",
"objc",
"parking_lot",
"raw-window-handle 0.5.0",
"rtrb",
"serde",
"serde_json",
"vst3-sys",
@ -1794,6 +1850,15 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "rtrb"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99e704dd104faf2326a320140f70f0b736d607c1caa1b1748a6c568a79819109"
dependencies = [
"cache-padded",
]
[[package]]
name = "rustc-demangle"
version = "0.1.21"
@ -1844,15 +1909,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "samplerate"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e032b2b24715c4f982f483ea3abdb3c9ba444d9f63e87b2843d6f998f5ba2698"
dependencies = [
"libsamplerate-sys",
]
[[package]]
name = "scoped-tls"
version = "1.0.1"
@ -2035,6 +2091,16 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "terminal_size"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c9afddd2cec1c0909f06b00ef33f94ab2cc0578c4a610aa208ddfec8aa2b43a"
dependencies = [
"rustix",
"windows-sys 0.45.0",
]
[[package]]
name = "thiserror"
version = "1.0.38"
@ -2182,7 +2248,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
name = "vst"
version = "0.1.0"
dependencies = [
"async-ringbuf",
"baseview",
"futures",
"gb-emu-lib",
"nih_plug",
"pixels",

View file

@ -12,6 +12,8 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
gb-emu-lib = { path = "../lib" }
nih_plug = { path = "../vendored/nih-plug", features = ["assert_process_allocs"] }
nih_plug = { path = "../vendored/nih-plug", features = ["standalone"] }
baseview = { path = "../vendored/baseview" }
pixels = "0.11.0"
async-ringbuf = "0.1.2"
futures = "0.3.26"

7
gb-vst/src/main.rs Normal file
View file

@ -0,0 +1,7 @@
use nih_plug::prelude::*;
use vst::GameboyEmu;
fn main() {
nih_export_standalone::<GameboyEmu>();
}

View file

@ -4,6 +4,7 @@ use baseview::{
Event, EventStatus, MouseButton, MouseEvent, Size, Window, WindowEvent, WindowHandler,
WindowInfo, WindowOpenOptions,
};
use gb_emu_lib::connect::Renderer;
use nih_plug::prelude::*;
use pixels::{Pixels, SurfaceTexture};
@ -29,6 +30,7 @@ impl Editor for Emulator {
title: String::from("gb-emu"),
size: Size::new(WIDTH as f64, HEIGHT as f64),
scale: baseview::WindowScalePolicy::SystemScaleFactor,
gl_config: None,
},
EmulatorWindow::new,
);
@ -76,7 +78,6 @@ impl EmulatorWindow {
fn update_pixbuf(&mut self) {
self.current_colour = rotate_colour(&self.current_colour);
self.render_pixbuf();
println!("colour now {:#?}", self.current_colour);
}
fn render_pixbuf(&mut self) {
@ -116,10 +117,23 @@ impl WindowHandler for EmulatorWindow {
..
}) = event
{
println!("click!");
nih_log!("nih click!");
self.update_pixbuf();
return EventStatus::Captured;
}
EventStatus::Ignored
}
}
#[derive(Default)]
pub struct EmulatorRenderer {}
impl Renderer for EmulatorRenderer {
fn prepare(&mut self, _width: usize, _height: usize) {}
fn display(&mut self, _buffer: &[u32]) {}
fn latest_joypad_state(&mut self) -> gb_emu_lib::connect::JoypadState {
gb_emu_lib::connect::JoypadState::default()
}
}

@ -1 +1 @@
Subproject commit a6e07b7ea78f3febe8c2434998be65cb4ce50094
Subproject commit 1c12e0510884852bbeaf4f284c1196e271c4db70

@ -1 +1 @@
Subproject commit 8ada33953924c7201c977c2e09546bd9c9bdfe56
Subproject commit 16f40eff4adb0a03a176d6e0fa7a4f794b484756