Skip to content
Snippets Groups Projects
Commit 4d05a8d2 authored by SeeLook's avatar SeeLook
Browse files

Added meter groups (definitions of measure rhythm grouping) to TscoreObject.

parent 540d301c
No related branches found
No related tags found
No related merge requests found
1.5.0
- porting visible part into QML
1.4.2
- added standalone AppImage for Linux
BUGS FIXES
- don't stop pitch detection after playing a note
- avoid false update messages
- properly detect default language under Win 10
1.4.1
BUGS FIXES
- Fixed issues with note range in custom created levels
......
......@@ -18,6 +18,7 @@
#include "tmeter.h"
#include "trhythm.h"
#include <QtCore/qdebug.h>
......
......@@ -46,9 +46,17 @@ public:
Tmeter(Emeter meter = NoMeter) : m_meter(meter) {}
Q_INVOKABLE Emeter meter() const { return m_meter; }
Q_INVOKABLE void setMeter(Emeter m) { m_meter = m; }
Q_INVOKABLE int upper() const; /**< Returns upper digit of time signature */
Q_INVOKABLE int lower() const; /**< Returns lower digit of time signature */
/**
* Returns upper digit of time signature
*/
Q_INVOKABLE int upper() const;
/**
* Returns lower digit of time signature
*/
Q_INVOKABLE int lower() const;
/**
* Returns text symbol of this time signature,
......@@ -56,17 +64,20 @@ public:
*/
Q_INVOKABLE QString symbol() const;
/**
* Returns numeric value representing duration of single measure,
* which is based on Trhythm calculation (RVALUE)
* 3/4 is 72, 4/4 is 96 (RVALUE), etc.
*/
/**
* Returns numeric value representing duration of single measure,
* which is based on Trhythm calculation (RVALUE)
* 3/4 is 72, 4/4 is 96 (RVALUE), etc.
*/
Q_INVOKABLE quint16 duration() const;
void toXml(QXmlStreamWriter& xml) const;
bool fromXml(QXmlStreamReader& xml);
Q_INVOKABLE void debug(const QString& text = QString()); /**< Prints current meter to std out with given text */
/**
* Prints current meter to std out with given text
*/
Q_INVOKABLE void debug(const QString& text = QString());
bool operator==(const Tmeter& m) const { return meter() == m.meter(); }
bool operator!=(const Tmeter& m) const { return meter() != m.meter(); }
......
......@@ -205,19 +205,16 @@ void TnoteObject::setNote(const Tnote& n) {
}
/** Overrides standard @p setX() method to shift note segment about accidental symbol width (if it is set) */
void TnoteObject::setX(qreal xx) {
QQuickItem::setX(xx + (m_note->alter ? m_alter->width() : 0.0));
}
/** shortcut to X coordinate of right note corner plus gap related to rhythm and staff gap factor */
qreal TnoteObject::rightX() {
return x() + width() + staff()->gapFactor() * rhythmFactor();
}
/** Returns gap factor after this note item depends on current rhythm value */
qreal TnoteObject::rhythmFactor() {
if (m_note->rhythm() == Trhythm::NoRhythm)
return 0.0;
......
......@@ -63,10 +63,19 @@ public:
QColor color() { return m_head->property("color").value<QColor>(); }
void setColor(const QColor& c);
/**
* Overrides standard @p setX() method to shift note segment about accidental symbol width (if it is set)
*/
void setX(qreal xx);
/**
* shortcut to X coordinate of right note corner plus gap related to rhythm and staff gap factor
*/
qreal rightX();
/**
* Returns gap factor after this note item depends on current rhythm value
*/
qreal rhythmFactor();
signals:
......
......@@ -32,6 +32,7 @@ TscoreObject::TscoreObject(QObject* parent) :
m_clefOffset(TclefOffset(3, 1))
{
m_meter = new Tmeter(Tmeter::Meter_4_4);
setMeter(4); // Tmeter::Meter_4_4
m_measures << new TmeasureObject(this);
}
......@@ -73,6 +74,43 @@ void TscoreObject::setKeySignatureEnabled(bool enKey) {
}
void TscoreObject::setMeter(int m) {
// set notes grouping
m_meter->setMeter(static_cast<Tmeter::Emeter>(m));
m_meterGroups.clear();
if (m_meter->lower() == 4) { // simple grouping: one group for each quarter
m_meterGroups << 24 << 48; // 2/4 and above
if (m_meter->meter() > Tmeter::Meter_2_4)
m_meterGroups << 72;
if (m_meter->meter() > Tmeter::Meter_3_4)
m_meterGroups << 96;
if (m_meter->meter() > Tmeter::Meter_4_4)
m_meterGroups << 120;
if (m_meter->meter() > Tmeter::Meter_5_4)
m_meterGroups << 144;
if (m_meter->meter() > Tmeter::Meter_6_4)
m_meterGroups << 168;
} else {
if (m_meter->meter() == Tmeter::Meter_3_8)
m_meterGroups << 36;
else if (m_meter->meter() == Tmeter::Meter_5_8)
m_meterGroups << 36 << 60;
else if (m_meter->meter() == Tmeter::Meter_6_8)
m_meterGroups << 36 << 72;
else if (m_meter->meter() == Tmeter::Meter_7_8)
m_meterGroups << 36 << 60 << 84;
else if (m_meter->meter() == Tmeter::Meter_9_8)
m_meterGroups << 36 << 72 << 108;
else if (m_meter->meter() == Tmeter::Meter_12_8)
m_meterGroups << 36 << 72 << 108 << 144;
}
qDebug() << "[TscoreObject] Meter changed" << m_meterGroups;
}
int TscoreObject::meterToInt() { return static_cast<int>(m_meter->meter()); }
//#################################################################################################
//################### PROTECTED ############################################
//#################################################################################################
......
......@@ -55,6 +55,7 @@ class NOOTKACORE_EXPORT TscoreObject : public QObject
Q_OBJECT
Q_PROPERTY(QObject* parent READ parent WRITE setParent)
Q_PROPERTY(int meter READ meterToInt WRITE setMeter NOTIFY meterChanged)
friend class TstaffObject;
friend class TmeasureObject;
......@@ -73,9 +74,28 @@ public:
void setKeySignatureEnabled(bool enKey);
Tmeter* meter() const { return m_meter; }
void setMeter(int m);
int meterToInt();
/**
* Returns duration of given @param grNr group starting from measure beginning
* Describes grouping (beaming - beam connections) of notes in a single measure for current meter.
* This is a group of a few int values - each representing duration of the one group:
* - for 3/8 it is only single 36 value - whole measure under one beam
* - for 3/4 it is 24, 48, 72) - three groups
*/
quint8 groupPos(int grNr) { return m_meterGroups[grNr]; }
/**
* Number of beaming groups for this meter
*/
int groupCount() { return m_meterGroups.count(); }
QList<Tnote>& notes();
signals:
void meterChanged();
protected:
void addStaff(TstaffObject* st);
......@@ -89,6 +109,7 @@ private:
QList<TstaffObject*> m_staves;
QList<TmeasureObject*> m_measures;
QList<Tnote> m_notes;
QList<quint8> m_meterGroups;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment