00001 /* 00002 * @(#)Metronome.h 3.00 25 May 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_METRONOME_H 00018 #define TSE3_METRONOME_H 00019 00020 #include "tse3/listen/Metronome.h" 00021 00022 #include "tse3/Notifier.h" 00023 #include "tse3/Playable.h" 00024 00025 namespace TSE3 00026 { 00046 class Metronome : public Playable, 00047 public Notifier<MetronomeListener> 00048 { 00049 public: 00050 00054 Metronome(); 00055 virtual ~Metronome(); 00056 00063 int channel() const { return _channel; } 00064 00071 void setChannel(int c); 00072 00079 int port() const { return _port; } 00080 00087 void setPort(int p); 00088 00095 int duration() const { return _duration; } 00096 00103 void setDuration(int d); 00104 00114 int barNote() const { return _barNote; } 00115 00124 void setBarNote(int n); 00125 00134 int barVelocity() const { return _barVelocity; } 00135 00144 void setBarVelocity(int v); 00145 00155 int beatNote() const { return _beatNote; } 00156 00165 void setBeatNote(int n); 00166 00175 int beatVelocity() const { return _beatVelocity; } 00176 00185 void setBeatVelocity(int v); 00186 00195 bool status(int mode) const 00196 { 00197 return _status & (1<<mode); 00198 } 00199 00207 void setStatus(int mode, bool s); 00208 00224 int beatsPerBar() const { return _beatsPerBar; } 00225 00235 void setBeatsPerBar(int bpb); 00236 00253 Clock barReference() const { return _barReference; } 00254 00264 void setBarReference(Clock br); 00265 00269 virtual PlayableIterator *iterator(Clock index); 00270 00274 virtual Clock lastClock() const; 00275 00276 friend class MetronomeIterator; 00277 00278 private: 00279 00280 Metronome &operator=(const Metronome &); 00281 Metronome(const Metronome &); 00282 00283 void calculateCommands(); 00284 00285 int _channel, _port; 00286 int _status; 00287 Clock _duration; 00288 int _barNote, _barVelocity; 00289 int _beatNote, _beatVelocity; 00290 int _beatsPerBar; 00291 Clock _barReference; 00292 00293 MidiCommand barNoteOn, barNoteOff; // Cached commands calculated 00294 MidiCommand beatNoteOn, beatNoteOff; // by calculateCommands 00295 00296 Clock pos; // Playable support 00297 }; 00298 } 00299 00300 #endif