Piano Synthesizer by Joe Amenta
The score file that generates the short
demonstration of the piano synthesizer is here.
The audio file
generated from this score file is here.
The piano samples themselves include the attack, decay, and sustain portions of an ADSR envelope.
The release portion is generated by linearly decreasing the note's amplitude over a period of 0.4 seconds.
The pedal is held down for a given number of beats, as specified in the score file.
While the pedal is held down, a given note is sustained for a number of beats equal to the greater value of: the number of pedal beats remaining and the number of beats that the key is held down.
(basic) A note is made louder by multiplying each sample's value by another value that depends on the amplitude specified in the score file.
(advanced) Each note is created from two recorded samples: loud and soft. The amplitude specified by the score file determines how much of each recorded sample will comprise the final note.
When the pedal is pressed down, a recorded sound sample is played.
When the pedal is released, a recorded sound sample is played.
Score file format:
The format for
the piano synthesizer is as follows:
beat="1" amp="0.7" duration="1.5" pedal="2.5" />
Piano instrument nodes and
- instrument - The name of
the instrument must be 'PianoInstrument'
- amp - The amplitude to
play the note at, between 0 and 1. 0 plays the note softly, and 1 plays the note loudly.
- measure - The measure
where the note starts. This value should be greater than or equal to 1.
- beat - The beat in the
measure where the note starts. This value should be greater than or equal to
one and less than or equal to the beatspermeasure value.
- duration - The amount of
time in beats that a key is held down for.
- key - Which key to play.
- pedal - This is an
optional attribute that dictates for how many beats the pedal is to be held down.
When a note with this attribute is first encountered, a pedal down sound is played.
Notes are sustained for a number of beats equal to their duration or the number of pedal
beats remaining, whichever is greater.