;; -*- cscsd-current-processing : "csound to dac" -*-
<About> ===================================================================

This demo, to be used within Emacs in Surmulot, demonstrates the generation
and graphical edition of MIDI data within a CSD.

The CSD here is a plain MIDI orchestra, with no score section at all.

It can directly be played from Emacs though: 
from the "CSD" menu, select "MPhrases -> fractal -> With output to DAC". 
this plays the <MPhrase> labelled "fractal".
... or click here: [[elisp:(cscsd-play-mphrase "fractal")]]
(see [[info:Csound-x:Handling%20MIDI%20data][Handling MIDI data]] for details).

You can also try "MPhrases -> fractal -> Edit phrase" to change the phrase
... or click here: [[elisp:(cscsd-edit-mphrase "fractal")]]
(see [[info:surmulot.info:Musical%20phrase%20editor][Musical phrase editor]] for more)

================================================================== </About>

<MPhrase label="loop">
|mphrase| mphrase:='ad50,e,d' kmusic repeat: 10.
</MPhrase>

<MPhrase label="fractal">
|mphrase| mphrase:='ad200,e,d,g,a' kmusic fractal.
</MPhrase>

<CsoundSynthesizer>
<CsInstruments>
/* bsln1.orc - written by Istvan Varga */
sr      =  44100
kr      =  22050
ksmps   =  2
nchnls  =  1

massign 1, 1

        instr 1

  imp4  notnum                                  ; pour MIDI
  imp5  veloc                                   ; id
  imp6  midictrl        10, 80, 92

  icps  =       440*exp(log(2)*(imp4-69)/12)    ; oscillator frequency
  iamp  =       0.0039+imp5*imp5/16192          ; amplitude
  ifrq1 =       440*exp(log(2)*(imp6-69)/12)    ; filter start freq.

  kamp  linsegr 1, 0.5, 1, 0.025, 0             ; release envelope

  kcps  port    icps, 0.005, icps*0.5           ; osc. frequency
  knumh =       sr/(2*kcps)

  kffrq port    0, 60/150, ifrq1                ; filter frequency

  a1    phasor  kcps                            ; oscillator
  a1    =       1-2*a1

  a1x   butterbp        a1, kffrq, icps*1.0     ; filters
  a1x   =       a1x*(2+kffrq/kcps)              ; correct amplitude
  a1    =       a1x+a1*0.5
  a1    butterlp        a1, kffrq

  a1    =       taninv(a1* 2.5*iamp) ; distortion
  a1    =       a1*kamp*20000

        out a1
        endin

</CsInstruments>

<CsScore>
</CsScore>
</CsoundSynthesizer>

