Piano Synthesizer Tutorial

Ning Hu and Roger B. Dannenberg

This page describes how to use the piano synthesizer in Nyquist. Both SAL and Lisp syntax are used. Lisp syntax is in small type.

First, load the file "pianosyn.lsp" to initialize the synthesizer. The file is in the "lib" directory.

> load "pianosyn"

> (load "pianosyn")

After the piano synthesizer has been initialized and returns, you can use the functions provided by the synthesizer program to generate piano sounds.

The functions are shown as below:

Generate a single note

Use the function:

piano-note(duration, step, dynamic)

(piano-note duration step dynamic)

This behavior returns a sound. You can play the sound.

Examples:

> play piano-note(4, 60, 100)

> (play (piano-note 4 60 100))
The commands above will generate and immediately play a C4 note that lasts 4 seconds, velocity at 100.

Synthesize piano music according to a midi file

To convert a midi file to sound, use the function:

piano-midi(midi-file-name)


(piano_midi midi_file_name)
This behavior will generate sound according to the score of the midi file. It generates stereo sound, and the sample rate is the default sound sample rate.

Convert midi file to sound file

To convert a midi file to a sound file using the piano synthesizer, use the function:

piano-midi2file(midi-file-name, sound-file-name)

(piano-midi2file midi-file-name sound-file-name)
This command will generate a sound file according to the score of the midi file and play it at the same time. It generates stereo sound, and the sample rate is the default sound sample rate.

Example:

> exec piano-midi2file("demo.mid", "demo.wav")

> (piano-midi2file "demo.mid" "demo.wav")