Vital
Loading...
Searching...
No Matches
main.cpp File Reference
#include "JuceHeader.h"
#include "load_save.h"
#include "tuning.h"
#include "synth_base.h"

Functions

String getArgumentValue (int argc, const char *argv[], const String &flag, const String &full_flag)
 Retrieves the value of a command-line argument following a given flag.
 
bool hasFlag (int argc, const char *argv[], const String &flag, const String &full_flag)
 Checks if a particular flag is present in the command-line arguments.
 
float getRenderLength (int argc, const char *argv[])
 Retrieves the desired length in seconds for rendering output audio from the command line.
 
std::vector< int > getRenderMidiNotes (int argc, const char *argv[])
 Parses the command line for desired MIDI note inputs to render.
 
float getRenderBpm (int argc, const char *argv[])
 Retrieves the BPM (Beats Per Minute) from command-line arguments.
 
void doRenderToFile (HeadlessSynth &headless_synth, int argc, const char *argv[])
 Renders the loaded synth configuration to an audio file if output is specified.
 
bool loadFromCommandLine (HeadlessSynth &synth, const String &command_line)
 Attempts to load a file from the command line into the HeadlessSynth.
 
int main (int argc, const char *argv[])
 The main entry point for the headless tool.
 

Function Documentation

◆ doRenderToFile()

void doRenderToFile ( HeadlessSynth & headless_synth,
int argc,
const char * argv[] )

Renders the loaded synth configuration to an audio file if output is specified.

Checks command-line flags for output path, whether to render images, length, BPM, and MIDI notes, and uses HeadlessSynth::renderAudioToFile to produce the result.

Parameters
headless_synthThe synth to render from.
argcThe number of arguments.
argvThe argument vector.

◆ getArgumentValue()

String getArgumentValue ( int argc,
const char * argv[],
const String & flag,
const String & full_flag )

Retrieves the value of a command-line argument following a given flag.

Searches through the command-line arguments for the specified short or long flag. If found, returns the next argument as the value. Otherwise, returns an empty string.

Parameters
argcThe number of command-line arguments.
argvThe array of command-line argument strings.
flagThe short flag (e.g. "-o").
full_flagThe long flag (e.g. "--output").
Returns
The value string following the given flag, or "" if not found.

◆ getRenderBpm()

float getRenderBpm ( int argc,
const char * argv[] )

Retrieves the BPM (Beats Per Minute) from command-line arguments.

Defaults to 120 BPM. Enforces minimum 5.0 BPM and max 900.0 BPM.

Parameters
argcThe number of arguments.
argvThe argument vector.
Returns
The BPM to use when rendering.

◆ getRenderLength()

float getRenderLength ( int argc,
const char * argv[] )

Retrieves the desired length in seconds for rendering output audio from the command line.

If not specified, defaults to 5.0 seconds. Caps at a maximum of 15.0 seconds.

Parameters
argcThe number of arguments.
argvThe argument vector.
Returns
The render length in seconds.

◆ getRenderMidiNotes()

std::vector< int > getRenderMidiNotes ( int argc,
const char * argv[] )

Parses the command line for desired MIDI note inputs to render.

Uses note names or numeric values. If none provided, defaults to MIDI note 48.

Parameters
argcThe number of arguments.
argvThe argument vector.
Returns
A vector of MIDI notes to use during rendering.

◆ hasFlag()

bool hasFlag ( int argc,
const char * argv[],
const String & flag,
const String & full_flag )

Checks if a particular flag is present in the command-line arguments.

Parameters
argcThe number of command-line arguments.
argvThe array of command-line argument strings.
flagThe short flag to check.
full_flagThe long flag to check.
Returns
True if the flag is found, false otherwise.

◆ loadFromCommandLine()

bool loadFromCommandLine ( HeadlessSynth & synth,
const String & command_line )

Attempts to load a file from the command line into the HeadlessSynth.

If the argument is a file path, tries to load it as a preset or wavetable. If successful, returns true.

Parameters
synthThe HeadlessSynth instance.
command_lineThe file path or command.
Returns
True if loaded successfully, false otherwise.

◆ main()

int main ( int argc,
const char * argv[] )

The main entry point for the headless tool.

Processes command-line arguments to optionally load a preset or wavetable and render it to an audio file.

Usage:

  • Provide a file path to load as a preset/wavetable.
  • Use flags like -o/–output for output file, -l/–length for render length, -m/–midi for MIDI notes, -b/–bpm for BPM, and -i/–render-images to produce image frames.
Parameters
argcThe number of arguments.
argvThe argument vector.
Returns
Returns 0 on success.