You are on page 1of 3

;;;;; Sampler Channel Maps

;;;;; Sampler maps contain mapping for base pitch as key to


corresponding "filename", base DB amplitude and panning.
; pair: first: midi pitch, second: filename, amp(db), pan (0:left/
sampler1 - 1:right/sampler2)
;;;;; They are defined by channel. They are employed later by
Makenote to prepare Samplor object messages.
$channel2 := map {
(95, ["APIZZd-95-N.A.wav", -1.0, 0.]),
(92, ["APIZZd-92-N.A.wav", -1.0, 0.]),
(89, ["APIZZd-89-N.A.wav", -1.0, 0.]),
(86, ["APIZZd-86-N.A.wav", -1.0, 0.]),
(82, ["APIZZd-82-N.A.wav", -1.0, 0.]),
(79, ["APIZZd-79-N.A.wav", -1.0, 0.]),
(72, ["APIZZd-72-N.A.wav", -1.0, 0.]),
(66, ["APIZZd-66-N.A.wav", -1.0, 0.]),
(62, ["APIZZd-62-N.A.wav", -1.0, 0.]),
(59, ["APIZZd-59-N.A.wav", -1.0, 0.]),
(56, ["APIZZd-56-N.A.wav", -1.0, 0.])
}

$channel12 := map {
(95, ["APIZZd-95-N.A.wav", -5.0, 1.]),
(92, ["APIZZd-92-N.A.wav", -5.0, 1.]),
(89, ["APIZZd-89-N.A.wav", -5.0, 1.]),
(86, ["APIZZd-86-N.A.wav", -5.0, 1.]),
(82, ["APIZZd-82-N.A.wav", -5.0, 1.]),
(79, ["APIZZd-79-N.A.wav", -5.0, 1.]),
(72, ["APIZZd-72-N.A.wav", -5.0, 1.]),
(66, ["APIZZd-66-N.A.wav", -5.0, 1.]),
(62, ["APIZZd-62-N.A.wav", -5.0, 1.]),
(59, ["APIZZd-59-N.A.wav", -5.0, 1.]),
(56, ["APIZZd-56-N.A.wav", -5.0, 1.])
}

;;;;; Samplor Object Map


; A MAP OF MAP... containing MIDI channel configurations
$samplor := map {
(2, $channel2),
(12, $channel12)
}

; Function to use in @find for map that attempts to find the closest
key to input $a
@fun_def @geq($a, $key, $value) { $key >= $a }
/* Translate MIDI message to Samplor messages
Samplor arguments: <bang> <buffer-name> <offset/0> <dur/0>
<trans-inPitchScale> <amp> <pan>
Transposition: in semi-tones in MAP, translates to
2^(x/12).
Amplitude: Combine amp in MAP (db) & velocity. In
Linear.
*/
@MACRO_DEF Makenote($pitch, $velocity, $channel, $dur)
{
group Midi_$channel
{
;; Samplor value for $channel are in the inner
table $samplor($channel)
;; Now we need to calculate the needed
transposition from existing pitches.
;; NOTE: We will store calculations in @LOCAL
variables.
;; There will be certainly parallel
calls to this module and this will avoid values being mixed through
various calls. You need to explicitly tell Antescofo if variables
are local:
@local $ref_pitch, $trans, $amplitude, $panning,
$filename
; find closest pitch in samplor to requested pitch
$ref_pitch := @find($samplor($channel),
@geq($pitch)) ; retourne 67
; calculate the transposition value in pitch-scale
factor for pitch in $p
$trans := @pow(2.,($pitch - $ref_pitch)/12.0)
; amplitude is Db value stored in MAP (convert to
linear) times velocity value (linear)
$amplitude := (($velocity/
127.0)*(@pow(10.,$samplor($channel)($ref_pitch)[1]/20)))
; panning and filename are just inside the map
$panning := ($samplor($channel)($ref_pitch)[2])
$filename := ($samplor($channel)($ref_pitch)[0])

;Annotation DEBUG: Reference pitch for $p is


$ref_pitch

samplor-in adsr 1. 1. 100. 20.


samplor-in 0. $filename 0 0 $trans $amplitude
$panning ;note-on
$dur samplor-in 0. $filename 0 0 $trans 0.
$panning ;note-off
}
}

/* Convenient Macro for setting Harmonizers


Note: In the score, harmonizers are set using semi-tones.
THe GIZMO object however uses pitch scale.
We convert semi-tones to pitch-scale factor using
(@pow(2., $x/12)) expression.
*/
@MACRO_DEF Harms($h1, $h2, $h3, $h4)
{
group harms
{
hr1-p (@pow(2., $h1/12.0))
hr2-p (@pow(2., $h2/12.0))
hr3-p (@pow(2., $h3/12.0))
hr4-p (@pow(2., $h4/12.0))
}
}

; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; Spatialization definitions and initializations
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

;;; Speaker Position table


$speakers := [ ; Table (of table) containing speaker
positions for Simple Spat patch
[1., 0., 0., 0., 0., 0.], ; speaker 1 (index = 0)
[0., 1., 0., 0., 0., 0.], ; speaker 2
[0., 0., 1., 0., 0., 0.],
[0., 0., 0., 1., 0., 0.],
[0., 0., 0., 0., 1., 0.],
[0., 0., 0., 0., 0., 1.] ]

You might also like