« Return to Thread: [csnd] Windcontroller Portamento with cpsmidib opcode

RE: [csnd] Windcontroller Portamento with cpsmidib opcode

by Iain McCurdy :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi,

Your portamento function (kport linseg icpsb, iportim, gicps) won't do anything because it begins and ends on the same value. I think what you want it to do is to glide from the previous pitch value to the current one, the following example does that. For pitch bend I would recommend 'pchbend' over 'cpsmidib'.
This is probably not the way that you want to implement pitch portamento. See second example.

;-----------------------------------------------------------------------------------------------------------------------
<CsoundSynthesizer>

<CsOptions>
-M0 -odac
</CsOptions>

<CsInstruments>

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

gisine    ftgen    0,0,4096,10,1
gkOctOld    init    8

instr 1
;PORTAMENTO TIME
iporttime    init    0.2
;READ MIDI PITCH VALUES (OCT FORMAT)
ioct    octmidi   
;PITCH BEND INFORMATION IS READ (2 SEMITONE RANGE)
kbend    pchbend    0, 2/12
;AMPLITUDE ENVELOPE
aenv    linenr    0.1, 0.01, 0.01, 0.01
;PORTAMENTO GLIDE FROM PREVIOUS PITCH TO CURRENT PITCH
koct    expseg    i(gkOctOld), iporttime, ioct, 1, ioct
;AUDIO OSCILATOR
asig    oscili    aenv, cpsoct(gkOctOld+kbend), gisine
;DEFINE OLD PITCH VALUE FOR NEXT PASS (I.E. NEXT NOTE); MUST BE GLOBAL VARIABLE
gkOctOld    =    koct
;SEND AUDIO TO OUTPUTS
outs    asig, asig
endin

</CsInstruments>

<CsScore>
f 0 3600
</CsScore>

</CsoundSynthesizer>
;-----------------------------------------------------------------------------------------------------------------------

A more likely method of using portamento, and the one that I think Tim suggests, is on a monophonic instrument in which 2 instruments are used: one senses changes in pitch values and whether a note is actually being played and the other actually creates the sound. The first instrument instructs the second instrument to play if required.

;-----------------------------------------------------------------------------------------------------------------------
<CsoundSynthesizer>

<CsOptions>
-odac -M0
</CsOptions>

<CsInstruments>

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

;INITIALISE GLOBAL VARIABLES
giportamento    init    0.06    ;PORTAMENTO TIME
gkcps        init    0       ;INITIALISE GLOBAL VARIABLES
gkNumInstr1    init    0       ;INITIALISE GLOBAL VARIABLES
gisine        ftgen    1, 0, 131072, 10, 1  ;A SINE WAVE - USED BY BOTH THE VIBRATO AND THE vco

;THIS INSTRUMENT SENSES INCOMING MIDI BUT DOESN'T MAKE ANY SOUND ITSELF, IT INSTRUCTS INSTR 2 TO PLAY
instr    1
;READ IN MIDI PITCH (OCT FORMAT)
ioct    octmidi
;PITCH BEND INFORMATION IS READ (2 SEMITONE RANGE)
kbend    pchbend    0, 2/12
;CPS VALUE FOR PITCH
gkcps    =    cpsoct(ioct + kbend)
;INSTR 2 IS INSTRUCTED TO PLAY A VERY LONG NOTE - ONLY ONE NOTE AT A TIME IS ALLOWED
;        KTRIGGER, KMINTIM, KMAXNUM, KINSNUM, KWHEN, KDUR
schedkwhen      1,           0,       1,       2,      0,   3600
endin

;SOUND PRODUCING INSTRUMENT (MONOPHONIC)      
instr    2
;SENSE THE NUMBER OF NOTES ARE BEING PLAYED BY INSTR 1
gkNumInstr1     active         1
;IF INSTR 1 IS NOT ACTIVE; I.E. NO MIDI NOTES ARE BEING HELD...
if        gkNumInstr1=0    then
turnoff        ;INSTR 2 TURNS ITSELF OFF IF INSTR IS INACTIVE
endif
;CREATE PORTAMENTO ON PITCH PARAMETER
kporttime    linseg    0, (.01), giportamento, (1), giportamento
kcps        portk    gkcps, kporttime
;AMPLITUDE ENVELOPE
aenv    linenr    0.5, 0.01, 0.01, 0.01
;CREATE AN OSILLATOR
asig        oscili     aenv, kcps, gisine
;SEND SIGNAL TO OUTPUT
outs    asig, asig
endin

