| 1 | /* |
|---|
| 2 | * libjdkmidi-2004 C++ Class Library for MIDI |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2004 J.D. Koftinoff Software, Ltd. |
|---|
| 5 | * www.jdkoftinoff.com |
|---|
| 6 | * jeffk@jdkoftinoff.com |
|---|
| 7 | * |
|---|
| 8 | * *** RELEASED UNDER THE GNU GENERAL PUBLIC LICENSE (GPL) April 27, 2004 *** |
|---|
| 9 | * |
|---|
| 10 | * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | * it under the terms of the GNU General Public License as published by |
|---|
| 12 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 13 | * (at your option) any later version. |
|---|
| 14 | * |
|---|
| 15 | * This program is distributed in the hope that it will be useful, |
|---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | * GNU General Public License for more details. |
|---|
| 19 | * |
|---|
| 20 | * You should have received a copy of the GNU General Public License |
|---|
| 21 | * along with this program; if not, write to the Free Software |
|---|
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 23 | */ |
|---|
| 24 | #ifndef JDKMIDI_MANAGER_H |
|---|
| 25 | #define JDKMIDI_MANAGER_H |
|---|
| 26 | |
|---|
| 27 | #include "jdkmidi/msg.h" |
|---|
| 28 | #include "jdkmidi/sysex.h" |
|---|
| 29 | #include "jdkmidi/driver.h" |
|---|
| 30 | #include "jdkmidi/sequencer.h" |
|---|
| 31 | #include "jdkmidi/tick.h" |
|---|
| 32 | |
|---|
| 33 | namespace jdkmidi |
|---|
| 34 | { |
|---|
| 35 | class MIDIManager : public MIDITick |
|---|
| 36 | { |
|---|
| 37 | public: |
|---|
| 38 | MIDIManager ( |
|---|
| 39 | MIDIDriver *drv, |
|---|
| 40 | MIDISequencerGUIEventNotifier *n=0, |
|---|
| 41 | MIDISequencer *seq_=0 |
|---|
| 42 | ); |
|---|
| 43 | |
|---|
| 44 | virtual ~MIDIManager(); |
|---|
| 45 | |
|---|
| 46 | void Reset(); |
|---|
| 47 | |
|---|
| 48 | // to set and get the current sequencer |
|---|
| 49 | void SetSeq ( MIDISequencer *seq ); |
|---|
| 50 | MIDISequencer *GetSeq(); |
|---|
| 51 | const MIDISequencer *GetSeq() const; |
|---|
| 52 | |
|---|
| 53 | // to get the driver that we use |
|---|
| 54 | MIDIDriver *GetDriver() |
|---|
| 55 | { |
|---|
| 56 | return driver; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | // to set and get the system time offset |
|---|
| 61 | void SetTimeOffset ( unsigned long off ); |
|---|
| 62 | unsigned long GetTimeOffset(); |
|---|
| 63 | |
|---|
| 64 | // to set and get the sequencer time offset |
|---|
| 65 | void SetSeqOffset ( unsigned long seqoff ); |
|---|
| 66 | unsigned long GetSeqOffset(); |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | // to manage the playback of the sequencer |
|---|
| 70 | void SeqPlay(); |
|---|
| 71 | void SeqStop(); |
|---|
| 72 | void SetRepeatPlay ( |
|---|
| 73 | bool flag, |
|---|
| 74 | unsigned long start_measure, |
|---|
| 75 | unsigned long end_measure |
|---|
| 76 | ); |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | // status request functions |
|---|
| 80 | bool IsSeqPlay() const; |
|---|
| 81 | bool IsSeqStop() const; |
|---|
| 82 | bool IsSeqRepeat() const; |
|---|
| 83 | |
|---|
| 84 | // inherited from MIDITick |
|---|
| 85 | virtual void TimeTick ( unsigned long sys_time ); |
|---|
| 86 | |
|---|
| 87 | protected: |
|---|
| 88 | |
|---|
| 89 | virtual void TimeTickPlayMode ( unsigned long sys_time_ ); |
|---|
| 90 | virtual void TimeTickStopMode ( unsigned long sys_time_ ); |
|---|
| 91 | |
|---|
| 92 | MIDIDriver *driver; |
|---|
| 93 | |
|---|
| 94 | MIDISequencer *sequencer; |
|---|
| 95 | |
|---|
| 96 | unsigned long sys_time_offset; |
|---|
| 97 | unsigned long seq_time_offset; |
|---|
| 98 | |
|---|
| 99 | volatile bool play_mode; |
|---|
| 100 | volatile bool stop_mode; |
|---|
| 101 | |
|---|
| 102 | MIDISequencerGUIEventNotifier *notifier; |
|---|
| 103 | |
|---|
| 104 | volatile bool repeat_play_mode; |
|---|
| 105 | long repeat_start_measure; |
|---|
| 106 | long repeat_end_measure; |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | }; |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | #endif |
|---|