home *** CD-ROM | disk | FTP | other *** search
/ IRIS Development Option 6.2 / IRIS_Development_Option_6.2_814-0478-001.iso / dist / dmedia_dev.idb / usr / include / midiio.h.z / midiio.h
C/C++ Source or Header  |  1996-03-14  |  5KB  |  174 lines

  1. /*****************************************************************************
  2.  * Copyright 1991, 1992, 1993 Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  *
  17.  ****************************************************************************/
  18.  
  19. /*
  20.  * midiio.h -- definitions for MIDI I/O port and configurations.
  21.  */
  22. #ifndef __MIDIIO_H__
  23. #define __MIDIIO_H__
  24. #pragma once
  25. #include "midi.h"
  26. #include <sys/midi.h>
  27.  
  28. #define NMIDIS       8
  29.  
  30. #define MI_STAMPING        1
  31. #define MI_TIMEOUT         2
  32. #define MI_BLOCKING        3
  33. #define MI_ACTIVE          4
  34. #define MI_OUTPUTTIME      5
  35. #define MI_SYNTH           6
  36.  
  37. #define MINOSTAMP    0
  38. #define MIDELTASTAMP 1
  39. #define MIRELSTAMP   2
  40.  
  41. #define MIBLOCKING      1
  42. #define MINONBLOCKING   0
  43.  
  44. #define MISYNTH         1
  45. #define MINOSYNTH       0
  46.  
  47. #define SYSEXSZ      0x200000
  48.  
  49. #ifdef __cplusplus
  50. // MIDI I/O port, configuration
  51. //
  52.  
  53. class MIioport;
  54.  
  55. #endif        /* __cplusplus */
  56. #define STAMPED 1
  57.  
  58. #ifdef __cplusplus
  59.  
  60. // class MIconfig tells MIport how to open.  MIconfigs
  61. // should be saveable and commicable between applications.
  62.  
  63. class MIconfig {
  64.   public:
  65.     MIconfig();
  66.  
  67.     u_int stamp() { return _stamp; }
  68.     void setstamp(u_int stamping) { _stamp = stamping; }
  69.  
  70.     MItime *timeout() { return &_timeout; }
  71.     void settimeout(MItime t) { _timeout = t; }
  72.  
  73.     MItime *outputtime() { return &_outputtime; }
  74.     void setoutputtime(MItime t) { _outputtime = t; }
  75.     
  76.     u_int blocking() { return _blocking; }
  77.     void setblocking(u_int b) { _blocking = b; }
  78.  
  79.     u_int activesense() { return _active; }
  80.     void setactivesense(u_int a) { _active = a; }
  81.  
  82.     u_int synth() { return _synth; }
  83.     void setsynth(u_int a) { _synth = a; }
  84.  
  85.     void setparams(u_int *params, u_int length);
  86.     void getparams(u_int *params, u_int length);
  87.  
  88.   private:
  89.     u_int _stamp:2;
  90.     u_int _blocking:1;
  91.     u_int _active:1;
  92.     u_int _synth:1;
  93.     MItime _timeout;   // timeout, for select within MIport
  94.     MItime _outputtime;   // amout of time a program can get ahead of output
  95. };
  96.  
  97. class sysex_s {
  98.   public:
  99.     int device;   // device sysex is occuring on
  100.     MItime stamp; // timestamp of first chunk 
  101.     char *buf;    // sysex buffer
  102.     int idx;      // current index into buffer
  103. };
  104.  
  105. class MIport {
  106.   public:
  107.     MIport() { open_ = 0; }
  108.     virtual int open(const char *direction, MIconfig *config);
  109.     virtual int close();
  110.  
  111.     virtual int send(MIevent* buf, int count);
  112.     virtual int receive(MIevent* buf, int count);
  113.  
  114.     const MItime start() { return bishop_usher; }
  115.     void setstart(struct timeval *t);
  116.     
  117.     int getfd() { return fd; }
  118.  
  119.     void setconfig(MIconfig* config);  // change configuration on the fly!
  120.     MIconfig *config() { return conf; }
  121.  
  122.     MItime *timeleft();
  123.  
  124.   protected:
  125.     int stampinput(int on);
  126.     int fd;
  127.     int open_:1;
  128.     int stamp_:1;
  129.     MIconfig *conf;
  130.     MItime bishop_usher;
  131.     MItime lasttime, runtime;
  132.     MItime makestamp(struct timeval);
  133.  
  134.     
  135.     sysex_s sysbufs[NMIDIS];
  136.     sysex_s *findbuf(int device);
  137.     void clrbuf(sysex_s *buf);
  138. };
  139.  
  140. #else        /* __cplusplus */
  141.  
  142. typedef void MIport;
  143. typedef void MIconfig;
  144.  
  145. extern MIconfig *MInewconfig();
  146. extern void MIfreeconfig(MIconfig*);
  147. extern void MIsetparams(MIconfig *, u_int *, u_int);
  148. extern void MIgetparams(MIconfig *, u_int *, u_int);
  149.  
  150. extern void MICsetstamp(MIconfig*, u_int);
  151. extern int MICstamp(MIconfig*);
  152. extern int MICblocking(MIconfig*);
  153. extern int MICactivesense(MIconfig*);
  154. extern const MItime *MICtimeout(MIconfig*);
  155. extern void MICsettimeout(MIconfig*, MItime*);
  156. extern void MICsetblocking(MIconfig*, u_int);
  157. extern void MICsetactivesense(MIconfig*, u_int);
  158.  
  159. extern MIport* MInewport();
  160. extern void MIfreeport(MIport*);
  161.  
  162. extern int MIopen(MIport*, const char*, MIconfig*);
  163. extern void MIclose(MIport*);
  164.  
  165. extern int MIsend(MIport*, MIevent*, int);
  166. extern int MIreceive(MIport*, MIevent*, int);
  167. extern void MIsetstart(MIport*, struct timeval *);
  168. extern const MItime *MIstart(MIport*);
  169. extern MItime *MItimeleft(MIport*);
  170. extern int MIgetfd(MIport*);
  171.  
  172. #endif        /* __cplusplus */
  173. #endif         /* __MIDIIO_H__ */
  174.