Just Intonation  Version 1.3.0 (18)
Explore scale-independent dynamically adapting tuning in just intonation
logfile.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //=============================================================================
21 // Tuning Log - Create a data log of all tuning events
22 //=============================================================================
23 
24 #ifndef LOGFILE_H
25 #define LOGFILE_H
26 
27 #include <QMidiMessage>
28 #include <QMap>
29 #include <QVariant>
30 #include <QElapsedTimer>
31 #include <QFile>
32 #include <QTextStream>
33 
34 #include "system/log.h"
35 
40 
41 class LogFile : public QObject, public Log
42 {
43  Q_OBJECT
44 public:
45  LogFile();
46 
47 signals:
49  void signalNewLogMessage (QVariant str);
50 
51 public slots:
52  void activateLogFile (bool on);
53  void receiveMidiEvent (QMidiMessage event);
54  void receiveTuningCorrections(const QMap<int, double> &corrections);
55 
56 private:
57  QString noteName(int key);
58  void addLine (qint64 milliseconds, const QString &line);
59  void registerKeypress (int key, bool pressed);
60  void flushKeypress ();
61 
62 private:
63  QElapsedTimer mTimer;
64  bool isActive;
65  QList<int> mPressed, mReleased;
67  QString mTuningMessage;
68 };
69 
70 #endif // LOGFILE_H
void registerKeypress(int key, bool pressed)
Public slot: Register pressed or released key.
Definition: logfile.cpp:184
QList< int > mReleased
Definition: logfile.h:65
void flushKeypress()
Terminate collection of multiple keypresses/releases and send them to the logfile.
Definition: logfile.cpp:207
void signalNewLogMessage(QVariant str)
bool isActive
Definition: logfile.h:64
void addLine(qint64 milliseconds, const QString &line)
Add a line to the logfile output.
Definition: logfile.cpp:161
void receiveTuningCorrections(const QMap< int, double > &corrections)
Public slot: Receive tuning corrections.
Definition: logfile.cpp:124
Create a data log of keypress and tuning events.
Definition: logfile.h:41
QElapsedTimer mTimer
Definition: logfile.h:63
QList< int > mPressed
Definition: logfile.h:65
QString mTuningMessage
Definition: logfile.h:67
void activateLogFile(bool on)
Switch logging on and off.
Definition: logfile.cpp:57
void receiveMidiEvent(QMidiMessage event)
Public slot: Receive MIDI event.
Definition: logfile.cpp:92
qint64 mTimeOfLastKeypress
Definition: logfile.h:66
Base class for managing log messages.
Definition: log.h:83
QString noteName(int key)
Note Name of a key.
Definition: logfile.cpp:74
LogFile()
Constructor of the LogFile, resets member variables.
Definition: logfile.cpp:36