Piano Synthesizer Tutorial

This page describes how to use the piano synthesizer in Nyquist.

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

>(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)

This behavior returns a sound. You can use (play (piano_note...)) or (s_save (piano_note...)...) to play or save the sound.

Examples:

> (play (piano_note 4 60 100))
The command 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)

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)

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:

>(piano_midi2file "demo.mid" "demo.wav")
"demo.mid" is the name of the midi file. It saves the output sound into "demo.wav", and plays it when generating the output.

Generated by Ning Hu([email protected]) Mar.22, 2001