Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

/home/pete/Work/TSE3.svn/tse3/src/tse3/Transport.h

Go to the documentation of this file.
00001 /*
00002  * @(#)Transport.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_TRANSPORT_H
00018 #define TSE3_TRANSPORT_H
00019 
00020 #include "tse3/listen/Transport.h"
00021 
00022 #include "tse3/Notifier.h"
00023 #include "tse3/Panic.h"
00024 #include "tse3/MidiMapper.h"
00025 #include "tse3/MidiEcho.h"
00026 #include "tse3/listen/Playable.h"
00027 #include "tse3/listen/PhraseEdit.h"
00028 #include "tse3/listen/MidiScheduler.h"
00029 #include "tse3/listen/FlagTrack.h"
00030 #include "tse3/listen/Metronome.h"
00031 
00032 #include <queue>
00033 #include <list>
00034 
00035 namespace TSE3
00036 {
00071     class Transport : public Listener<MidiSchedulerListener>,
00072                       public Listener<FlagTrackListener>,
00073                       public Listener<PhraseEditListener>,
00074                       public Listener<MetronomeListener>,
00075                       public Listener<PlayableListener>,
00076                       public Notifier<TransportListener>
00077     {
00078         public:
00079 
00090             Transport(Metronome     *metronome,
00091                       MidiScheduler *scheduler);
00092             virtual ~Transport();
00093 
00099             void attachCallback(TransportCallback *c);
00100 
00106             void detachCallback(TransportCallback *c);
00107 
00114             MidiScheduler *scheduler() const { return _scheduler; }
00115 
00124             MidiFilter *filter() { return &_filter; };
00125 
00131             Panic *startPanic() { return &_startPanic; }
00132 
00138             Panic *endPanic() { return &_endPanic; }
00139 
00145             MidiMapper *midiMapper() { return &_midiMapper; }
00146 
00152             MidiEcho *midiEcho() { return &_midiEcho; }
00153 
00166             void setFlagTrack(FlagTrack *f) { flagTrack = f; }
00167 
00178             bool synchro() const { return _synchro; }
00179 
00186             void setSynchro(bool s);
00187 
00198             bool punchIn() const { return _punchIn; }
00199 
00206             void setPunchIn(bool p);
00207 
00217             bool autoStop() const { return _autoStop; }
00218 
00225             void setAutoStop(bool s);
00226 
00234             Clock playLeadIn() const { return _playLeadIn; }
00235 
00242             void setPlayLeadIn(Clock c);
00243 
00251             Clock recordLeadIn() const { return _recLeadIn; }
00252 
00259             void setRecordLeadIn(Clock c);
00260 
00270             void play(Playable *p, Clock startTime);
00271 
00311             void record(Playable *p, Clock startTime,
00312                         PhraseEdit *pe, MidiFilter *filter = 0);
00313 
00323             void stop();
00324 
00333             void ff(bool strong);
00334 
00338             void ffFlag();
00339 
00348             void rew(bool strong);
00349 
00353             void rewFlag();
00354 
00371             void poll();
00372 
00378             int status() const { return _status; }
00379 
00390             Playable *playable() const { return _playable; }
00391 
00396             enum TransportMode
00397             {
00398                 Resting,
00399                 Playing,
00400                 Recording,
00401                 SynchroPlaying,
00402                 SynchroRecording
00403             };
00404 
00415             Clock lookAhead() const { return _lookAhead; }
00416 
00423             void setLookAhead(Clock c);
00424 
00434             Clock minimumLookAhead() const { return _minimumLookAhead; }
00435 
00451             bool adaptiveLookAhead() const { return _adaptiveLookAhead; }
00452 
00459             void setAdaptiveLookAhead(bool ala);
00460 
00470             int breakUps() const { return _breakUps; }
00471 
00490             void inject(MidiCommand c);
00491 
00495             virtual void MidiScheduler_Started(MidiScheduler *);
00496 
00500             virtual void MidiScheduler_Stopped(MidiScheduler *);
00501 
00505             virtual void MidiScheduler_Moved(MidiScheduler *);
00506 
00510             virtual void Notifier_Deleted(FlagTrack *);
00511 
00515             virtual void Notifier_Deleted(Metronome *);
00516 
00520             virtual void Notifier_Deleted(MidiScheduler *);
00521 
00525             virtual void Notifier_Deleted(PhraseEdit *);
00526 
00530             virtual void Notifier_Deleted(Playable *);
00531 
00532         private:
00533 
00534             Transport &operator=(const Transport &);
00535             Transport(const Transport &);
00536 
00537             void startPlayback();
00538 
00543             void pollPlayback();
00544 
00549             void stopPlayback(Clock stopTime);
00550 
00557             void shiftBy(Clock c);
00558 
00562             void callback_MidiOut(MidiCommand c);
00563 
00567             void callback_MidiIn(MidiCommand c);
00568 
00573             void handleMidiSchedulerEvent();
00574 
00575             std::list<TransportCallback *>  callbacks;
00576             Playable                       *_playable;
00577             PlayableIterator               *iterator;
00578             FlagTrack                      *flagTrack;
00579             PhraseEdit                     *recPE;
00580             std::priority_queue<MidiEvent,
00581                                 std::vector<MidiEvent>,
00582                                 std::greater<MidiEvent> >
00583                                             noteOffBuffer;
00584             Metronome                      *metronome;
00585             PlayableIterator               *metronomeIterator;
00586             MidiScheduler                  *_scheduler;
00587             MidiFilter                      _filter;
00588             Panic                           _startPanic;
00589             Panic                           _endPanic;
00590             MidiMapper                      _midiMapper;
00591             MidiEcho                        _midiEcho;
00592 
00593             int                             _status;
00594             bool                            _synchro;
00595             bool                            _punchIn;
00596             bool                            _autoStop;
00597             Clock                           lastScheduledClock;
00598             Clock                           lastPollPlaybackClock;
00599             bool                            _adaptiveLookAhead;
00600             Clock                           _lookAhead;
00601             static const Clock              _minimumLookAhead;
00602             int                             _breakUps;
00603             bool                            punchedInYet;
00604             MidiFilter                     *punchInFilter;
00605             bool                            punchInStatus;
00606             MidiCommand                     injectedMidiCommand;
00607 
00608             Clock                           _playLeadIn;
00609             Clock                           _recLeadIn;
00610 
00616             Clock transportLeadIn;
00617     };
00618 }
00619 
00620 #endif

Generated on Wed May 25 14:45:08 2005 for TSE3 by doxygen 1.3.2