Hz.Samplo is a soundfile-based sythesizer that supports three synthesis approaches: Soundfont Player, Wavetable Synthesis, Granular Synthesis.
This example shows Hz.Samplo
operating as a soundfont player.
We use SampleMgr to preload
88 stereo sound files that make up the accordion
voice from
midi-js's
"port" of the FatBoy
soundfont.
code snippet
// first preload samples
let bank = "MIDIJS/FatBoy";
let voice = "accordion";
let voiceref = `${bank}_${voice}`;
let asamps = await SampleMgr.PreloadSamples(bank, voice);
// next create our anode instance.
let samplo = scene.NewAnode("Hz.Samplo", {name:"accordion"});
// ... more instruments and graph-wiring ...
await ascene.Sync();
// finally load samples into samplo.
await samplo.LoadPreset(asamps.AsPreset(), voiceref);
This example shows Hz.Samplo
operating as a soundfont player. Since
our wavetable file is a single local file, we have no need of SampleMgr
but we do need to ensure the path is fully qualified via ResolveWSFile
.
code snippet
const thisDir = path.dirname(this.GetFilePath());
const wtfile = path.join(thisDir, "data/quadsaw.wav");
let preset = {
SynthMode: 1, // wavetable mode.
wavetable: await ResolveWSFile(wtfile)
};
// ... elide setup ...
let samplo = scene.NewAnode("Hz.Samplo"); // 0 inputs, 1 2ch output
// ... more instruments and graph-wiring ...
await scene.Sync();
await samplo.LoadPreset(preset);
This example shows Hz.Samplo
operating as a granular synthesizer .
Here we preload a single local file but use SampleMgr
to format
a our single-note soundfile for consumption by Hz.Samplo
.
code snippet
let cwd = path.dirname(this.GetFilePath());
let wspath = await ResolveWSFile(cwd); // convert to fullpath
// Note: placing our soundfiles (3rd argument, below) in an array,
// we convey the idea that the sound files aren't `tonal` and
// therefore have no associated MIDI note. You can load your
// own tonal files by using an object like so:
// {"C3": "data/fermiSpectacular.wav"}
let sfPreset = SampleMgr.AsPresetFromLocalVoice(wspath,
"fermi", ["data/fermiSpectacular.wav"]);
await samplo.LoadPreset(sfPreset);
Use the interface in the HzPlugins tab
to explore all the Granular knobs.
Use Fibers Panel
or right-click Clear Sandboxes
to cancel.
This example shows Hz.Samplo
operating as a granular synthesizer
using soundfont-based sample files. This means that the sounds
are correlated by the MIDI notes that trigger the synth. Here we're
careful to say correlated because the perceived pitch is controlled
by various settings, most importantly the Grain Rate
.
Use the interface in the HzPlugins tab
to explore all the knobs
controlling the Granular synth.
Use Fibers Panel
or right-click Clear Sandboxes
to cancel.