Csound Csound-dev Csound-tekno Search About

[Csnd] Reading Midi Pitch Bend

Date2021-08-20 00:51
FromMike McGonagle
Subject[Csnd] Reading Midi Pitch Bend
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.

Mike
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

Date2021-08-20 07:30
From"Jeanette C."
SubjectRe: [Csnd] Reading Midi Pitch Bend
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: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Cinderella's got to go <3
(Britney Spears)

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

Date2021-08-20 07:44
FromPete Goodeve
SubjectRe: [Csnd] Reading Midi Pitch Bend
AttachmentsNone  

Date2021-08-20 08:17
FromMike McGonagle
SubjectRe: [Csnd] Reading Midi Pitch Bend
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!

Mike

On Fri, Aug 20, 2021 at 1:44 AM Pete Goodeve <pete.goodeve@computer.org> wrote:
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", abs(gkBend)+1, gkBend
        endif
endin
-----------------------------------

The '+1' offset in printf ensures it prints even when bend goes to zero.

HTH

        -- Pete --


On Fri, Aug 20, 2021 at 08:30:31AM +0200, Jeanette C. wrote:
> 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: https://www.audiobombs.com/users/jeanette_c
>  * GitHub: https://github.com/jeanette-c
>
> Cinderella's got to go <3
> (Britney Spears)
>
> 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
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

Date2021-08-20 19:54
FromPete Goodeve
SubjectRe: [Csnd] Reading Midi Pitch Bend
AttachmentsNone  

Date2021-08-21 21:29
FromMike McGonagle
SubjectRe: [Csnd] Reading Midi Pitch Bend
Thanks, Pete! I've actually finished with my midi input functions, now just got to tie those things to making the audio sing!

On Fri, Aug 20, 2021, 1:54 PM Pete Goodeve <pete.goodeve@computer.org> wrote:
On Fri, Aug 20, 2021 at 02:17:28AM -0500, Mike McGonagle wrote:
> 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 --

>
> On Fri, Aug 20, 2021 at 1:44 AM Pete Goodeve <pete.goodeve@computer.org>
> wrote:
>
> > 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", abs(gkBend)+1, gkBend
> >         endif
> > endin
> > -----------------------------------
> >
> > The '+1' offset in printf ensures it prints even when bend goes to zero.
> >
> > HTH
> >
> >         -- Pete --
> >
> >
> > On Fri, Aug 20, 2021 at 08:30:31AM +0200, Jeanette C. wrote:
> > > 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: https://www.audiobombs.com/users/jeanette_c
> > >  * GitHub: https://github.com/jeanette-c
> > >
> > > Cinderella's got to go <3
> > > (Britney Spears)
> > >
> > > 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
> >
>
> 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
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