corrected example from Dr. B

corrected example from Dr. B

<CsoundSynthesizer>
/*
    This CSD is based on the partikkel example written by Joachim Heintz and Oeyvind Brandtsegg.
    Some of it was written by others, but I forgot who.  Sorry :(
*/
<CsInstruments>
sr      = 44100
ksmps   = 16
nchnls  = 2

0dbfs = 1

; IMPORTANT: giFile must be table # 1 for the partikkel patch to work.
giFile      ftgen   1, 0, 1048577, 7, 0, 1048576, 0 ; A blank table to be filled with audio data using "loadsamp" message.
giCosine    ftgen   200, 0, 8193, 9, 1, 1, 90       ; cosine
giDisttab   ftgen   201, 0, 32768, 7, 0, 32768, 1   ; for kdistribution
giPan       ftgen   202, 0, 32768, -21, 1           ; for panning (random values between 0 and 1)

#define WINDOW_TABLE_BASE # 100 #
giWinHamming   ftgen 100, 0, 4096, 20, 1 ; Hamming
giWinHanning   ftgen 101, 0, 4096, 20, 2 ; Hanning
giWinBartlett  ftgen 102, 0, 4096, 20, 3 ; Bartlett
giWinBlackman  ftgen 103, 0, 4096, 20, 4 ; Blackman
giWinBlackHar  ftgen 104, 0, 4096, 20, 5 ; Blackman - Harris
giWinGaussian  ftgen 105, 0, 4096, 20, 6 ; Gaussian
giWinSync      ftgen 106, 0, 4096, 20, 9 ; Sync
giWinPerc      ftgen 107, 0, 512, 7, 0, 12, 1, 500, 0       ; PERCUSSIVE - STRAIGHT SEGMENTS
giWinPercExp   ftgen 108, 0, 512, 5, .001, 12, 1, 500, .001 ; PERCUSSIVE - EXPONENTIAL SEGMENTS
giWinGate      ftgen 109, 0, 512, 7, 0, 6, 1, 500, 1, 6, 0  ; GATE - WITH ANTI-CLICK RAMP UP AND RAMP DOWN SEGMENTS
giWinRevPerc   ftgen 110, 0, 512, 7, 0, 500, 1, 12, 0      ; REVERSE PERCUSSIVE - STRAIGHT SEGMENTS
giWinRevPerc2  ftgen 111, 0, 512, 5, .001, 500, 1, 12, .001 ; REVERSE PERCUSSIVE - EXPONENTIAL SEGMENTS

instr 1
    ipan  init 0            ; panning narrow 0 to wide 1
    kdist chnget "k_g_dist" ; grain distribution (0=periodic, 1=scattered)
    iWin  chnget "i_win"    ; The window index to use for grains.  (0 is minimum)
    iWin  = iWin + $WINDOW_TABLE_BASE

    kGrainAmp  chnget "k_g_amp"
    kGrainRate chnget "k_g_rate"  ; grains per second
    kGrainSize chnget "k_g_size"  ; grain size in ms
    iTrans     chnget "k_g_trans" ; transposition
    kTrans     chnget "k_g_trans" ; transposition
    kposrand   chnget "k_posRand" ; time position randomness (offset) of the pointer in ms
    iPos       chnget "k_pos"     ; normalized position
    kPos       chnget "k_pos"     ; normalized position
    kPosGlide  chnget "k_posGlide"; If > 0, then apply glide to changes in position, == glide time
    kPortTime  chnget "k_port"
    kPortTime  = kPortTime * .5

    ; Get length of source wave file, needed for both transposition and time pointer.
    ; NOTE: Since we're using the "loadsamp" message to load audio data into table giFile,
    ; associated table data like nsmps will be incorrect.
    iFileLength     tableng giFile
    iFileDur        = iFileLength / sr
    iFileDurInvert  = 1 / iFileDur

    ; Sync Input
    async           = 0

    ; Grain Envelope
    kenv2amt        = 1          ; use only secondary envelope
    ienv2tab        = iWin       ; grain (secondary) envelope
    ienv_attack     = -1         ; default attack envelope (flat)
    ienv_decay      = -1         ; default decay envelope (flat)
    ksustain_amount = 0.5        ; no meaning in this case (use only secondary envelope, ienv2tab)
    ka_d_ratio      = 0.5        ; no meaning in this case (use only secondary envelope, ienv2tab)

    ; Amplitude
    kamp            = kGrainAmp  ; grain amplitude
    igainmasks      = -1         ; (default) no gain masking
    aExtEnv         = 1

    ; Transposition
    iorig           = iFileDurInvert ; original pitch
    kTrans          portk kTrans, kPortTime, iTrans
    kwavfreq        = iorig * kTrans

    ; Other Pitch Related Stuff
    ksweepshape     = 0          ; no frequency sweep
    iwavfreqstarttab= -1         ; default frequency sweep start
    iwavfreqendtab  = -1         ; default frequency sweep end
    awavfm          = 0          ; no FM input
    ifmamptab       = -1         ; default FM scaling (=1)
    kfmenv          = -1         ; default FM envelope (flat)

    ; Trainlet Related
    icosine         = giCosine   ; cosine ftable
    kTrainCps       = kGrainRate ; set trainlet cps equal to grain rate for single-cycle trainlet in each grain
    knumpartials    = 1          ; number of partials in trainlet
    kchroma         = 1          ; balance of partials in trainlet

    ; Panning Using Channel Masks
    imid            = .5         ; center
    ileftmost       = imid - ipan * .5
    irightmost      = imid + ipan * .5
    giPanthis       ftgen    0, 0,  32768, -24, giPan, ileftmost, irightmost    ; rescales giPan according to ipan
                    tableiw  0, 0,  giPanthis               ; change index 0 ...
                    tableiw  32766, 1, giPanthis            ; ... and 1 for ichannelmasks
    ichannelmasks   = giPanthis                             ; ftable for panning

    ; Random Gain Masking
    krandommask     = 0

    ; Source Waveforms
    kwaveform1      = giFile     ; source waveform
    kwaveform2      = giFile     ; all 4 sources are the same
    kwaveform3      = giFile
    kwaveform4      = giFile
    iwaveamptab     = -1         ; (default) equal mix of source waveforms and no amplitude for trainlets

    ; Time Pointer
	kPos = (kPos * sr) / ftlen(giFile)
    kPos lineto kPos, kPosGlide
    afilposphas upsamp kPos
    afilposphas wrap afilposphas, 0, 1

    ; Generate Random Deviation of the Time Pointer
    kposrandsec     = kposrand * .001   ; ms -> sec
    kposrand        = kposrandsec * iFileDurInvert ; phase values (0-1)
    krndpos         linrand  kposrand   ; random offset in phase values

    ; Add Random Deviation to the Time Pointer
    asamplepos1     = afilposphas + krndpos; resulting phase values (0-1)
    asamplepos2     = asamplepos1
    asamplepos3     = asamplepos1
    asamplepos4     = asamplepos1

    ; Original Key for Each Source Waveform
    kwavekey1       = 1
    kwavekey2       = kwavekey1
    kwavekey3       = kwavekey1
    kwavekey4       = kwavekey1

    ; Maximum Number of Grains per K Period
    imax_grains     = 100

    aL, aR  partikkel kGrainRate, kdist, giDisttab, async, kenv2amt, ienv2tab, \
        ienv_attack, ienv_decay, ksustain_amount, ka_d_ratio, kGrainSize, kamp, igainmasks, \
        kwavfreq, ksweepshape, iwavfreqstarttab, iwavfreqendtab, awavfm, \
        ifmamptab, kfmenv, icosine, kTrainCps, knumpartials, \
        kchroma, ichannelmasks, krandommask, kwaveform1, kwaveform2, kwaveform3, kwaveform4, \
        iwaveamptab, asamplepos1, asamplepos2, asamplepos3, asamplepos4, \
        kwavekey1, kwavekey2, kwavekey3, kwavekey4, imax_grains

        outs aL * aExtEnv, aR * aExtEnv
endin

; This instr turns off instr 1.
; The turnoff2 command is only executed once.
instr 2
	turnoff2 1, 0, 0
	turnoff
endin

