NAME
Peta::Synth::Server - the synthesizer behind a web page
VERSION
version 0.2610180
SYNOPSIS
use Peta::Synth::Server;
Peta::Synth::Server->new(port => 8360, midi_dir => 'songs', bank => 'my-bank.json')->run;
or peta-synth serve.
DESCRIPTION
Serves a page from which the synthesizer is played and set up while it sounds: every instrument's and drum's patch, the channels (instrument, volume, pan, reverb send, mute, arpeggiator), the reverb, the quality; MIDI files are played from a directory or dropped onto the page, and keys come from the page's keyboard, the computer's keyboard, or a MIDI device through the browser's Web MIDI.
A file is played from its start or from a position, paused and played on; each channel shows its first instrument from the file's start, not only when its first note comes; from a position, the channels are set up as the file has them there (its programs, controllers and system exclusive before it), and its notes begin from there. What is played live (the page's keys and controls, Web MIDI, in) can be recorded: into a MIDI file of the directory, named by when the recording began, the channels it plays set up as they were then.
What is set by hand (on the page, or by MIDI played live) is held against the file's events on that channel until it is let go (see "by_hand, held, let_go, forget_held" in Peta::Synth::Synth); another file forgets it.
The sound goes to the browser over a WebSocket and is played there; the browser's clock paces the rendering. When the render takes most of the time there is, new notes get fewer partials, and more again when there is room (auto). The messages are listed at the top of the source.
It listens on 127.0.0.1 unless told otherwise: whoever reaches the port can play the synth and save MIDI files into its directory.
METHODS
new
Peta::Synth::Server->new(
host => '127.0.0.1',
port => 8360,
rate => 48000,
partials => 48,
engine => 'auto',
fidelity => 'mid',
midi_dir => '.',
bank => $file,
in => 'all',
auto => 1,
ahead => 0.12,
quantum => 512,
);
bank is a JSON file of instrument changes, read at the start and written when the page saves; in, MIDI read besides the page's, as Peta::Synth::Input takes it (none unless given); ahead is how far, in seconds, the sound is rendered in front of what the browser has played.
run, stop
Serves until stop.
url, synth
The address served, and the Peta::Synth::Synth that plays.
AUTHOR
PetaMem s.r.o. <info@petamem.com>
COPYRIGHT
Copyright (c) 2026 PetaMem s.r.o.
LICENSE
This package is free software, dual-licensed under the Artistic License 2.0 and the BSD 2-Clause License. See the LICENSE file of the distribution.