<CsoundSynthesizer>

/*
 * mini_lavie.csd (2nd version)
 * 12-April-2008
 * Bruce H. McCosar
 *
 * This is part 2 of my first Csound project. It's based on
 * "La vie sous la mer (or, the Mermaid Wife)", the second
 * song on my third Jamendo album.
 *
 * With the 2nd version, I've tried to develop a bowed sound
 * for the sparse chords (mostly guide tones, until later in
 * the song where they suspend).
 *
 * The notes are a snippet from a longer MIDI file, transformed into
 * a score file by midi2sco:
 *
 *     http://jwgibbs.cchem.berkeley.edu/pete/midi2sco/
 * 
 * This is part of a longer piece, so I'm calling the series
 * 'mini-lavie' until I get all the instruments designed.
 * I still need the other manuals (II and III).  I'll post
 * the intermediate files as I learn more.
 * 
 * If you'd like to hear the original song (live instruments,
 * not Csound), you can find my albums at:
 *
 *     http://www.jamendo.com/en/artist/bruce.h.mccosar
 */

<CsOptions>
-d -W -o test.wav 
</CsOptions>
 
<CsInstruments>

; ------------------------------------------------------------ HEADER
sr	=	44100
kr	=	4410
ksmps	=	10
nchnls	=	2

; ------------------------------------------------------- INSTRUMENTS


garvL	init	0
garvR	init	0


;	opcodes
;	|     |
	instr	100 ; ==================> WaveTerrain Pedal Bass
; . . . . . . . . . . . . . . . . . . . . . . . . . . . controls
icps	=	cpsmidinn(p4)/2 ; generate as 1 octave lower
ivel	=	p5
irsend	=	0.04 		; reverb send
; . . . . . . . . . . . . . . . . . . . . control interpretation
iamp	=	ivel*280
; 		The higher the velocity,
;		the narrower the initial x radius
iradx	=	1 - 0.5*p5/88  ; starting rx
kradx	line	iradx, p3, 0.5 ; sweeps to a circle
; 		The higher the velocity, the further
;		displaced along the line y = (5/4)x
idy	=	0.5 + 1.5*p5/88/4
idx	=	0.5 + 1.5*p5/88/5
kctrx	line	idx, 1.54, 0.5 ; sweeps back to center
kctry	line	idy, 1.54, 0.5 ; sweeps back to center
; . . . . . . . . . . . . . . . . . . . . . . . . . . . . signal
;		(variables renamed to more standard forms)
;		Stereo tracks take slightly different paths
;		through the wave terrain
;	wterrain kamp, kcps, kctrx, kctry, kradx, krady, kfnx, kfny
aL	wterrain iamp, icps, kctrx, kctry+0.04, kradx, 0.5, 1, 2
aR	wterrain iamp, icps, kctrx+0.04, kctry, kradx, 0.5, 1, 2
;	dcblock	ain [, igain=0.99]
aL	dcblock	aL
aR	dcblock aR
; . . . . . . . . . . . . . . . . . . . . . . . . . .  envelopes
;	adsr	iatt, idec, islev, irel
aenv	adsr	0.10*p3, 0.05*p3, 0.90, 0.05*p3
; . . . . . . . . . . . . . . . . . . . . . . . . . . . . output
;	dcblock	ain [, igain=0.99]
aL	dcblock	aL
aR	dcblock aR
	outs	aL*aenv, aR*aenv
; . . . . . . . . . . . . . . . . . . . . . . . . . . .  fx send
garvL	=	garvL + aL*irsend
garvR	=	garvR + aL*irsend
	endin


;	opcodes
;	|     |
	instr	101 ; ==================> Chorused Waveguide Bow