</CsInstruments>
<CsScore>
f0 86400
;i1 0 86400 ; Removed by D. Pyon.
e
</CsScore>
</CsoundSynthesizer>
<bsbPanel>
 Widgets
 <objectName/>
 <x>100</x>
 <y>100</y>
 <width>320</width>
 <height>240</height>
 <visible>true</visible>
 <uuid/>
 <bgcolor mode="nobackground">
  <r>255</r>
  <g>255</g>
  255
 </bgcolor>
</bsbPanel>
<bsbPresets>
</bsbPresets>

<CsoundSynthesizer>
/*
    This CSD is based on the partikkel example written by Joachim Heintz and Oeyvind Brandtsegg.
    Some of it was written by others, but I forgot who.  Sorry :(
*/
<CsInstruments>
sr      = 44100
ksmps   = 16
nchnls  = 2

0dbfs = 1

; IMPORTANT: giFile must be table # 1 for the partikkel patch to work.
giFile      ftgen   1, 0, 1048577, 7, 0, 1048576, 0 ; A blank table to be filled with audio data using "loadsamp" message.
giCosine    ftgen   200, 0, 8193, 9, 1, 1, 90       ; cosine
giDisttab   ftgen   201, 0, 32768, 7, 0, 32768, 1   ; for kdistribution
giPan       ftgen   202, 0, 32768, -21, 1           ; for panning (random values between 0 and 1)

#define WINDOW_TABLE_BASE # 100 #
giWinHamming   ftgen 100, 0, 4096, 20, 1 ; Hamming
giWinHanning   ftgen 101, 0, 4096, 20, 2 ; Hanning
giWinBartlett  ftgen 102, 0, 4096, 20, 3 ; Bartlett
giWinBlackman  ftgen 103, 0, 4096, 20, 4 ; Blackman
giWinBlackHar  ftgen 104, 0, 4096, 20, 5 ; Blackman - Harris
giWinGaussian  ftgen 105, 0, 4096, 20, 6 ; Gaussian
giWinSync      ftgen 106, 0, 4096, 20, 9 ; Sync
giWinPerc      ftgen 107, 0, 4096, 7, 0, 12, 1, 500, 0       ; PERCUSSIVE - STRAIGHT SEGMENTS
giWinPercExp   ftgen 108, 0, 4096, 5, .001, 12, 1, 500, .001 ; PERCUSSIVE - EXPONENTIAL SEGMENTS
giWinGate      ftgen 109, 0, 4096, 7, 0, 6, 1, 500, 1, 6, 0  ; GATE - WITH ANTI-CLICK RAMP UP AND RAMP DOWN SEGMENTS
giWinRevPerc   ftgen 110, 0, 4096, 7, 0, 500, 1, 12, 0,      ; REVERSE PERCUSSIVE - STRAIGHT SEGMENTS
giWinRevPerc2  ftgen 111, 0, 4096, 5, .001, 500, 1, 12, .001 ; REVERSE PERCUSSIVE - EXPONENTIAL SEGMENTS

instr 1
    ipan  init 0            ; panning narrow 0 to wide 1
    kdist chnget "k_g_dist" ; grain distribution (0=periodic, 1=scattered)
    iWin  chnget "i_win"    ; The window index to use for grains.  (0 is minimum)
    iWin  = iWin + $WINDOW_TABLE_BASE

    kGrainAmp  chnget "k_g_amp"
    kGrainRate chnget "k_g_rate"  ; grains per second
    kGrainSize chnget "k_g_size"  ; grain size in ms
    iTrans     chnget "k_g_trans" ; transposition
    kTrans     chnget "k_g_trans" ; transposition
    kposrand   chnget "k_posRand" ; time position randomness (offset) of the pointer in ms
    iPos       chnget "k_pos"     ; normalized position
    kPos       chnget "k_pos"     ; normalized position
    kPosGlide  chnget "k_posGlide"; If > 0, then apply glide to changes in position, == glide time
    kPortTime  chnget "k_port"
    kPortTime  = kPortTime * .5

    ; Get length of source wave file, needed for both transposition and time pointer.
    ; NOTE: Since we're using the "loadsamp" message to load audio data into table giFile,
    ; associated table data like nsmps will be incorrect.
    iFileLength     tableng giFile
    iFileDur        = iFileLength / sr
    iFileDurInvert  = 1 / iFileDur

    ; Sync Input
    async           = 0

    ; Grain Envelope
    kenv2amt        = 1          ; use only secondary envelope
    ienv2tab        = iWin       ; grain (secondary) envelope
    ienv_attack     = -1         ; default attack envelope (flat)
    ienv_decay      = -1         ; default decay envelope (flat)
    ksustain_amount = 0.5        ; no meaning in this case (use only secondary envelope, ienv2tab)
    ka_d_ratio      = 0.5        ; no meaning in this case (use only secondary envelope, ienv2tab)

    ; Amplitude
    kamp            = kGrainAmp  ; grain amplitude
    igainmasks      = -1         ; (default) no gain masking
    aExtEnv         = 1

    ; Transposition
    iorig           = iFileDurInvert ; original pitch
    kTrans          portk kTrans, kPortTime, iTrans
    kwavfreq        = iorig * kTrans

    ; Other Pitch Related Stuff
    ksweepshape     = 0          ; no frequency sweep
    iwavfreqstarttab= -1         ; default frequency sweep start
    iwavfreqendtab  = -1         ; default frequency sweep end
    awavfm          = 0          ; no FM input
    ifmamptab       = -1         ; default FM scaling (=1)
    kfmenv          = -1         ; default FM envelope (flat)

    ; Trainlet Related
    icosine         = giCosine   ; cosine ftable
    kTrainCps       = kGrainRate ; set trainlet cps equal to grain rate for single-cycle trainlet in each grain
    knumpartials    = 1          ; number of partials in trainlet
    kchroma         = 1          ; balance of partials in trainlet

    ; Panning Using Channel Masks
    imid            = .5         ; center
    ileftmost       = imid - ipan * .5
    irightmost      = imid + ipan * .5
    giPanthis       ftgen    0, 0,  32768, -24, giPan, ileftmost, irightmost    ; rescales giPan according to ipan
                    tableiw  0, 0,  giPanthis               ; change index 0 ...
                    tableiw  32766, 1, giPanthis            ; ... and 1 for ichannelmasks
    ichannelmasks   = giPanthis                             ; ftable for panning

    ; Random Gain Masking
    krandommask     = 0

    ; Source Waveforms
    kwaveform1      = giFile     ; source waveform
    kwaveform2      = giFile     ; all 4 sources are the same
    kwaveform3      = giFile
    kwaveform4      = giFile
    iwaveamptab     = -1         ; (default) equal mix of source waveforms and no amplitude for trainlets

    ; Time Pointer
	kPos = (kPos * sr) / ftlen(giFile)
    kPos lineto kPos, kPosGlide
    afilposphas upsamp kPos
    afilposphas wrap afilposphas, 0, 1

    ; Generate Random Deviation of the Time Pointer
    kposrandsec     = kposrand * .001   ; ms -> sec
    kposrand        = kposrandsec * iFileDurInvert ; phase values (0-1)
    krndpos         linrand  kposrand   ; random offset in phase values

    ; Add Random Deviation to the Time Pointer
    asamplepos1     = afilposphas + krndpos; resulting phase values (0-1)
    asamplepos2     = asamplepos1
    asamplepos3     = asamplepos1
    asamplepos4     = asamplepos1

    ; Original Key for Each Source Waveform
    kwavekey1       = 1
    kwavekey2       = kwavekey1
    kwavekey3       = kwavekey1
    kwavekey4       = kwavekey1

    ; Maximum Number of Grains per K Period
    imax_grains     = 100

    aL, aR  partikkel kGrainRate, kdist, giDisttab, async, kenv2amt, ienv2tab, \
        ienv_attack, ienv_decay, ksustain_amount, ka_d_ratio, kGrainSize, kamp, igainmasks, \
        kwavfreq, ksweepshape, iwavfreqstarttab, iwavfreqendtab, awavfm, \
        ifmamptab, kfmenv, icosine, kTrainCps, knumpartials, \
        kchroma, ichannelmasks, krandommask, kwaveform1, kwaveform2, kwaveform3, kwaveform4, \
        iwaveamptab, asamplepos1, asamplepos2, asamplepos3, asamplepos4, \
        kwavekey1, kwavekey2, kwavekey3, kwavekey4, imax_grains

        outs aL * aExtEnv, aR * aExtEnv
