Csound Csound-dev Csound-tekno Search About

[Csnd] Csound Keyboard in FLPanel

Date2019-12-09 06:24
Fromslobodanip
Subject[Csnd] Csound Keyboard in FLPanel
Hello Everyone! Currently, I'm working on a Csound project. On this, I'm
planning to do a keyboard in a FLpanel using FLkeyIn and I would like to
play different notes at the same time and I was wondering how I can do it.
Any suggestions appreciated. 

Thank you!





--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-12-10 17:51
FromRichard Knight
SubjectRe: [Csnd] Csound Keyboard in FLPanel

Hi

The first thing to note is that the number of simultaneous notes playable will depend on the rollover of the keyboard itself (ie number of keys it reports at once), which differs. Most will support at least three for certain keys (eg for ctrl-alt etc combinations) but sometimes certain groups of keys will not report simultaneously depending on how the keyboard switch matrix is designed. I've tested the following on mine and can get up to five simultaneous notes, but as little as two with certain key positions.

Basically FLkeyIn reports key down as a positive int and key down as a negative int. So one way would be to schedule/turnoff an instrument with a decimal instrument number which specifically identifies it as being associated with that key. Here's an example that I tested out, it just uses the raw ascii values as note numbers, so you'd need to do some kind of ascii key number to note number/frequency mapping:

 

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

sr = 44100
kr = 4410
nchnls = 2
0dbfs = 1


; basic panel
FLpanel "FLkeyIn", 400, 300, -1, -1, 5, 1, 1
FLpanelEnd
FLrun


; key sensing/action
instr 1
    ; get key
    kascii FLkeyIn
    kchanged changed kascii

    if (kchanged == 1) then

        ; is key down
        if (kascii > 0) then
            
            ; trigger event with instr num specific to the key
            event "i", 2+(kascii/1000), 0, 3600, kascii

        ; is key up
        elseif (kascii < 0) then

            ; turn off instr num specific to the key
            turnoff2 2+((0-kascii)/1000), 0, 1
        endif
    endif

endin


; basic tone
instr 2

    ; implement key ascii number to midi note number/etc mapping here
    ikey = p4
    icps = cpsmidinn(p4*0.7)
    a1 oscil 0.1, icps
    

    ; for key up release
    xtratim 0.5
    krelease init 0
    krelease release
    if (krelease == 1) then
        aout = a1 * line:k(1, 0.5, 0)
    else
        aout = a1
    endif

    outs aout, aout
endin


</CsInstruments>
<CsScore>
i 1 0 120
</CsScore>
</CsoundSynthesizer>

 

 

 

On Sun, 8 Dec 2019 23:24:50 -0700, slobodanip wrote:

Hello Everyone! Currently, I'm working on a Csound project. On this, I'm
planning to do a keyboard in a FLpanel using FLkeyIn and I would like to
play different notes at the same time and I was wondering how I can do it.
Any suggestions appreciated. 

Thank you!





--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here


Date2019-12-13 10:46
Fromslobodanip
SubjectRe: [Csnd] Csound Keyboard in FLPanel
Amazing, thank you for your ideas & example. Sorry for the late response.

Cheers,
Slobodan



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here