| I had the need of one of these so I threw something together(see
below). It could do with some extra functionality, like different
playback patterns of the notes being held. It could also do with some
kind of sorting on the held notes array, but it seems to work Ok as a
proof of concept.
-+rtaudio=jack -odac -+rtmidi=virtual -M0 -b2048
sr = 44100
ksmps = 64
nchnls = 2
0dbfs=1
gkNumNotes init 0
gkNotes[] init 10
massign 1, 1
;instrument is always on and listens for incoming MIDI notes
instr 1000
;reset gkNumNotes to 0 when no notes are playing
if active:k(2)==0 then
gkNumNotes=0
endif
kstatus, kchan, kNoteNum, kVel midiin ;read in midi
ktrigger changed kstatus, kchan, kNoteNum, kVel ;trigger if midi data changes
if ktrigger=1 && kstatus!=0 then ;if status byte is non-zero...
; printks "status:%d%tchannel:%d%tdata1:%d%tdata2:%d%n",0,kstatus,kchan,kNoteNum,kVel
if kVel!=0 then
gkNotes[gkNumNotes] = kNoteNum
gkNumNotes = gkNumNotes+1
else
gkNumNotes = gkNumNotes-1
endif
endif
endin
;instrument is triggered by MIDI notes, and in turn
;triggers the sound synth, cycling through the held
;notes array. We only ever want one instance of this so
;we use turnoff to make sure.
instr 1
iInstances active 1
if iInstances>1 then
turnoff
endif
kIndex init 0
if metro(4)==1 then
event "i", 2, 0, 1, gkNotes[kIndex]
;printks "Note:%d Index:%d, NumNotes:%d\n", 0, gkNotes[kIndex],
kIndex, gkNumNotes
kIndex = kIndex
f1 0 1024 10 1
i1000 0 36000
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Csound-users mailing list
Csound-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-users
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |