~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to midithread.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//=========================================================
2
2
//  MusE
3
3
//  Linux Music Editor
4
 
//  $Id: midithread.h,v 1.2 2001/11/20 15:19:31 muse Exp $
 
4
//  $Id: midithread.h,v 1.1.1.1 2003/10/29 10:05:18 wschweer Exp $
5
5
//
6
6
//  (C) Copyright 2001 Werner Schweer (ws@seh.de)
7
7
//=========================================================
11
11
 
12
12
#include <qobject.h>
13
13
#include "thread.h"
 
14
#include "pos.h"
 
15
#include "mpevent.h"
14
16
 
15
17
class Part;
16
18
class Event;
 
19
class MidiPlayEvent;
17
20
class MidiEvent;
18
21
class Track;
19
22
class MidiPort;
24
27
class SynthI;
25
28
class MidiInstrument;
26
29
 
 
30
enum State {IDLE, PLAY, START_PLAY, SYNC, PRECOUNT};
 
31
static const int REC_NOTE_FIFO_SIZE = 16;
 
32
 
27
33
//---------------------------------------------------------
28
34
//   MidiMsgId
29
35
//    this are the messages send from the GUI thread to
31
37
//---------------------------------------------------------
32
38
 
33
39
enum MidiMsgId {
34
 
      SEQM_ADD_TRACK, SEQM_REMOVE_TRACKS, SEQM_CHANGE_TRACK, SEQM_MOVE_TRACK,
 
40
      SEQM_ADD_TRACK, SEQM_REMOVE_TRACK, SEQM_CHANGE_TRACK, SEQM_MOVE_TRACK,
35
41
      SEQM_ADD_PART, SEQM_REMOVE_PART, SEQM_CHANGE_PART,
36
42
      SEQM_ADD_EVENT, SEQM_REMOVE_EVENT, SEQM_CHANGE_EVENT,
37
43
      SEQM_ADD_TEMPO, SEQM_SET_TEMPO, SEQM_REMOVE_TEMPO, SEQM_ADD_SIG,
 
44
      SEQM_SET_GLOBAL_TEMPO,
38
45
      SEQM_UNDO, SEQM_REDO,
39
 
      SEQM_RESET_DEVICES, SEQM_INIT_DEVICES, SEQM_MIDI_LOCAL_OFF,
 
46
      SEQM_RESET_DEVICES, SEQM_INIT_DEVICES, SEQM_PANIC,
 
47
      SEQM_MIDI_LOCAL_OFF,
40
48
      SEQM_MIDI_CTRL, SEQM_MIDI_MASTER_VOLUME,
41
49
      SEQM_SET_MIDI_DEVICE,
42
50
      SEQM_PLAY_MIDI_EVENT,
74
82
      Q_OBJECT;
75
83
 
76
84
      QTimer* heartBeatTimer;       // controls gui refreshes
77
 
      MidiThreadPrivate* data;
 
85
      State state;
 
86
      int timerFd;
 
87
      int sigFd;
 
88
 
 
89
      // play values:
 
90
      int playTickPos;        // current midi tick position in song
 
91
      int rtcStartTick;
 
92
      int endSlice;
 
93
 
 
94
      MPEventList playEvents;
 
95
      MPEventList stuckNotes;
 
96
 
 
97
      bool controlChanged;
 
98
 
 
99
      int recTick;            // ext sync tick position
 
100
      int lastTickPos;        // position of last sync tick
 
101
 
 
102
      // record values:
 
103
      int recNoteFifo[REC_NOTE_FIFO_SIZE];
 
104
      volatile int noteFifoSize;
 
105
      int noteFifoWindex;
 
106
      int noteFifoRindex;
 
107
 
 
108
      Pos startRecord;
 
109
      Pos endRecord;
 
110
      bool loopPassed;
 
111
 
 
112
      // run values:
 
113
      unsigned _midiTick;
 
114
 
 
115
      unsigned rtcTick;             // free running rtcTick
 
116
      unsigned rtcTickStart;        // pos 0.0.0
 
117
 
 
118
      unsigned samplePos;           // audio sample time base
 
119
      unsigned samplePosStart;      // pos 0.0.0
 
120
 
 
121
      unsigned midiClock;           // next midi clock pos in midi ticks
 
122
      int realRtcTicks;             // current rtc tick rate 1/sec
 
123
      int tempoSN;                  // last tempo serial number to track
 
124
                                    //    tempo changes
 
125
      double mclock1, mclock2;
 
126
 
 
127
      unsigned midiClick;
 
128
      int clickno;
 
129
      int clicksMeasure;
 
130
      int ticksBeat;
78
131
 
79
132
      virtual void processMsg(const ThreadMsg*);
80
133
      virtual void defaultTick();
84
137
      int recTimeStamp() const;
85
138
      void recordStop();
86
139
      void sendLocalOff();
87
 