; . . . . . . . . . . . . . . . . . . . . . . . . . . . controls
icps	=	cpsmidinn(p4)
ivel	=	p5
irsend	=	0.15 		; reverb send
; . . . . . . . . . . . . . . . . . . . . control interpretation
iamp	=	ivel*80
; 		Pressure varies slightly with bow stroke.
ipmax	=	4.5*p5/100
;	linen	kamp, irise, idur, idec
kpres	linen	ipmax, 0.1*p3, p3, 0.2*p3
;		Vibrato becomes stronger for longer notes.
ivmax	=	0.012
;	linseg	ia, idur, ib ...
kvamp	linseg	0, 0.5, 0, 2, ivmax, 3, ivmax
; . . . . . . . . . . . . . . . . . . . . . . . . . . . . signal
;	wgbow	kamp, kcps, kpres, krat, kvibf, kvamp, ifn
a0	wgbow	iamp, icps, kpres, 0.127, 5, kvamp, 1
a1	wgbow	iamp, icps*1.01, kpres, 0.128, 4, kvamp, 1
a2	wgbow	iamp, icps*0.99, kpres, 0.126, 6, kvamp, 1
aL	=	a0 + a1*0.6 + a2*0.2
aR	=	a0 + a2*0.6 + a1*0.2
; . . . . . . . . . . . . . . . . . . . . . . . . . . . . filter
;	tone	asig, khp
aL	tone	aL, 1200
aR	tone	aR, 1200
; . . . . . . . . . . . . . . . . . . . . . . . . . . . . output
	outs	aL, aR
; . . . . . . . . . . . . . . . . . . . . . . . . . . .  fx send
garvL	=	garvL + aL*irsend
garvR	=	garvR + aL*irsend
	endin


	instr 200 ; ======================> Global Stereo Reverb
; . . . . . . . . . . . . . . . . . . . . . . . . . . . controls
irtime	=	p4
; . . . . . . . . . . . . . . . . . . . . . . . . . . . . signal
;	nreverb asig, ktime, khdif
aL	nreverb garvL, irtime, 1
aR	nreverb garvR, irtime, 1
; . . . . . . . . . . . . . . . . . . . . . . . . . . . . output
	outs	aL, aR
; . . . . . . . . . . . . . . . . . . . . . . . . . . . .  reset
garvL	=	0
garvR	=	0
	endin

</CsInstruments>

<CsScore>

; ---------------------------------------------------------- F-TABLES

; f1 = standard sine wave (fundamental)
; #	time    size	gen	str series..
f 1	0	32768	10	1

; f2 =  experimental wave (2D modulator)
; #	time    size	gen	nh	lh	r
f 2	0	32768	11	4	1	0.3

; ------------------------------------------------------------- SCORE

; = Reverb Channel
; p1	p2	p3	p4
; inst	time	dur	rtime
i 200	0	15	1.54

; ====================================================> Bass (P)
; p1	p2	p3	p4	p5
; inst	time	dur	note	vel
i 100	0.679	0.536	46	51
i 100	1.214	0.357	53	60
i 100	1.571	0.179	46	59
i 100	1.750	0.536	53	69
i 100	2.286	1.071	46	51
i 100	3.357	0.536	44	61
i 100	3.893	0.357	51	60
i 100	4.250	0.179	44	53
i 100	4.429	0.536	51	63
i 100	4.964	1.071	44	59
i 100	6.036	0.536	42	53
i 100	6.571	0.357	49	57
i 100	6.929	0.179	42	47
i 100	7.107	0.536	49	72
i 100	7.643	1.071	42	53
i 100	8.714	0.536	44	53
i 100	9.250	0.357	51	47
i 100	9.607	0.179	44	32
i 100	9.786	0.536	51	73
i 100	10.321	1.071	44	52

; ============================================> Light Chords (I)
; p1	p2	p3	p4	p5
; inst	time	dur	note	vel
i 101	0.500	2.321	56	66
i 101	0.500	2.321	61	60
i 101	3.179	2.679	54	60
i 101	3.179	2.679	60	63
i 101	5.857	2.679	53	86
i 101	5.857	2.679	58	94
i 101	8.536	2.679	54	73
i 101	8.536	2.679	60	60
i 101	11.214	2.342	56	62
i 101	11.214	2.343	61	64

</CsScore>
 
</CsoundSynthesizer>
