Generators
Making a sound with QMusic is relatively easy. There are some primitive generator units provided in the Generators group of the Audio Units panel. The following chain for iinstance will produce a continuous tone of 440Hz:
There are other waveforms that can be produced via the Generator audio unit. It allows choosing among sine, sawtooth, square, and triangle waveforms.
Note that the generator component has a Limit bandpass property that will effectively reduce the aliasing effect of the complex harmonics waveforms.
MIDI input
We can use the MIDI in unit from the MIDI section to feed us the tone frequency. The MIDI unit responds to the MIDI events, like keys ons and offs, and pitch bend, and outputs the corresponding frequency.
Envelope
If you run the circuit you will notice that the tone does not go off when the key is released, it just keeps playing. In order to make the tone generator react properly on the keys on and off events we have to introduce the envelope unit.
Provided envelope unit outputs classic ADSR (attack-decay-sustain-release) curve and reacts on MIDI key on and off events. The attack, decay, and release times are controlled via the envelope's properties panel, as well as the sustain level.
Additionaly the envelope unit allows enabling and disabling the signal chain processing depending on whether a note is played or not. Disabling the signal chain when it does not produce any sound will effectively reduce the CPU load. It is also important to use these flags when constructing a voice of a polyphonic instrument.
Effects
Now we can inprove the synthesized sound quality by adding filters and effects. QMusic provides some simple effects, like reverberation, that we can use.
<< Back to the front page