Csound Csound-dev Csound-tekno Search About

Re: drum kit

Date1998-12-09 13:12
FromBob Douglas
SubjectRe: drum kit
I don't know if it's any use for the linseg error, but I noticed that f2 is
specified with size 2**n + 1 (ie. 2049).  Firstly, f-statements for oscili (ks
in the HHat) should have a wrapped guard point, ie. size should be 2**n
exactly. Secondly, the durations in f2 add up to 2048, not 2049.

This means that f2 will be continued on with the same contour to fill the
guard point. In the case of gen5, I think this means placing a value in
location 2049 of  0.0001/(0.667/0.0001) exp (1/1792) which comes out to
0.0000995, which is getting pretty close (?) to zero which gen5 doesn't like.
Yeah, I know it's drawing a bit of a long bow.....

Bob Douglas
  

> ;f1 0 2048 10 1                                                                 ;sine wave
> ;f2 0 2049 5  1 256 .667 1792 .0001                             ;exp env
 
> HHat:
> 
> idur    =                       0.3335
> ifrq    =                       15000
> 
> k4      linseg          1, idur-.05, 1, .05, 0, .01, 0
> 
> ks      oscili          iamp, idur, 2
> ar      randi           ks, ifrq
> a1      atone           ar, ks+ifrq
> a1      balance         a1, ar
> a1      oscili          a1, ifrq, 1
> 
> asig    =                       k4*a1
>                 goto            end
> 
> end:
>                 out                     asig
>                 endin


Received: from wallace.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa08986;
          9 Dec 98 14:58 GMT
Received: from [144.173.6.14] (helo=exeter.ac.uk)
	by wallace.maths.bath.ac.uk with esmtp (Exim 1.92 #2)
	for jpff@maths.bath.ac.uk
	id 0znl4C-0003XM-00; Wed, 9 Dec 1998 14:58:16 +0000
Received: from noether [144.173.8.10] by hermes via SMTP (OAA25113); Wed, 9 Dec 1998 14:52:44 GMT
Received: from exeter.ac.uk by maths.ex.ac.uk; Wed, 9 Dec 1998 14:52:29 GMT
Received: from JZGC0U96dQMzquBXcU1JidwrvRdRf3S4@sungod.ccs.yorku.ca [130.63.236.104] by hermes via ESMTP (OAA24286); Wed, 9 Dec 1998 14:52:28 GMT
Received: from sunburn.ccs.yorku.ca (J5Csx7+wot/1agGzZlqFUn8nq4W6tu9i@sunburn.ccs.yorku.ca [130.63.236.110]) by sungod.ccs.yorku.ca (8.8.7/8.6.11) with ESMTP id JAA10327 for ; Wed, 9 Dec 1998 09:52:11 -0500 (EST)
Received: from localhost (wechard@localhost) by sunburn.ccs.yorku.ca (8.8.7/8.7.6) with ESMTP id JAA21267 for ; Wed, 9 Dec 1998 09:52:10 -0500 (EST)
X-Authentication-Warning: sunburn.ccs.yorku.ca: wechard owned process doing -bs
Date: Wed, 9 Dec 1998 09:52:10 -0500 (EST)
From: William Echard 
X-Sender: wechard@sunburn.ccs.yorku.ca
To: csound 
Subject: tutorials on realtime MIDI in?
Message-ID: 
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

I'm wondering if someone could point me to some tutorials, or at least
sample orchestras and scores, for doing realtime control from a MIDI
keyboard?

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!        William Echard          !!
!!    Music, York University      !!
!!            Toronto             !!
!!       wechard@yorku.ca         !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



Received: from shaun.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa09634;
          9 Dec 98 18:18 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 0znoC4-0002Y3-00; Wed, 9 Dec 1998 18:18:36 +0000
Received: from noether [144.173.8.10] by hermes via SMTP (SAA25023); Wed, 9 Dec 1998 18:02:23 GMT
Received: from exeter.ac.uk by maths.ex.ac.uk; Wed, 9 Dec 1998 18:02:09 GMT
Received: from agora.stm.it [195.62.32.1] by hermes via ESMTP (SAA24063); Wed, 9 Dec 1998 18:01:57 GMT
Received: from agora.stm.it (ppp01-17.dial-access.stm.it [195.62.37.17]) by agora.stm.it (8.8.8/8.8.5) with ESMTP id TAA29921; Wed, 9 Dec 1998 19:01:19 +0100 (ITA)
Message-ID: <366EBC50.D7B382D6@agora.stm.it>
Date: Wed, 09 Dec 1998 19:07:12 +0100
From: Gabriel Maldonado 
X-Mailer: Mozilla 4.06 [en] (Win95; I)
MIME-Version: 1.0
To: William Echard 
CC: csound 
Subject: Re: tutorials on realtime MIDI in?
References: 
Content-Type: multipart/mixed; boundary="------------99CA7D8C92B56C9911A68588"
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

This is a multi-part message in MIME format.
--------------99CA7D8C92B56C9911A68588
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

William,
here is a very simple example of using midi-in port. It is icluded in the zipped archive
of my realtime version of Csound, which is available at my web site.


William Echard wrote:
> 
> I'm wondering if someone could point me to some tutorials, or at least
> sample orchestras and scores, for doing realtime control from a MIDI
> keyboard?
> 
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> !!        William Echard          !!
> !!    Music, York University      !!
> !!            Toronto             !!
> !!       wechard@yorku.ca         !!
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

-- 
Gabriel Maldonado

http://www.agora.stm.it/G.Maldonado/home2.htm
--------------99CA7D8C92B56C9911A68588
Content-Type: application/x-unknown-content-type-orcfile; name="test.ORC"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="test.ORC"

OyoqIDw8PCBvcmMgZm9yIERpcmVjdENzb3VuZCB0ZXN0ID4+Pg0KOyoqIFRyeSB0byBydW4g
RGlyZWN0Q3NvdW5kIHdpdGggdGhlIGZvbGxvd2luZyBmbGFnczoNCjsqKiANCjsqKiBjc291
bmQuZXhlIC0rWCAtK0sgLWIxMDAgdGVzdC5vcmMgdGVzdC5zY28gDQo7KiogDQo7KiogVGhl
biBhbnN3ZXIgdG8gdGhlIGNvbnNvbGUgcmVxdWVzdHMgYWJvdXQgdGhlIG1pZGkgcG9ydCBu
dW1iZXIgDQo7KiogYW5kIHRoZSBEaXJlY3RTb3VuZCBkZXZpY2UgbnVtYmVyLiBUcnkgdG8g
cGxheSB0aGUgbWlkaSBrZXlib2FyZC4gDQo7KiogSWYgYWxsIGlzIE9LIChpLmUuIGlmIHlv
dSBjYW4gaGVhciB0aGUgbm90ZXMgeW91IHBsYXkpIHRoZW4NCjsqKiBjbG9zZSBjc291bmQg
YW5kIHJlcnVuIGl0IHN1cHByZXNzaW5nIHRoZSBjb25zb2xlIG1lc3NhZ2UgZGlzcGxheToN
CjsqKiANCjsqKiBjc291bmQuZXhlIC0rTyAtbTAgLStYIC0rSyAtYjEwMCB0ZXN0Lm9yYyB0
ZXN0LnNjbyANCjsqKiANCjsqKiBOb3RpY2UgdGhhdCB0aGUgbGF0ZW5jeSBkZWxheSBpcyBo
dWdlbHkgcmVkdWNlZCByZXNwZWN0IHByZXZpb3VzIHZlcnNpb25zDQo7Kiogb2YgUlRzb3Vu
ZC4gSWYgeW91IGhhdmUgYSBQRU5USVVNIElJIHByb2Nlc3NvciB5b3UgY2FuIHJlZHVjZSB0
aGUgYnVmZmVyDQo7KiogYnkgdHlwaW5nIGEgc21hbGxlciBudW1iZXIgcmVmZXJyaW5nIHRv
IC1iIGZsYWcNCg0KDQoJc3IgPSA0NDEwMCAgDQoJa3IgPSA0NDENCglrc21wcyA9IDEwMA0K
CW5jaG5scyA9IDEJDQoNCglpbnN0cgkxDQppbnVtCW5vdG51bQ0KaWNwcwljcHNtaWRpDQpp
YW1wCWFtcG1pZGkJNDAwMA0Ka21wCWxpbmVucglpYW1wLCAwLCAuOCwgLjAxIA0KYTEJb3Nj
aWxpCWttcCwgaWNwcywgMQ0KCW91dAlhMSAgICAgIA0KCWVuZGluDQoNCg0KDQoNCg0KDQoN
Cg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg==
--------------99CA7D8C92B56C9911A68588
Content-Type: application/x-unknown-content-type-scofile; name="test.SCO"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="test.SCO"

ZjEgMCAxMjggMTAgMSAwIDEgMCAxIDAgMSAgOyBhdWRpbyBmdW5jdGlvbg0KDQo7ZjEgMCAx
MDQ4NTc2IDEwIDEgMCAxIDAgMSAwIDEgIDsgYXVkaW8gZnVuY3Rpb24NCjtmMiAwIDEwNDg1
NzYgMTAgMQ0KDQpmMCA2MDAJOyBhbGxvd3MgcmVhbHRpbWUgbWlkaSBwbGF5aW5nIGZvciA2
MDAgc2Vjb25kcw0KZQ0KDQoNCg0KDQoNCg0KDQoNCg0K
--------------99CA7D8C92B56C9911A68588--



Received: from shaun.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa10322;
          9 Dec 98 22:34 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 0znsC0-0002kj-00; Wed, 9 Dec 1998 22:34:48 +0000
Received: from noether [144.173.8.10] by hermes via SMTP (WAA09081); Wed, 9 Dec 1998 22:33:00 GMT
Received: from exeter.ac.uk by maths.ex.ac.uk; Wed, 9 Dec 1998 22:32:48 GMT
Received: from root@ruacad.runet.edu [137.45.128.4] by hermes via ESMTP (WAA13992); Wed, 9 Dec 1998 22:32:46 GMT
Received: from midiman (ruppp194.runet.edu [137.45.10.194])
	by ruacad.runet.edu (8.9.1/8.9.1) with SMTP id RAA06197
	for ; Wed, 9 Dec 1998 17:32:42 -0500 (EST)
Message-Id: <4.1.19981209172209.009969c0@mail.runet.edu>
X-Sender: cguirrer@mail.runet.edu
X-Mailer: QUALCOMM Windows Eudora Pro Version 4.1 
Date: Wed, 09 Dec 1998 17:31:15 -0500
To: csound@maths.ex.ac.uk
From: Christian Guirreri 
Subject: WinCSound performance
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

I first wanted to mention I've really been enjoying the feedback from this
list!

I'm wondering if there is any information about WinCSound performance
compared to other OS's, particularly the Power Mac version.  I run CSound
on a Power Mac at school with 32MB RAM and it appears to be much faster
than my Win98-based, PII-266, 128MB RAM, all SCSI system at home.  We have
version 3.92 at school and I'm running 3.93 at home.  The orc+sco I'm using
has 8 instruments, one of which uses a 500K sample loaded in an ftable, and
the work is about 5:00 long.  Compiling at home is nearly twice longer than
it is at school.  I'm wondering if others have seen similar results (kind
of difficult considering we all have different computers), and if there are
any performance tips and tweaks.

