00001 /* 00002 * @(#)MidiFilter.h 3.00 8 June 1999 00003 * 00004 * Copyright (c) 2000 Pete Goodliffe (pete@cthree.org) 00005 * 00006 * This file is part of TSE3 - the Trax Sequencer Engine version 3.00. 00007 * 00008 * This library is modifiable/redistributable under the terms of the GNU 00009 * General Public License. 00010 * 00011 * You should have received a copy of the GNU General Public License along 00012 * with this program; see the file COPYING. If not, write to the Free Software 00013 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00014 * 00015 */ 00016 00017 #ifndef TSE3_EVENTFILTER_H 00018 #define TSE3_EVENTFILTER_H 00019 00020 #include "tse3/listen/MidiFilter.h" 00021 00022 #include "tse3/Notifier.h" 00023 #include "tse3/Filter.h" 00024 #include "tse3/Serializable.h" 00025 #include "tse3/Midi.h" 00026 00027 namespace TSE3 00028 { 00057 class MidiFilter : public Filter, 00058 public Serializable, 00059 public Notifier<MidiFilterListener> 00060 { 00061 public: 00062 00067 MidiFilter(); 00068 MidiFilter(const MidiFilter &); 00069 virtual ~MidiFilter(); 00070 MidiFilter &operator=(const MidiFilter &); 00071 00081 bool status() const { return _status; } 00082 00089 void setStatus(bool s); 00090 00101 bool channelFilter(int c) const { return _channelFilter & (1<<c); } 00102 00110 void setChannelFilter(int c, bool val); 00111 00121 int channel() const { return _channel; } 00122 00129 void setChannel(int c); 00130 00140 int port() const { return _port; } 00141 00148 void setPort(int p); 00149 00156 Clock offset() const { return _offset; } 00157 00164 void setOffset(Clock o); 00165 00175 int timeScale() const { return _timeScale; } 00176 00183 void setTimeScale(int t); 00184 00194 Clock quantise() const { return _quantise; } 00195 00202 void setQuantise(Clock q); 00203 00214 Clock minLength() const { return _minLength; } 00215 00222 void setMinLength(Clock ml); 00223 00234 Clock maxLength() const { return _maxLength; } 00235 00242 void setMaxLength(Clock ml); 00243 00253 int transpose() const { return _transpose; } 00254 00261 void setTranspose(int t); 00262 00274 int minVelocity() const { return _minVelocity; } 00275 00282 void setMinVelocity(int v); 00283 00295 int maxVelocity() const { return _maxVelocity; } 00296 00303 void setMaxVelocity(int v); 00304 00315 Clock velocityScale() const { return _velocityScale; } 00316 00323 void setVelocityScale(int v); 00324 00328 virtual MidiEvent filter(const MidiEvent &e) const; 00329 00333 virtual void save(std::ostream &o, int i) const; 00334 00338 virtual void load(std::istream &i, SerializableLoadInfo &info); 00339 00340 private: 00341 00342 void setChannelFilter(int c) { _channelFilter = c; } 00343 00344 bool _status; 00345 unsigned int _channelFilter; 00346 int _channel; 00347 int _port; 00348 Clock _offset; 00349 int _timeScale; 00350 Clock _quantise; 00351 Clock _minLength; 00352 Clock _maxLength; 00353 int _transpose; 00354 int _minVelocity; 00355 int _maxVelocity; 00356 int _velocityScale; 00357 }; 00358 } 00359 00360 #endif