| 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 | /* |
|---|
| 25 | ** Copyright 1986 to 1998 By J.D. Koftinoff Software, Ltd. |
|---|
| 26 | ** |
|---|
| 27 | ** All rights reserved. |
|---|
| 28 | ** |
|---|
| 29 | ** No one may duplicate this source code in any form for any reason |
|---|
| 30 | ** without the written permission given by J.D. Koftinoff Software, Ltd. |
|---|
| 31 | ** |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | #ifndef JDKMIDI_ADVANCEDSEQUENCER_H |
|---|
| 35 | |
|---|
| 36 | #define JDKMIDI_ADVANCEDSEQUENCER_H |
|---|
| 37 | |
|---|
| 38 | #include "jdkmidi/midi.h" |
|---|
| 39 | #include "jdkmidi/msg.h" |
|---|
| 40 | #include "jdkmidi/sysex.h" |
|---|
| 41 | #include "jdkmidi/multitrack.h" |
|---|
| 42 | #include "jdkmidi/filereadmultitrack.h" |
|---|
| 43 | #include "jdkmidi/sequencer.h" |
|---|
| 44 | #include "jdkmidi/manager.h" |
|---|
| 45 | #include "jdkmidi/driver.h" |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | #include "jdkmidi/driverdump.h" |
|---|
| 49 | |
|---|
| 50 | #include <string> |
|---|
| 51 | #include <vector> |
|---|
| 52 | |
|---|
| 53 | #define MAX_WARP_POSITIONS (128) |
|---|
| 54 | #define MEASURES_PER_WARP (4) |
|---|
| 55 | |
|---|
| 56 | namespace jdkmidi |
|---|
| 57 | { |
|---|
| 58 | class AdvancedSequencer |
|---|
| 59 | { |
|---|
| 60 | public: |
|---|
| 61 | AdvancedSequencer(); |
|---|
| 62 | virtual ~AdvancedSequencer(); |
|---|
| 63 | |
|---|
| 64 | bool OpenMIDI ( int in_port, int out_port, int timer_resolution=5 ); |
|---|
| 65 | void CloseMIDI(); |
|---|
| 66 | |
|---|
| 67 | void SetMIDIThruEnable ( bool f ); |
|---|
| 68 | bool GetMIDIThruEnable() const; |
|---|
| 69 | |
|---|
| 70 | void SetMIDIThruChannel ( int chan ); |
|---|
| 71 | int GetMIDIThruChannel() const; |
|---|
| 72 | |
|---|
| 73 | void SetMIDIThruTranspose ( int val ); |
|---|
| 74 | int GetMIDIThruTranspose() const; |
|---|
| 75 | |
|---|
| 76 | bool Load ( const char *fname ); |
|---|
| 77 | void Reset(); |
|---|
| 78 | |
|---|
| 79 | void GoToMeasure ( int measure, int beat=0 ); |
|---|
| 80 | void GoToTime ( MIDIClockTime t ); |
|---|
| 81 | void Play ( int clock_offset = 0 ); |
|---|
| 82 | void RepeatPlay ( bool enable, int start_measure, int end_measure ); |
|---|
| 83 | void Pause(); |
|---|
| 84 | void Stop(); |
|---|
| 85 | |
|---|
| 86 | bool IsPlay() |
|---|
| 87 | { |
|---|
| 88 | return mgr.IsSeqPlay(); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | void UnmuteAllTracks(); |
|---|
| 92 | void SoloTrack ( int trk ); |
|---|
| 93 | void UnSoloTrack(); |
|---|
| 94 | void SetTrackMute ( int trk, bool f ); |
|---|
| 95 | |
|---|
| 96 | void SetTempoScale ( double scale ); |
|---|
| 97 | double GetTempoWithoutScale() const; |
|---|
| 98 | double GetTempoWithScale() const; |
|---|
| 99 | |
|---|
| 100 | int GetMeasure() const; |
|---|
| 101 | int GetBeat() const; |
|---|
| 102 | |
|---|
| 103 | int GetTimeSigNumerator() const; |
|---|
| 104 | int GetTimeSigDenominator() const; |
|---|
| 105 | |
|---|
| 106 | int GetTrackNoteCount ( int trk ) const; |
|---|
| 107 | const char *GetTrackName ( int trk ) const; |
|---|
| 108 | int GetTrackVolume ( int trk ) const; |
|---|
| 109 | |
|---|
| 110 | void SetTrackVelocityScale ( int trk, int scale ); |
|---|
| 111 | int GetTrackVelocityScale ( int trk ) const; |
|---|
| 112 | |
|---|
| 113 | void SetTrackRechannelize ( int trk, int chan ); |
|---|
| 114 | int GetTrackRechannelize ( int trk ) const; |
|---|
| 115 | |
|---|
| 116 | void SetTrackTranspose ( int trk, int trans ); |
|---|
| 117 | int GetTrackTranspose ( int trk ) const; |
|---|
| 118 | |
|---|
| 119 | void ExtractMarkers ( std::vector< std::string > *list ); |
|---|
| 120 | int GetCurrentMarker() const; |
|---|
| 121 | |
|---|
| 122 | int FindFirstChannelOnTrack ( int trk ); |
|---|
| 123 | |
|---|
| 124 | void ExtractWarpPositions(); |
|---|
| 125 | |
|---|
| 126 | bool IsChainMode() const |
|---|
| 127 | { |
|---|
| 128 | return chain_mode; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | MIDIMultiProcessor thru_processor; |
|---|
| 132 | MIDIProcessorTransposer thru_transposer; |
|---|
| 133 | MIDIProcessorRechannelizer thru_rechannelizer; |
|---|
| 134 | |
|---|
| 135 | MIDIDriverDump driver; |
|---|
| 136 | |
|---|
| 137 | MIDIMultiTrack tracks; |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | MIDISequencerGUIEventNotifierText notifier; |
|---|
| 141 | |
|---|
| 142 | MIDISequencer seq; |
|---|
| 143 | |
|---|
| 144 | MIDIClockTime marker_times[1024]; |
|---|
| 145 | int num_markers; |
|---|
| 146 | |
|---|
| 147 | MIDIManager mgr; |
|---|
| 148 | |
|---|
| 149 | long repeat_start_measure; |
|---|
| 150 | long repeat_end_measure; |
|---|
| 151 | bool repeat_play_mode; |
|---|
| 152 | |
|---|
| 153 | int num_warp_positions; |
|---|
| 154 | MIDISequencerState *warp_positions[MAX_WARP_POSITIONS]; |
|---|
| 155 | |
|---|
| 156 | bool file_loaded; |
|---|
| 157 | bool chain_mode; |
|---|
| 158 | }; |
|---|
| 159 | |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | #endif |
|---|