Thanks again,
Christian Guirreri

cguirrer@runet.edu
ICQ 9318646


Received: from wallace.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa10500;
          9 Dec 98 23:18 GMT
Received: from [144.173.6.14] (helo=exeter.ac.uk)
	by wallace.maths.bath.ac.uk with esmtp (Exim 1.92 #2)
	for jpff@maths.bath.ac.uk
	id 0znssX-00045m-00; Wed, 9 Dec 1998 23:18:45 +0000
Received: from noether [144.173.8.10] by hermes via SMTP (XAA17286); Wed, 9 Dec 1998 23:16:00 GMT
Received: from exeter.ac.uk by maths.ex.ac.uk; Wed, 9 Dec 1998 23:15:47 GMT
Received: from dns2.seanet.com [199.181.164.2] by hermes via ESMTP (XAA15552); Wed, 9 Dec 1998 23:15:46 GMT
Received: from seanet.com (costello.seanet.com [204.182.65.218]) by mx.seanet.com (8.8.8/Seanet-8.7.3) with ESMTP id PAA26310; Wed, 9 Dec 1998 15:15:37 -0800 (PST)
Message-ID: <366F03A2.60810F55@seanet.com>
Date: Wed, 09 Dec 1998 15:11:30 -0800
From: Sean Costello 
X-Mailer: Mozilla 4.04 [en] (Win95; U)
MIME-Version: 1.0
To: Christian Guirreri 
CC: csound@maths.ex.ac.uk
Subject: Re: WinCSound performance
References: <4.1.19981209172209.009969c0@mail.runet.edu>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

Christian Guirreri wrote:

> I'm wondering if there is any information about WinCSound performance
> compared to other OS's, particularly the Power Mac version.  I run CSound
> on a Power Mac at school with 32MB RAM and it appears to be much faster
> than my Win98-based, PII-266, 128MB RAM, all SCSI system at home.  We have
> version 3.92 at school and I'm running 3.93 at home.  The orc+sco I'm using
> has 8 instruments, one of which uses a 500K sample loaded in an ftable, and
> the work is about 5:00 long.  Compiling at home is nearly twice longer than
> it is at school.  I'm wondering if others have seen similar results (kind
> of difficult considering we all have different computers), and if there are
> any performance tips and tweaks.

I don't have any specific performance figures, but I can back up your
observations about Csound running in Win 98.  I have a dual boot Win
98/Linux machine, with a Pentium II running at 300 MHz.  Performance of
Csound is at least 3 times faster (from my observations) in Linux than
in Win 98.  From my knowledge of operating system internals, I believe
this speed difference is due to the fact that Windows 98 is spawned from
the loins of the devil.

Sean Costello


Received: from wallace.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa10963;
          10 Dec 98 2:40 GMT
Received: from [144.173.6.14] (helo=exeter.ac.uk)
	by wallace.maths.bath.ac.uk with esmtp (Exim 1.92 #2)
	for jpff@maths.bath.ac.uk
	id 0znw1O-0004IB-00; Thu, 10 Dec 1998 02:40:06 +0000
Received: from noether [144.173.8.10] by hermes via SMTP (CAA10259); Thu, 10 Dec 1998 02:37:19 GMT
Received: from exeter.ac.uk by maths.ex.ac.uk; Thu, 10 Dec 1998 02:37:06 GMT
Received: from dewdrop2.mindspring.com [207.69.200.82] by hermes via ESMTP (CAA03917); Thu, 10 Dec 1998 02:37:05 GMT
Received: from axe (user-38ld06o.dialup.mindspring.com [209.86.128.216])
	by dewdrop2.mindspring.com (8.8.5/8.8.5) with SMTP id VAA25588;
	Wed, 9 Dec 1998 21:37:03 -0500 (EST)
Message-ID: <002901be23e7$acd4d740$d88056d1@axe>
From: Michael Gogins 
To: csound@maths.ex.ac.uk, Christian Guirreri 
MMDF-Warning:  Parse error in original version of preceding line at UK.AC.Bath.maths.omphalos
Subject: Re: WinCSound performance
Date: Wed, 9 Dec 1998 21:49:12 -0500
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

I don't have performance times, but certainly, on my Pentium 166 with 48
megabytes RAM running Windows 95, Winsound was considerably slower than
consound or csound through version 3.46. Since then I have not extensively
used Winsound.

I would have guessed that consound.exe (native Windows console application)
or csound.exe (32-bit DOS extender application) would be faster than the
PowerMac, however, for comparably priced current processors. There are in
fact benchmarks (I just looked them up) that confirm my guess at
http://members.tripod.com/~slinkP/pw_linux/csbench.html.

-----Original Message-----
From: Christian Guirreri 
To: csound@maths.ex.ac.uk 
Date: Wednesday, December 09, 1998 5:38 PM
Subject: WinCSound performance


>I first wanted to mention I've really been enjoying the feedback from this
>list!
>
>I'm wondering if there is any information about WinCSound performance
>compared to other OS's, particularly the Power Mac version.  I run CSound
>on a Power Mac at school with 32MB RAM and it appears to be much faster
>than my Win98-based, PII-266, 128MB RAM, all SCSI system at home.  We have
>version 3.92 at school and I'm running 3.93 at home.  The orc+sco I'm using
>has 8 instruments, one of which uses a 500K sample loaded in an ftable, and
>the work is about 5:00 long.  Compiling at home is nearly twice longer than
>it is at school.  I'm wondering if others have seen similar results (kind
>of difficult considering we all have different computers), and if there are
>any performance tips and tweaks.
>
>Thanks again,
>Christian Guirreri
>
>cguirrer@runet.edu
>ICQ 9318646



