Hi, I’m creating an instrument where I would like to use the pitch bend wheel to control the pitch of an automated sequence of pitches. Only trouble is there doesn’t seem to be an opcode that will read the raw pitch bend data without that opcode being inside an active midi event. I can read the controller data without having to have it within a midi event, but why not pitch bend?
Is there a way to create a midi event from within Csound? If I could create a midi event instance from Csound, I could have that read the pitch wheel and then i can pipe the data where I need it to be.
Hi Mike,
try midiin . It has four outputs, one being kstatus, which marks the kind of event being read, which includes pitchbend.
kstatus, kchannel, kdata1, kkdata2 midiin
if (kstatus == 224) then
; do your pitchbend reading from data1 and data2
endif
Damn...! Jeanette got her answer in while I was playing!! (:-))
I was going to say just about the same, except I mocked up
this little instrument that seems to work just fine:
Thank you, Jeanette and Pete. Just seems so many opcodes do the same thing
that I didn't think about going about it with a different approach!
midiin is worth remembering because it can be rather useful, as it takes 'raw MIDI'.
I was afraid at one time that it would "absorb" the event, but it doesn't. Any
instrument that's active when the event arrives will get a copy.
BTW there was a minor brain fade in my test code. The line should of course be:
gkBend = kd2 \- 64*128
I was somehow thinking of the 7-bit value range rather than the multiplier.
-- Pete --
> Damn...! Jeanette got her answer in while I was playing!! :\-)
> I was going to say just about the same, except I mocked up
> this little instrument that seems to work just fine:
>
> gkBend init 0
>
> alwayson "Bend"
>
> instr Bend
> kstat, kchn, kd1, kd2 midiin
> /* printf "Value=%d %d %d\n", kd2, kstat, kd2, kd1 */
> if kstat == 224 then
> gkBend = kd2 \- 64*127 ; ignoring LSB
> printf "bend=%d\n", absgkBend+1, gkBend
> endif
> endin
> -----------------------------------
>
> The '+1' offset in printf ensures it prints even when bend goes to zero.
>
> HTH
>
> -- Pete --
>
>
> > Hi Mike,
> > try midiin . It has four outputs, one being kstatus, which marks the
> kind
> > of event being read, which includes pitchbend.
> > kstatus, kchannel, kdata1, kkdata2 midiin
> > if kstatus == 224 then
> > ; do your pitchbend reading from data1 and data2
> > endif
> >
> > HTH.
> >
> > Best wishes,
> >
> > Jeanette
> >
> > --
> > * Website: http://juliencoder.de - for summer is a state of sound
> > * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
> > * Audiobombs: Jeanette C.
> > * GitHub: jeanette-c · GitHub
> >
> > Cinderella's got to go <3
> > Britney Spears
> >
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE
> > Send bugs reports to
> > Issues · csound/csound · GitHub
> > Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE
> Send bugs reports to
> Issues · csound/csound · GitHub
> Discussions of bugs and features can be posted here
>