Audacity Support Forum / Audacity and Nyquist / Nyquist Reference Manual / Nyquist Examples and Tutorials

Piano Synthesizer Tutorial

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

Sound examples: piano-note.ogg - demo.ogg


First, load the file "pianosyn.lsp" to initialize the synthesizer. The file is in the Nyquist "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))

- Sound example: piano-note.ogg

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

- Sound example: demo.ogg

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

A demo.mid midi file can be downloaded from here by right-click - save target as...

Generated by Ning Hu(ning_hu@cmu.edu) Mar.22, 2001


Audacity Support Forum / Audacity and Nyquist / Nyquist Reference Manual / Nyquist Examples and Tutorials