endin

; This instr turns off instr 1.
; The turnoff2 command is only executed once.
instr 2
	turnoff2 1, 0, 0
	turnoff
endin

</CsInstruments>
<CsScore>
f0 86400
;i1 0 86400 ; Removed by D. Pyon.
e
</CsScore>
</CsoundSynthesizer>


no message

no message

<CsoundSynthesizer>
<CsOptions>
csound -R -W -Z -f -o xanadu-high-resolution.wav
</CsOptions>
<CsInstruments>
sr          =           88200
ksmps       =           1
nchnls      =           2
;--------------------------------------------------------
;Instrument 1 : plucked strings chorused left/right and
;       pitch-shifted and delayed taps thru exponential
;       functions, and delayed.
;--------------------------------------------------------

            instr       1
ishift      =           .00666667               ;shift it 8/1200.
ipch        =           cpspch(p5)              ;convert parameter 5 to cps.
ioct        =           octpch(p5)              ;convert parameter 5 to oct.
kvib        poscil      1/120, ipch/50, 1      ;vibrato
ag          pluck       2000, cpsoct(ioct+kvib), 1000, 1, 1
agleft      pluck       2000, cpsoct(ioct+ishift), 1000, 1, 1
agright     pluck       2000, cpsoct(ioct-ishift), 1000, 1, 1
adamping    linsegr     0.0, 0.006, 1.0, p3 - 0.066, 1.0, 0.06, 0.0
ag          =           adamping * ag
agleft      =           adamping * agleft
agright     =           adamping * agright
af1         expon       .1, p3, 1.0             ;exponential from 0.1 to 1.0
af2         expon       1.0, p3, .1             ;exponential from 1.0 to 0.1
adump       delayr      2.0                     ;set delay line of 2.0 sec
atap1       deltap3     af1                     ;tap delay line with kf1 func.
atap2       deltap3     af2                     ;tap delay line with kf2 func.
ad1         deltap3     2.0                     ;delay 2 sec.
ad2         deltap3     1.1                     ;delay 1.1 sec.
            delayw      ag                      ;put ag signal into delay line.
            outs        agleft+atap1+ad1, agright+atap2+ad2
            endin
;-------------------------------------------------------------
;Instrument 2 : plucked strings chorused left/right and
;       pitch-shifted with fixed delayed taps.
;------------------------------------------------------------

            instr       2
ishift      =           .00666667               ;shift it 8/1200.
ipch        =           cpspch(p5)              ;convert parameter 5 to cps.
ioct        =           octpch(p5)              ;convert parameter 5 to oct.
kvib        poscil      1/120, ipch/50, 1       ;vibrato
ag          pluck       1000, cpsoct(ioct+kvib), 1000, 1, 1
agleft      pluck       1000, cpsoct(ioct+ishift), 1000, 1, 1
agright     pluck       1000, cpsoct(ioct-ishift), 1000, 1, 1
adamping    linsegr     0.0, 0.006, 1.0, p3 - 0.066, 1.0, 0.06, 0.0
ag          =           adamping * ag
agleft      =           adamping * agleft
agright     =           adamping * agright
adump       delayr      0.3                     ;set delay line of 0.3 sec
ad1         deltap3     0.1                     ;delay 100 msec.
ad2         deltap3     0.2                     ;delay 200 msec.
            delayw      ag                      ;put ag sign into del line.
            outs        agleft+ad1, agright+ad2
            endin
;-----------------------------------------------------------
;Instrument 3 : New FM algorithm, modified to produce large timbre
;               shifts using modulation of I and r. Detuned chorusing employed.
;-----------------------------------------------------------
            instr       3
ishift      =           .00666667               ;shift it 8/1200.
ipch        =           cpspch(p5)              ;convert parameter 5 to cps.
ioct        =           octpch(p5)              ;convert parameter 5 to oct.
aadsr       linsegr     0, p3/3, 1.0, p3/3, 1.0, p3/3, 0 ;ADSR envelope
amodi       linseg      0, p3/3, 5, p3/3, 3, p3/3, 0 ;ADSR envelope for I
amodr       linseg      p6, p3, p7              ;r moves from p6->p7 in p3 sec.
a1          =           amodi*(amodr-1/amodr)/2
a1ndx       =           abs(a1*2/20)            ;a1*2 is normalized from 0-1.
a2          =           amodi*(amodr+1/amodr)/2
a3          tablei      a1ndx, 3, 1             ;lookup tbl in f3, normal index
ao1         poscil      a1, ipch, 2             ;cosine
a4          =           exp(-0.5*a3+ao1)
ao2         poscil      a2*ipch, ipch, 2        ;cosine
aoutl       poscil      1000*aadsr*a4, ao2+cpsoct(ioct+ishift), 1 ;fnl outleft
aoutr       poscil      1000*aadsr*a4, ao2+cpsoct(ioct-ishift), 1 ;fnl outright
            outs        aoutl, aoutr
            endin

</CsInstruments>
<CsScore>
;       Score for final project in Digital Audio Processing
;       ---------------------------------------------------

;           Piece entitled :  X A N A D U (short version)
;                           Joseph T. Kung, 12/12/88
;            Instruments modified for higher precision
;                         Michael Gogins, 07/22/2006

;           The first part of the score will specify all function
;       tables used in the piece. The second part specifies
;       the instruments and notes. The latter is divided into
;       7 sections, each playing a chord on a different
;                 instrument.
;       The chords are uncommon guitar chords that use the open
;       B and E strings often. These will be transposed by
;       octaves on some chords.

;       Each instrument will play a chord for 15 seconds. The
;                 timbre
;       of the instrument will change in that interval and join
;       with the next instrument/chord sequence. Instrument 3
;       uses a modified FM synthesis technique. This is joined
;       by an additional plucked-string instrument
;       (instruments 1 and 2).

;   The Function Tables
;   -------------------
;All functions are post-normalized (max value is 1) if p4 is
;POSITIVE.

f1 0 65536 10 1      ;sine wave
f2 0 65536 11 1      ;cosine wave
f3 0 65536 -12 20.0  ;unscaled ln(I(x)) from 0 to 20.0

;-----------------------------------------------------------

;----- This section comprises all the new FM sounds -----------

;F#7addB chord on a guitar
i3 0 15 0 7.06 2.0 0.2  ;F#
i3 . . . 8.01 . .   ;C# above
i3 . . . 8.06 . .   ;F# octave above 1st one
i3 . . . 8.10 . .   ;Bb next one up
i3 . . . 8.11 . .   ;B
i3 . . . 9.04 . .   ;E

;D6add9 chord on a guitar
i3 7.5 15 0 6.02 1.7 0.5    ;D
i3 . . . 6.09 . .   ;A above
i3 . . . 7.02 . .   ;D octave above 1st one
i3 . . . 7.06 . .   ;F# next one up
i3 . . . 6.11 . .   ;B
i3 . . . 7.04 . .   ;E

;Bmajadd11 chord on a guitar
i3 15 15 0 7.11 1.4 0.8 ;B
i3 . . . 8.06 . .   ;F# above
i3 . . . 8.11 . .   ;B octave above 1st one
i3 . . . 9.03 . .   ;D# next one up
i3 . . . 8.11 . .   ;B
i3 . . . 9.04 . .   ;E;

;Amajadd9 chord on a guitar
i3 22.5 15 0 6.09 1.1 1.1   ;A
i3 . . . 7.04 . .   ;E above
i3 . . . 8.09 . .   ;A octave above 1st one
i3 . . . 8.01 . .   ;C# next one up
i3 . . . 7.11 . .   ;B
i3 . . . 8.04 . .   ;E

;Bmajadd11 chord on a guitar
i3 30 15 0 6.11 0.8 1.4 ;B
i3 . . . 7.06 . .   ;F# above
i3 . . . 7.11 . .   ;B octave above 1st one
i3 . . . 8.03 . .   ;D# next one up
i3 . . . 7.11 . .   ;B
i3 . . . 8.04 . .   ;E;

