Csound Csound-dev Csound-tekno Search About

[Csnd] Real Time Filter Issues

Date2014-08-23 02:24
FromMarshall West
Subject[Csnd] Real Time Filter Issues
Hello, 

I'm having trouble successfully implementing Csound's filter opcodes in the
MIDI-controlled instrument I've pasted below. I'm wanting a low-pass
resonant filter, and the few that I've tried work until I apply a sweep to
the cut off frequency, at which point the audio drops out entirely. I've
tried varying ksmps and my buffer values to no avail. I've written a version
of this instrument to read from a score and am very pleased with the sound.
Would love to get this to run via MIDI. Any advice would be greatly
appreciated as I'm relatively new to csound. 

Thanks in advance, 

Marshall 

sr = 44100 
ksmps = 256 
nchnls = 2 

gisquare  	ftgen    	1, 0, 4097, 10, 1, 0, 1/3, 0, 1/5, 0, 1/7, 0, 1/9 

                        ctrlinit 1,74,.30,71,0,73,0,72,.025,3,40,9,40,80,.1 

                                opcode Smooth,k,k ;Applies portamento to
incoming MIDI data 
kres	xin ;Opcode input 
kportTime linseg  	0,0.001,0.01 ; create a value that quickly ramps up to
0.01 
kres      	portk   kres,kportTime ; create a filtered version of kres 
                                xout	kres 
                                endop 
                                
                                opcode AD,k,ik ;Realtime Attack/decay
envelope 
iatt,kdec	xin ;Opcode inputs 
ktime init 0 ;Initialize  variables 
kv	init 0 
kt	init 0 
ikontrolBlock = 1/kr ;Calculate seconds per control sample 
ktime = ktime+ikontrolBlock ;Clock 
if ktime < iatt then ;Attack interval 
kt	= iatt 
kv = 1 
else ;Decay interval 
kt	= kdec 
kv	=	0 
endif 
kenv  	portk  	kv, kt ;Apply portamento to changes in volume 
             	xout  	kenv 
                               endop 

                        instr 1	
iamp	ampmidi	32768 
;Oscillators 1 and 2 
kosc1Tune	ctrl7	1,3,40,1500 
kosc1Tune	Smooth	kosc1Tune 
kosc2Tune	ctrl7	1,9,40,1500 
kosc2Tune	Smooth	kosc2Tune 
aosc1	poscil iamp*.5, kosc1Tune, 1 
aosc2	poscil iamp*.5, kosc2Tune, 1 
;Resonant lowpass filter 
kfco	ctrl7	1,74,30,4000 ;Cut-off frequency 
kfco	Smooth	kfco 
krez	ctrl7	1,71,0,1 ;Resonance 
krez	Smooth	krez 
;Filter envelope 
iatt	=	.01 
ksweep	ctrl7	1,73,0,1 ;Filter sweep amount 
ksweep	Smooth	ksweep 
ksweepDec	ctrl7	1,72,0.025,5 ;Filter envelope decay 
ksweepDec	Smooth	ksweepDec 
kfiltEnv	AD	iatt,ksweepDec 
kfiltEnv	=	kfiltEnv*iamp ;Envelope is velocity sensitive 
kfco	=	kfco+(kfiltEnv*ksweep*(4000-30)) 
asig	moogladder	aosc1+aosc2,kfco,krez 
kampDec	ctrl7	1,80,0.1,5 ;Amplitude envelope decay 
kampDec	Smooth	kampDec 
kampEnv	AD	iatt,kampDec 
                                out	asig*kampEnv 
                                endin 



--
View this message in context: http://csound.1045644.n5.nabble.com/Real-Time-Filter-Issues-tp5737082.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2014-08-23 06:22
FromKevin Welsh
SubjectRe: [Csnd] Real Time Filter Issues
I think I was having similar problems last night when working with an
instrument that uses moogvcf2.  I also tried moogvcf as a test, and
had the same result.  Strangely, I seemed to have more of a problem
when panning the sound as compared to keeping it static.  I didn't get
to experiment with it much more past that tho.

On Fri, Aug 22, 2014 at 9:24 PM, Marshall West  wrote:
> Hello,
>
> I'm having trouble successfully implementing Csound's filter opcodes in the
> MIDI-controlled instrument I've pasted below. I'm wanting a low-pass
> resonant filter, and the few that I've tried work until I apply a sweep to
> the cut off frequency, at which point the audio drops out entirely. I've
> tried varying ksmps and my buffer values to no avail. I've written a version
> of this instrument to read from a score and am very pleased with the sound.
> Would love to get this to run via MIDI. Any advice would be greatly
> appreciated as I'm relatively new to csound.
>
> Thanks in advance,
>
> Marshall
>
> sr = 44100
> ksmps = 256
> nchnls = 2
>
> gisquare        ftgen           1, 0, 4097, 10, 1, 0, 1/3, 0, 1/5, 0, 1/7, 0, 1/9
>
>                         ctrlinit 1,74,.30,71,0,73,0,72,.025,3,40,9,40,80,.1
>
>                                 opcode Smooth,k,k ;Applies portamento to
> incoming MIDI data
> kres    xin ;Opcode input
> kportTime linseg        0,0.001,0.01 ; create a value that quickly ramps up to
> 0.01
> kres            portk   kres,kportTime ; create a filtered version of kres
>                                 xout    kres
>                                 endop
>
>                                 opcode AD,k,ik ;Realtime Attack/decay
> envelope
> iatt,kdec       xin ;Opcode inputs
> ktime init 0 ;Initialize  variables
> kv      init 0
> kt      init 0
> ikontrolBlock = 1/kr ;Calculate seconds per control sample
> ktime = ktime+ikontrolBlock ;Clock
> if ktime < iatt then ;Attack interval
> kt      = iatt
> kv = 1
> else ;Decay interval
> kt      = kdec
> kv      =       0
> endif
> kenv    portk   kv, kt ;Apply portamento to changes in volume
>                 xout    kenv
>                                endop
>
>                         instr 1
> iamp    ampmidi 32768
> ;Oscillators 1 and 2
> kosc1Tune       ctrl7   1,3,40,1500
> kosc1Tune       Smooth  kosc1Tune
> kosc2Tune       ctrl7   1,9,40,1500
> kosc2Tune       Smooth  kosc2Tune
> aosc1   poscil iamp*.5, kosc1Tune, 1
> aosc2   poscil iamp*.5, kosc2Tune, 1
> ;Resonant lowpass filter
> kfco    ctrl7   1,74,30,4000 ;Cut-off frequency
> kfco    Smooth  kfco
> krez    ctrl7   1,71,0,1 ;Resonance
> krez    Smooth  krez
> ;Filter envelope
> iatt    =       .01
> ksweep  ctrl7   1,73,0,1 ;Filter sweep amount
> ksweep  Smooth  ksweep
> ksweepDec       ctrl7   1,72,0.025,5 ;Filter envelope decay
> ksweepDec       Smooth  ksweepDec
> kfiltEnv        AD      iatt,ksweepDec
> kfiltEnv        =       kfiltEnv*iamp ;Envelope is velocity sensitive
> kfco    =       kfco+(kfiltEnv*ksweep*(4000-30))
> asig    moogladder      aosc1+aosc2,kfco,krez
> kampDec ctrl7   1,80,0.1,5 ;Amplitude envelope decay
> kampDec Smooth  kampDec
> kampEnv AD      iatt,kampDec
>                                 out     asig*kampEnv
>                                 endin
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Real-Time-Filter-Issues-tp5737082.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>
>
>