home *** CD-ROM | disk | FTP | other *** search
/ Phoenix Heaven Sunny 2 / APPARE2.BIN / oh_towns / taropyon / he386 / ccisrc / gmega.c < prev    next >
Text File  |  1995-06-20  |  6KB  |  229 lines

  1. /*************************************************************************
  2. *    for KAWAI GMega
  3. *************************************************************************/
  4.  
  5. int        GMegaUnitRcvCh = 0x00;
  6.  
  7. int        GMega_macroInit( char *sqr )
  8. {
  9.     GMegaUnitRcvCh = 0x00;
  10.     /*                    マクロ名                CCI 関数名    */
  11.     MMac_extDefine( sqr, "GMega_setUnitRcvCh"  , "GMega_setUnitRcvCh" , MMAC_ATT_EXT, NULL );
  12.     MMac_extDefine( sqr, "exGMega_system"      , "exGMega_system"     , MMAC_ATT_EXT, NULL );
  13.     MMac_extDefine( sqr, "exGMega_section"     , "exGMega_section"    , MMAC_ATT_EXT, NULL );
  14.     MMac_extDefine( sqr, "exGMega_single"      , "exGMega_single"     , MMAC_ATT_EXT, NULL );
  15.     MMac_extDefine( sqr, "exGMega_percussion"  , "exGMega_percussion" , MMAC_ATT_EXT, NULL );
  16.  
  17.     MMac_extDefine( sqr, "_GMEGA_MACRO_DEFINED", "" , MMAC_ATT_NORMAL , NULL );
  18.  
  19.     return (NORMAL);
  20. }
  21.  
  22. /*************************************************************************
  23. *    $GMega_setUnitRcvCh(ch)
  24. *    ch    1~16
  25. *************************************************************************/
  26.  
  27. int        GMega_setUnitRcvCh( char *sqr, size_t bufSiz, char *buf, int argc, char **argv )
  28. {
  29.     int        ch;
  30.  
  31.     if ( argc < 1 )
  32.     {
  33. _ERR:    MM_setErrMsg(sqr,"GMega system exclusive error! (unit receive channel)");
  34.         return (ERR);
  35.     }
  36.     ch = atoi(argv[0]) - 1;
  37.     if ( ch < 0 || ch > 15 )
  38.         goto _ERR;
  39.     GMegaUnitRcvCh = ch;
  40.     return (0);
  41. }
  42.  
  43. /*************************************************************************
  44. *    exGMega_system(no,data)    :    system function
  45. *        no        … function no.    (dec)
  46. *        data    … data            (dec)
  47. *************************************************************************/
  48.  
  49. int        exGMega_system( char *sqr, size_t bufSiz, char *buf, int argc, char **argv )
  50. {
  51.     char        excl[32], tmp[256];
  52.     unsigned    siz;
  53.     int            no, dat;
  54.  
  55.     if ( argc < 2 )
  56.     {
  57.         MM_setErrMsg(sqr,"GMega system exclusive error! (system function)");
  58.         return (ERR);
  59.     }
  60.     no  = atoi(argv[0]);
  61.     dat = atoi(argv[1]);
  62.     excl[ 0] = 0xF0;
  63.     excl[ 1] = 0x40;
  64.     excl[ 2] = GMegaUnitRcvCh;
  65.     excl[ 3] = 0x10;
  66.     excl[ 4] = 0x00;
  67.     excl[ 5] = 0x08;
  68.     excl[ 6] = 0x00;
  69.     excl[ 7] = no;
  70.     excl[ 8] = 0x00;
  71.     excl[ 9] = (dat>>4) & 0x0F;
  72.     excl[10] =  dat     & 0x0F;
  73.     excl[11] = 0xF7;
  74.     siz = 12;
  75.     siz = make_sysEx(tmp, siz, excl );
  76.     if ( siz >= bufSiz )
  77.     {
  78.         MM_setErrMsg(sqr,_OUT_OF_STRING_SPACE);
  79.         return (ERR);
  80.     }
  81.     memcpy( buf, tmp, siz );
  82.     return (siz);
  83. }
  84.  
  85.  
  86. /*************************************************************************
  87. *    exGMega_section(no,sec,data)    :    section function
  88. *        no        … function no.    (dec)
  89. *        sec        … section no    (dec.1~32)
  90. *        data    … data            (dec)
  91. *************************************************************************/
  92.  
  93. int        exGMega_section( char *sqr, size_t bufSiz, char *buf, int argc, char **argv )
  94. {
  95.     char        excl[32], tmp[256];
  96.     unsigned    siz;
  97.     int            no, sec, dat;
  98.  
  99.     if ( argc < 3 )
  100.     {
  101. _ERR:
  102.         MM_setErrMsg(sqr,"GMega system exclusive error! (section function)");
  103.         return (ERR);
  104.     }
  105.     no  = atoi(argv[0]);
  106.     sec = atoi(argv[1]) - 1;
  107.     dat = atoi(argv[2]);
  108.     if ( sec < 0 || sec > 31 )
  109.         goto _ERR;
  110.     excl[ 0] = 0xF0;
  111.     excl[ 1] = 0x40;
  112.     excl[ 2] = GMegaUnitRcvCh;
  113.     excl[ 3] = 0x10;
  114.     excl[ 4] = 0x00;
  115.     excl[ 5] = 0x08;
  116.     excl[ 6] = 0x01;
  117.     excl[ 7] = no;
  118.     excl[ 8] = sec;
  119.     excl[ 9] = (dat>>4) & 0x0F;
  120.     excl[10] =  dat     & 0x0F;
  121.     excl[11] = 0xF7;
  122.     siz = 12;
  123.     siz = make_sysEx(tmp, siz, excl );
  124.     if ( siz >= bufSiz )
  125.     {
  126.         MM_setErrMsg(sqr,_OUT_OF_STRING_SPACE);
  127.         return (ERR);
  128.     }
  129.     memcpy( buf, tmp, siz );
  130.     return (siz);
  131. }
  132.  
  133. /*************************************************************************
  134. *    exGMega_single(no,sub,data1,data2)    :    single function
  135. *        no        … function no.    (dec)
  136. *        sub        … single no.    (dec 1~128)
  137. *        data1    … data1        (dec)
  138. *        data2    … data2        (dec)
  139. *************************************************************************/
  140.  
  141. int        exGMega_single( char *sqr, size_t bufSiz, char *buf, int argc, char **argv )
  142. {
  143.     char        excl[32], tmp[256];
  144.     unsigned    siz;
  145.     int            no, sub, dat1, dat2;
  146.  
  147.     if ( argc < 4 )
  148.     {
  149. _ERR:
  150.         MM_setErrMsg(sqr,"GMega system exclusive error! (single function)");
  151.         return (ERR);
  152.     }
  153.     no   = atoi(argv[0]);
  154.     sub  = atoi(argv[1]) - 1;
  155.     dat1 = atoi(argv[2]);
  156.     dat2 = atoi(argv[3]);
  157.     if ( sub < 0 || sub > 127 )
  158.         goto _ERR;
  159.     excl[ 0] = 0xF0;
  160.     excl[ 1] = 0x40;
  161.     excl[ 2] = GMegaUnitRcvCh;
  162.     excl[ 3] = 0x10;
  163.     excl[ 4] = 0x00;
  164.     excl[ 5] = 0x08;
  165.     excl[ 6] = 0x03;
  166.     excl[ 7] = no;
  167.     excl[ 8] = sub;
  168.     excl[ 9] = (dat1>>4) & 0x0F;
  169.     excl[10] =  dat1     & 0x0F;
  170.     excl[11] = (dat2>>4) & 0x0F;
  171.     excl[12] =  dat2     & 0x0F;
  172.     excl[13] = 0xF7;
  173.     siz = 14;
  174.     siz = make_sysEx(tmp, siz, excl );
  175.     if ( siz >= bufSiz )
  176.     {
  177.         MM_setErrMsg(sqr,_OUT_OF_STRING_SPACE);
  178.         return (ERR);
  179.     }
  180.     memcpy( buf, tmp, siz );
  181.     return (siz);
  182. }
  183.  
  184. /*************************************************************************
  185. *    exGMega_percussion(no,sub,data)
  186. *        no        … function no.        (dec)
  187. *        sub        … percussion no.    (dec 0~127)
  188. *        data    … data                (dec)
  189. *************************************************************************/
  190.  
  191. int        exGMega_percussion( char *sqr, size_t bufSiz, char *buf, int argc, char **argv )
  192. {
  193.     char        excl[32], tmp[256];
  194.     unsigned    siz;
  195.     int            no, sub, dat;
  196.  
  197.     if ( argc < 3 )
  198.     {
  199. _ERR:
  200.         MM_setErrMsg(sqr,"GMega system exclusive error! (percussion function)");
  201.         return (ERR);
  202.     }
  203.     no  = atoi(argv[0]);
  204.     sub = atoi(argv[1]);
  205.     dat = atoi(argv[2]);
  206.  
  207.     excl[ 0] = 0xF0;
  208.     excl[ 1] = 0x40;
  209.     excl[ 2] = GMegaUnitRcvCh;
  210.     excl[ 3] = 0x10;
  211.     excl[ 4] = 0x00;
  212.     excl[ 5] = 0x08;
  213.     excl[ 6] = 0x04;
  214.     excl[ 7] = no;
  215.     excl[ 8] = sub;
  216.     excl[ 9] = (dat>>4) & 0x0F;
  217.     excl[10] =  dat     & 0x0F;
  218.     excl[11] = 0xF7;
  219.     siz = 12;
  220.     siz = make_sysEx(tmp, siz, excl );
  221.     if ( siz >= bufSiz )
  222.     {
  223.         MM_setErrMsg(sqr,_OUT_OF_STRING_SPACE);
  224.         return (ERR);
  225.     }
  226.     memcpy( buf, tmp, siz );
  227.     return (siz);
  228. }
  229.