;Gmaj6 chord on a guitar
i3 37.5 15 0 5.07 0.5 1.7   ;G
i3 . . . 6.02 . .   ;D above
i3 . . . 6.07 . .   ;G octave above 1st one
i3 . . . 6.11 . .   ;B on G string
i3 . . . 6.11 . .   ;B
i3 . . . 7.04 . .   ;E

;F#7addB chord on a guitar
i3 45 15 0 7.06 0.2 2.0 ;F#
i3 . . . 8.01 . .   ;C# above
i3 . . . 8.06 . .   ;F# octave above 1st one
i3 . . . 8.10 . .   ;Bb next one up
i3 . . . 8.11 . .   ;B
i3 . . . 9.04 . .   ;E

; This section adds the plucked chords to the beginning of each
; section.

;F#7addB chord on a guitar
i1 0 10 0 8.06  ;F#
i1 0.1 . . 9.01 ;C# above
i1 0.2 . . 9.06 ;F# octave above 1st one
i1 0.3 . . 9.10 ;Bb next one up
i1 0.4 . . 9.11 ;B
i1 0.5 . . 10.04    ;E

;D6add9 chord on a guitar
i2 7.5 10 0 8.02    ;D
i2 7.6 . . 8.09     ;A above
i2 7.7 . . 9.02     ;D octave above 1st one
i2 7.8 . . 9.06     ;F# next one up
i2 7.9 . . 9.11     ;B
i2 8.0 . . 10.04    ;E

;Bmajadd11 chord on a guitar
i2 15 10 0 8.11     ;B
i2 15.1 . . 9.06    ;F# above
i2 15.2 . . 9.11    ;B octave above 1st one
i2 15.3 . . 10.03   ;D# next one up
i2 15.4 . . 9.11    ;B
i2 15.5 . . 10.04   ;E;

;Amajadd9 chord on a guitar
i2 22.5 10 0 8.09   ;A
i2 22.6 . . 9.04    ;E above
i2 22.7 . . 10.09   ;A octave above 1st one
i2 22.8 . . 10.01   ;C# next one up
i2 22.9 . . 9.11    ;B
i2 23.0 . . 10.04   ;E

;Bmajadd11 chord on a guitar
i2 30 10 0 8.11     ;B
i2 30.1 . . 9.06    ;F# above
i2 30.2 . . 9.11    ;B octave above 1st one
i2 30.3 . . 10.03   ;D# next one up
i2 30.4 . . 9.11    ;B
i2 30.5 . . 10.04   ;E;

;Gmaj6 chord on a guitar
i2 37.5 10 0 8.07   ;G
i2 37.6 . . 9.02    ;D above
i2 37.7 . . 9.07    ;G octave above 1st one
i2 37.8 . . 9.11    ;B on G string
i2 37.9 . . 9.11    ;B
i2 38.0 . . 10.04   ;E

;F#7addB chord on a guitar
i1 45 10 0 9.06     ;F#
i1 45.1 . . 10.01   ;C# above
i1 45.2 . . 10.06   ;F# octave above 1st one
i1 45.3 . . 10.10   ;Bb next one up
i1 45.4 . . 10.11   ;B
i1 45.5 . . 11.04   ;E
e

</CsScore>
</CsoundSynthesizer>

<CsoundSynthesizer>
<CsOptions>
csound -R -W -Z -f -o xanadu.wav
</CsOptions>
<CsInstruments>
sr          =           88200
ksmps       =           1
nchnls      =           2
;--------------------------------------------------------
;Instrument 1 : plucked strings chorused left/right and
;       pitch-shifted and delayed taps thru exponential
;       functions, and delayed.
;--------------------------------------------------------

            instr       1
ishift      =           .00666667               ;shift it 8/1200.
ipch        =           cpspch(p5)              ;convert parameter 5 to cps.
ioct        =           octpch(p5)              ;convert parameter 5 to oct.
kvib        poscil      1/120, ipch/50, 1      ;vibrato
ag          pluck       2000, cpsoct(ioct+kvib), 1000, 1, 1
agleft      pluck       2000, cpsoct(ioct+ishift), 1000, 1, 1
agright     pluck       2000, cpsoct(ioct-ishift), 1000, 1, 1
adamping    linsegr     0.0, 0.006, 1.0, p3 - 0.066, 1.0, 0.06, 0.0
ag          =           adamping * ag
agleft      =           adamping * agleft
agright     =           adamping * agright
af1         expon       .1, p3, 1.0             ;exponential from 0.1 to 1.0
af2         expon       1.0, p3, .1             ;exponential from 1.0 to 0.1
adump       delayr      2.0                     ;set delay line of 2.0 sec
atap1       deltap3     af1                     ;tap delay line with kf1 func.
atap2       deltap3     af2                     ;tap delay line with kf2 func.
ad1         deltap3     2.0                     ;delay 2 sec.
ad2         deltap3     1.1                     ;delay 1.1 sec.
            delayw      ag                      ;put ag signal into delay line.
            outs        agleft+atap1+ad1, agright+atap2+ad2
            endin
;-------------------------------------------------------------
;Instrument 2 : plucked strings chorused left/right and
;       pitch-shifted with fixed delayed taps.
;------------------------------------------------------------

            instr       2
ishift      =           .00666667               ;shift it 8/1200.
ipch        =           cpspch(p5)              ;convert parameter 5 to cps.
ioct        =           octpch(p5)              ;convert parameter 5 to oct.
kvib        poscil      1/120, ipch/50, 1       ;vibrato
ag          pluck       1000, cpsoct(ioct+kvib), 1000, 1, 1
agleft      pluck       1000, cpsoct(ioct+ishift), 1000, 1, 1
agright     pluck       1000, cpsoct(ioct-ishift), 1000, 1, 1
adamping    linsegr     0.0, 0.006, 1.0, p3 - 0.066, 1.0, 0.06, 0.0
ag          =           adamping * ag
agleft      =           adamping * agleft
agright     =           adamping * agright
adump       delayr      0.3                     ;set delay line of 0.3 sec
ad1         deltap3     0.1                     ;delay 100 msec.
ad2         deltap3     0.2                     ;delay 200 msec.
            delayw      ag                      ;put ag sign into del line.
            outs        agleft+ad1, agright+ad2
            endin
;-----------------------------------------------------------
;Instrument 3 : New FM algorithm, modified to produce large timbre
;               shifts using modulation of I and r. Detuned chorusing employed.
;-----------------------------------------------------------
            instr       3
ishift      =           .00666667               ;shift it 8/1200.
ipch        =           cpspch(p5)              ;convert parameter 5 to cps.
ioct        =           octpch(p5)              ;convert parameter 5 to oct.
aadsr       linsegr     0, p3/3, 1.0, p3/3, 1.0, p3/3, 0 ;ADSR envelope
amodi       linseg      0, p3/3, 5, p3/3, 3, p3/3, 0 ;ADSR envelope for I
amodr       linseg      p6, p3, p7              ;r moves from p6->p7 in p3 sec.
a1          =           amodi*(amodr-1/amodr)/2
a1ndx       =           abs(a1*2/20)            ;a1*2 is normalized from 0-1.
a2          =           amodi*(amodr+1/amodr)/2
a3          tablei      a1ndx, 3, 1             ;lookup tbl in f3, normal index
ao1         poscil      a1, ipch, 2             ;cosine
a4          =           exp(-0.5*a3+ao1)
ao2         poscil      a2*ipch, ipch, 2        ;cosine
aoutl       poscil      1000*aadsr*a4, ao2+cpsoct(ioct+ishift), 1 ;fnl outleft
aoutr       poscil      1000*aadsr*a4, ao2+cpsoct(ioct-ishift), 1 ;fnl outright
            outs        aoutl, aoutr
            endin

</CsInstruments>
<CsScore>
;       Score for final project in Digital Audio Processing
;       ---------------------------------------------------

;           Piece entitled :  X A N A D U (short version)
;                           Joseph T. Kung, 12/12/88
;            Instruments modified for higher precision
;                         Michael Gogins, 07/22/2006

;           The first part of the score will specify all function
;       tables used in the piece. The second part specifies
;       the instruments and notes. The latter is divided into
;       7 sections, each playing a chord on a different
;                 instrument.
;       The chords are uncommon guitar chords that use the open
;       B and E strings often. These will be transposed by
;       octaves on some chords.

