00001 /* 00002 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 * MIDIFileReader C++ classes 00020 * This code is part of the CLAM library, but also usable stand-alone. 00021 * Maarten de Boer <mdeboer@iua.upf.es> 00022 * 00023 */ 00024 #ifndef __MIDIMessage__ 00025 #define __MIDIMessage__ 00026 00027 #include "MIDIDataTypes.hxx" 00028 00029 namespace MIDI 00030 { 00031 00032 class Message 00033 /* an ordinary MIDI message contains between 2 and 4 bytes. reserve 00034 ** space for the maximum, 4. */ 00035 { 00036 friend class Event; 00037 public: 00038 Message() 00039 { 00040 mData.mStatus = 0; 00041 mData.mData1 = 0; 00042 mData.mData2 = 0; 00043 mData.mData3 = 0; 00044 } 00045 00046 Message(Byte status,Byte data1,Byte data2 = 0,Byte data3 = 0) 00047 { 00048 mData.mStatus = status; 00049 mData.mData1 = data1; 00050 mData.mData2 = data2; 00051 mData.mData3 = data3; 00052 } 00053 00054 Byte operator [] (int i) const { return mVal[i]; } 00055 00056 void Update(Byte status = 0,Byte data1 = 0,Byte data2 = 0,Byte data3 = 0) 00057 { 00058 if(status) {mData.mStatus = status;} 00059 if(data1) {mData.mData1 = data1;} 00060 if(data2) {mData.mData2 = data2;} 00061 if(data3) {mData.mData3 = data3;} 00062 } 00063 00064 private: 00065 union 00066 { 00067 struct 00068 { 00069 Byte mStatus; 00070 Byte mData1; 00071 Byte mData2; 00072 Byte mData3; 00073 } mData; 00074 00075 Byte mVal[4]; 00076 }; 00077 }; 00078 00079 } 00080 00081 #endif 00082