This third example is a MIDI controlled sawtooth synth on Core 1.
Here is the Faust code for the MIDI controlled sawtooth synth. Notice the use of the metadata elements:
freq
– If a MIDI noteOn event is received it’s MIDI keyNumber is mapped to a frequency.bend
– if a MIDI pitchBend message is received it is mapped to a bend value.gain
– if a MIDI noteOn message is received it’s velocity value is mapped to a gain value which ranges from [0 .. 1.0]gate
– if MIDI noteOn/noteOff messages are received they are mapped to a gate value (0/1)[midi:ctrl 1]
– A Faust control (slider, etc) can be mapped to listen to a MIDI continuous controller.import("stdfaust.lib"); normMIDI(mv) = mv/127.0; vol = normMIDI(hslider("Ctrl Value IN (Ctrl 1) [midi:ctrl 1]", 60, 0, 127, 1)) ; f = nentry("freq",200,40,2000,0.01); bend = nentry("bend",1,0,10,0.01) : si.polySmooth(t,0.999,1); g = nentry("gain",1,0,1,0.01); t = button("gate"); freq = f*bend; envelope = t*g*vol : si.smoo; process = os.sawtooth(freq)*envelope <: _,_;
The block diagram button can be used to generate a hierarchical block diagram for an algorithm. This block diagram is hierarchical. Here are a few of the hierarchical levels:
Export/compile to a specific platform
button sam
sam-source-poly-4
and then Export
fast_pow2.h
samFaustDSP.cpp
samFaustDSP.h