96 kHz.org
Advanced Audio Recording

A virtual analog Piano in VHDL

This page describes some details of my virtual piano based on the physical string and wood model in VHDL language. Have a look the detailed comparison between DSP and FPGA for virtual analog modeling in the case of strings in the former page: virtual analog piano. Energy controlled self oscillating elements are used to represent the basic parts of a piano consisting of various groups of strings and wood which all interact with each other in a kind of a matrix. While the first models were limited in complexity because of the small FPGA platform and also were not much optimized for FPGA usage (they were mostly derived from older DSP equations describing strings with the known differential equations), the new platform works with optimized models which are totally pipelined. The functions are spread over at least 2 Altera Cylcone 2 FPGAs, while 4 are intended to be conncected:

 

music instrument modeling in VHDL - a virtual Piano in a Cyclone II FPGA

 

The currently used platform is an Altera Cyclone II system from www.fpga-dev.de together with my Gleichmann-PCB which can be connected and extended easily since they only need to be synched on system level with an accuracy in the range of the 96kHz-timing and need some wires for MIDI input and Audio output. S/PDIF based signaling is used for both. See the digital audio dsp structure and the MIDI via S/PDIF page for details. For the correct function of the linear working synthesizer (each voice is strictly related to one sound channel) it is necessary to map incoming MIDI data (all on channel 1) to all 1024 channels to make use of the oscillators. As a result the lowest available piano sound is mapped to tone number 0 in the channels 0 ... 7 and the highest number is moved to channels 1016 to 1023, where the oscillators play all the same sound.

 

VHDL piano - MIDI and Oscillator routing - Jürgen Schuhmacher

  

All adjacent oscillators of the same group of 8 channels react on the same frequency, generating either the base frequency, their harmonics or transient sounds which are more or less independent from the frequency like hammer mechanics emulation. Each channel is thus related to exactly one oscillator voice and will produce only the sound of one string including transient behavior and harmonics. As the particular oscillators are independent from ech other, any individual setting can apply including a little trimming of the harmonics against the base frequency as it is common for string instruments. 

The physically grouped strings in the real piano also require some copies of the oscillators which are controlled by the same MIDI tone channel and act slightly different to. This is done by an overlay of 2 additional oscillator voice groups. The frequencies themselves again have individual settings which allows to set the typical frequency spreading which has to be applied at real pianos. The wooden parts are also emulated by oscillators which can stay passive and are not controlled from the outside. Altogether 48 oscillators are used for one channel finally and 16 more are planned for outer wood modeling. For all piano voices a number of 8192 oscillators are be required.

 

A virtual piano model

 

virtual analog piano model - Juergen Schuhmacher

The current audio synthesis platform runs on 48MHz offering 512 time slots to generate the intended 96kHz frequency for the audio signals which required 16 of such platforms. To go around with only 4, the sample frequency was lowered back to 48kHz which has some negative impact on the oscillator precision, since tests show, that for ease of calculation the sample frequency has to be at least 3-5 times higher than the desired final audio sampling frequency, which would be 48x4 = 192kHz or better 256 kHz.

Thanks to parallelization the oscillator overlay for the 3 grouped strings can be done in one FPGA when area saving methods are used which is easier at 48MHz speed in this device. Cutting down the number of MIDI channels to the half be concentrating on the mid of the range, the design is small enough to fit into the 4 devices. Every Cyclone FPGA is responsible for 16 MIDI notes now. The drawback of FPGA spreading is evident: The coupling of the information of adjacent strings cannot be quicker than the parameter exchange of the FPGAs allows this. For this platform, this issue is ignored to be able to use a maximum of parameter update. In a future platform a larger FPGA will holds all the information will solve this problem.

 

virtual keyboard on vga for FPGA based Real Piano

visualization of the piano on a vga screen

 

State of the art

The piano in the extended platform is generating 64 notes (C2 Major upwards) with air and wood modeling as well as basic coupling. The sound already is similar to a real piano, but tuning has to go one to achieve the optimum. The modules can be controlled similar to the PLD ORGAN

 

 Read an earlier article about the Virtual Piano

 

 

© 2007 J.S.