00001 /* 00002 * Copyright 1997, Brown University, Providence, RI. 00003 * 00004 * All Rights Reserved 00005 * 00006 * Permission to use, copy, modify, and distribute this software and its 00007 * documentation for any purpose other than its incorporation into a 00008 * commercial product is hereby granted without fee, provided that the 00009 * above copyright notice appear in all copies and that both that 00010 * copyright notice and this permission notice appear in supporting 00011 * documentation, and that the name of Brown University not be used in 00012 * advertising or publicity pertaining to distribution of the software 00013 * without specific, written prior permission. 00014 * 00015 * BROWN UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 00016 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY 00017 * PARTICULAR PURPOSE. IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE FOR 00018 * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00019 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00020 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00021 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00022 */ 00023 00024 #ifndef ICUBEX_H 00025 #define ICUBEX_H 00026 00027 #include "dev/polled.H" 00028 #include "dev/dev1d.H" 00029 00030 #ifdef WIN32 00031 #include "windows.h" 00032 #include "mmsystem.h" 00033 #else 00034 #include <unistd.h> 00035 #include <fcntl.h> 00036 #endif 00037 00038 00039 // This device is only polled when not in Windows. In Win32, 00040 // there is a midi callback event. 00041 00042 class DEVICubeX : public DEVice 00043 #ifndef WIN32 00044 , public DEVpolled 00045 #endif 00046 { 00047 public: 00048 00049 DEVICubeX(Cstr_ptr &devname); 00050 virtual ~DEVICubeX(); 00051 00052 void reportChannel(int channel, double data); 00053 00054 #ifndef WIN32 00055 // only a polled device when not in windows. 00056 void do_poll(); 00057 #else 00058 unsigned char SysXFlag; 00059 #endif 00060 00061 protected: 00062 00063 bool openMidi(); 00064 bool _midiSuccess; 00065 00066 DEVice_1d *_channels[32]; 00067 bool _askForMidiPort; 00068 00069 bool _activeChannels[32]; 00070 00071 #ifdef WIN32 00072 int _windev; 00073 int _woutdev; 00074 HMIDIIN _midiInPort; 00075 MIDIHDR _midiInHdr; 00076 #else 00077 str_ptr _lindev; 00078 str_ptr _loutdev; 00079 int _fdin; 00080 int _fdout; 00081 int _curpos; 00082 unsigned char _buffer[2048]; 00083 #endif 00084 00085 }; 00086 00087 #endif