Rust-VST2 项目使用教程
1. 项目的目录结构及介绍
Rust-VST2 项目的目录结构如下:
rust-vst2/
├── examples/
├── src/
├── .gitignore
├── .travis.yml
├── Cargo.toml
├── LICENSE
├── README.md
├── appveyor.yml
├── appveyor_rust_install.ps1
└── osx_vst_bundler.sh
目录介绍:
- examples/: 包含示例插件的代码。
- src/: 包含项目的主要源代码。
- .gitignore: Git 忽略文件配置。
- .travis.yml: Travis CI 配置文件。
- Cargo.toml: Rust 项目的配置文件。
- LICENSE: 项目许可证文件。
- README.md: 项目说明文档。
- appveyor.yml: AppVeyor CI 配置文件。
- appveyor_rust_install.ps1: AppVeyor 使用的 Rust 安装脚本。
- osx_vst_bundler.sh: macOS 平台下的 VST 打包脚本。
2. 项目的启动文件介绍
项目的启动文件位于 src/lib.rs
,该文件是 Rust-VST2 库的入口点。以下是 src/lib.rs
的部分代码:
#[macro_use]
extern crate vst2;
use vst2::plugin::{Info, Plugin};
#[derive(Default)]
struct BasicPlugin;
impl Plugin for BasicPlugin {
fn get_info(&self) -> Info {
Info {
name: "Basic Plugin".to_string(),
unique_id: 1357,
..Default::default()
}
}
}
plugin_main!(BasicPlugin);
启动文件介绍:
- extern crate vst2: 引入 vst2 库。
- use vst2::plugin::{Info, Plugin}: 引入必要的 trait 和结构体。
- struct BasicPlugin: 定义一个基本的插件结构体。
- impl Plugin for BasicPlugin: 实现
Plugin
trait,定义插件的基本信息。 - plugin_main!(BasicPlugin): 调用宏
plugin_main
,导出必要的函数以供 VST 宿主使用。
3. 项目的配置文件介绍
项目的配置文件是 Cargo.toml
,该文件用于配置 Rust 项目的依赖和构建选项。以下是 Cargo.toml
的部分内容:
[package]
name = "rust-vst2"
version = "0.0.1"
authors = ["overdrivenpotato"]
license = "MIT"
description = "A library to help facilitate creating VST plugins in rust"
repository = "https://github.com/overdrivenpotato/rust-vst2"
[dependencies]
libloading = "^0.3"
libc = "^0.2"
bitflags = "^0.7"
log = "^0.3"
num = "^0.1"
[lib]
name = "vst2"
crate-type = ["dylib"]
配置文件介绍:
- [package]: 定义项目的名称、版本、作者、许可证和描述等信息。
- [dependencies]: 定义项目依赖的库及其版本。
- [lib]: 定义库的名称和类型(动态库)。
通过以上介绍,您可以更好地理解和使用 Rust-VST2 项目。希望本教程对您有所帮助!