~ubuntu-branches/ubuntu/quantal/muse/quantal

« back to all changes in this revision

Viewing changes to muse/tempo.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2005-08-23 17:19:39 UTC
  • mto: (4.1.1 breezy) (1.1.9) (10.1.6 sid)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20050823171939-hd8fgzokb4dbj007
Tags: upstream-0.7.1+0.7.2pre2
ImportĀ upstreamĀ versionĀ 0.7.1+0.7.2pre2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=========================================================
 
2
//  MusE
 
3
//  Linux Music Editor
 
4
//  $Id: tempo.h,v 1.2 2004/01/11 18:55:34 wschweer Exp $
 
5
//
 
6
//  (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
 
7
//=========================================================
 
8
 
 
9
#ifndef __TEMPO_H__
 
10
#define __TEMPO_H__
 
11
 
 
12
#include <map>
 
13
 
 
14
#ifndef MAX_TICK
 
15
#define MAX_TICK (0x7fffffff/100)
 
16
#endif
 
17
 
 
18
class Xml;
 
19
 
 
20
//---------------------------------------------------------
 
21
//   Tempo Event
 
22
//---------------------------------------------------------
 
23
 
 
24
struct TEvent {
 
25
      int tempo;
 
26
      unsigned tick;    // new tempo at tick
 
27
      unsigned frame;   // precomputed time for tick in sec
 
28
 
 
29
      int read(Xml&);
 
30
      void write(int, Xml&, int) const;
 
31
 
 
32
      TEvent() { }
 
33
      TEvent(unsigned t, unsigned tk) {
 
34
            tempo = t;
 
35
            tick  = tk;
 
36
            frame = 0;
 
37
            }
 
38
      };
 
39
 
 
40
//---------------------------------------------------------
 
41
//   TempoList
 
42
//---------------------------------------------------------
 
43
 
 
44
typedef std::map<unsigned, TEvent*, std::less<unsigned> > TEMPOLIST;
 
45
typedef TEMPOLIST::iterator iTEvent;
 
46
typedef TEMPOLIST::const_iterator ciTEvent;
 
47
typedef TEMPOLIST::reverse_iterator riTEvent;
 
48
typedef TEMPOLIST::const_reverse_iterator criTEvent;
 
49
 
 
50
class TempoList : public TEMPOLIST {
 
51
      int _tempoSN;           // serial no to track tempo changes
 
52
      bool useList;
 
53
      int _tempo;             // tempo if not using tempo list
 
54
      int _globalTempo;       // %percent 50-200%
 
55
 
 
56
      void normalize();
 
57
      void add(unsigned tick, int tempo);
 
58
      void change(unsigned tick, int newTempo);
 
59
      void del(iTEvent);
 
60
      void del(unsigned tick);
 
61
 
 
62
   public:
 
63
      TempoList();
 
64
      void clear();
 
65
 
 
66
      void read(Xml&);
 
67
      void write(int, Xml&) const;
 
68
      void dump() const;
 
69
 
 
70
      int tempo(unsigned tick) const;
 
71
      unsigned tick2frame(unsigned tick, unsigned frame, int* sn) const;
 
72
      unsigned tick2frame(unsigned tick, int* sn = 0) const;
 
73
      unsigned frame2tick(unsigned frame, int* sn = 0) const;
 
74
      unsigned frame2tick(unsigned frame, unsigned tick, int* sn) const;
 
75
      int tempoSN() const { return _tempoSN; }
 
76
      void setTempo(unsigned tick, int newTempo);
 
77
      void addTempo(unsigned t, int tempo);
 
78
      void delTempo(unsigned tick);
 
79
      void changeTempo(unsigned tick, int newTempo);
 
80
      bool setMasterFlag(unsigned tick, bool val);
 
81
      int globalTempo() const           { return _globalTempo; }
 
82
      void setGlobalTempo(int val);
 
83
      };
 
84
 
 
85
extern TempoList tempomap;
 
86
#endif