Received: from wallace.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa10975;
          10 Dec 98 2:42 GMT
Received: from [144.173.6.14] (helo=exeter.ac.uk)
	by wallace.maths.bath.ac.uk with esmtp (Exim 1.92 #2)
	for jpff@maths.bath.ac.uk
	id 0znw3E-0004IJ-00; Thu, 10 Dec 1998 02:42:00 +0000
Received: from noether [144.173.8.10] by hermes via SMTP (CAA15897); Thu, 10 Dec 1998 02:40:32 GMT
Received: from exeter.ac.uk by maths.ex.ac.uk; Thu, 10 Dec 1998 02:40:19 GMT
Received: from dewdrop2.mindspring.com [207.69.200.82] by hermes via ESMTP (CAA14020); Thu, 10 Dec 1998 02:40:18 GMT
Received: from axe (user-38ld06o.dialup.mindspring.com [209.86.128.216])
	by dewdrop2.mindspring.com (8.8.5/8.8.5) with SMTP id VAA25650;
	Wed, 9 Dec 1998 21:40:13 -0500 (EST)
Message-ID: <002e01be23e8$1df91300$d88056d1@axe>
From: Michael Gogins 
To: Sean Costello , 
    Christian Guirreri 
Cc: csound@maths.ex.ac.uk
MMDF-Warning:  Parse error in original version of preceding line at UK.AC.Bath.maths.omphalos
Subject: Re: WinCSound performance
Date: Wed, 9 Dec 1998 21:52:23 -0500
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

Check out http://members.tripod.com/~slinkP/pw_linux/csbench.html. According
to this, times between Windows and Linux on comparable processors are
comparable. Measurements are better than anecdotes.

-----Original Message-----
From: Sean Costello 
To: Christian Guirreri 
Cc: csound@maths.ex.ac.uk 
Date: Wednesday, December 09, 1998 6:22 PM
Subject: Re: WinCSound performance


>Christian Guirreri wrote:
>
>> I'm wondering if there is any information about WinCSound performance
>> compared to other OS's, particularly the Power Mac version.  I run CSound
>> on a Power Mac at school with 32MB RAM and it appears to be much faster
>> than my Win98-based, PII-266, 128MB RAM, all SCSI system at home.  We
have
>> version 3.92 at school and I'm running 3.93 at home.  The orc+sco I'm
using
>> has 8 instruments, one of which uses a 500K sample loaded in an ftable,
and
>> the work is about 5:00 long.  Compiling at home is nearly twice longer
than
>> it is at school.  I'm wondering if others have seen similar results (kind
>> of difficult considering we all have different computers), and if there
are
>> any performance tips and tweaks.
>
>I don't have any specific performance figures, but I can back up your
>observations about Csound running in Win 98.  I have a dual boot Win
>98/Linux machine, with a Pentium II running at 300 MHz.  Performance of
>Csound is at least 3 times faster (from my observations) in Linux than
>in Win 98.  From my knowledge of operating system internals, I believe
>this speed difference is due to the fact that Windows 98 is spawned from
>the loins of the devil.
>
>Sean Costello



Received: from wallace.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa11325;
          10 Dec 98 6:17 GMT
