Wherein we discuss Hz's options for representing musical notes in your compositions.
Most musical compositions are built atop sequences of carefully selected musical notes. In the context of a Programmable Sound System the question arises, how best to represent them?
Hz offers you several options to represent notes. These can be freely mixed and matched in your compositions.
Songs.hz
is a notation for ergonomically expressing multi-track,
multi-voice compositions replete with controls over tempo and
note expressions like pan, pitch-bend, volume, etc. Hz offers
the ability to author, visualize and perform songs in this notation.
You can view this environment as a musical programming environment
since the primary programmable components are Song, Voice, Track, Section
and Sequencer. Songs.hz is not a general programming environment
and therefore is much easier to master.
songs_hz:0.1.0
Song(Id:"mysong")
{
Track(Id:"melody")
{
[a#3 bb3]!3
}
}
Once you make the move to storing your tunes in .hz
files you unlock the
augmented editing capabilities in the Code Editor.
To summarize:
More details can be found here and working examples here.
To achieve arbitrary programmability, Hz supports both
JavaScript and Lua programming.
These are coupled with the MusicAPI and
Tonal to empower you to "do anything
you can imagine".
This example shows one approach to expressing musical ideas with the combination of JavaScript and our MusicAPI.
// initialize audio engine and a synth node.
let ascene = await Ascene.BeginFiber(this);
console.log("Audio scene is ready to go.");
let inst = ascene.NewAnode("Surge XT");
let dac = ascene.GetDAC();
ascene.Connect(inst, dac);
await ascene.Sync();
// request a string of notes using MIDI note numbers.
let noteDur = ascene.Seconds(1);
for(let key=40; key<=60;key++)
{
inst.NoteOn(key, .8);
await ascene.Wait(noteDur);
inst.NoteOff(key, .8);
yield;
}
It's possible to embed note-generation sequence into separate free-running (asynchronous) functions and in this way you can control multiple independent streams of notes simultaneously.
MIDI Files store notes in a .mid
file. These can be performed
with the MidiFile class. MIDI files have
been around for some time and are an excellent means to exchange notes with
other composition tools. But because the .mid
file format is binary,
special tooling is required to modify them. Moreover, the range of applications
of MIDI Files is fairly broad and this means that all .mid
files are not
created equal. There are 3 subformats, an MPE (Polyphonic Expression) extension
spec and a next generation (MIDI 2) becoming more commonplace. For these reasons
MIDI files may not be the best representation for storing your compositional
elements.