NAME

Synth::Config - Synthesizer settings librarian

VERSION

version 0.0045

SYNOPSIS

use Synth::Config ();

my $model = 'Moog Matriarch';

my $synth = Synth::Config->new(model => $model);

my $name = 'My favorite setting';

my $id1 = $synth->make_setting(name => $name, group => 'filter', etc => '...');
my $id2 = $synth->make_setting(name => $name, group => 'sequencer', etc => '...');

my $setting = $synth->recall_setting(id => $id1);
# { id => 1, group => 'filter' }

# update the group key
$synth->make_setting(id => $id1, group => 'envelope');

my $settings = $synth->search_settings(name => $name);
# [ { id => 1, group => 'envelope', etc => '...' }, { id => 2, group => 'sequencer', etc => '...' } ]

$settings = $synth->search_settings(group => 'sequencer');
# [ { id => 2, group => 'sequencer', etc => '...' } ]

my $models = $synth->recall_models;
# [ 'moog_matriarch' ]

my $names = $synth->recall_names;
# [ 'My favorite setting' ]

# declare the possible settings
my %spec = ( # default initial model specification
  order      => [qw(group parameter control group_to param_to bottom top value unit is_default)],
  group      => [],
  parameter  => {},
  control    => [qw(knob switch slider patch)],
  group_to   => [],
  param_to   => [],
  bottom     => [qw(off 0 1 7AM 20)],
  top        => [qw(on 3 4 6 7 5PM 20_000 100%)],
  value      => [],
  unit       => [qw(Hz o'clock)],
  is_default => [0, 1],
);
my $spec_id = $synth->make_spec(%spec);
my $specs = $synth->recall_spec(id => $spec_id);

# remove stuff!
$synth->remove_spec;
$synth->remove_setting(id => $id1);     # remove a particular setting
$synth->remove_settings(name => $name); # remove all setting sharing the same name
$synth->remove_model(model => $model);  # remove the entire model

DESCRIPTION

Synth::Config provides a way to save and recall synthesizer control settings in a database.

This does not control the synth. It is simply a way to manually record the parameters defined by knob, slider, switch, or patch settings in an SQLite database. It is a "librarian", if you will.

ATTRIBUTES

model

$model = $synth->model;

The model name of the synthesizer.

This is turned into lowercase and all non-alpha-num characters are converted to an underline character (_).

dbname

$dbname = $synth->dbname;

Database name

Default: synth-config.db

verbose

$verbose = $synth->verbose;

Show progress.

METHODS

new

$synth = Synth::Config->new(model => $model);

Create a new Synth::Config object.

This automatically makes an SQLite database with a table named for the given model.

make_setting

my $id = $synth->make_setting(%args);

Save a named setting and return the record id.

The name is required to perform an insert. If an id is given, an update is performed.

The setting is a single JSON field that can contain any key/value pairs. These pairs must include at least a group to be searchable.

Example:

name: 'My Best Setting!'
settings:
  group   parameter control bottom top   value unit is_default
  filters cutoff    knob    20     20000 200   Hz   1

name: 'My Other Best Setting!'
settings:
  group parameter control group_to param_to is_default
  mixer output    patch   filters  vcf-1-in 0

recall_setting

my $setting = $synth->recall_setting(id => $id);

Return the parameters of a setting for the given id.

search_settings

my $settings = $synth->search_settings(
  some_setting    => $valu2,
  another_setting => $value2,
);

Return all the settings given a search query.

recall_all

my $settings = $synth->recall_all;

Return all the settings for the synth model.

recall_models

my $models = $synth->recall_models;

Return all the know models. This method can be called without having specified a synth model in the constructor.

recall_names

my $names = $synth->recall_names;

Return all the setting names.

remove_setting

$synth->remove_setting(id => $id);

Remove a setting given an id.

remove_settings

$synth->remove_settings(name => $name);

Remove all settings for a given name.

remove_model

$synth->remove_model;

Remove the database table for the current object model.

make_spec

my $id = $synth->make_spec(%args);

Save a model specification and return the record id.

If an id is given, an update is performed.

The spec is a single JSON field that can contain any key/value pairs that define the configuration - groups, parameters, values, etc. of a model.

recall_spec

my $specs = $synth->recall_spec(id => $id);

Return the model configuration specification for the given id.

remove_spec

$synth->remove_spec;

Remove the database table for the current object model configuration specification.

SEE ALSO

The t/01-methods.t and the eg/*.pl files in this distribution

The Mojolicious::Lite user interface that automates synthesizer configuration saving and retrieval is eg/synth-config-mojo.pl.

Moo

Mojo::JSON

Mojo::SQLite

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2023-2024 by Gene Boggs.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)