[Csnd] can anybody help with a sensekey trigger instrument?
Date | 2011-06-24 23:06 |
From | Aaron Krister Johnson |
Subject | [Csnd] can anybody help with a sensekey trigger instrument? |
Hi all, I'm try to have an audio file fade in or fade out based on hitting ASCII keys on the keyboard (so I'm trying to use "sensekey". I'm doing "i" and "o" for fade-in and fade-out actions. Can someone tell me what's wrong with the below .csd setup that it's not working? I've verified that instrument 2 and 1 work well together alone, but the trick is to trigger instr 2 via instr 3, which is waiting for key-press events. I suppose one could do all this within one instrument, but I confess, my brain can never quite wrap itself around how to use reinit/rireturn within label blocks, and all the various goto/kgoto stuff. If someone can re-write this example under one instrument using them, and show that it works, maybe I could make sense of it. :) Any help would be appreciated! |
Date | 2011-06-24 23:47 |
From | Louis Cohen |
Subject | Re: [Csnd] can anybody help with a sensekey trigger instrument? |
Aaron, In my routine for sensing the keyboard I use this form: kKey, kkeydown sensekey I test for kkeydown == 1 before I decide that kKey has a useful value. If kkeydown != 1, I ignore any value that kKey might have. This works on MacOSX, could be different on other systems. -Lou Cohen On Jun 24, 2011, at 6:06 PM, Aaron Krister Johnson wrote: > Hi all, > > I'm try to have an audio file fade in or fade out based on hitting > ASCII keys on the keyboard (so I'm trying to use "sensekey". I'm doing > "i" and "o" for fade-in and fade-out actions. > > Can someone tell me what's wrong with the below .csd setup that it's > not working? I've verified that instrument 2 and 1 work well together > alone, but the trick is to trigger instr 2 via instr 3, which is > waiting for key-press events. > > I suppose one could do all this within one instrument, but I confess, > my brain can never quite wrap itself around how to use reinit/rireturn > within label blocks, and all the various goto/kgoto stuff. If someone > can re-write this example under one instrument using them, and show > that it works, maybe I could make sense of it. :) > > Any help would be appreciated! > > > |
Date | 2011-06-25 06:40 |
From | Tarmo Johannes |
Subject | Re: [Csnd] can anybody help with a sensekey trigger instrument? |
Hello, Aaron, like Louis, I have used also similar routin to read from the keybaoard: kkey, kpressed sensekey if (kpressed==1 && kkey>=48 && kkey<=53 ) then ; 0= ASCII 48, 5=ASCII53 jne kvolume=(kkey-48)/5 ; .. etc endif so try if it work sfor you: kkey, kpressed sensekey if (kpressed==1 && kkey==105) then event_i "i", 2, 0, -1, 1 elseif (kpressed==1 && kkey==111) then event_i "i", 2, 0, -1, 0 endif On Saturday 25 June 2011 01:47:02 Louis Cohen wrote: > Aaron, > > In my routine for sensing the keyboard I use this form: > > kKey, kkeydown sensekey > > I test for kkeydown == 1 before I decide that kKey has a useful value. > If kkeydown != 1, I ignore any value that kKey might have. > > This works on MacOSX, could be different on other systems. > > -Lou Cohen > > On Jun 24, 2011, at 6:06 PM, Aaron Krister Johnson wrote: > > > Hi all, > > > > I'm try to have an audio file fade in or fade out based on hitting > > ASCII keys on the keyboard (so I'm trying to use "sensekey". I'm doing > > "i" and "o" for fade-in and fade-out actions. > > > > Can someone tell me what's wrong with the below .csd setup that it's > > not working? I've verified that instrument 2 and 1 work well together > > alone, but the trick is to trigger instr 2 via instr 3, which is > > waiting for key-press events. > > > > I suppose one could do all this within one instrument, but I confess, > > my brain can never quite wrap itself around how to use reinit/rireturn > > within label blocks, and all the various goto/kgoto stuff. If someone > > can re-write this example under one instrument using them, and show > > that it works, maybe I could make sense of it. :) > > > > Any help would be appreciated! > > > > > > |
Date | 2011-06-25 08:23 |
From | Iain McCurdy |
Subject | RE: [Csnd] can anybody help with a sensekey trigger instrument? |
Hi Aaron, I've made a couple of changes and appended the changed code for instr 2 &3. Looking at your example the first thing I noticed in instr 3 is that you have an i-time only opcode (event_i) within a k-rate 'if' interrogation. I changed this to the k-rate compatible 'event'. Also the linsegrs in instr 2 didn't seem necessary as this instrument never gets turned off. I changed them to linsegs and instr 2 only stays active for as long a it needs for the ramp up or ramp down. It derives its ramp up or ramp down time from the p3 given to it by instr 3. The turnoff2s in instr 3 are there to cancel any ramp ups or downs in progress. Hope this helps, Iain instr 2 prints "hey" ;;;for testing istart = i(gkenv) if p4==1 goto ramp_up goto ramp_down ramp_up: gkenv linseg istart, p3, 1 goto ending ramp_down: gkenv linseg istart, p3, 0 goto ending ending: gkenv = gkenv ;;;dummy stuff endin instr 3 kkey sensekey if (kkey==105) then turnoff2 2,0,0 event "i", 2, 0, 3, 1 ;ramp up elseif (kkey==111) then turnoff2 2,0,0 event "i", 2, 0, 0.5, 0 ;ramp down endif endin > Date: Fri, 24 Jun 2011 17:06:53 -0500 > From: aaron@akjmusic.com > To: csound@lists.bath.ac.uk > Subject: [Csnd] can anybody help with a sensekey trigger instrument? > > Hi all, > > I'm try to have an audio file fade in or fade out based on hitting > ASCII keys on the keyboard (so I'm trying to use "sensekey". I'm doing > "i" and "o" for fade-in and fade-out actions. > > Can someone tell me what's wrong with the below .csd setup that it's > not working? I've verified that instrument 2 and 1 work well together > alone, but the trick is to trigger instr 2 via instr 3, which is > waiting for key-press events. > > I suppose one could do all this within one instrument, but I confess, > my brain can never quite wrap itself around how to use reinit/rireturn > within label blocks, and all the various goto/kgoto stuff. If someone > can re-write this example under one instrument using them, and show > that it works, maybe I could make sense of it. :) > > Any help would be appreciated! > > > <CsoundSynthesizer> > <CsOptions> > -+rtaudio=jack -odac:system:playback_ -iadc:system:capture_ > </CsOptions> > <CsInstruments> > sr = 44100 > ksmps = 128 > nchnls = 2 > 0dbfs = 1 > > gkenv init 0 > > instr 1 > a1, a2 diskin2 "prologue.wav", 1, 0 ;;;insert your own working wav file here > outs a1*gkenv, a2*gkenv > endin > > instr 2 > prints "hey" ;;;for testing > istart = i(gkenv) > if p4==1 goto ramp_up > goto ramp_down > ramp_up: > gkenv linsegr istart, 3, 1, 0, 1 > goto ending > ramp_down: > gkenv linsegr istart, .5, 0, 0, 0 > goto ending > > ending: > gkenv = gkenv ;;;dummy stuff > endin > > instr 3 > kkey sensekey > if (kkey==105) then > event_i "i", 2, 0, -1, 1 > elseif (kkey==111) then > event_i "i", 2, 0, -1, 0 > endif > endin > > </CsInstruments> > <CsScore> > i1 0 3600 > i3 0 3600 > e > </CsScore> > </CsoundSynthesizer> > > -- > Aaron Krister Johnson > http://www.akjmusic.com > http://www.untwelve.org > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" > |
Date | 2011-06-25 09:38 |
From | joachim heintz |
Subject | Re: [Csnd] can anybody help with a sensekey trigger instrument? |
hi aaron - just a hint that there are two udo's which might be useful for your situation: KeyOnce returns '1' if a certain ascii key has been pressed: http://www.csounds.com/udo/displayOpcode.php?opcode_id=133 KeyHold returns '1' as long as a certain key is pressed: http://www.csounds.com/udo/displayOpcode.php?opcode_id=134 hope this helps, too - joachim Am 25.06.2011 00:06, schrieb Aaron Krister Johnson: > Hi all, > > I'm try to have an audio file fade in or fade out based on hitting > ASCII keys on the keyboard (so I'm trying to use "sensekey". I'm doing > "i" and "o" for fade-in and fade-out actions. > > Can someone tell me what's wrong with the below .csd setup that it's > not working? I've verified that instrument 2 and 1 work well together > alone, but the trick is to trigger instr 2 via instr 3, which is > waiting for key-press events. > > I suppose one could do all this within one instrument, but I confess, > my brain can never quite wrap itself around how to use reinit/rireturn > within label blocks, and all the various goto/kgoto stuff. If someone > can re-write this example under one instrument using them, and show > that it works, maybe I could make sense of it. :) > > Any help would be appreciated! > > > |
Date | 2011-06-28 02:13 |
From | Aaron Krister Johnson |
Subject | Re: [Csnd] can anybody help with a sensekey trigger instrument? |
Hi Iain, all, I actually came up with a similar solution to yours on my own, Iain! What follows is the code. Uses 'turnoff2' and I figured out, after much frustration, that I needed 'event' instead of 'event_i'.... :) Thanks again. AKJ |
Date | 2011-06-28 04:03 |
From | andreas russo |
Subject | [Csnd] beat based envelope |
hi guys, I'm new to Csound and it's the first time I write here. I this is clear enough: I was wondering if there's a way to give beat values to an envelope rathare than time values. i.e. kenv linseg 8, .5, 4, .2, 6 where .5 and .2 (idur1 and idur2 that is) refer to the tempo statement in the score section rather than actual seconds. I hope this is clear enough, I'd really appreciate your help. andreas |
Date | 2011-06-28 12:18 |
From | Iain McCurdy |
Subject | RE: [Csnd] beat based envelope |
Hi Andreas, I was going to suggest something involving the 'tempoval' or 'miditempo' but giving them a quick test I'm not sure they're working properly (MAC / v5.13) - unless I'm misunderstanding what they are supposed to do. I haven't used them before. Below is a test example and the pasted output. The tempo is changing but tempoval and miditempo don't reflect this. Results are the same in real-time and deferred time. I. <CsoundSynthesizer> <CsOptions> -odac </CsOptions> <CsInstruments> instr 1 ktempo tempoval printk 1,ktempo endin instr 2 ktempo miditempo printk 1,ktempo endin </CsInstruments> <CsScore> t 0 60 8 120 16 60 i 1 0 8 i 2 8 8 </CsScore> </CsoundSynthesizer> new alloc for instr 1: i 1 time 0.00023: 60.00000 i 1 time 1.00000: 60.00000 i 1 time 2.00000: 60.00000 i 1 time 3.00000: 60.00000 i 1 time 4.00000: 60.00000 i 1 time 5.00000: 60.00000 i 1 time 6.00000: 60.00000 B 0.000 .. 8.000 T 6.000 TT 6.000 M: 0.0 new alloc for instr 2: i 2 time 6.00023: 60.00000 i 2 time 7.00000: 60.00000 i 2 time 8.00000: 60.00000 i 2 time 9.00000: 60.00000 i 2 time 10.00000: 60.00000 i 2 time 11.00000: 60.00000 i 2 time 12.00000: 60.00000 B 8.000 .. 16.000 T 12.000 TT 12.000 M: 0.0 Score finished in csoundPerform(). From: andreasrusso@gmail.com Date: Mon, 27 Jun 2011 23:03:31 -0400 To: csound@lists.bath.ac.uk Subject: [Csnd] beat based envelope hi guys, I'm new to Csound and it's the first time I write here. I this is clear enough: I was wondering if there's a way to give beat values to an envelope rathare than time values. i.e. kenv linseg 8, .5, 4, .2, 6 where .5 and .2 (idur1 and idur2 that is) refer to the tempo statement in the score section rather than actual seconds. I hope this is clear enough, I'd really appreciate your help. andreas |
Date | 2011-06-28 15:48 |
From | Aidan Collins |
Subject | Re: [Csnd] beat based envelope |
It might require a bit of focus when writing the durations of your note events, but if you make things relative to your p3 value they should change appropriately when you change the tempo. so if you have a note event: i1 0 4 which would be 4 beats at t 0 60 kenv linseg 0, p3*.25, 1, p3*.5, 1, p3*.25 should be 1 beat fading in, 2 beats open, 1 beat fading out which should stay the same when you change the tempo with a t statement, like t 0 120 The drawback being those relative beat values would change when you change note duration (p3). Aidan On Tue, Jun 28, 2011 at 7:18 AM, Iain McCurdy |
Date | 2011-06-28 16:08 |
From | Jacob Joaquin |
Subject | Re: [Csnd] beat based envelope |
There's a trick in which you can pass the tempo using p3. If you set p3 to 1, that one value will be converted into seconds-per-beat (SPB) before it reaches the instrument. Take the following score line for example: i 1 0 1 4 At 60 BPMs, p3 equals 1. At 120 BPMs, the value of p3 would be 0.5. What I do is use p4 as the duration; First I grab the SPB, then reset the value of p3: ispb = p3 ; Get the seconds-per-beat value p3 = ispb * p4 ; Reset the duration >From here, you can create envelope segment lengths. Here's an example script in which changing the tempo retains the envelope beats. |
Date | 2011-06-28 21:02 |
From | joachim heintz |
Subject | Re: [Csnd] beat based envelope |
looks like there is a bug in tempoval. i tried this: |
Date | 2011-06-29 01:12 |
From | Aidan Collins |
Subject | Re: [Csnd] beat based envelope |
Jacob, That trick is pretty amazing. I had always assumed that p3 was sacred from the score and had no idea you could redefine it like that without having unexpected results. Thanks for the tip! A Sent from my iPhone On Jun 28, 2011, at 11:08 AM, Jacob Joaquin |
Date | 2011-06-29 20:10 |
From | andreas russo |
Subject | Re: [Csnd] beat based envelope |
thanks for all the amazing suggestions. I'm gonna try em all tonight. Andreas On Jun 28, 2011, at 20:12, Aidan Collins |
Date | 2011-07-01 08:45 |
From | andreas russo |
Subject | [Csnd] stereo bug? |
I have been using Csound for less than two months, so I'm not sure if the topic has been treated already. I googled it and couldn't seem to find any mention. basically I'm experiencing a panning problem: every time I bounce the Csound project to an actual audio file, the stereo channels are reversed. what should come from the left channel comes out of the right one, and viceversa. I thought it might have been my unexperienced coding skills and the mess I created in the whole Csound file, but I've just run this test which I don't think could be more simple than this: <CsoundSynthesizer> <CsOptions> -odac </CsOptions> <CsInstruments> sr = 44100 kr = 4410 ksmps = 10 nchnls = 2 instr 1 awn noise 3000, .5 aL,aR pan2 awn, p4 outs aL,aR endin </CsInstruments> <CsScore> ;i strt dur pan ;••••••••••••••••••• i1 0 .5 1 i. 1 .5 0 </CsScore> </CsoundSynthesizer> when rendered in Csound, the first white noise comes from the right channel, and the second one comes from left. when recorded, it's exactly the opposite. if you want to listen to the result, I've uploaded the file here: http://www.sendspace.com/file/aaimaw it's not that much of a big deal for me, I could just reverse the cannels with audacity, but in case it's a common bug, it might help fixing it. just for the sake of debugging: • I'm running Csound in Snow Leopard on a MacBook Pro • the problem comes up both when using my Avid Mbox 3 interface and when using my built-in device hope this might help. andreas |
Date | 2011-07-01 09:00 |
From | Victor Lazzarini |
Subject | Re: [Csnd] stereo bug? |
Victor On 1 Jul 2011, at 08:45, andreas russo wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2011-07-01 09:14 |
From | andreas russo |
Subject | Re: [Csnd] stereo bug? |
that's what I thought, It'd be really weird. that's why I thought it might be some hardware/software combo causing this. can't really find another explaination. I'm running Csound 5.1.3.0 in Qutecsound 0.6.1. andreas On Jul 1, 2011, at 04:00, Victor Lazzarini wrote:
|
Date | 2011-07-01 09:54 |
From | Victor Lazzarini |
Subject | Re: [Csnd] stereo bug? |
You probably mean 5.13? In any case, that is the current version. How are you playing your soundfiles? Did you try just playing with say with quicktime? Victor On 1 Jul 2011, at 09:14, andreas russo wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2011-07-02 08:44 |
From | andreas russo |
Subject | Re: [Csnd] stereo bug? |
yes sorry, 5.13. current version anyway. I played the file in quicktime, itunes, vlc... and the spectrum in audacity clearly shows the stereo image is reversed. looks like it's some sort of problem with my csound playback setup. I'll try to figure it out. On Jul 1, 2011, at 04:54, Victor Lazzarini wrote:
|
Date | 2011-07-02 09:53 |
From | Victor Lazzarini |
Subject | Re: [Csnd] stereo bug? |
How are you 'bouncing'? Are you using -o soundfile_name ? On 2 Jul 2011, at 08:44, andreas russo wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2011-07-04 06:00 |
From | andreas russo |
Subject | Re: [Csnd] stereo bug? |
I'm sorry victor, but I'm not sure what you mean by "using -o soundfile_name". On Jul 2, 2011, at 04:53, Victor Lazzarini wrote:
|
Date | 2011-07-04 08:44 |
From | joachim heintz |
Subject | Re: [Csnd] stereo bug? |
if you need some information, you can have a look at http://en.flossmanuals.net/csound/ch014_e-rendering-to-file/ best - joachim Am 04.07.2011 07:00, schrieb andreas russo: > I'm sorry victor, but I'm not sure what you mean by "using -o > soundfile_name". > > On Jul 2, 2011, at 04:53, Victor Lazzarini wrote: > >> How are you 'bouncing'? Are you using -o soundfile_name ? >> >> >> On 2 Jul 2011, at 08:44, andreas russo wrote: >> >>> yes sorry, 5.13. current version anyway. >>> I played the file in quicktime, itunes, vlc... and the spectrum in >>> audacity clearly shows the stereo image is reversed. >>> >>> looks like it's some sort of problem with my csound playback setup. >>> I'll try to figure it out. >>> >>> On Jul 1, 2011, at 04:54, Victor Lazzarini wrote: >>> >>>> You probably mean 5.13? In any case, that is the current version. >>>> How are you playing your soundfiles? Did you try just playing with >>>> say with quicktime? >>>> >>>> Victor >>>> >>>> On 1 Jul 2011, at 09:14, andreas russo wrote: >>>> >>>>> that's what I thought, It'd be really weird. >>>>> that's why I thought it might be some hardware/software combo >>>>> causing this. >>>>> can't really find another explaination. >>>>> >>>>> I'm running Csound 5.1.3.0 in Qutecsound 0.6.1. >>>>> >>>>> >>>>> andreas >>>>> >>>>> On Jul 1, 2011, at 04:00, Victor Lazzarini wrote: >>>>> >>>>>> I can't reproduce this. Channels are correctly placed here. I'd be >>>>>> surprised if this was the case, I am sure someone else would have >>>>>> noticed. >>>>>> >>>>>> Victor >>>>>> >>>>>> >>>>>> On 1 Jul 2011, at 08:45, andreas russo wrote: >>>>>> >>>>>>> hey guys, >>>>>>> >>>>>>> I have been using Csound for less than two months, so I'm not >>>>>>> sure if the topic has been treated already. >>>>>>> I googled it and couldn't seem to find any mention. >>>>>>> >>>>>>> basically I'm experiencing a panning problem: every time I bounce >>>>>>> the Csound project to an actual audio file, the stereo channels >>>>>>> are reversed. >>>>>>> what should come from the left channel comes out of the right >>>>>>> one, and viceversa. >>>>>>> >>>>>>> I thought it might have been my unexperienced coding skills and >>>>>>> the mess I created in the whole Csound file, but I've just run >>>>>>> this test which I don't think could be more simple than this: >>>>>>> >>>>>>> /* |
Date | 2011-07-04 09:21 |
From | Victor Lazzarini |
Subject | Re: [Csnd] stereo bug? |
Ok, so you're probably using the 'recording button' in qutecsound, which will then make this bug a qutecsound one, there is no problem with Csound. Andres, Joachim, could you check it? Victor On 4 Jul 2011, at 06:00, andreas russo wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2011-07-04 19:15 |
From | joachim heintz |
Subject | Re: [Csnd] stereo bug? |
oh yes, that's indeed the problem. i will file it to the qcs bug tracker. thanks for notifying. joachim Am 04.07.2011 10:21, schrieb Victor Lazzarini: > Ok, so you're probably using the 'recording button' in qutecsound, which > will then make this bug a qutecsound one, there is no problem with > Csound. Andres, Joachim, could you check it? > > Victor > On 4 Jul 2011, at 06:00, andreas russo wrote: > >> I'm sorry victor, but I'm not sure what you mean by "using -o >> soundfile_name". >> >> On Jul 2, 2011, at 04:53, Victor Lazzarini wrote: >> >>> How are you 'bouncing'? Are you using -o soundfile_name ? >>> >>> >>> On 2 Jul 2011, at 08:44, andreas russo wrote: >>> >>>> yes sorry, 5.13. current version anyway. >>>> I played the file in quicktime, itunes, vlc... and the spectrum in >>>> audacity clearly shows the stereo image is reversed. >>>> >>>> looks like it's some sort of problem with my csound playback setup. >>>> I'll try to figure it out. >>>> >>>> On Jul 1, 2011, at 04:54, Victor Lazzarini wrote: >>>> >>>>> You probably mean 5.13? In any case, that is the current version. >>>>> How are you playing your soundfiles? Did you try just playing with >>>>> say with quicktime? >>>>> >>>>> Victor >>>>> >>>>> On 1 Jul 2011, at 09:14, andreas russo wrote: >>>>> >>>>>> that's what I thought, It'd be really weird. >>>>>> that's why I thought it might be some hardware/software combo >>>>>> causing this. >>>>>> can't really find another explaination. >>>>>> >>>>>> I'm running Csound 5.1.3.0 in Qutecsound 0.6.1. >>>>>> >>>>>> >>>>>> andreas >>>>>> >>>>>> On Jul 1, 2011, at 04:00, Victor Lazzarini wrote: >>>>>> >>>>>>> I can't reproduce this. Channels are correctly placed here. I'd >>>>>>> be surprised if this was the case, I am sure someone else would >>>>>>> have noticed. >>>>>>> >>>>>>> Victor >>>>>>> >>>>>>> >>>>>>> On 1 Jul 2011, at 08:45, andreas russo wrote: >>>>>>> >>>>>>>> hey guys, >>>>>>>> >>>>>>>> I have been using Csound for less than two months, so I'm not >>>>>>>> sure if the topic has been treated already. >>>>>>>> I googled it and couldn't seem to find any mention. >>>>>>>> >>>>>>>> basically I'm experiencing a panning problem: every time I >>>>>>>> bounce the Csound project to an actual audio file, the stereo >>>>>>>> channels are reversed. >>>>>>>> what should come from the left channel comes out of the right >>>>>>>> one, and viceversa. >>>>>>>> >>>>>>>> I thought it might have been my unexperienced coding skills and >>>>>>>> the mess I created in the whole Csound file, but I've just run >>>>>>>> this test which I don't think could be more simple than this: >>>>>>>> >>>>>>>> /* |