;       Each instrument will play a chord for 15 seconds. The
;                 timbre
;       of the instrument will change in that interval and join
;       with the next instrument/chord sequence. Instrument 3
;       uses a modified FM synthesis technique. This is joined
;       by an additional plucked-string instrument
;       (instruments 1 and 2).

;   The Function Tables
;   -------------------
;All functions are post-normalized (max value is 1) if p4 is
;POSITIVE.

f1 0 65536 10 1      ;sine wave
f2 0 65536 11 1      ;cosine wave
f3 0 65536 -12 20.0  ;unscaled ln(I(x)) from 0 to 20.0

;-----------------------------------------------------------

;----- This section comprises all the new FM sounds -----------

;F#7addB chord on a guitar
i3 0 15 0 7.06 2.0 0.2  ;F#
i3 . . . 8.01 . .   ;C# above
i3 . . . 8.06 . .   ;F# octave above 1st one
i3 . . . 8.10 . .   ;Bb next one up
i3 . . . 8.11 . .   ;B
i3 . . . 9.04 . .   ;E

;D6add9 chord on a guitar
i3 7.5 15 0 6.02 1.7 0.5    ;D
i3 . . . 6.09 . .   ;A above
i3 . . . 7.02 . .   ;D octave above 1st one
i3 . . . 7.06 . .   ;F# next one up
i3 . . . 6.11 . .   ;B
i3 . . . 7.04 . .   ;E

;Bmajadd11 chord on a guitar
i3 15 15 0 7.11 1.4 0.8 ;B
i3 . . . 8.06 . .   ;F# above
i3 . . . 8.11 . .   ;B octave above 1st one
i3 . . . 9.03 . .   ;D# next one up
i3 . . . 8.11 . .   ;B
i3 . . . 9.04 . .   ;E;

;Amajadd9 chord on a guitar
i3 22.5 15 0 6.09 1.1 1.1   ;A
i3 . . . 7.04 . .   ;E above
i3 . . . 8.09 . .   ;A octave above 1st one
i3 . . . 8.01 . .   ;C# next one up
i3 . . . 7.11 . .   ;B
i3 . . . 8.04 . .   ;E

;Bmajadd11 chord on a guitar
i3 30 15 0 6.11 0.8 1.4 ;B
i3 . . . 7.06 . .   ;F# above
i3 . . . 7.11 . .   ;B octave above 1st one
i3 . . . 8.03 . .   ;D# next one up
i3 . . . 7.11 . .   ;B
i3 . . . 8.04 . .   ;E;

;Gmaj6 chord on a guitar
i3 37.5 15 0 5.07 0.5 1.7   ;G
i3 . . . 6.02 . .   ;D above
i3 . . . 6.07 . .   ;G octave above 1st one
i3 . . . 6.11 . .   ;B on G string
i3 . . . 6.11 . .   ;B
i3 . . . 7.04 . .   ;E

;F#7addB chord on a guitar
i3 45 15 0 7.06 0.2 2.0 ;F#
i3 . . . 8.01 . .   ;C# above
i3 . . . 8.06 . .   ;F# octave above 1st one
i3 . . . 8.10 . .   ;Bb next one up
i3 . . . 8.11 . .   ;B
i3 . . . 9.04 . .   ;E

; This section adds the plucked chords to the beginning of each
; section.

;F#7addB chord on a guitar
i1 0 10 0 8.06  ;F#
i1 0.1 . . 9.01 ;C# above
i1 0.2 . . 9.06 ;F# octave above 1st one
i1 0.3 . . 9.10 ;Bb next one up
i1 0.4 . . 9.11 ;B
i1 0.5 . . 10.04    ;E

;D6add9 chord on a guitar
i2 7.5 10 0 8.02    ;D
i2 7.6 . . 8.09     ;A above
i2 7.7 . . 9.02     ;D octave above 1st one
i2 7.8 . . 9.06     ;F# next one up
i2 7.9 . . 9.11     ;B
i2 8.0 . . 10.04    ;E

;Bmajadd11 chord on a guitar
i2 15 10 0 8.11     ;B
i2 15.1 . . 9.06    ;F# above
i2 15.2 . . 9.11    ;B octave above 1st one
i2 15.3 . . 10.03   ;D# next one up
i2 15.4 . . 9.11    ;B
i2 15.5 . . 10.04   ;E;

;Amajadd9 chord on a guitar
i2 22.5 10 0 8.09   ;A
i2 22.6 . . 9.04    ;E above
i2 22.7 . . 10.09   ;A octave above 1st one
i2 22.8 . . 10.01   ;C# next one up
i2 22.9 . . 9.11    ;B
i2 23.0 . . 10.04   ;E

;Bmajadd11 chord on a guitar
i2 30 10 0 8.11     ;B
i2 30.1 . . 9.06    ;F# above
i2 30.2 . . 9.11    ;B octave above 1st one
i2 30.3 . . 10.03   ;D# next one up
i2 30.4 . . 9.11    ;B
i2 30.5 . . 10.04   ;E;

;Gmaj6 chord on a guitar
i2 37.5 10 0 8.07   ;G
i2 37.6 . . 9.02    ;D above
i2 37.7 . . 9.07    ;G octave above 1st one
i2 37.8 . . 9.11    ;B on G string
i2 37.9 . . 9.11    ;B
i2 38.0 . . 10.04   ;E

;F#7addB chord on a guitar
i1 45 10 0 9.06     ;F#
i1 45.1 . . 10.01   ;C# above
i1 45.2 . . 10.06   ;F# octave above 1st one
i1 45.3 . . 10.10   ;Bb next one up
i1 45.4 . . 10.11   ;B
i1 45.5 . . 11.04   ;E
e

</CsScore>
</CsoundSynthesizer>


Added FLsetVal_i to example.

Added FLsetVal_i to example.

<CsoundSynthesizer>
<CsOptions>
-b100 -B1800 -odac3
</CsOptions>
<CsInstruments>
sr=44100
kr=441
ksmps=100
nchnls=2

        FLpanel "This Panel contains a Knob and shows its current value",400,300
ih1     FLvalue "This is current value of output of the Knob", 100,20,50,20
gk1,gih  FLknob  "Current value of this Knob is shown in a text field", 80,5000,-1,1, ih1, 90, 150,100
        FLpanelEnd
        FLrun

        instr 1
        FLsetVal_i 440, gih
a1      oscili  3000, gk1, 1
        outs     a1,a1
        endin
</CsInstruments>
<CsScore>
f1 0 1024 10 1
i1 0 3600

</CsScore>
</CsoundSynthesizer>

<CsoundSynthesizer>
<CsOptions>
-b100 -B1800 -odac1
</CsOptions>
<CsInstruments>
sr=44100
kr=441
ksmps=100
nchnls=2

        FLpanel "This Panel contains a Knob and shows its current value",400,300
ih1     FLvalue "This is current value of output of the Knob", 100,20,50,20
gk1,ih  FLknob  "Current value of this Knob is shown in a text field", 80,5000,-1,1, ih1, 90, 150,100
        FLpanelEnd
        FLrun

        instr 1
a1      oscili  3000, gk1, 1
        outs     a1,a1
        endin
</CsInstruments>
<CsScore>
f1 0 1024 10 1
i1 0 3600

</CsScore>
</CsoundSynthesizer>


lalalala

lalalala

; Vox Output
;
; The bedrock of this file comes from the fof example in the Csound Opcode Help
;
; Tasks:
;   -Figure out how to end notes by changing kamp at end of notes
;   -Add more formants for richer sound

<CsoundSynthesizer>
<CsOptions>
;-odac ;;;realtime audio out
;-iadc ;;;realtime audio in
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1

alwayson "Vox"       ; Vox instrument only ends when score ends/program stops running
giOSC OSCinit 6006
giSine    ftgen 1, 0, 16384, 10, 1
giSigmoid ftgen 2, 0, 1024,  19, 0.5, 0.5, 270, 0.5

