Skip to content

Commit

Permalink
WIP chapter 3
Browse files Browse the repository at this point in the history
  • Loading branch information
geom3trik committed Oct 18, 2023
1 parent 8c69df0 commit dd9a2e7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# vizia-plug-book
Tutorial for creating a audio plugins using Vizia and Nih-Plug
Tutorial for creating a audio plugins using Nih-Plug and Vizia.
2 changes: 1 addition & 1 deletion book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ authors = ["George Atkinson"]
language = "en"
multilingual = false
src = "src"
title = "Creating audio plugins with Vizia and Nih-Plug"
title = "Creating audio plugins with Nih-Plug and Vizia"
5 changes: 3 additions & 2 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Summary

- [Setup](./setup.md)
<!-- - [Logging and Debugging](./logging_debugging.md) -->
- [Getting started](./getting_started.md)
<!-- - [Logging and debugging](./logging_debugging.md) -->
<!-- - [A simple gain plugin](./gain.md) -->
5 changes: 5 additions & 0 deletions src/gain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# A Simple Gain Plugin

The template used in the [getting started](./setup.md) chapter creates for us a simple gain plugin. In this chapter we'll add a knob to control the gain of the audio input, as well as a peek meter to visualize the audio level after the gain has been applied.

##
27 changes: 18 additions & 9 deletions src/setup.md → src/getting_started.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Chapter 1

# Getting Started

## Creating a new project using the template

First, we'll use [cookicutter](https://github.com/cookiecutter/cookiecutter) to create a new nih-plug project using the [nih-plug template](https://github.com/robbert-vdh/nih-plug-template).

We can run the template generator using [pipx](https://pypa.github.io/pipx/) with the following in a directory of your choosing:
We can run the template generator using [pipx](https://pypa.github.io/pipx/) with the following:

```
pipx run cookiecutter gh:robbert-vdh/nih-plug-template
Expand All @@ -19,13 +18,13 @@ The CLI tool will prompt you to enter a name for the plugin, in this case we've

The template creates a nih-plug project without a GUI, so first we need to change the dependencies to include vizia into the project.

Open the `Cargo.toml` and add the following dependency below the `nih_plug` dependency:
Open the `Cargo.toml` file and add the following below the `nih_plug` dependency:

```toml
nih_plug_vizia = { git = "https://github.com/robbert-vdh/nih-plug.git" }
```

Note that the git URL is the same as the `nih_plug` dependency above it as the crates are from the same repository.
Note that the git URL is the same as the `nih_plug` dependency above it as both crates are from the same repository.

## Adding a basic Vizia GUI

Expand Down Expand Up @@ -54,15 +53,25 @@ The `create_vizia_editor` function creates the vizia GUI window with a size dete

Within the closure passed to the `create_vizia_editor` function is where we create the vizia GUI and add some controls. In this case we've added a simple label to begin with.

To actually add the GUI to the plugin we need to add an `editor` method to the `Plugin` trait implementation of `ViziaPlug`. Add the following to `lib.rs` below the `process` method:
To actually add the GUI to the plugin we need to add an `editor` method to the implementation of the`Plugin` trait for the `ViziaPlug` type. Add the following to the `lib.rs` file below the `process()` method:

```rust
fn editor(&mut self, _async_executor: AsyncExecutor<Self>) -> Option<Box<dyn Editor>> {
editor::create(self.params.clone())
}
```

And also include the `editor` module by adding `'mod editor;'` to the top of the `lib.rs` file above the `ViziaPlug` struct definition.
We also need to include the `editor` module by adding `'mod editor;'` to the top of the `lib.rs` file above the `ViziaPlug` struct definition.

## Building the plugin

The plugin can be compiled with the following:

```shell
cargo xtask bundle vizia_plug --release
```

This will create both clap and vst versions of the plugin in the `target/bundled` directory. Simply move the `.vst` and/or `.clap` files to the appropriate folder(s) so that they can be found by the Digital Audio Workstation (DAW).

## Running the plugin standalone

Expand Down Expand Up @@ -94,6 +103,6 @@ fn main() {

For the above to work the `ViziaPlug` struct must be made public.

Finally, use `cargo run` to build and run the standalone version of the plugin, which should then appear:
Finally, use `cargo run` to build and run the standalone version of the plugin:

<img src="./img/hello_gui.png" alt="" width="200"/>
<img src="./img/hello_gui.png" alt="" width="300"/>
2 changes: 1 addition & 1 deletion src/logging_debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Setting up logging

## Debugging with Bitwig
## Debugging with a DAW

0 comments on commit dd9a2e7

Please sign in to comment.