      bool filterEvent(const MidiEvent* event, int type, bool thru);
 
140
      bool filterEvent(const MidiPlayEvent* event, int type, bool thru);
88
141
      void mtcSyncMsg(const MTC& mtc, bool seekFlag);
89
142
      void statePlay();
90
143
      static void midiTick(void* p, void*);
91
144
      void initDevices();
92
145
 
 
146
      void startPlay(int);
 
147
      void stopPlay();
 
148
      void seek(int pos);
 
149
      void playEvent(const MidiPlayEvent* event);
 
150
      void processTimerTick();
 
151
      void processMidiClock();
 
152
      void nextEvents(int starTick, int endTick);
 
153
      void panic();
 
154
 
93
155
   public slots:
94
156
      void seqSignal(int fd);
95
157
      void resetDevices();
101
163
      void midiNote(int, int);
102
164
 
103
165
   public:
104
 
      MidiThread(bool rt=true, int prio=50, bool ml = true);
 
166
      MidiThread(int prio, const char* name);
105
167
      ~MidiThread();
106
 
      virtual void start();
 
168
      void start();
 
169
      virtual void threadStop();
 
170
      virtual void threadStart(void*);
 
171
 
107
172
      bool sendMessage(const MidiMsg* m, bool doUndo);
108
173
 
109
174
      bool isPlaying() const;
117
182
      void msgPlay(bool val);
118
183
 
119
184
      void msgAddTrack(Track* track, bool u = true);
120
 
      void msgRemoveTracks(bool u = true);
 
185
      void msgRemoveTracks();
121
186
      void msgChangeTrack(Track* oldTrack, Track* newTrack, bool u = true);
122
187
      void msgMoveTrack(int idx1, int dx2, bool u = true);
123
188
      void msgAddPart(Part*, bool u = true);
129
194
      void msgScanAlsaMidiPorts();
130
195
      void msgAddTempo(int tick, int tempo, bool doUndoFlag = true);
131
196
      void msgSetTempo(int tick, int tempo, bool doUndoFlag = true);
 
197
      void msgSetGlobalTempo(int val);
132
198
      void msgDeleteTempo(int tick, int tempo, bool doUndoFlag = true);
133
199
      void msgAddSig(int tick, int z, int n, bool doUndoFlag = true);
134
200
      void msgAddSynthI(SynthI* synth);
135
201
      void msgShowInstrumentGui(MidiInstrument*, bool);
 
202
      void msgPanic();
136
203
 
137
204
      void undo();
138
205
      void redo();
140
207
      void masterVolChanged(int val);
141
208
 
142
209
      void setMidiDevice(MidiPort*, MidiDevice*);
143
 
      void playMidiEvent(MidiEvent* event);
 
210
      void playMidiEvent(MidiPlayEvent* event);
144
211
      void rescanAlsaPorts();
145
 
      int curTickPos() const;
146
212
 
147
 
      void eventReceived(MidiEvent* event);
 
213
      void eventReceived(MidiPlayEvent* event);
 
214
      void eventReceived(int port, unsigned char chan, unsigned char c1, unsigned c2);
148
215
 
149
216
      void mmcInput(const unsigned char* p, int n);
150
217
      void mtcInputQuarter(int, unsigned char c);
151
218
      void mtcInputFull(const unsigned char* p, int n);
152
 
      void eventReceived(int, unsigned char chan, unsigned char c1, unsigned c2);
153
219
      void nonRealtimeSystemSysex(const unsigned char*, int);
154
220
      void realtimeSystemInput(int, int);
155
221
      void setSongPosition(int, int);
156
222
      void midiPortsChanged();
157
223
      };
158
224
 
 
225
extern MidiThread* midiThread;
159
226
#endif
160
227