instr Vox
	; Combine five formants together to create
	; a transformation from an alto-"a" sound
	; to an alto-"i" sound.
	; Values common to all of the formants.
	koct init 0
	kris init 0.003
	kdur init 0.02
	kdec init 0.007
	iolaps = 100
	itotdur = 3600

	kfund init 300
	kmidipitch init 0
	knotedur init 3600

	;Listen for OSC messages
	ktrig OSClisten giOSC, "/note", "ff", kmidipitch, knotedur
	kfund = cpsmidinn(kmidipitch)

	; First formant.
	k1amp = ampdb(0)
	;k1form line 800, p3, 350
	k1form init 800
	k1band line 80, i(knotedur), 50

	; Second formant.
	k2amp line ampdb(-4), i(knotedur), ampdb(-20)
	;k2form line 1150, p3, 1700
	k2form init 1150
	k2band line 90, i(knotedur), 100

	; Third formant.
	k3amp line ampdb(-20), i(knotedur), ampdb(-30)
	;k3form line 2800, p3, 2700
	k3form init 2800
	k3band init 120

	; Fourth formant.
	k4amp init ampdb(-36)
	;k4form line 3500, p3, 3700
	k4form init 3500
	k4band line 130, i(knotedur), 150

	; Fifth formant.
	k5amp init ampdb(-60)
	k5form init 4950
	k5band line 140, i(knotedur), 200

	a1 fof k1amp, kfund, k1form, koct, k1band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur
	a2 fof k2amp, kfund, k2form, koct, k2band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur
	a3 fof k3amp, kfund, k3form, koct, k3band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur
	a4 fof k4amp, kfund, k4form, koct, k4band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur
	a5 fof k5amp, kfund, k5form, koct, k5band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur

	; Combine all of the formants together
	asig sum (a1+a2+a3+a4+a5)
	outs asig, asig
endin

</CsInstruments>
<CsScore>
e 3600 ; Program runs for an hour
</CsScore>
</CsoundSynthesizer>
<bsbPanel>
 Widgets
 <objectName/>
 <x>100</x>
 <y>100</y>
 <width>320</width>
 <height>240</height>
 <visible>true</visible>
 <uuid/>
 <bgcolor mode="nobackground">
  <r>255</r>
  <g>255</g>
  255
 </bgcolor>
</bsbPanel>
<bsbPresets>
</bsbPresets>

; Vox Output
;
; The bedrock of this file comes from the fof example in the Csound Opcode Help
;
; Tasks:
;   -Figure out how to end notes by changing kamp at end of notes
;   -Add more formants for richer sound

<CsoundSynthesizer>
<CsOptions>
;-odac ;;;realtime audio out
;-iadc ;;;realtime audio in
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1

alwayson "Vox"       ; Vox instrument only ends when score ends/program stops running
giOSC OSCinit 6007
giSine    ftgen 1, 0, 16384, 10, 1
giSigmoid ftgen 2, 0, 1024,  19, 0.5, 0.5, 270, 0.5

instr Vox
	; Combine five formants together to create
	; a transformation from an alto-"a" sound
	; to an alto-"i" sound.
	; Values common to all of the formants.
	koct init 0
	kris init 0.003
	kdur init 0.02
	kdec init 0.007
	iolaps = 100
	itotdur = 3600

	;kamp init 1
	kfund init 300
	knotedur init 3600

	;Listen for OSC messages
	ktrig OSClisten giOSC, "/note", "ff", kfund, knotedur

	; First formant.
	k1amp = ampdb(0)
	;k1form line 800, p3, 350
	k1form init 800
	k1band line 80, i(knotedur), 50

	; Second formant.
	k2amp line ampdb(-4), i(knotedur), ampdb(-20)
	;k2form line 1150, p3, 1700
	k2form init 1150
	k2band line 90, i(knotedur), 100

	; Third formant.
	k3amp line ampdb(-20), i(knotedur), ampdb(-30)
	;k3form line 2800, p3, 2700
	k3form init 2800
	k3band init 120

	; Fourth formant.
	k4amp init ampdb(-36)
	;k4form line 3500, p3, 3700
	k4form init 3500
	k4band line 130, i(knotedur), 150

	; Fifth formant.
	k5amp init ampdb(-60)
	k5form init 4950
	k5band line 140, i(knotedur), 200

	a1 fof k1amp, kfund, k1form, koct, k1band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur
	a2 fof k2amp, kfund, k2form, koct, k2band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur
	a3 fof k3amp, kfund, k3form, koct, k3band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur
	a4 fof k4amp, kfund, k4form, koct, k4band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur
	a5 fof k5amp, kfund, k5form, koct, k5band, kris, kdur, kdec, iolaps, giSine, giSigmoid, itotdur

	; Combine all of the formants together
	asig sum (a1+a2+a3+a4+a5) ;* 13000
	outs asig, asig
endin

</CsInstruments>
<CsScore>
e 3600 ; Program runs for an hour
</CsScore>
</CsoundSynthesizer>
<bsbPanel>
 Widgets
 <objectName/>
 <x>100</x>
 <y>100</y>
 <width>320</width>
 <height>240</height>
 <visible>true</visible>
 <uuid/>
 <bgcolor mode="nobackground">
  <r>255</r>
  <g>255</g>
  255
 </bgcolor>
</bsbPanel>
<bsbPresets>
</bsbPresets>


cladsyn example

cladsyn example

<CsoundSynthesizer>
<CsOptions>
--opcode-lib=./libclop1.dylib
</CsOptions>
<CsInstruments>

ksmps = 64
0dbfs = 1

instr 1
ifftsize = 2048
ihopsize = 512
ibins = 1024
idev =  1 ; /* device number */
asig1 vco2 0.5, 440
fsig = pvsanal(asig1, ifftsize,ihopsize, ifftsize, 1)
asig = cladsynth(fsig,1,1,ibins,idev)
asig = linenr(asig,0.001,0.01,0.01)
    out(asig*0.5)

endin

instr 2
ifftsize = 2048
ihopsize = 512
ibins = 1024
asig1 vco2 0.5, 440
fsig = pvsanal(asig1, ifftsize,ihopsize, ifftsize, 1)
asig = pvsadsyn(fsig,ibins,1)
asig = linenr(asig,0.001,0.01,0.01)
    out(asig*0.5)

endin

</CsInstruments>
<CsScore>
i1 0 60
</CsScore>
</CsoundSynthesizer>

<CsoundSynthesizer>
<CsOptions>
--opcode-lib=./libclop1.dylib
</CsOptions>
<CsInstruments>

ksmps = 64
0dbfs = 1

instr 1
ifftsize = 2048
ihopsize = 512
ibins = 1024
idev =  1 ; /* device number */
asig1,adp mp3in "/users/victor/audio/metheny.mp3"
fsig = pvsanal(asig1, ifftsize,ihopsize, ifftsize, 1)
asig = cladsynth(fsig,1,1,ibins,idev)
asig = linenr(asig,0.001,0.01,0.01)
    out(asig*0.5)

endin

instr 2
ifftsize = 2048
ihopsize = 512
ibins = 1024
asig1,adp diskin "/users/victor/audio/metheny.wav",1,0,1
fsig = pvsanal(asig1, ifftsize,ihopsize, ifftsize, 1)
asig = pvsadsyn(fsig,ibins,1)
asig = linenr(asig,0.001,0.01,0.01)
    out(asig*0.5)

endin

</CsInstruments>
<CsScore>
i1 0 60
</CsScore>
</CsoundSynthesizer>


adding csound PD class

adding csound PD class

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
sr=44100
kr=44.1
ksmps=1000
nchnls=2

        FLpanel "This Panel contains a Knob and shows its current value",400,300
ih1     FLvalue "This is current value of output of the Knob", 100,20,50,20
gk1,gih  FLknob  "Current value of this Knob is shown in a text field", 80,5000,-1,1, ih1, 90, 150,100
        FLpanelEnd
        FLrun

        instr 1
        FLsetVal_i 440, gih
a1      oscili  3000, gk1, 1
        outs     a1,a1
        endin
</CsInstruments>
<CsScore>
f1 0 1024 10 1
i1 0 2 440

</CsScore>
</CsoundSynthesizer>

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
sr=44100
kr=44.1
ksmps=1000
nchnls=2
/*
        FLpanel "This Panel contains a Knob and shows its current value",400,300
ih1     FLvalue "This is current value of output of the Knob", 100,20,50,20
gk1,gih  FLknob  "Current value of this Knob is shown in a text field", 80,5000,-1,1, ih1, 90, 150,100
        FLpanelEnd
        FLrun
*/
        instr 1
;        FLsetVal_i 440, gih
a1      oscili  3000, p4, 1
        outs     a1,a1
        endin
</CsInstruments>
<CsScore>
f1 0 1024 10 1
i1 0 2 440

</CsScore>
</CsoundSynthesizer>


updating

updating

A class examining the use of phasors to read an f-table
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

  instr 1
    //Amplitude var
    iAmp = p4
    //Freq
    iFreq = p5
    //So you can reuse this setup for multipule f-tables via the p6
    iTableLength = p6
    //Which table to use
    iTableNumber = p7

    //Create a phasor (i.e a clock that counts from 0 to 1)
    aPhasor phasor iFreq
    //Devide the phasor by the table length (kind of like defining the step length)
    aScaled = aPhasor * iTableLength
    //Which table to use
    aTable table aScaled, iTableNumber
    //Scale the output by the correct p-Field (p4)
    aOsc = aTable * iAmp
    //Export the thing
    out aOsc

  endin

</CsInstruments>
<CsScore>
//Sine Wave
f 1 0 16384 10 1

i 1 1 1 1 880 16384 1

</CsScore>
</CsoundSynthesizer>

A class examining the use of phasors to read an f-table
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

  instr 1
    //Amplitude var
    iAmp = p4
    //Freq
    iFreq = p5
    //So you can reuse this setup for multipule f-tables via the p6
    iTableLength = p6
    //Which table to use
    iTableNumber = p7

    //Create a phasor (i.e a clock that counts from 0 to 1)
    aPhasor phasor iFreq
    //Devide the phasor by the table length (kind of like defining the step length)
    aScaled = aPhasor * iTableLength
    //Which table to use
    aTable table aScaled, iTableNumber
    //Scale the output by the correct p-Field (p4)
    aOsc = aTable * iAmp
    //Export the thing
    aOsc out

  endin

</CsInstruments>
<CsScore>
//Sine Wave
f 1 0 16384 10 1

i 0 1 1 1 880 16384 1

</CsScore>
</CsoundSynthesizer>


Line endings

Line endings

<CsoundSynthesizer>
<CsOptions>
-d  -B2048 -b2048
</CsOptions>
<CsInstruments>
sr=44100
ksmps=10
nchnls=1

instr 1

k1 invalue "amp"
k1 tonek k1, 10
k2 invalue "freq"
k3 invalue "filfreq"
k4 invalue "filq"
asig oscili k1,k2,1
afil resonz asig, k3, k3/k4, 1
outvalue "freq", k2
     out afil
endin

</CsInstruments>
<CsScore>
f1 0 16384 10 1 .5 .33 .25 .2 .16 .14 .12 .1 .9 .8 .7 .6 .5
i1 0 600

</CsScore>

</CsoundSynthesizer>

</CsInstruments>
<CsScore>
f1 0 16384 10 1
i1 0 60

</CsScore>

</CsoundSynthesizer>


fl.csd example fixed

fl.csd example fixed

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
sr=44100
kr=44.1
ksmps=1000
nchnls=2

        FLpanel "This Panel contains a Knob and shows its current value",400,300
ih1     FLvalue "This is current value of output of the Knob", 100,20,50,20
gk1,gih  FLknob  "Current value of this Knob is shown in a text field", 80,5000,-1,1, ih1, 90, 150,100
        FLpanelEnd
        FLrun

        instr 1
        FLsetVal_i 440, gih
a1      oscili  3000, gk1, 1
        outs     a1,a1
        endin
</CsInstruments>
<CsScore>
f1 0 1024 10 1
i1 0 3600

</CsScore>
</CsoundSynthesizer>

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
sr=44100
kr=44.1
ksmps=1000
nchnls=2

        FLpanel "This Panel contains a Knob and shows its current value",400,300
ih1     FLvalue "This is current value of output of the Knob", 100,20,50,20
gk1,gih  FLknob  "Current value of this Knob is shown in a text field", 80,5000,-1,1, ih1, 90, 150,100
        FLpanelEnd
        FLrun

        instr 1
        FLsetVal_i 440, gih
a1      oscili  3000, gk1, 1
        outs     a1,a1
        endin
</CsInstruments>
<CsScore>
f1 0 1024 10 1
i1 0 2 440

</CsScore>
</CsoundSynthesizer>


no message

no message

<CsoundSynthesizer>
<CsOptions>
csound -RWfo chuas_oscillator.wav
</CsOptions>
<CsInstruments>
sr              =           44100
ksmps           =           100
nchnls          =           2
0dbfs           =           10000

gibuzztable     ftgen       1, 0, 16384, 10, 1

                instr 1
                ; sys_variables = system_vars(5:12); % L,R0,C2,G,Ga,Gb,E,C1 or p8:p15
                ; integ_variables = [system_vars(14:16),system_vars(1:2)]; % x0,y0,z0,dataset_size,step_size or p17:p19, p4:p5
istep_size 	    =           p5
iL 	            =           p8
iR0             =           p9
iC2             =           p10
iG 	            =           p11
iGa             =           p12
iGb             =           p13
iE              =           p14
iC1             =           p15
iI3             =           p17
iV2             =           p18
iV1             =           p19
iattack         =           0.02
isustain        =           p3
irelease        =           0.02
p3              =           iattack + isustain + irelease
iscale          =           1.0
adamping        linseg	    0.0, iattack, iscale, isustain, iscale, irelease, 0.0
aguide          buzz        5000, 440, sr/440, gibuzztable
aI3, aV2, aV1   chuap       iL, iR0, iC2, iG, iGa, iGb, iE, iC1, iI3, iV2, iV1, istep_size
asignal         balance     aV2, aguide
                outs        adamping * asignal, adamping * asignal
                endin
</CsInstruments>
<CsScore>
;        Adapted from ABC++ MATLAB example data.
i 1 0 20 1500 .1   -1 -1 -0.00707925 0.00001647 100  1 -.99955324 -1.00028375 1 -.00222159 204.8 -2.36201596260071 3.08917625807226e-03 3.87075614929199 7 .4 .004 1 86 30; torus attractor ( gallery of attractors )
i 1 + 20 1500 .425  0 -1  1.3506168  0              -4.50746268737 -1 2.4924 .93 1 1 0 -22.28662665 .009506608 -22.2861576 32 10 2 20 86 30 ; heteroclinic orbit
i 1 + 20 1024 .05  -1 -1  0.00667    0.000651    10 -1 .856 1.1 1 .06 51.2 -20.200590133667 .172539323568344 -4.07686233520508 2.5 10 .2 1 66 81 ; periodic attractor (torus breakdown route)
i 1 + 20 1024	0.05	-1	-1	0.00667	0.000651	10	-1	0.856	1.1	1	0.1	153.6	21.12496758	0.03001749	0.515828669	2.5	10	0.2	1	66	81	 ; torus attractor (torus breakdown route)'
</CsScore>
</CsoundSynthesizer>

<CsoundSynthesizer>
<CsOptions>
csound -RWfo chuas_oscillator.wav
</CsOptions>
<CsInstruments
sr              =           44100
ksmps           =           100
nchnls          =           2
0dbfs           =           10000

gibuzztable     ftgen       1, 0, 16384, 10, 1

                instr 1
                ; sys_variables = system_vars(5:12); % L,R0,C2,G,Ga,Gb,E,C1 or p8:p15
                ; integ_variables = [system_vars(14:16),system_vars(1:2)]; % x0,y0,z0,dataset_size,step_size or p17:p19, p4:p5
istep_size 	    =           p5
iL 	            =           p8
iR0             =           p9
iC2             =           p10
iG 	            =           p11
iGa             =           p12
iGb             =           p13
iE              =           p14
iC1             =           p15
iI3             =           p17
iV2             =           p18
iV1             =           p19
iattack         =           0.02
isustain        =           p3
irelease        =           0.02
p3              =           iattack + isustain + irelease
iscale          =           1.0
adamping        linseg	    0.0, iattack, iscale, isustain, iscale, irelease, 0.0
aguide          buzz        5000, 440, sr/440, gibuzztable
aI3, aV2, aV1   chuap       iL, iR0, iC2, iG, iGa, iGb, iE, iC1, iI3, iV2, iV1, istep_size
asignal         balance     aV2, aguide
                outs        adamping * asignal, adamping * asignal
                endin
