Expand description
§Augmented Audio: Audio Processor Standalone
This is part of https://github.com/yamadapc/augmented-audio. Please review its goals. This
crate builds upon audio_processor_traits::AudioProcessor
.
Provides a stand-alone audio-processor runner for AudioProcessor
implementations.
§Navigating the documentation
- Look at exported functions & macros; the structs/traits are for more advanced/internal usage.
- Start with
audio_processor_main
andaudio_processor_main_with_midi
- There are plenty examples in the
augmented-audio
repository
The gist of it is:
- Implement
AudioProcessor
orSimpleAudioProcessor
fromaudio_processor_traits
- Call
audio_processor_main(processor)
- You now have a CLI for rendering online (CPAL, use your mic) or offline (pass a file through your processor & write
the results to a
.wav
)
A VST may also be generated through the standalone_vst
module and by enabling the vst
feature flag.
§Example usage
Declare the AudioProcessor
:
use audio_processor_traits::{AudioBuffer, AudioContext, AudioProcessor};
struct GainProcessor {}
impl GainProcessor { fn new() -> Self { GainProcessor {} }}
impl AudioProcessor for GainProcessor {
type SampleType = f32;
fn process(&mut self, _context: &mut AudioContext, data: &mut AudioBuffer<Self::SampleType>) {
for channel in data.channels_mut() {
for sample in channel {
*sample = *sample * 0.4;
}
}
}
}
Declare the main function:
ⓘ
fn main() {
let processor = GainProcessor::new();
audio_processor_standalone::audio_processor_main(processor);
}
§Usage of the command-line
ⓘ
audio-processor-standalone
USAGE:
my-crate [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-i, --input-file <INPUT_PATH> An input audio file to process
--midi-input-file <MIDI_INPUT_FILE> If specified, this MIDI file will be passed through the processor
-o, --output-file <OUTPUT_PATH> If specified, will render offline into this file (WAV)
Modules§
- offline
- Offline rendering implementation (offline functionality will not work on iOS for now)
- options
- Options handling for standalone processor
- standalone_
cpal - Online standalone implementation using CPAL
- standalone_
processor - Internal wrapper types
- standalone_
vst - VST support (VST is not compiled for iOS)
Macros§
- generic_
standalone_ run - generic_
standalone_ vst - standalone_
start_ for_ env - Use
VirtualHost
on cfg(test), otherwise callstandalone_start
. - standalone_
vst
Structs§
- Standalone
Audio Only Processor - A standalone processor impl that will only process audio
- Standalone
Handles - Handles to the CPAL streams and MIDI host. Playback will stop when these are dropped.
- Standalone
Processor Impl - A standalone processor impl that will process audio and MIDI
Traits§
- Standalone
Processor - Abstract standalone processor with runtime optional MIDI handling.
Functions§
- audio_
processor_ main - A default main function for an
AudioProcessor
. - audio_
processor_ main_ with_ midi - A default main function for an
AudioProcessor
andMidiEventHandler
. - audio_
processor_ start - Start an
AudioProcessor
as a stand-alone cpal app> - audio_
processor_ start_ with_ midi - Start an
AudioProcessor
/MidiEventHandler
as a stand-alone cpal app and forward MIDI messages received on all inputs to it. - standalone_
start - Start a processor using CPAL. Returns
StandaloneHandles
which can be used to take the processor back and stop the stream. - standalone_
start_ with - Same as
standalone_start
but takes an options parameter.