| At 6:45 PM -0300 12/13/98, luis jure wrote:
>I don't have Erik's instrument, maybe you could post it
>again to the list?
By (almost) popular request, two versions of Pulse-Width Modulation.
sr=44100
kr=44100
ksmps=1
nchnls=1
instr 1
a1 linseg 0.1,0.05,1000,p3-.1,10000,0.05,0.1
k3 linseg 0,0.05,0,p3-.1,1,0.05,1
k1 phasor p5 ; p5 is note frequency in cps
k2 = (k1 < k3 ? (k1 /(2*k3)): ((1-2*k3+k1)/(2*(1-k3))))
; k3 is the symmetry index, varies from 0 to 1. 0.5 gives symmetric wave
k4 tablei k2, 1,1 ; table 1 should contain a band-limited square or
;triangle wave, the second 1 indicate use normalized (0-1) index into table
a2 = k4 ;a2 is your audio out. Multiply by amplitude before sending
out a2*a1
endin
;***sco*** (WATCH THE EMAIL WRAPPING) *******
; triangle
;f1 0 4096 9 1 1000 90 3 111.111111 90 5 40 90 7 20.4081633 90 9 12.345679
90 11 8.26446281 90 13 5.91715976 90 15 4.44444444 90 17 3.46020761 90 19
2.7700831 90 21 2.2675737 90
; triangle
f1 0 4096 10 1000 0 -111.111111 0 40 0 -20.4081633 0 12.345679 0
-8.26446281 0 5.91715976 0 -4.44444444 0 3.46020761 0 -2.7700831 0 2.2675737
; square
;f1 0 4096 9 1 1000 0 3 333.333333 0 5 200 0 7 142.857143 0 9 111.111111 0
11 90.9090909 0 13 76.9230769 0 15 66.6666667 0 17 58.8235294 0 19
52.6315789 0 21 47.6190476 0
i1 0 5 0 440
i1 5 5 0 220
i1 10 5 0 110
f0 16
e
;
;
;VERSION 2 (For those who don't like kr=sr)
sr=44100
kr=441
ksmps=100
nchnls=1
instr 1
a1 linseg 0.1,0.05,1000,p3-.1,10000,0.05,0.1
a3 linseg 0.55,0.05,0.55,p3-0.1,0.999,0.05,0.999 ;modulation index
a9 phasor p5 ; p5 is note frequency in cps
a2 = log(exp(25*a9/2/a3)+exp(25*(1-2*a3+a9)/(2-2*a3)))/25
a4 tablei a2, 1,1 ; table 1 should contain a band-limited square or
;triangle wave, the second 1 indicate use normalized (0-1) index into table
out a4*a1
endin
;***sco*** (WATCH THE EMAIL WRAPPING) *******
; triangle
f1 0 4096 9 1 1000 90 3 111.111111 90 5 40 90 7 20.4081633 90 9 12.345679
90 11 8.26446281 90 13 5.91715976 90 15 4.44444444 90 17 3.46020761 90 19
2.7700831 90 21 2.2675737 90
;f1 0 4096 9 1 1000 0 3 333.333333 0 5 200 0 7 142.857143 0 9 111.111111 0
11 90.9090909 0 13 76.9230769 0 15 66.6666667 0 17 58.8235294 0 19
52.6315789 0 21 47.6190476 0
i1 0 5 0 440
i1 5 5 0 220
i1 10 5 0 110
f0 16
e
;
;
-------------------------------------------------------------------------------
Erik Spjut (spyoot, rhymes with cute) - Associate Professor of Engineering
and Associate Director for Engineering Computing, Center for Design Education
Harvey Mudd College, Claremont, CA 91711-5990 USA
Erik_Spjut@hmc.edu Ph & Voice mail (909) 607-3890 Fax (909) 621-8967
Received: from shaun.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa24709;
14 Dec 98 19:59 GMT
Received: from [144.173.6.14] (helo=exeter.ac.uk)
by shaun.maths.bath.ac.uk with esmtp (Exim 1.92 #2)
for jpff@maths.bath.ac.uk
id 0zpe9T-0005bW-00; Mon, 14 Dec 1998 19:59:31 +0000
Received: from noether [144.173.8.10] by hermes via SMTP (TAA12779); Mon, 14 Dec 1998 19:55:53 GMT
Received: from exeter.ac.uk by maths.ex.ac.uk; Mon, 14 Dec 1998 19:55:40 GMT
Received: from kgallagh@tempest.ocis.temple.edu [155.247.166.120] by hermes via ESMTP (TAA21026); Mon, 14 Dec 1998 19:55:38 GMT
Received: from localhost (kgallagh@localhost)
by tempest.ocis.temple.edu (8.8.8/8.8.8) with SMTP id OAA25779
for ; Mon, 14 Dec 1998 14:55:37 -0500 (EST)
Date: Mon, 14 Dec 1998 14:55:36 -0500 (EST)
From: Kevin Gallagher
X-Sender: kgallagh@tempest.ocis.temple.edu
To: Csound Discussion List
Subject: xyin
Message-ID:
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk
How do I assign an input window for use with the xyin opcode?
Kevin Gallager, kgallagh@astro.temple.edu
Web - http://astro.temple.edu/~kgallagh
|