</CsInstruments>

<CsScore>
f 0 3600    ;DUMMY SCORE EVENT - REAL TIME PERFORMANCE FOR 1 HOUR
</CsScore>

</CsoundSynthesizer>
;-----------------------------------------------------------------------------------------------------------------------


You should still investigate Steven Yi's work on designing legato instruments.
I hope this helps,

Bye,
Iain


Date: Tue, 30 Jun 2009 17:49:53 -0400
From: jaikai10@...
To: csound@...
Subject: [Csnd] [csnd] Windcontroller Portamento with cpsmidib opcode

Hello! csounder.

It is a question about Portamento and cpsmidib.

This csd file is for woodwind instrument for Akai_Ewi and Wiimote.

This csd use cpsmidib with i-rate as note input and Linseg opcode as a portamento funtion, in this case I can't control pitchbend, when I am blowing Ewi(noteon).

Can you tell me what I miss, some hint or tips for using k-rate_cpsmidib and portamento together, Or another Idea for making portamento.

Thank you in advance.

<CsoundSynthesizer>
<CsOptions>
-odac           -iadc     -d
</CsOptions>
<CsInstruments>

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

giseed = .5
garev init 0
gicps init 440



gitable1 ftgen 1, 0, 4096, 10, 1
gitable2 ftgen 3, 0, 4097, -10, 2661, 87, 33, 18
gitable3 ftgen 4, 0, 4097, -10, 174, 12,
gitable4 ftgen 5, 0, 4097, -10, 314, 13,
gitable5 ftgen 6, 0, 16, -2, 40, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 10240


ctrlinit 1, 2, 0


instr 1 ; This is based on Flute1.csd from Dr. Boulanger's csound library.
             I modified it for Midi_Windcontoroller and Wiimote.

knoise chnget "breathnoise"
kvib chnget "vibrato"
kport chnget "port"
kfilt chnget "filt"
kfilt2 chnget "filt2"
iportim chnget "portamento"

icpsb init gicps

icps cpsmidib

gicps = icps

kport linseg icpsb, iportim, gicps


kbreath midictrl 2, 0, 1
gkbreath = kbreath


kbreath port kbreath, 0.02
kbreath linenr kbreath, 0.02, 0.05, 0.1


kvibdepth = abs(kvib*kport/100.)
kvibdepth randi kvibdepth*.1, 1000,giseed
giseed  =       frac(giseed*105.947)
kport    = kport + kvibdepth

iphase  = giseed

knfrq   = kport

kampr1  randi   .02*kbreath, 10, giseed                 
giseed  =       frac(giseed*105.947)
kamp1   =       kbreath + kampr1
kampr2  randi   .02*kbreath, 10, giseed                 
giseed  =       frac(giseed*105.947)
kamp2   =       kbreath + kampr2
kampr3  randi   .02*kbreath, 10, giseed              
giseed  =       frac(giseed*105.947)
kamp3   =       kbreath + kampr3

awt1    oscili  kamp1, kport, gitable3, iphase             
awt2    oscili  kamp2, kport, gitable4, iphase
awt3    oscili  kamp3, kport, gitable5, iphase


awnoise rand  20000, giseed
afiltn  butbp awnoise, knfrq,100

kbreath  = (knoise = 1 ? kbreath : 0)

asig    =       awt1 + awt2 + awt3+(afiltn*kbreath*.4)
asig    =       asig/3/4000
    

afilt   tone    asig, kfilt2
asig    balance afilt, asig

outs    asig, asig

garev   =       garev + asig
       


endin

instr 100
  
;printk 1, gkbreath                                                           

;krevenv linseg  2, p3, 2, 1.0, 0.1
arev   reverb  garev, 2.0;krevenv
;arev clip arev, 5              
                outs    arev*0.1, arev*0.1               
garev =         0                                               

endin




</CsInstruments>
<CsScore>
f 0 36000

i 100 0 3600



</CsScore>
</CsoundSynthesizer>


Windows Liveā„¢: Keep your life in sync. Check it out.

 « Return to Thread: [csnd] Windcontroller Portamento with cpsmidib opcode