Simple Synthesizer Part 1

Download Report

Transcript Simple Synthesizer Part 1

Simple Synthesizer Part 4
Based on Floss Manuals (Pure Data)
“Building a Simple Synthesizer”
By Derek Holzer
Slides by Denny Lin
Copyright © 2011 by Denny Lin
1
Controlling the Synthesizer
• Two ways for synthesizer and user
interface:
– Input from computer keyboard. The ASCII
value of the key pressed is gathered by the
key object, which converts its into frequency
values using the mtof object
– Input from MIDI keyboard. Reads the note
number and velocity from channel 1 using the
notein 1 object.
Copyright © 2011 by Denny Lin
2
Building a 16-Step Sequencer
• Consists of a:
– Constrained counter
– MIDI note storage and
retrieval
– Simple subtractive
synthesizer with ADSR
envelope to play back
notes
Copyright © 2011 by Denny Lin
3
A Four Stage Filtered Additive
Synthesizer
• Consists of the
following stages:
–
–
–
–
Input
Oscillator
Filter
Amplifier
• These four stages are
contained in subpatches
Copyright © 2011 by Denny Lin
4
Input Stage
• The key object gets the
ASCII value of the key
pressed on the computer
keyboard
• ASCII value is sent to left
most outlet
• Center outlet sends the
same ASCII value as the
left most outlet
• Right most outlet sends a
bang used by the ADSR
generator
Copyright © 2011 by Denny Lin
5
Oscillator Stage
• Takes the midi number
and converts it to a
frequency used by the
two phasor~ objects
• Second phasor~ object
has slightly de-tuned
pitch (input is multiplied
by 0.99 –almost one--)
• Output is added, and
scaled down to 0.5 before
delivering to the audio
outlet
Copyright © 2011 by Denny Lin
6
Filter Stage
• Uses a Voltage Controlled
Filter to perform subtractive
synthesis.
• The VCO’s center frequency is
set to 1.5 times (half an
octave) above the incoming
audio signal
• The center frequency is
packed and sent to the line~
object, so it ramps to the
center frequency in 300ms
• The ramp from the line~ object
creates a filter sweeping effect
Copyright © 2011 by Denny Lin
7
Amplifier Stage
• The amplitude of the
audio signal is
modified by the ADSR
envelope
• Controls the overall
volume of the signal
coming in from the
Filter Stage
• Output is sent to the
audio outlet
Copyright © 2011 by Denny Lin
8
The poly object
• The poly object assigns a voice number to
a pitch and velocity pair
• poly object creation arguments:
– First: Number of voices
– Second: Voice stealing mode (what to do
when input exceeds number of voices)
• 0 = no voice stealing; ignore new note event
• 1 = turns off oldest voice stored to make space for
new note event
Copyright © 2011 by Denny Lin
9
Building a polyphonic synthesizer
• Use the notein object to extract pitch and velocity pairs from the
MIDI data stream
• Assign a voice number to pitch and velocity pairs with the poly
object
• Pack the voice number, pitch, and velocity information into a list
• Route the list by voice number to multiple oscillators. Must have one
oscillator for each voice. Can filter each voice individually, or as a
group
• The next example filters voices individually, because each voice has
a filter that sweeps to a unique pitch for that voice. To minimize
control lines, the filter is built into the oscillator
• Polyphonic output amplitude can be modified by an ADSR envelope
and amplified
Copyright © 2011 by Denny Lin
10
A polyphonic MIDI synthesizer
Based on Benoît Rouits’ “A Real Polyphonic MIDI Organ” http://puredata.info/author/ben
Copyright © 2011 by Denny Lin
11