turnon and turnoff2 errors
Date | 2016-03-01 08:03 |
From | Emmett Palaima |
Subject | turnon and turnoff2 errors |
Hi, I'm working on a project using csound on the raspberry pi, part of which involves using python to read the pi's GPIO pins as a control value, which I then use to turn on and off a bank of instruments. I set up the following code to test the idea out; its pretty basic, one instrument just reads a value off of a pin and uses that to write a variable to csound, which then gives the command to turn off one of the 2 remaining instruments and turn on the other when it sees the proper value. It seems like it should work but I'm getting some very strange results. Instruments 2 and 3 start as on when theres absolutely nothing in the code to make them do so, and pressing the buttons turns them off, but not on. No idea whats going on here, seems like it might be a bug in the turnon/turnoff opcodes. Any help would be greatly appreciated. Here is the code, Thanks! <CsoundSynthesizer> <CsOptions> -odac:hw:1,0 -iadc:hw:1,0 ;-b 512 ;-B 512 ;-+rtaudio= </CsOptions> <CsInstruments> sr = 48000 ksmps = 128 nchnls = 2 0dbfs = 1.0 turnon 1 pyinit instr 1 pyrun "a = 0.0" pyrun "b = 0.0" pyruni{{ import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(4, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP) }} pyrun{{ if(GPIO.input(4) ==1): print 'Button 1 Pressed' a = 2.0 b = 0.0 if(GPIO.input(24) ==0): print 'Button 2 Pressed' a = 0.0 b = 1.0 }} k1 pyeval "a" k2 pyeval "b" ;printk 1, k1 ;printk 1, k2 if (k1 == 2) then turnon 2 turnoff2 3, 0, .01 printk 0.1, k1 endif if (k2 == 1) then turnon 3 turnoff2 2, 0, .01 printk 0.1, k2 endif k1 = 0 k2 = 0 endin instr 2 kgain invalue "Gain" ain, ain2 ins arv, arv2 reverbsc ain, ain2, 0.9, 12000 out arv+ain, arv+ain endin
instr 3 kgain invalue "Gain" ain, ain2 ins klfo lfo 300, 5, 0 afilt lowpass2 ain, klfo+600, 10 out afilt, afilt endin
</CsInstruments> <CsScore>
</CsScore> </CsoundSynthesizer> |
Date | 2016-03-05 11:49 |
From | Hlöðver Sigurðsson |
Subject | Re: turnon and turnoff2 errors |
Where's the instrument number 3 you are refering to? 2016-03-01 9:03 GMT+01:00 Emmett Palaima <epalaima@berklee.edu>:
|