Csound Csound-dev Csound-tekno Search About

[Csnd] Midi to OSC and polyphony

Date2019-11-16 08:34
Fromzappfinger
Subject[Csnd] Midi to OSC and polyphony
I am trying to convert midi to OSC. It works well with single notes, but not
with chords.
The receiving end (a Pyo Python program) could receive OSC lists, but how do
I generate these?
My idea is to store the first note in an array, and add subsequent notes
that arrive within a short time interval. Then send the array over OSC...

Here's my code so far:

; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

massign 0,12


instr 12
	mididefault   60, p3
	midinoteoncps p4, p5
	ikey	init p4
	iVel	init p5

	kDur        timeinsts          ; running total of duration of this note
	kRelease    release            ; sense when note is ending
	print ikey,iVel
	OSCsend     1, "localhost",8000, "/midi/non", "i", p4
	OSCsend     1, "localhost",8000, "/midi/amp", "i", iVel
	if kRelease=1 then            ; if note is about to end
	    printk2 kDur
	    OSCsend     1, "localhost",8000, "/midi/non", "i", p4
	    OSCsend     1, "localhost",8000, "/midi/amp", "i", 0
	endif
endin





--
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-11-16 16:17
FromOeyvind Brandtsegg
SubjectRe: [Csnd] Midi to OSC and polyphony
Hi,

You oculd simplify it by sending all the parameters in one OSC message, like:
OSCsend     1, "localhost",8000, "/midi/note", "ii", inote, ivel  
and you can keep on adding more values if you want.

There is a slight overhead on sending OSC messages, so for large amounts of data, you could also bundle them

Oeyvind

lør. 16. nov. 2019 kl. 09:20 skrev zappfinger <zappfinger@gmail.com>:
I am trying to convert midi to OSC. It works well with single notes, but not
with chords.
The receiving end (a Pyo Python program) could receive OSC lists, but how do
I generate these?
My idea is to store the first note in an array, and add subsequent notes
that arrive within a short time interval. Then send the array over OSC...

Here's my code so far:
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1

massign 0,12


instr 12
        mididefault   60, p3
        midinoteoncps p4, p5
        ikey    init p4
        iVel    init p5

        kDur        timeinsts          ; running total of duration of this note
        kRelease    release            ; sense when note is ending
        print ikey,iVel
        OSCsend     1, "localhost",8000, "/midi/non", "i", p4
        OSCsend     1, "localhost",8000, "/midi/amp", "i", iVel
        if kRelease=1 then            ; if note is about to end
            printk2 kDur
            OSCsend     1, "localhost",8000, "/midi/non", "i", p4
            OSCsend     1, "localhost",8000, "/midi/amp", "i", 0
        endif
endin

</CsInstruments>



--
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
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