Your First Project
On this page you turn the beat from the last pages into a piece: a file that plays the same every time, which you run from the terminal and get as a WAV file.
Work in the hello project from Your First Sound.
Before you start
Section titled “Before you start”Open the hello folder and check that it contains resonon.toml and src/main.non.
Evaluate STOP; in VSCode if the earlier beat is playing. The terminal run starts independently
of that live session; it needs no variables from previous evaluations.
Look at the project
Section titled “Look at the project”resonon new hello made this folder:
hello/├── resonon.toml├── src/│ └── main.non├── README.md├── LICENSE└── .gitignoreresonon.tomlnames the project and the version of resonon it is written for. Resonon finds a project by this file, so the code insrc/can find its kits and packages on any machine.src/main.nonis the piece. It is the file thatresonon runruns.
Write the piece
Section titled “Write the piece”Until now you ran lines one at a time, and the session kept them. A piece must do everything by
itself, from the top. Replace what is in src/main.non with this:
use "std/instruments" { Sampler, Kit };use "std/effects" { Lowpass, Delay };
set_project_title("hello");set_bpm(120);
let drums = AudioTrack("drums");drums.set_instrument(Sampler(Kit("CR-78")));drums << [bd _ sd _, hh hh hh hh];drums.set_effects(#[Lowpass("lowpass", 1200), Delay("delay", 0.25, 0.4)]);
let bass = AudioTrack("bass");bass.set_instrument(Sampler(Kit("TR-808")));bass << [bd _ _ bd, _ _ bd _];
render(8);It is the beat you built, with two new lines at the top and one at the end:
set_project_title("hello")names the piece.set_bpm(120)sets its tempo: 120 BPM, and four beats in each cycle.render(8)plays 8 cycles of the master output into a WAV file, faster than real time.
Run it
Section titled “Run it”Save the file. In a terminal, in the hello folder, run:
resonon runResonon runs src/main.non from the top and exits. The file is in a new folder in the project:
renders/hello_<date>_<time>/master.wavOpen it in any audio player. It is 16 seconds long: 8 cycles of 2 seconds.
resonon run works from any folder inside the project. It runs the file once and stops, so a line
like PLAY; in a piece plays nothing that you can hear: the program ends at once. To hear a piece
while you work on it, select its lines in VSCode and press Cmd+Enter, as before.
Bounce each track
Section titled “Bounce each track”Change the last line so that each track gets its own file, next to the mix:
render(#[drums, bass, master], 8);Run resonon run again. A new folder has drums.wav, bass.wav and master.wav. Every run makes
a new folder, so a render never writes over another one.
Next steps
Section titled “Next steps”- Arrange a Song — the next tutorial: give the beat a form, from intro to chorus
- Render a Project — every way to render
- Two Ways to Run a Piece — why resonon has two ways to run a piece
- resonon.toml — every key of the project file