</CsInstruments>
<CsScore>
;        Adapted from ABC++ MATLAB example data.
i 1 0 20 1500 .1   -1 -1 -0.00707925 0.00001647 100  1 -.99955324 -1.00028375 1 -.00222159 204.8 -2.36201596260071 3.08917625807226e-03 3.87075614929199 7 .4 .004 1 86 30; torus attractor ( gallery of attractors )
i 1 + 20 1500 .425  0 -1  1.3506168  0              -4.50746268737 -1 2.4924 .93 1 1 0 -22.28662665 .009506608 -22.2861576 32 10 2 20 86 30 ; heteroclinic orbit
i 1 + 20 1024 .05  -1 -1  0.00667    0.000651    10 -1 .856 1.1 1 .06 51.2 -20.200590133667 .172539323568344 -4.07686233520508 2.5 10 .2 1 66 81 ; periodic attractor (torus breakdown route)
i 1 + 20 1024	0.05	-1	-1	0.00667	0.000651	10	-1	0.856	1.1	1	0.1	153.6	21.12496758	0.03001749	0.515828669	2.5	10	0.2	1	66	81	 ; torus attractor (torus breakdown route)'
</CsScore>
</CsoundSynthesizer>


Fixed overflow due to very long performance (2^31 or more control periods)

<CsoundSynthesizer>
<CsOptions>
</CsOptions>

<CsInstruments>

sr= 44100
kr = 4410
ksmps = 10
nchnls= 4

instr 1
kfreq invalue "freq"
kamp  invalue "amp"
a0    = 0
asyn  oscili p4*kamp, p5*kfreq, 1
        outq asyn*0.7, asyn*0.3,a0,a0
endin

instr 2

as1,as2,as3,as4 inq
krvt  invalue "rev"
klt   invalue "del"
kfm   invalue "modf"
kmod  phasor kfm
adel upsamp klt
a0  = 0
acmb flanger  as4, adel, krvt
      outvalue "mod",  kmod
        outs a0,a0,acmb*0.3, acmb*0.7
endin

</CsInstruments>

<CsScore>
f0 450000
f1 0 4096 10 1
i2 0 450000
</CsScore>

</CsoundSynthesizer>

<CsoundSynthesizer>
<CsOptions>
</CsOptions>

<CsInstruments>

sr= 44100
kr = 4410
ksmps = 10
nchnls= 4

instr 1
kfreq invalue "freq"
kamp  invalue "amp"
a0    = 0
asyn  oscili p4*kamp, p5*kfreq, 1
        outq asyn*0.7, asyn*0.3,a0,a0
endin

instr 2

as1,as2,as3,as4 inq
krvt  invalue "rev"
klt   invalue "del"
kfm   invalue "modf"
kmod  phasor kfm
adel upsamp klt
a0  = 0
acmb flanger  as4, adel, krvt
      outvalue "mod",  kmod
        outs a0,a0,acmb*0.3, acmb*0.7
endin

</CsInstruments>

<CsScore>
f0 36000000
f1 0 4096 10 1
i2 0 36000
</CsScore>

</CsoundSynthesizer>


added print debug statement

added print debug statement

<CsoundSynthesizer>

<CsInstruments>
sr=44100
ksmps=1
nchnls=2

giamp = 10000

		opcode testUDO, i, i
ipch	xin
print ipch
ipch 	= ipch * 2
		xout ipch
		endop

	instr 1	;untitled

iamp = giamp

ipch = p4

kenv	linseg 0, p3 * (.25 + .25), 1, p3 * .5 * 1, 0
kenv 	= kenv * iamp

ifreq	testUDO ipch

aout	vco2 kenv, ifreq

	outs aout, aout
	endin

</CsInstruments>

<CsScore>

i1	0.0	1 440
i1  + . 550
i1  + . 660
i1  + . 770
i1  + . 880

e

</CsScore>

</CsoundSynthesizer>

<CsoundSynthesizer>

<CsInstruments>
sr=44100
ksmps=1
nchnls=2

giamp = 10000

		opcode testUDO, i, i
ipch	xin
ipch 	= ipch * 2
		xout ipch
		endop

	instr 1	;untitled

iamp = giamp

ipch = p4

kenv	linseg 0, p3 * (.25 + .25), 1, p3 * .5 * 1, 0
kenv 	= kenv * iamp

ifreq	testUDO ipch

aout	vco2 kenv, ifreq

	outs aout, aout
	endin

</CsInstruments>

<CsScore>

i1	0.0	1 440
i1  + . 550
i1  + . 660
i1  + . 770
i1  + . 880

e

</CsScore>

</CsoundSynthesizer>


Line endings

Line endings


further enhanced RTTI test

further enhanced RTTI test

<CsoundSynthesizer>
;<CsOptions>
;</CsOptions>
; ==============================================
<CsInstruments>

sr	=	44100
ksmps	=	1
nchnls	=	2
0dbfs	=	1

gi_var = 22
gk_var = 33
gS_var = "TEST"

opcode testUDO, 0, iiS

i0, i1, S2  xin

print i0
print_type i0
print i1
print_type i1
prints S2
print_type S2

prints "\nTEST UDO\n"
prints "Testing constants...\n"
print 44
print_type 44
print_type "test"

prints "Testing Global Vars...\n"
print_type gi_var
print_type gk_var
print_type gS_var

ivar = 300
kvar = 400
avar init 0

prints "Testing Local Vars...\n"
print_type ivar
print ivar
print_type kvar
print_type avar

prints "Testing PFields...\n"
print_type p1
print p1
print_type p2
print p2
print_type p3
print p3
print_type p4
print p4
print_type p5
prints p5

endop

instr testInstr

prints "Testing constants...\n"
print 44
print_type 44
print_type "test"

prints "Testing Global Vars...\n"
print_type gi_var
print_type gk_var
print_type gS_var

ivar = 300
kvar = 400
avar init 0

prints "Testing Local Vars...\n"
print_type ivar
print ivar
print_type kvar
print_type avar

prints "Testing PFields...\n"
print_type p1
print p1
print_type p2
print p2
print_type p3
print p3
print_type p4
print p4
print_type p5
prints p5

testUDO(1, 2, "testUDO")

turnoff

endin

instr 2

print_type p4
prints p4
print_type p5
prints p5
print_type p6
prints p6

turnoff

endin

instr 3
pset 3, 0, 4, 5, 6

print p3
print p4
print p5
turnoff

endin
</CsInstruments>

; ==============================================
<CsScore>
i "testInstr" 0 .5 999 "testPfield"
i2 0 3 "aaa" "bbb" "ccc"
i3 0 3
</CsScore>

</CsoundSynthesizer>

<CsoundSynthesizer>
;<CsOptions>
;</CsOptions>
; ==============================================
<CsInstruments>

sr	=	44100
ksmps	=	1
nchnls	=	2
0dbfs	=	1

gi_var = 22
gk_var = 33
gS_var = "TEST"

instr testInstr

prints "Testing constants...\n"
print 44
print_type 44
print_type "test"

prints "Testing Global Vars...\n"
print_type gi_var
print_type gk_var
print_type gS_var

ivar = 300
kvar = 400
avar init 0

prints "Testing Local Vars...\n"
print_type ivar
print ivar
print_type kvar
print_type avar

prints "Testing PFields...\n"
print_type p1
print p1
print_type p2
print p2
print_type p3
print p3
print_type p4
print p4
print_type p5
prints p5

turnoff

endin

instr 2

print_type p4
prints p4
print_type p5
prints p5
print_type p6
prints p6

turnoff

endin

instr 3
pset 3, 0, 4, 5, 6

print p3
print p4
print p5
turnoff

endin
</CsInstruments>

; ==============================================
<CsScore>
i "testInstr" 0 .5 999 "testPfield"
i2 0 3 "aaa" "bbb" "ccc"
i3 0 3
</CsScore>

</CsoundSynthesizer>


Removed because redundant.

Removed because redundant.