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

« back to all changes in this revision

Viewing changes to event.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: event.h,v 1.3 2002/02/07 08:14:48 muse Exp $
 
4
//  $Id: event.h,v 1.1.1.1 2003/10/29 10:05:07 wschweer Exp $
5
5
//
6
6
//  (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
7
7
//=========================================================
17
17
#include <map>
18
18
 
19
19
class MidiTrack;
 
20
class MidiPlayEvent;
20
21
class Clip;
 
22
class Xml;
21
23
 
22
24
//---------------------------------------------------------
23
25
//   Attribute
82
84
 
83
85
   protected:
84
86
      int refs;
85
 
      int _port;
86
 
      int _channel;
87
87
      bool _selected;
88
88
 
89
89
   public:
90
90
      Event();
91
 
      Event(int p, int c, int t, int l);
 
91
      Event(int t, int l);
92
92
      Event(const Event& ev);
93
93
 
94
94
      virtual ~Event() {}
95
95
 
96
96
      int incRefs(int val)      { refs += val; return refs; }
97
97
 
98
 
      int port() const          { return _port; }
99
 
      void setPort(int val)     { _port = val; }
100
 
 
101
 
      int channel() const       { return _channel; }
102
 
      void setChannel(int val)  { _channel = val; }
103
 
 
104
98
      bool selected() const      { return _selected; }
105
99
      void setSelected(bool val) { _selected = val; }
106
100
 
110
104
      virtual void write(int, Xml&, int offset) const = 0;
111
105
      virtual void dump() const;
112
106
      virtual Event* clone() = 0;
113
 
      virtual Event* mid(const Pos&, const Pos&) = 0;
 
107
      virtual Event* mid(int, int) = 0;
 
108
      };
 
109
 
 
110
//---------------------------------------------------------
 
111
//   EvData
 
112
//    variable len event data (sysex, meta)
 
113
//---------------------------------------------------------
 
114
 
 
115
struct EvData {
 
116
      unsigned char* data;
 
117
      int dataLen;
 
118
      int refCount;
 
119
 
 
120
      EvData()  { data = 0; dataLen = 0; refCount = 0; }
 
121
 
 
122
      ~EvData() {
 
123
            if (data)
 
124
                  delete[] data;
 
125
            }
 
126
      EvData(const unsigned char* p, int l) {
 
127
            setData(p, l);
 
128
            }
 
129
      void setData(const unsigned char* p, int l) {
 
130
            data = new unsigned char[l];
 
131
            memcpy(data, p, l);
 
132
            dataLen = l;
 
133
            }
114
134
      };
115
135
 
116
136
//---------------------------------------------------------
137
157
      char _stem;                   // 0 - automatic
138
158
                                    // 1 - up
139
159
                                    // 2 - down
140
 
      unsigned char* _data;
141
 
      int _dataLen;
 
160
      EvData* edata;
142
161
      AttributeList attributes;
143
162
      MidiTrack* _trk;              //  only unsed inside
144
163
                                    //  sequencer
146
165
   public:
147
166
      MidiEvent();
148
167
      MidiEvent(const MidiEvent&);
 
168
      MidiEvent(const MidiPlayEvent*);
149
169
      virtual ~MidiEvent();
 
170
      MidiEvent& operator=(const MidiEvent&);
150
171
 
151
 
      MidiEvent(int port, int channel, int tick, EventType type, int a, int b, int c, int len);
152
 
      MidiEvent(int port, int channel, int tick, EventType type, int len, const unsigned char* data);
 
172
      MidiEvent(int tick, EventType type, int a, int b, int c, int len);
 
173
      MidiEvent(int tick, EventType type, int len, const unsigned char* data);
153
174
 
154
175
      bool isNote() const                   { return _type == Note; }
155
 
      bool isNoteOff() const { 
156
 
            return (_type == NoteOff) || ((_type == Note) && (b == 0)); 
 
176
      bool isNoteOff() const {
 
177
            return (_type == NoteOff) || ((_type == Note) && (b == 0));
157
178
            }
158
179
      bool isNoteOff(MidiEvent*);
159
180
 
160
 
      int pitch() const                     { return a;      }
161
 
      int program() const                   { return a;      }
162
 
      int cntrl() const                     { return a;      }
163
 
      int dataA() const                     { return a;      }
164
 
      void setA(int val)                    { a = val;       }
165
 
      void setPitch(int v)                  { a = v;         }
166
 
 
167
 
      int cntrlVal() const                  { return b;      }
168
 
      int dataB() const                     { return b;      }
169
 
      int velo() const                      { return b;      }
170
 
      void setB(int val)                    { b = val;       }
171
 
      void setVelo(int v)                   { b = v;         }
172
 
 
173
 
      int veloOff() const                   { return c;      }
174
 
      int dataC() const                     { return c;      }
175
 
      void setC(int val)                    { c = val;       }
176
 
      void setVeloOff(int v)                { c = v;         }
177
 
 
178
 
      const unsigned char* data() const     { return _data;  }
179
 
      void setData(unsigned char* d)        { _data = d;     }
180
 
      int dataLen() const                   { return _dataLen; }
181
 
      void setDataLen(int l)                { _dataLen = l;  }
182
 
      EventType type() const                { return _type;  }
183
 
      void setType(EventType t)             { _type = t;     }
184
 
      void setEnh(int enh)                  { _enh = enh;    }
185
 
      int enh() const                       { return _enh;   }
186
 
      int voice() const                     { return _voice; }
187
 
      void setVoice(int v)                  { _voice = v;    }
188
 
      int stem() const                      { return _stem;  }
189
 
      void setStem(int v)                   { _stem = v;     }
 
181
      int pitch() const                      { return a;      }
 
182
      int program() const                    { return a;      }
 
183
      int cntrl() const                      { return a;      }
 
184
      int dataA() const                      { return a;      }
 
185
      void setA(int val)                     { a = val;       }
 
186
      void setPitch(int v)                   { a = v;         }
 
187
 
 
188
      int cntrlVal() const                   { return b;      }
 
189
      int dataB() const                      { return b;      }
 
190
      int velo() const                       { return b;      }
 
191
      void setB(int val)                     { b = val;       }
 
192
      void setVelo(int v)                    { b = v;         }
 
193
 
 
194
      int veloOff() const                    { return c;      }
 
195
      int dataC() const                      { return c;      }
 
196
      void setC(int val)                     { c = val;       }
 
197
      void setVeloOff(int v)                 { c = v;         }
 
198
 
 
199
      const unsigned char* data() const      { return edata->data;  }
 
200
      int dataLen() const                    { return edata->dataLen; }
 
201
      EvData* eventData() const              { return edata; }
 
202
      void setEvData(EvData* ed)             { edata = ed; }
 
203
 
 
204
      EventType type() const                 { return _type;  }
 
205
      void setType(EventType t)              { _type = t;     }
 
206
      void setEnh(int enh)                   { _enh = enh;    }
 
207
      int enh() const                        { return _enh;   }
 
208
      int voice() const                      { return _voice; }
 
209
      void setVoice(int v)                   { _voice = v;    }
 
210
      int stem() const                       { return _stem;  }
 
211
      void setStem(int v)                    { _stem = v;     }
190
212
      virtual void dump() const;
191
213
      virtual void read(Xml&);
192
214
      virtual void write(int, Xml&, int offset=0) const;
193
215
      void readAttr(Xml& xml);
194
 
      iAttribute beginAttr()                    { return attributes.begin(); }
195
 
      iAttribute endAttr()                      { return attributes.end(); }
196
 
      Attribute* addAttr(const Attribute& a)    { return attributes.add(a); }
197
 
      void addLyrics(const QString& s)          { attributes.addLyrics(s); }
198
 
      void eraseAttr(iAttribute i)              { attributes.erase(i); }
199
 
      virtual Event* clone()                    { return new MidiEvent(*this); }
200
 
      virtual Event* mid(const Pos&, const Pos&);
 
216
      iAttribute beginAttr()                 { return attributes.begin(); }
 
217
      iAttribute endAttr()                   { return attributes.end(); }
 
218
      Attribute* addAttr(const Attribute& a) { return attributes.add(a); }
 
219
      void addLyrics(const QString& s)       { attributes.addLyrics(s); }
 
220
      void eraseAttr(iAttribute i)           { attributes.erase(i); }
 
221
      virtual Event* clone()                 { return new MidiEvent(*this); }
 
222
      virtual Event* mid(int, int);
201
223
 
202
 
      MidiTrack* trk() const   { return _trk; }
203
 
      void setTrk(MidiTrack*t) { _trk = t; }
 
224
      MidiTrack* trk() const                 { return _trk; }
 
225
      void setTrk(MidiTrack*t)               { _trk = t; }
204
226
      };
205
227
 
206
228
//---------------------------------------------------------
212
234
 
213
235
   public:
214
236
      WaveEvent();
215
 
      WaveEvent(int, int, int, Clip*);
 
237
      WaveEvent(int, Clip*);
216
238
      virtual ~WaveEvent() {}
217
239
 
218
240
      Clip* clip() const    { return _clip; }
221
243
      virtual void read(Xml&);
222
244
      virtual void write(int, Xml&, int offset=0) const;
223
245
      virtual Event* clone();
224
 
      virtual Event* mid(const Pos&, const Pos&);
 
246
      virtual Event* mid(int, int);
225
247
      virtual void dump() const;
226
248
      };
227
249
 
228
250
typedef std::multimap<int, Event*, std::less<int> >::iterator iEvent;
 
251
typedef std::multimap<int, Event*, std::less<int> >::reverse_iterator riEvent;
229
252
typedef std::multimap<int, Event*, std::less<int> >::const_iterator ciEvent;
230
253
typedef std::pair <iEvent, iEvent> EventRange;
231
254
 
235
258
//---------------------------------------------------------
236
259
 
237
260
class EventList : std::multimap<int, Event*, std::less<int> > {
 
261
      int ref;          // number of references to this EventList
 
262
      int aref;         // number of active references (exclude undo list)
238
263
      void deselect();
 
264
 
239
265
   public:
240
 
      EventList() {}
 
266
      EventList()       { ref = 0; aref = 0;  }
241
267
      ~EventList();
 
268
 
 
269
      void incRef(int n)    { ref += n;    }
 
270
      int refCount() const  { return ref;  }
 
271
      void incARef(int n)   { aref += n;   }
 
272
      int arefCount() const { return aref; }
 
273
 
242
274
      iEvent find(Event*);
243
275
      void erase(iEvent);
244
276
      void erase(iEvent istart, iEvent iend);
263
295
      EventRange equal_range(int i)   {
264
296
            return std::multimap<int, Event*, std::less<int> >::equal_range(i);
265
297
            }
 
298
      void read(Xml& xml, const char* name);
266
299
      };
267
300
 
268
301
#endif