Csound Csound-dev Csound-tekno Search About

[Cs-dev] repost of Justin Smith patch

Date2011-10-05 10:58
Fromjpff@cs.bath.ac.uk
Subject[Cs-dev] repost of Justin Smith patch
I initially sent this from the wrong email account, one not subscribed to
this list - so I guess it didn't go through before?

Attached are a set of patches that allow reading of 14 bit NRPN midi data,
reverse engineered from the NRPN messages sent by my BCF2000.

I ended up modifying the MCHNBLK data structure in csoundCore.h to add
nrpn related status bookkeeping (trying to follow the style of the
existing storage of control data), and similarly copying the operation of
the ctrl7 opcode and its usage of the control data array to make a new
"nrpnin" opcode.

I can try to copy the existing ctrl7 manual page and edit it as
appropriate to document nrpnin, but realistically in the near future I
will be more interested in using the new nrpn data I can now use to
control my synths than I will be in editing a help file :)

If someone would like to review / test my code and / or work on the
documentation I would be very appreciative, I will be testing the code for
the next few days myself (using it to make some music that is).

The naming of the diff files is a bit weird, but I hope you can puzzle out
the meaning -- let me know if you want the diffs in a particular format or
if you prefer I just send you the whole file so you can generate the diffs
yourselves or whathaveyou.

I will gladly hand over copyright to the owners of csound, but would
appreciate a little note indicating my contribution if this code ends up
being used in csound.



305,307d342
<     /** nrpn status */
<     int     nrpnlsb, nrpnmsb, nrpnnum, nrpnstate;
<     MYFLT   nrpnval[128];

239,240c239
<       if (n == NRPNMSB && chn->nrpnstate == 0) {
< /* first message out of the four messages making up 1 NRPN value */
---
>       if (n == NRPNMSB || n == RPNMSB) {
242d240
< chn->nrpnstate = 1;
244,257c242
<       else if (n == RPNMSB) {
<         chn->dpmsb = mep->dat2;
<       }
<       else if (n == NRPNLSB && chn->nrpnstate == 1) {
<         chn->dplsb = mep->dat2;
< chn->nrpnnum = mep->dat2; /* compare next 2 steps with this for error
<     detection at a future point? */
<         if (chn->dplsb == 127 && chn->dpmsb == 127)
<           chn->datenabl = 0;
<         else
<           chn->datenabl = 1;
< chn->nrpnstate = 2;
<       }
<       else if (n == RPNLSB) {
---
>       else if (n == NRPNLSB || n == RPNLSB) {
264,270d248
<       else if (chn->dpmsb == 0 && mep->dat1 == 38 && chn->nrpnstate == 3) {
< /* get the nrpnlsb (final part) of an NRPN parameter */
< /* messagelsb here should equal chn->nrpnnum */
< chn->nrpnlsb = mep->dat2;
< chn->nrpnval[chn->nrpnnum] = (chn->nrpnmsb<<7)+chn->nrpnlsb;
< chn->nrpnstate = 0;
<       }
275,285c253,256
<         if (msb == 0) {
<  if (lsb == 0) {
<    chn->pbensens = (MYFLT) mep->dat2;
<  } else if (mep->dat1 == 6 && chn->nrpnstate == 2) {
<    /* get the nrpnmsb of an NRPN parameter */
<    /* messagelsb here should equal chn->nrpnnum */
<    chn->nrpnmsb = mep->dat2;
<    chn->nrpnstate = 3;
<  }
< }
< else if (msb == 1) {            /* GS system PART PARAMS */
---
>         if (msb == 0 && lsb == 0) {
>           chn->pbensens = (MYFLT) mep->dat2;
>         }
>         else if (msb == 1) {            /* GS system PART PARAMS */
306,307c277,278
<                             Str("unknown drum param nos, msb %d lsb %d
d1 %d d2 %d\n"),
<                             (int) msb, (int) lsb, (int) mep->dat1, (int)
mep->dat2);
---
>                             Str("unknown drum param nos, msb %d lsb %d\n"),
>                             (int) msb, (int) lsb);
327c298
<       else {
---
>       else
329d299
<       }

346,380d345
< static int nrpninset(CSOUND *csound, NRPNIN *p)
< {
<     int32  ctlno;
<     int chan;
<     if (UNLIKELY((ctlno = (int32) *p->ictlno) < 0 || ctlno > 127)) {
<       return csound->InitError(csound, Str("illegal controller number"));
<     }
<     else if (UNLIKELY((chan=(int) *p->ichan-1) < 0 || chan > 15)) {
<       return csound->InitError(csound,
<                      Str("illegal midi channel")); /* gab-A2 (chan
number fix)*/
<     }
<     /*else if (midi_in_p_num < 0) midi_in_error("ctrl7");*/
<     else p->ctlno = ctlno;
<     if (*p->ifn > 0) {
<       if (UNLIKELY(((p->ftp = csound->FTFind(csound, p->ifn)) == NULL)))
<         p->flag = FALSE;  /* invalid ftable */
<       else p->flag= TRUE;
<     }
<     else p->flag= FALSE;
<     return OK;
< }
<
< static int nrpnin(CSOUND *csound, NRPNIN *p)
< {
<     MYFLT value =
<       (MYFLT) (csound->m_chnbp[(int) *p->ichan-1]->nrpnval[p->ctlno]) *
<       oneTOf14bit;
<     if (p->flag)  {             /* if valid ftable,use value as index   */
<       value =
<         *(p->ftp->ftable + (int32)(value*p->ftp->flen)); /* no
interpolation */
<     }
<     *p->r = value * (*p->imax - *p->imin) + *p->imin;   /* scales the
output */
<     return OK;
< }
<
645d609
< { "nrpnin", S(NRPNIN),  3,   "k", "iikko", (SUBR)nrpninset,
(SUBR)nrpnin, NULL },

67,74d66
<     MYFLT  *r, *ichan, *ictlno, *imin, *imax, *ifn;
<     int16 flag;
<     FUNC *ftp;
<     int32   ctlno;
< } NRPNIN;
<
< typedef struct {
<     OPDS   h;


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2011-10-05 11:03
FromVictor Lazzarini
SubjectRe: [Cs-dev] repost of Justin Smith patch
yes, I think this will have to wait until the next release. Is Justin  
here on this list? We'll need a manual page too.

Victor
On 5 Oct 2011, at 10:58, jpff@cs.bath.ac.uk wrote:

> I initially sent this from the wrong email account, one not  
> subscribed to
> this list - so I guess it didn't go through before?
>
> Attached are a set of patches that allow reading of 14 bit NRPN midi  
> data,
> reverse engineered from the NRPN messages sent by my BCF2000.
>
> I ended up modifying the MCHNBLK data structure in csoundCore.h to add
> nrpn related status bookkeeping (trying to follow the style of the
> existing storage of control data), and similarly copying the  
> operation of
> the ctrl7 opcode and its usage of the control data array to make a new
> "nrpnin" opcode.
>
> I can try to copy the existing ctrl7 manual page and edit it as
> appropriate to document nrpnin, but realistically in the near future I
> will be more interested in using the new nrpn data I can now use to
> control my synths than I will be in editing a help file :)
>
> If someone would like to review / test my code and / or work on the
> documentation I would be very appreciative, I will be testing the  
> code for
> the next few days myself (using it to make some music that is).
>
> The naming of the diff files is a bit weird, but I hope you can  
> puzzle out
> the meaning -- let me know if you want the diffs in a particular  
> format or
> if you prefer I just send you the whole file so you can generate the  
> diffs
> yourselves or whathaveyou.
>
> I will gladly hand over copyright to the owners of csound, but would
> appreciate a little note indicating my contribution if this code  
> ends up
> being used in csound.
>
>
>
> 305,307d342
> <     /** nrpn status */
> <     int     nrpnlsb, nrpnmsb, nrpnnum, nrpnstate;
> <     MYFLT   nrpnval[128];
>
> 239,240c239
> <       if (n == NRPNMSB && chn->nrpnstate == 0) {
> < /* first message out of the four messages making up 1 NRPN value */
> ---
>>      if (n == NRPNMSB || n == RPNMSB) {
> 242d240
> < chn->nrpnstate = 1;
> 244,257c242
> <       else if (n == RPNMSB) {
> <         chn->dpmsb = mep->dat2;
> <       }
> <       else if (n == NRPNLSB && chn->nrpnstate == 1) {
> <         chn->dplsb = mep->dat2;
> < chn->nrpnnum = mep->dat2; /* compare next 2 steps with this for  
> error
> <     detection at a future point? */
> <         if (chn->dplsb == 127 && chn->dpmsb == 127)
> <           chn->datenabl = 0;
> <         else
> <           chn->datenabl = 1;
> < chn->nrpnstate = 2;
> <       }
> <       else if (n == RPNLSB) {
> ---
>>      else if (n == NRPNLSB || n == RPNLSB) {
> 264,270d248
> <       else if (chn->dpmsb == 0 && mep->dat1 == 38 && chn- 
> >nrpnstate == 3) {
> < /* get the nrpnlsb (final part) of an NRPN parameter */
> < /* messagelsb here should equal chn->nrpnnum */
> < chn->nrpnlsb = mep->dat2;
> < chn->nrpnval[chn->nrpnnum] = (chn->nrpnmsb<<7)+chn->nrpnlsb;
> < chn->nrpnstate = 0;
> <       }
> 275,285c253,256
> <         if (msb == 0) {
> <  if (lsb == 0) {
> <    chn->pbensens = (MYFLT) mep->dat2;
> <  } else if (mep->dat1 == 6 && chn->nrpnstate == 2) {
> <    /* get the nrpnmsb of an NRPN parameter */
> <    /* messagelsb here should equal chn->nrpnnum */
> <    chn->nrpnmsb = mep->dat2;
> <    chn->nrpnstate = 3;
> <  }
> < }
> < else if (msb == 1) {            /* GS system PART PARAMS */
> ---
>>        if (msb == 0 && lsb == 0) {
>>          chn->pbensens = (MYFLT) mep->dat2;
>>        }
>>        else if (msb == 1) {            /* GS system PART PARAMS */
> 306,307c277,278
> <                             Str("unknown drum param nos, msb %d  
> lsb %d
> d1 %d d2 %d\n"),
> <                             (int) msb, (int) lsb, (int) mep->dat1,  
> (int)
> mep->dat2);
> ---
>>                            Str("unknown drum param nos, msb %d lsb  
>> %d\n"),
>>                            (int) msb, (int) lsb);
> 327c298
> <       else {
> ---
>>      else
> 329d299
> <       }
>
> 346,380d345
> < static int nrpninset(CSOUND *csound, NRPNIN *p)
> < {
> <     int32  ctlno;
> <     int chan;
> <     if (UNLIKELY((ctlno = (int32) *p->ictlno) < 0 || ctlno > 127)) {
> <       return csound->InitError(csound, Str("illegal controller  
> number"));
> <     }
> <     else if (UNLIKELY((chan=(int) *p->ichan-1) < 0 || chan > 15)) {
> <       return csound->InitError(csound,
> <                      Str("illegal midi channel")); /* gab-A2 (chan
> number fix)*/
> <     }
> <     /*else if (midi_in_p_num < 0) midi_in_error("ctrl7");*/
> <     else p->ctlno = ctlno;
> <     if (*p->ifn > 0) {
> <       if (UNLIKELY(((p->ftp = csound->FTFind(csound, p->ifn)) ==  
> NULL)))
> <         p->flag = FALSE;  /* invalid ftable */
> <       else p->flag= TRUE;
> <     }
> <     else p->flag= FALSE;
> <     return OK;
> < }
> <
> < static int nrpnin(CSOUND *csound, NRPNIN *p)
> < {
> <     MYFLT value =
> <       (MYFLT) (csound->m_chnbp[(int) *p->ichan-1]->nrpnval[p- 
> >ctlno]) *
> <       oneTOf14bit;
> <     if (p->flag)  {             /* if valid ftable,use value as  
> index   */
> <       value =
> <         *(p->ftp->ftable + (int32)(value*p->ftp->flen)); /* no
> interpolation */
> <     }
> <     *p->r = value * (*p->imax - *p->imin) + *p->imin;   /* scales  
> the
> output */
> <     return OK;
> < }
> <
> 645d609
> < { "nrpnin", S(NRPNIN),  3,   "k", "iikko", (SUBR)nrpninset,
> (SUBR)nrpnin, NULL },
>
> 67,74d66
> <     MYFLT  *r, *ichan, *ictlno, *imin, *imax, *ifn;
> <     int16 flag;
> <     FUNC *ftp;
> <     int32   ctlno;
> < } NRPNIN;
> <
> < typedef struct {
> <     OPDS   h;
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure  
> contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and  
> makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie




------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2011-10-05 22:53
FromJustin Glenn Smith
SubjectRe: [Cs-dev] repost of Justin Smith patch
I am on the list, but mostly just browsing subject lines at the moment, being generally busy between day job / an upcoming performance / my next album (the whole reason for this patch in the first place) / the new girlfriend.

I can answer any questions about the code, and may be able to eventually put together a manual page if there are no other volunteers.

As far as quality I have been using this patch consistently since I made it without issue (unlike my Linux joystick patch which is misbehaving in a few ways and I think needs a total overhaul). It may need to be modified for coding style(?). It wasn't possible to do the code as a plugin, because the lowest level midi parsing code in the csound core needs to be modified in order to access NRPN input (or so it seemed - I would be delighted to find out I am wrong about this).

Victor Lazzarini wrote:
> yes, I think this will have to wait until the next release. Is Justin  
> here on this list? We'll need a manual page too.
> 
> Victor
> On 5 Oct 2011, at 10:58, jpff@cs.bath.ac.uk wrote:
> 
>> I initially sent this from the wrong email account, one not  
>> subscribed to
>> this list - so I guess it didn't go through before?
>>
>> Attached are a set of patches that allow reading of 14 bit NRPN midi  
>> data,
>> reverse engineered from the NRPN messages sent by my BCF2000.
>>
>> I ended up modifying the MCHNBLK data structure in csoundCore.h to add
>> nrpn related status bookkeeping (trying to follow the style of the
>> existing storage of control data), and similarly copying the  
>> operation of
>> the ctrl7 opcode and its usage of the control data array to make a new
>> "nrpnin" opcode.
>>
>> I can try to copy the existing ctrl7 manual page and edit it as
>> appropriate to document nrpnin, but realistically in the near future I
>> will be more interested in using the new nrpn data I can now use to
>> control my synths than I will be in editing a help file :)
>>
>> If someone would like to review / test my code and / or work on the
>> documentation I would be very appreciative, I will be testing the  
>> code for
>> the next few days myself (using it to make some music that is).
>>
>> The naming of the diff files is a bit weird, but I hope you can  
>> puzzle out
>> the meaning -- let me know if you want the diffs in a particular  
>> format or
>> if you prefer I just send you the whole file so you can generate the  
>> diffs
>> yourselves or whathaveyou.
>>
>> I will gladly hand over copyright to the owners of csound, but would
>> appreciate a little note indicating my contribution if this code  
>> ends up
>> being used in csound.
>>
>>
>>
>> 305,307d342
>> <     /** nrpn status */
>> <     int     nrpnlsb, nrpnmsb, nrpnnum, nrpnstate;
>> <     MYFLT   nrpnval[128];
>>
>> 239,240c239
>> <       if (n == NRPNMSB && chn->nrpnstate == 0) {
>> < /* first message out of the four messages making up 1 NRPN value */
>> ---
>>>      if (n == NRPNMSB || n == RPNMSB) {
>> 242d240
>> < chn->nrpnstate = 1;
>> 244,257c242
>> <       else if (n == RPNMSB) {
>> <         chn->dpmsb = mep->dat2;
>> <       }
>> <       else if (n == NRPNLSB && chn->nrpnstate == 1) {
>> <         chn->dplsb = mep->dat2;
>> < chn->nrpnnum = mep->dat2; /* compare next 2 steps with this for  
>> error
>> <     detection at a future point? */
>> <         if (chn->dplsb == 127 && chn->dpmsb == 127)
>> <           chn->datenabl = 0;
>> <         else
>> <           chn->datenabl = 1;
>> < chn->nrpnstate = 2;
>> <       }
>> <       else if (n == RPNLSB) {
>> ---
>>>      else if (n == NRPNLSB || n == RPNLSB) {
>> 264,270d248
>> <       else if (chn->dpmsb == 0 && mep->dat1 == 38 && chn- 
>>> nrpnstate == 3) {
>> < /* get the nrpnlsb (final part) of an NRPN parameter */
>> < /* messagelsb here should equal chn->nrpnnum */
>> < chn->nrpnlsb = mep->dat2;
>> < chn->nrpnval[chn->nrpnnum] = (chn->nrpnmsb<<7)+chn->nrpnlsb;
>> < chn->nrpnstate = 0;
>> <       }
>> 275,285c253,256
>> <         if (msb == 0) {
>> <  if (lsb == 0) {
>> <    chn->pbensens = (MYFLT) mep->dat2;
>> <  } else if (mep->dat1 == 6 && chn->nrpnstate == 2) {
>> <    /* get the nrpnmsb of an NRPN parameter */
>> <    /* messagelsb here should equal chn->nrpnnum */
>> <    chn->nrpnmsb = mep->dat2;
>> <    chn->nrpnstate = 3;
>> <  }
>> < }
>> < else if (msb == 1) {            /* GS system PART PARAMS */
>> ---
>>>        if (msb == 0 && lsb == 0) {
>>>          chn->pbensens = (MYFLT) mep->dat2;
>>>        }
>>>        else if (msb == 1) {            /* GS system PART PARAMS */
>> 306,307c277,278
>> <                             Str("unknown drum param nos, msb %d  
>> lsb %d
>> d1 %d d2 %d\n"),
>> <                             (int) msb, (int) lsb, (int) mep->dat1,  
>> (int)
>> mep->dat2);
>> ---
>>>                            Str("unknown drum param nos, msb %d lsb  
>>> %d\n"),
>>>                            (int) msb, (int) lsb);
>> 327c298
>> <       else {
>> ---
>>>      else
>> 329d299
>> <       }
>>
>> 346,380d345
>> < static int nrpninset(CSOUND *csound, NRPNIN *p)
>> < {
>> <     int32  ctlno;
>> <     int chan;
>> <     if (UNLIKELY((ctlno = (int32) *p->ictlno) < 0 || ctlno > 127)) {
>> <       return csound->InitError(csound, Str("illegal controller  
>> number"));
>> <     }
>> <     else if (UNLIKELY((chan=(int) *p->ichan-1) < 0 || chan > 15)) {
>> <       return csound->InitError(csound,
>> <                      Str("illegal midi channel")); /* gab-A2 (chan
>> number fix)*/
>> <     }
>> <     /*else if (midi_in_p_num < 0) midi_in_error("ctrl7");*/
>> <     else p->ctlno = ctlno;
>> <     if (*p->ifn > 0) {
>> <       if (UNLIKELY(((p->ftp = csound->FTFind(csound, p->ifn)) ==  
>> NULL)))
>> <         p->flag = FALSE;  /* invalid ftable */
>> <       else p->flag= TRUE;
>> <     }
>> <     else p->flag= FALSE;
>> <     return OK;
>> < }
>> <
>> < static int nrpnin(CSOUND *csound, NRPNIN *p)
>> < {
>> <     MYFLT value =
>> <       (MYFLT) (csound->m_chnbp[(int) *p->ichan-1]->nrpnval[p- 
>>> ctlno]) *
>> <       oneTOf14bit;
>> <     if (p->flag)  {             /* if valid ftable,use value as  
>> index   */
>> <       value =
>> <         *(p->ftp->ftable + (int32)(value*p->ftp->flen)); /* no
>> interpolation */
>> <     }
>> <     *p->r = value * (*p->imax - *p->imin) + *p->imin;   /* scales  
>> the
>> output */
>> <     return OK;
>> < }
>> <
>> 645d609
>> < { "nrpnin", S(NRPNIN),  3,   "k", "iikko", (SUBR)nrpninset,
>> (SUBR)nrpnin, NULL },
>>
>> 67,74d66
>> <     MYFLT  *r, *ichan, *ictlno, *imin, *imax, *ifn;
>> <     int16 flag;
>> <     FUNC *ftp;
>> <     int32   ctlno;
>> < } NRPNIN;
>> <
>> < typedef struct {
>> <     OPDS   h;
>>
>>
>> ------------------------------------------------------------------------------
>> All the data continuously generated in your IT infrastructure  
>> contains a
>> definitive record of customers, application performance, security
>> threats, fraudulent activity and more. Splunk takes this data and  
>> makes
>> sense of it. Business sense. IT sense. Common sense.
>> http://p.sf.net/sfu/splunk-d2dcopy1
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> Dr Victor Lazzarini
> Senior Lecturer
> Dept. of Music
> NUI Maynooth Ireland
> tel.: +353 1 708 3545
> Victor dot Lazzarini AT nuim dot ie
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2011-10-07 17:00
FromAndres Cabrera
SubjectRe: [Cs-dev] repost of Justin Smith patch
Hi,

Would these opcodes be equivalent or similar to ctrl14, ctrl21,
midic14, and midic21?

Cheers,
Andres

On Wed, Oct 5, 2011 at 10:53 PM, Justin Glenn Smith
 wrote:
> I am on the list, but mostly just browsing subject lines at the moment, being generally busy between day job / an upcoming performance / my next album (the whole reason for this patch in the first place) / the new girlfriend.
>
> I can answer any questions about the code, and may be able to eventually put together a manual page if there are no other volunteers.
>
> As far as quality I have been using this patch consistently since I made it without issue (unlike my Linux joystick patch which is misbehaving in a few ways and I think needs a total overhaul). It may need to be modified for coding style(?). It wasn't possible to do the code as a plugin, because the lowest level midi parsing code in the csound core needs to be modified in order to access NRPN input (or so it seemed - I would be delighted to find out I am wrong about this).
>
> Victor Lazzarini wrote:
>> yes, I think this will have to wait until the next release. Is Justin
>> here on this list? We'll need a manual page too.
>>
>> Victor
>> On 5 Oct 2011, at 10:58, jpff@cs.bath.ac.uk wrote:
>>
>>> I initially sent this from the wrong email account, one not
>>> subscribed to
>>> this list - so I guess it didn't go through before?
>>>
>>> Attached are a set of patches that allow reading of 14 bit NRPN midi
>>> data,
>>> reverse engineered from the NRPN messages sent by my BCF2000.
>>>
>>> I ended up modifying the MCHNBLK data structure in csoundCore.h to add
>>> nrpn related status bookkeeping (trying to follow the style of the
>>> existing storage of control data), and similarly copying the
>>> operation of
>>> the ctrl7 opcode and its usage of the control data array to make a new
>>> "nrpnin" opcode.
>>>
>>> I can try to copy the existing ctrl7 manual page and edit it as
>>> appropriate to document nrpnin, but realistically in the near future I
>>> will be more interested in using the new nrpn data I can now use to
>>> control my synths than I will be in editing a help file :)
>>>
>>> If someone would like to review / test my code and / or work on the
>>> documentation I would be very appreciative, I will be testing the
>>> code for
>>> the next few days myself (using it to make some music that is).
>>>
>>> The naming of the diff files is a bit weird, but I hope you can
>>> puzzle out
>>> the meaning -- let me know if you want the diffs in a particular
>>> format or
>>> if you prefer I just send you the whole file so you can generate the
>>> diffs
>>> yourselves or whathaveyou.
>>>
>>> I will gladly hand over copyright to the owners of csound, but would
>>> appreciate a little note indicating my contribution if this code
>>> ends up
>>> being used in csound.
>>>
>>>
>>>
>>> 305,307d342
>>> <     /** nrpn status */
>>> <     int     nrpnlsb, nrpnmsb, nrpnnum, nrpnstate;
>>> <     MYFLT   nrpnval[128];
>>>
>>> 239,240c239
>>> <       if (n == NRPNMSB && chn->nrpnstate == 0) {
>>> < /* first message out of the four messages making up 1 NRPN value */
>>> ---
>>>>      if (n == NRPNMSB || n == RPNMSB) {
>>> 242d240
>>> < chn->nrpnstate = 1;
>>> 244,257c242
>>> <       else if (n == RPNMSB) {
>>> <         chn->dpmsb = mep->dat2;
>>> <       }
>>> <       else if (n == NRPNLSB && chn->nrpnstate == 1) {
>>> <         chn->dplsb = mep->dat2;
>>> < chn->nrpnnum = mep->dat2; /* compare next 2 steps with this for
>>> error
>>> <     detection at a future point? */
>>> <         if (chn->dplsb == 127 && chn->dpmsb == 127)
>>> <           chn->datenabl = 0;
>>> <         else
>>> <           chn->datenabl = 1;
>>> < chn->nrpnstate = 2;
>>> <       }
>>> <       else if (n == RPNLSB) {
>>> ---
>>>>      else if (n == NRPNLSB || n == RPNLSB) {
>>> 264,270d248
>>> <       else if (chn->dpmsb == 0 && mep->dat1 == 38 && chn-
>>>> nrpnstate == 3) {
>>> < /* get the nrpnlsb (final part) of an NRPN parameter */
>>> < /* messagelsb here should equal chn->nrpnnum */
>>> < chn->nrpnlsb = mep->dat2;
>>> < chn->nrpnval[chn->nrpnnum] = (chn->nrpnmsb<<7)+chn->nrpnlsb;
>>> < chn->nrpnstate = 0;
>>> <       }
>>> 275,285c253,256
>>> <         if (msb == 0) {
>>> <  if (lsb == 0) {
>>> <    chn->pbensens = (MYFLT) mep->dat2;
>>> <  } else if (mep->dat1 == 6 && chn->nrpnstate == 2) {
>>> <    /* get the nrpnmsb of an NRPN parameter */
>>> <    /* messagelsb here should equal chn->nrpnnum */
>>> <    chn->nrpnmsb = mep->dat2;
>>> <    chn->nrpnstate = 3;
>>> <  }
>>> < }
>>> < else if (msb == 1) {            /* GS system PART PARAMS */
>>> ---
>>>>        if (msb == 0 && lsb == 0) {
>>>>          chn->pbensens = (MYFLT) mep->dat2;
>>>>        }
>>>>        else if (msb == 1) {            /* GS system PART PARAMS */
>>> 306,307c277,278
>>> <                             Str("unknown drum param nos, msb %d
>>> lsb %d
>>> d1 %d d2 %d\n"),
>>> <                             (int) msb, (int) lsb, (int) mep->dat1,
>>> (int)
>>> mep->dat2);
>>> ---
>>>>                            Str("unknown drum param nos, msb %d lsb
>>>> %d\n"),
>>>>                            (int) msb, (int) lsb);
>>> 327c298
>>> <       else {
>>> ---
>>>>      else
>>> 329d299
>>> <       }
>>>
>>> 346,380d345
>>> < static int nrpninset(CSOUND *csound, NRPNIN *p)
>>> < {
>>> <     int32  ctlno;
>>> <     int chan;
>>> <     if (UNLIKELY((ctlno = (int32) *p->ictlno) < 0 || ctlno > 127)) {
>>> <       return csound->InitError(csound, Str("illegal controller
>>> number"));
>>> <     }
>>> <     else if (UNLIKELY((chan=(int) *p->ichan-1) < 0 || chan > 15)) {
>>> <       return csound->InitError(csound,
>>> <                      Str("illegal midi channel")); /* gab-A2 (chan
>>> number fix)*/
>>> <     }
>>> <     /*else if (midi_in_p_num < 0) midi_in_error("ctrl7");*/
>>> <     else p->ctlno = ctlno;
>>> <     if (*p->ifn > 0) {
>>> <       if (UNLIKELY(((p->ftp = csound->FTFind(csound, p->ifn)) ==
>>> NULL)))
>>> <         p->flag = FALSE;  /* invalid ftable */
>>> <       else p->flag= TRUE;
>>> <     }
>>> <     else p->flag= FALSE;
>>> <     return OK;
>>> < }
>>> <
>>> < static int nrpnin(CSOUND *csound, NRPNIN *p)
>>> < {
>>> <     MYFLT value =
>>> <       (MYFLT) (csound->m_chnbp[(int) *p->ichan-1]->nrpnval[p-
>>>> ctlno]) *
>>> <       oneTOf14bit;
>>> <     if (p->flag)  {             /* if valid ftable,use value as
>>> index   */
>>> <       value =
>>> <         *(p->ftp->ftable + (int32)(value*p->ftp->flen)); /* no
>>> interpolation */
>>> <     }
>>> <     *p->r = value * (*p->imax - *p->imin) + *p->imin;   /* scales
>>> the
>>> output */
>>> <     return OK;
>>> < }
>>> <
>>> 645d609
>>> < { "nrpnin", S(NRPNIN),  3,   "k", "iikko", (SUBR)nrpninset,
>>> (SUBR)nrpnin, NULL },
>>>
>>> 67,74d66
>>> <     MYFLT  *r, *ichan, *ictlno, *imin, *imax, *ifn;
>>> <     int16 flag;
>>> <     FUNC *ftp;
>>> <     int32   ctlno;
>>> < } NRPNIN;
>>> <
>>> < typedef struct {
>>> <     OPDS   h;
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> All the data continuously generated in your IT infrastructure
>>> contains a
>>> definitive record of customers, application performance, security
>>> threats, fraudulent activity and more. Splunk takes this data and
>>> makes
>>> sense of it. Business sense. IT sense. Common sense.
>>> http://p.sf.net/sfu/splunk-d2dcopy1
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> Dr Victor Lazzarini
>> Senior Lecturer
>> Dept. of Music
>> NUI Maynooth Ireland
>> tel.: +353 1 708 3545
>> Victor dot Lazzarini AT nuim dot ie
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> All the data continuously generated in your IT infrastructure contains a
>> definitive record of customers, application performance, security
>> threats, fraudulent activity and more. Splunk takes this data and makes
>> sense of it. Business sense. IT sense. Common sense.
>> http://p.sf.net/sfu/splunk-d2dcopy1
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https:/

Date2011-10-07 19:33
FromJustin Smith
SubjectRe: [Cs-dev] repost of Justin Smith patch
AttachmentsNone  None  

nrpn and nrpnin are identical looking and analogously-behaving for their datatype in orchestras (same argument order and argument type etc.).

Implementation-wise the output opcode is very similar, but the input opcode is different (NRPN is an odd fit for the way csound processes raw MIDI input data).

----- Original message -----
> Hi,
>
> Would these opcodes be equivalent or similar to ctrl14, ctrl21,
> midic14, and midic21?
>
> Cheers,
> Andres
>
> On Wed, Oct 5, 2011 at 10:53 PM, Justin Glenn Smith
> <noisesmith@gmail.com> wrote:
> > I am on the list, but mostly just browsing subject lines at the
> > moment, being generally busy between day job / an upcoming performance
> > / my next album (the whole reason for this patch in the first place) /
> > the new girlfriend.
> >
> > I can answer any questions about the code, and may be able to
> > eventually put together a manual page if there are no other volunteers.
> >
> > As far as quality I have been using this patch consistently since I
> > made it without issue (unlike my Linux joystick patch which is
> > misbehaving in a few ways and I think needs a total overhaul). It may
> > need to be modified for coding style(?). It wasn't possible to do the
> > code as a plugin, because the lowest level midi parsing code in the
> > csound core needs to be modified in order to access NRPN input (or so
> > it seemed - I would be delighted to find out I am wrong about this).
> >
> > Victor Lazzarini wrote:
> > > yes, I think this will have to wait until the next release. Is Justin
> > > here on this list? We'll need a manual page too.
> > >
> > > Victor
> > > On 5 Oct 2011, at 10:58, jpff@cs.bath.ac.uk wrote:
> > >
> > > > I initially sent this from the wrong email account, one not
> > > > subscribed to
> > > > this list - so I guess it didn't go through before?
> > > >
> > > > Attached are a set of patches that allow reading of 14 bit NRPN
> > > > midi data,
> > > > reverse engineered from the NRPN messages sent by my BCF2000.
> > > >
> > > > I ended up modifying the MCHNBLK data structure in csoundCore.h to
> > > > add nrpn related status bookkeeping (trying to follow the style of
> > > > the existing storage of control data), and similarly copying the
> > > > operation of
> > > > the ctrl7 opcode and its usage of the control data array to make a
> > > > new "nrpnin" opcode.
> > > >
> > > > I can try to copy the existing ctrl7 manual page and edit it as
> > > > appropriate to document nrpnin, but realistically in the near
> > > > future I will be more interested in using the new nrpn data I can
> > > > now use to control my synths than I will be in editing a help file
> > > > :)
> > > >
> > > > If someone would like to review / test my code and / or work on the
> > > > documentation I would be very appreciative, I will be testing the
> > > > code for
> > > > the next few days myself (using it to make some music that is).
> > > >
> > > > The naming of the diff files is a bit weird, but I hope you can
> > > > puzzle out
> > > > the meaning -- let me know if you want the diffs in a particular
> > > > format or
> > > > if you prefer I just send you the whole file so you can generate
> > > > the diffs
> > > > yourselves or whathaveyou.
> > > >
> > > > I will gladly hand over copyright to the owners of csound, but
> > > > would appreciate a little note indicating my contribution if this
> > > > code ends up
> > > > being used in csound.
> > > >
> > > >
> > > >
> > > > 305,307d342
> > > > <     /** nrpn status */
> > > > <     int     nrpnlsb, nrpnmsb, nrpnnum, nrpnstate;
> > > > <     MYFLT   nrpnval[128];
> > > >
> > > > 239,240c239
> > > > <       if (n == NRPNMSB && chn->nrpnstate == 0) {
> > > > < /* first message out of the four messages making up 1 NRPN value
> > > > */ ---
> > > > >      if (n == NRPNMSB || n == RPNMSB) {
> > > > 242d240
> > > > < chn->nrpnstate = 1;
> > > > 244,257c242
> > > > <       else if (n == RPNMSB) {
> > > > <         chn->dpmsb = mep->dat2;
> > > > <       }
> > > > <       else if (n == NRPNLSB && chn->nrpnstate == 1) {
> > > > <         chn->dplsb = mep->dat2;
> > > > < chn->nrpnnum = mep->dat2; /* compare next 2 steps with this for
> > > > error
> > > > <     detection at a future point? */
> > > > <         if (chn->dplsb == 127 && chn->dpmsb == 127)
> > > > <           chn->datenabl = 0;
> > > > <         else
> > > > <           chn->datenabl = 1;
> > > > < chn->nrpnstate = 2;
> > > > <       }
> > > > <       else if (n == RPNLSB) {
> > > > ---
> > > > >      else if (n == NRPNLSB || n == RPNLSB) {
> > > > 264,270d248
> > > > <       else if (chn->dpmsb == 0 && mep->dat1 == 38 && chn-
> > > > > nrpnstate == 3) {
> > > > < /* get the nrpnlsb (final part) of an NRPN parameter */
> > > > < /* messagelsb here should equal chn->nrpnnum */
> > > > < chn->nrpnlsb = mep->dat2;
> > > > < chn->nrpnval[chn->nrpnnum] = (chn->nrpnmsb<<7)+chn->nrpnlsb;
> > > > < chn->nrpnstate = 0;
> > > > <       }
> > > > 275,285c253,256
> > > > <         if (msb == 0) {
> > > > <  if (lsb == 0) {
> > > > <    chn->pbensens = (MYFLT) mep->dat2;
> > > > <  } else if (mep->dat1 == 6 && chn->nrpnstate == 2) {
> > > > <    /* get the nrpnmsb of an NRPN parameter */
> > > > <    /* messagelsb here should equal chn->nrpnnum */
> > > > <    chn->nrpnmsb = mep->dat2;
> > > > <    chn->nrpnstate = 3;
> > > > <  }
> > > > < }
> > > > < else if (msb == 1) {            /* GS system PART PARAMS */
> > > > ---
> > > > >        if (msb == 0 && lsb == 0) {
> > > > >          chn->pbensens = (MYFLT) mep->dat2;
> > > > >        }
> > > > >        else if (msb == 1) {            /* GS system PART PARAMS
> > > > > */
> > > > 306,307c277,278
> > > > <                             Str("unknown drum param nos, msb %d
> > > > lsb %d
> > > > d1 %d d2 %d\n"),
> > > > <                             (int) msb, (int) lsb, (int)
> > > > mep->dat1, (int)
> > > > mep->dat2);
> > > > ---
> > > > >                            Str("unknown drum param nos, msb %d
> > > > > lsb %d\n"),
> > > > >                            (int) msb, (int) lsb);
> > > > 327c298
> > > > <       else {
> > > > ---
> > > > >      else
> > > > 329d299
> > > > <       }
> > > >
> > > > 346,380d345
> > > > < static int nrpninset(CSOUND *csound, NRPNIN *p)
> > > > < {
> > > > <     int32  ctlno;
> > > > <     int chan;
> > > > <     if (UNLIKELY((ctlno = (int32) *p->ictlno) < 0 || ctlno >
> > > > 127)) { <       return csound->InitError(csound, Str("illegal
> > > > controller number"));
> > > > <     }
> > > > <     else if (UNLIKELY((chan=(int) *p->ichan-1) < 0 || chan >
> > > > 15)) { <       return csound->InitError(csound,
> > > > <                      Str("illegal midi channel")); /* gab-A2
> > > > (chan number fix)*/
> > > > <     }
> > > > <     /*else if (midi_in_p_num < 0) midi_in_error("ctrl7");*/
> > > > <     else p->ctlno = ctlno;
> > > > <     if (*p->ifn > 0) {
> > > > <       if (UNLIKELY(((p->ftp = csound->FTFind(csound, p->ifn)) ==
> > > > NULL)))
> > > > <         p->flag = FALSE;  /* invalid ftable */
> > > > <       else p->flag= TRUE;
> > > > <     }
> > > > <     else p->flag= FALSE;
> > > > <     return OK;
> > > > < }
> > > > <
> > > > < static int nrpnin(CSOUND *csound, NRPNIN *p)
> > > > < {
> > > > <     MYFLT value =
> > > > <       (MYFLT) (csound->m_chnbp[(int) *p->ichan-1]->nrpnval[p-
> > > > > ctlno]) *
> > > > <       oneTOf14bit;
> > > > <     if (p->flag)  {             /* if valid ftable,use value as
> > > > index   */
> > > > <       value =
> > > > <         *(p->ftp->ftable + (int32)(value*p->ftp->flen)); /* no
> > > > interpolation */
> > > > <     }
> > > > <     *p->r = value * (*p->imax - *p->imin) + *p->imin;   /* scales
> > > > the
> > > > output */
> > > > <     return OK;
> > > > < }
> > > > <
> > > > 645d609
> > > > < { "nrpnin", S(NRPNIN),  3,   "k", "iikko", (SUBR)nrpninset,
> > > > (SUBR)nrpnin, NULL },
> > > >
> > > > 67,74d66
> > > > <     MYFLT  *r, *ichan, *ictlno, *imin, *imax, *ifn;
> > > > <     int16 flag;
> > > > <     FUNC *ftp;
> > > > <     int32   ctlno;
> > > > < } NRPNIN;
> > > > <
> > > > < typedef struct {
> > > > <     OPDS   h;
> > > >
> > > >
> > > > ------------------------------------------------------------------------------
> > > > All the data continuously generated in your IT infrastructure
> > > > contains a
> > > > definitive record of customers, application performance, security
> > > > threats, fraudulent activity and more. Splunk takes this data and
> > > > makes
> > > > sense of it. Business sense. IT sense. Common sense.
> > > > http://p.sf.net/sfu/splunk-d2dcopy1
> > > > _______________________________________________
> > > > Csound-devel mailing list
> > > > Csound-devel@lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> > >
> > > Dr Victor Lazzarini
> > > Senior Lecturer
> > > Dept. of Music
> > > NUI Maynooth Ireland
> > > tel.: +353 1 708 3545
> > > Victor dot Lazzarini AT nuim dot ie
> > >
> > >
> > >
> > >
> > > ------------------------------------------------------------------------------
> > > All the data continuously generated in your IT infrastructure
> > > contains a definitive record of customers, application performance,
> > > security threats, fraudulent activity and more. Splunk takes this
> > > data and makes sense of it. Business sense. IT sense. Common sense.
> > > http://p.sf.net/sfu/splunk-d2dcopy1
> > > _______________________________________________
> > > Csound-devel mailing list
> > > Csound-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> > >
> >
> >
> > ------------------------------------------------------------------------------
> > All the data continuously generated in your IT infrastructure contains
> > a definitive record of customers, application performance, security
> > threats, fraudulent activity and more. Splunk takes this data and makes
> > sense of it. Business sense. IT sense. Common sense.
> > http://p.sf.net/sfu/splunk-d2dcopy1
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously
> valuable. Why? It contains a definitive record of application
> performance, security threats, fraudulent activity, and more. Splunk
> takes this data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2dcopy2
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel