MuseScore  3.4
Music composition and notation
importmidi_fraction.h
Go to the documentation of this file.
1 #ifndef IMPORTMIDI_FRACTION_H
2 #define IMPORTMIDI_FRACTION_H
3 
4 #include "libmscore/fraction.h"
5 
6 
7 namespace Ms {
8 
10  {
11  public:
13  ReducedFraction(int z, int n);
14  explicit ReducedFraction(const Fraction &);
15 
17  int numerator() const { return numerator_; }
18  int denominator() const { return denominator_; }
19 
20  static ReducedFraction fromTicks(int ticks);
21  ReducedFraction reduced() const;
23  double toDouble() const { return numerator_ * 1.0 / denominator_; }
24  int ticks() const;
25  void reduce();
26  bool isIdenticalTo(const ReducedFraction &f) const
27  { return (f.numerator_ == numerator_ && f.denominator_ == denominator_); }
28 
35 
36  ReducedFraction operator+(const ReducedFraction& v) const { return ReducedFraction(*this) += v; }
37  ReducedFraction operator-(const ReducedFraction& v) const { return ReducedFraction(*this) -= v; }
38  ReducedFraction operator*(const ReducedFraction& v) const { return ReducedFraction(*this) *= v; }
39  ReducedFraction operator*(int v) const { return ReducedFraction(*this) *= v; }
40  ReducedFraction operator/(const ReducedFraction& v) const { return ReducedFraction(*this) /= v; }
41  ReducedFraction operator/(int v) const { return ReducedFraction(*this) /= v; }
42 
43  bool operator<(const ReducedFraction&) const;
44  bool operator<=(const ReducedFraction&) const;
45  bool operator>=(const ReducedFraction&) const;
46  bool operator>(const ReducedFraction&) const;
47  bool operator==(const ReducedFraction&) const;
48  bool operator!=(const ReducedFraction&) const;
49 
50  private:
51  void preventOverflow();
52 
55  };
56 
57 ReducedFraction toMuseScoreTicks(int tick, int oldDivision, bool isDivisionInTps);
58 
59 } // namespace Ms
60 
61 
62 #endif // IMPORTMIDI_FRACTION_H
bool operator<=(const ReducedFraction &) const
Definition: importmidi_fraction.cpp:284
ReducedFraction & operator+=(const ReducedFraction &)
Definition: importmidi_fraction.cpp:197
ReducedFraction operator+(const ReducedFraction &v) const
Definition: importmidi_fraction.h:36
int numerator() const
Definition: importmidi_fraction.h:17
ReducedFraction operator*(const ReducedFraction &v) const
Definition: importmidi_fraction.h:38
ReducedFraction operator/(int v) const
Definition: importmidi_fraction.h:41
ReducedFraction operator/(const ReducedFraction &v) const
Definition: importmidi_fraction.h:40
void reduce()
Definition: importmidi_fraction.cpp:157
double toDouble() const
Definition: importmidi_fraction.h:23
void preventOverflow()
Definition: importmidi_fraction.cpp:174
bool operator==(const ReducedFraction &) const
Definition: importmidi_fraction.cpp:305
bool isIdenticalTo(const ReducedFraction &f) const
Definition: importmidi_fraction.h:26
ReducedFraction()
Definition: importmidi_fraction.cpp:99
ReducedFraction toMuseScoreTicks(int tick, int oldDivision, bool isDivisionInTps)
Definition: importmidi_fraction.cpp:322
ReducedFraction & operator/=(const ReducedFraction &)
Definition: importmidi_fraction.cpp:250
ReducedFraction & operator-=(const ReducedFraction &)
Definition: importmidi_fraction.cpp:210
ReducedFraction operator-(const ReducedFraction &v) const
Definition: importmidi_fraction.h:37
ReducedFraction operator*(int v) const
Definition: importmidi_fraction.h:39
bool operator>=(const ReducedFraction &) const
Definition: importmidi_fraction.cpp:298
Definition: aeolus.cpp:26
ReducedFraction absValue() const
Definition: importmidi_fraction.h:22
int denominator_
Definition: importmidi_fraction.h:54
int ticks() const
Definition: importmidi_fraction.cpp:134
ReducedFraction reduced() const
Definition: importmidi_fraction.cpp:122
Definition: importmidi_fraction.h:9
bool operator>(const ReducedFraction &) const
Definition: importmidi_fraction.cpp:291
Fraction fraction() const
Definition: importmidi_fraction.h:16
Definition: fraction.h:46
bool operator!=(const ReducedFraction &) const
Definition: importmidi_fraction.cpp:312
int denominator() const
Definition: importmidi_fraction.h:18
bool operator<(const ReducedFraction &) const
Definition: importmidi_fraction.cpp:277
int numerator_
Definition: importmidi_fraction.h:53
static ReducedFraction fromTicks(int ticks)
Definition: importmidi_fraction.cpp:117
ReducedFraction & operator*=(const ReducedFraction &)
Definition: importmidi_fraction.cpp:223