Just Intonation  Version 1.3.0 (18)
Explore scale-independent dynamically adapting tuning in just intonation
application.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 // Application Class
22 //=============================================================================
23 
24 #ifndef APPLICATION_H
25 #define APPLICATION_H
26 
27 #include <QObject>
28 #include <QApplication>
29 #include <QQmlApplicationEngine>
30 #include <QSettings>
31 #include <QTranslator>
32 
33 #include "system/startupsound.h"
34 #include "system/downloader.h"
35 #include "instrument/instrument.h"
36 #include "audio/audiooutput.h"
37 #include "sampler/soundgenerator.h"
38 #include "sampler/midihandler.h"
39 #include "midiplayer/midiplayer.h"
40 #include "midi.h"
42 #include "audio/audiooutput.h"
43 #include "tuner/tuner.h"
44 #include "system/logfile.h"
45 #include "touchscreenkeyboard.h"
46 #include "system/fileopendialog.h"
48 
49 extern void mobileError(QString msg);
50 
59 
60 class Application : public QObject, public Log
61 {
62  Q_OBJECT
63 public:
64  Application (QApplication &app);
65  void init (QQmlApplicationEngine &engine);
66  void start();
67  void stop();
68  void exit();
69 
70  void suspend();
71  void resume();
72 
73  void installTranslations();
74  bool restartRequested() { return mRestartRequest; }
75 
76 public:
78  bool loadMidiFile (QString filename);
79 
80  void mobileMessage(QString msg);
81 
82 public slots:
83  // Discover feedback loop
86 
87 private slots:
88  // System
89  void handleApplicationStates(Qt::ApplicationState state);
90  void restartApplication();
91  void changeLocale (QString locale);
92 
93  // Internet download
94  void cancelLoading();
95  void loadingFinished (bool success);
96  void loadInstrument (int selectedindex);
97  void newInstrumentDownloaded (QString localpath);
98  void startDownload (bool forced=false);
99 
100  // Audio
101  void selectAudioParameters (int devIndex, int srIndex,
102  int buffersize, int packetsize);
103  void resetAudioParameters();
104  void onAudioDevicesAdded(QStringList list);
105  void onAudioDevicesRemoved(QStringList list);
106  void onChangeOfAvailableAudioDevices(QStringList list);
108  void onConnectionSuccessfullyEstablished(bool success);
109 
110  // Various
111  void hearExample(int number);
112  void emitAveragePitchProgression (double pitchProgression);
115 
116 signals:
117  // System
118  void setQmlLocale(QVariant string);
119  void showDownloadDialog();
120  void getSettingsFromQml();
121  void sendMobileMessage(QVariant string);
122 
123  // Instrument selection
124  void setQmlInstrumentNames (QVariant stringlist);
125  void setQmlSelectedInstrument (QVariant index);
126  void startLoadingInstrument (QString name);
127 
128  // Audio
129  void setAudioDeviceName (QVariant name);
130  void setAudioDeviceList (QVariant list, QVariant index);
131  void setAudioSampleRates (QVariant list, QVariant index);
132  void setAudioBufferSizes (QVariant buffer, QVariant packet);
133  void connectAudioDevice (bool active);
134 
135  // Tuning
136  void signalCircularGauge (QVariant progression);
137 
138  // Various
139  void setSelectedExample (QVariant number);
140 
141 private:
142  void setInstrumentSelector (int index=0);
143  QStringList updateShownInstrumentNames();
144  QString shorten(const QString &device, int truncation=30) const;
145 
146 private:
147  // System
148  QApplication* pApplication;
150  bool mStarted;
151  QSettings mSettings;
152  QString mLocale;
154  QTranslator mQtTranslator;
155  QTranslator mAppTranslator;
158 
177 };
178 
179 #endif // APPLICATION_H
void stop()
Stop the application and its components.
QSettings mSettings
Definition: application.h:151
void setInstrumentSelector(int index=0)
Set the content of the instrument selector.
void suspend()
Suspend the application This function suspends the application and all modules. This is essential e...
bool mMidiPlayerWasPlaying
Definition: application.h:174
Downloader * getDownloader()
Definition: application.h:77
Class handling Midi events.
Definition: midihandler.h:38
void setAudioSampleRates(QVariant list, QVariant index)
MidiMicrotonal mMidiMicrotonalConverter
Definition: application.h:161
bool loadMidiFile(QString filename)
Load a Midi file.
bool mSuspended
Definition: application.h:175
Class managing the generation of sound.
double mLastEmittedPitchProgression
Definition: application.h:176
void changeLocale(QString locale)
Slot: Change the language.
void hearExample(int number)
Private slot: Hear a Midi example.
void newInstrumentDownloaded(QString localpath)
Private slot: New instrument downloaded.
void setQmlSelectedInstrument(QVariant index)
MidiHandler mMidiHandler
Definition: application.h:166
void handleApplicationStates(Qt::ApplicationState state)
Function executed when application state changes (platform-dependent) Takes action if the state of th...
static PlatformTools & getSingleton()
Definition: platformtools.h:56
void startLoadingInstrument(QString name)
void showDownloadDialog()
Class handling Midi input and output.
Definition: midi.h:39
void onAudioDevicesRemoved(QStringList list)
Private slot: An audio device has been removed (test)
void setAudioDeviceName(QVariant name)
void init(QQmlApplicationEngine &engine)
Initialization of the application.
void mobileError(QString msg)
void setQmlInstrumentNames(QVariant stringlist)
void start()
Start the application and its components.
void setQmlLocale(QVariant string)
Midi Player.
Definition: midiplayer.h:84
void connectAudioDevice(bool active)
void onInputOutputStatusChanged()
I/O configuration changed, cancel converter inhibition.
Application(QApplication &app)
Application constructor.
Definition: application.cpp:47
QString shorten(const QString &device, int truncation=30) const
Shorten very long device names.
Downloader mDownloader
Definition: application.h:156
Create a data log of keypress and tuning events.
Definition: logfile.h:41
Class for playing a startup soundThis module manages to play a short audio file at startup (welcome j...
Definition: startupsound.h:44
void emitAveragePitchProgression(double pitchProgression)
Emit the newly calculated average pitch progression.
QApplication * pApplication
Definition: application.h:148
void onConnectionSuccessfullyEstablished(bool success)
Private slot: on audio connection established.
FileOpenDialog mFileOpenDialog
Definition: application.h:157
QString mCurrentMidiDevice
Definition: application.h:172
Module for a file-open dialog.
Class managing the download of large files from a repository in the background.
Definition: downloader.h:48
void getSettingsFromQml()
Class describing an instrument.
Definition: instrument.h:36
Tuner mTuner
Definition: application.h:167
QTranslator mQtTranslator
Definition: application.h:154
QStringList mAvailableMidiDevices
Definition: application.h:170
void disableScreenSaver()
Definition: application.h:113
void setSelectedExample(QVariant number)
This is the main class of the tuner module to be included by the user.
Definition: tuner.h:48
void loadInstrument(int selectedindex)
Private slot: Load an instrument.
Class for converting an ordinary Midi stream into a microtonal one.
TouchscreenKeyboard mKeyboard
Definition: application.h:169
void exit()
Exit from the application and all its components.
Class for audio output.
Definition: audiooutput.h:45
bool restartRequested()
Definition: application.h:74
MidiPlayer mMidiPlayer
Definition: application.h:159
Touchscreen keyboard.
void resetAudioParameters()
Reset audio parameters.
bool mMidiAutomaticRecognition
Definition: application.h:173
Instrument mInstrument
Definition: application.h:164
void onAudioDevicesAdded(QStringList list)
Private slot: New audio device added (test)
void cancelLoading()
Private slot: Cancel the loading process.
bool mRestartRequest
Definition: application.h:153
SoundGenerator mSoundGenerator
Definition: application.h:165
void restartApplication()
Restart the application by force.
StartupSound mStartupSound
Definition: application.h:149
QStringList mAvailableMidiOutputDevices
Definition: application.h:171
void startDownload(bool forced=false)
Private slot: Start download.
void resume()
resume
AudioOutput mAudioOutput
Definition: application.h:162
void loadingFinished(bool success)
Private slot: Loading finished.
void selectAudioParameters(int devIndex, int srIndex, int buffersize, int packetsize)
Private slot: Select audio parameters.
void setAudioDeviceList(QVariant list, QVariant index)
QString mLocale
Definition: application.h:152
void sendMobileMessage(QVariant string)
void installTranslations()
Install existing translations.
virtual void enableScreensaver()
Function to enable the screen saver.
Definition: platformtools.h:80
QStringList updateShownInstrumentNames()
Update the list of instruments in the Qml Combo box.
virtual void disableScreensaver()
Function to disable the screen saver.
Definition: platformtools.h:73
void onChangeOfAvailableAudioDevices(QStringList list)
Private slot: The list of availabel devices has changed (test)
Main application.
Definition: application.h:60
int mNumberOfExample
Definition: application.h:163
void enableScreenSaver()
Definition: application.h:114
QTranslator mAppTranslator
Definition: application.h:155
void setAudioBufferSizes(QVariant buffer, QVariant packet)
void onCurrentDeviceParametersChanged()
Private slot: on current audio device parameters changed.
void mobileMessage(QString msg)
Show error message on mobile phone while it is connected to a keyboard.
Base class for managing log messages.
Definition: log.h:83
void signalCircularGauge(QVariant progression)
LogFile mTuningLog
Definition: application.h:168
void onClosedMidiLoopDetected()
Slot: Closed Midi feedback loop discovered, inhibit converter.