Received: from [144.173.6.14] (helo=exeter.ac.uk)
	by wallace.maths.bath.ac.uk with esmtp (Exim 1.92 #2)
	for jpff@maths.bath.ac.uk
	id 0znzPS-0004VS-00; Thu, 10 Dec 1998 06:17:10 +0000
Received: from noether [144.173.8.10] by hermes via SMTP (GAA21269); Thu, 10 Dec 1998 06:15:17 GMT
Received: from exeter.ac.uk by maths.ex.ac.uk; Thu, 10 Dec 1998 06:15:03 GMT
Received: from smtp1.erols.com [207.172.3.234] by hermes via ESMTP (GAA22367); Thu, 10 Dec 1998 06:15:02 GMT
Received: from oemcomputer (207-172-91-164.s37.as3.nyb.erols.com [207.172.91.164])
	by smtp1.erols.com (8.8.8/8.8.5) with SMTP id BAA14024
	for ; Thu, 10 Dec 1998 01:14:56 -0500 (EST)
Message-ID: <366F2C5A.655C@erols.com>
Date: Wed, 09 Dec 1998 21:05:14 -0500
From: Paul Winkler 
Reply-To: zarmzarm@erols.com
X-Mailer: Mozilla 3.03 (Win95; I)
MIME-Version: 1.0
To: Csound mailing list 
Subject: Pulse width modulation!
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

This should please the analog fans...

Some time ago there was a discussion of simulating pulse width
modulation. I don't remember anyone posting a solution. Well, the other
day, inspiration struck, and I came up with the idea to do it by
indexing a square wave in a funny way... This orc is rather simple with
some rough edges, but it gives the idea and doesn't sound too bad. Put
an amplitude envelope, a filter, and a chorus on there, and we're off to
Roland heaven...

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;copyright 1998 Paul M. Winkler, zarmzarm@erols.com
;****++++
;**** Last modified: Wed Dec  9 20:32:30 1998
;****----
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


	sr	=	44100
	kr	=	22050
	ksmps	=	2
	nchnls	=	1

            instr 1
            ;  simulated pulse width modulation

; This works! But p5 should be handled better.
ipitch = cpspch (p4)
aindex   phasor    ipitch

; Make the WIDTH (p5) 'feel' a little nicer -- an exponential curve from 
; ftlen/2 to ftlen, controlled by a linear percentage (0 to 100).
; This is not great: p5 less than about 10 is TOO small!
ilength = ftlen(1) 
inum = p5 * p5 * .0001 ; normalize it to 0 - 1
; pow would be a better solution, but it's broken in my csound version?

irange = ( ilength + ( inum * ilength )) * .5
aindex = aindex * irange
print irange
; display   aindex, .1                           
aout   table          aindex, 1;  use f1
out aout 
            endin 

            instr 2
; Same thing, only pulse width is controlled by an envelope.
ipitch = cpspch (p4)
aindex   phasor    ipitch
ilength = ftlen(1) 
krange   expseg  ilength * .5, p3 * .5, ilength, p3 * .5, ilength * .5
aindex = aindex * krange
aout   table          aindex, 1;  table 1
out aout 
            endin

;;;;;; sample score!

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;copyright 1998 Paul M. Winkler, zarmzarm@erols.com
;****++++
;**** Last modified: Wed Dec  9 20:34:05 1998
;****----
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

f1 0  512  -7   30000 256 30000 0 -30000 256 -30000 ;square wave,
!normalized

;  at dur pch    width     

t 0 180
i1 0  1   6.00   100
i. +  .5  6.02   100
i. .  .    .     50
i. .  .   6.03   50 
i. .  .   6.00   10 
i. .  .   6.01   10  
i. .  .   6.10   10
i. .  .   7.10   20   
i. .  .   7.08   .
i. .  .   7.07   40
i. .  .   6.07   .
i. .  .   5.07   60
i. .  .   4.07   .
i. .  .   5.07   80
i. .  .   4.07   . 
i. .  .   5.07   100 
i. .  .   4.07    >
i. .  2   5.07   30

s
t 0 120
i2 1 3   5.00
i2 + 3   5.11
i2 . 3   6.10
i2 . 3   7.09
i2 . 3   8.08
i2 . 3   9.07
i2 . 3   10.06
i2 . 3   11.05     ; quite bad aliasing there!