Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
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  *****************************************************************************/
20 //=============================================================================
21 // Application Class
22 //=============================================================================
24 #ifndef APPLICATION_H
25 #define APPLICATION_H
27 #include <QObject>
28 #include <QApplication>
29 #include <QQmlApplicationEngine>
30 #include <QSettings>
31 #include <QTranslator>
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/filehandler.h"
49 extern void mobileError(QString msg);
60 class Application : public QObject, public Log
61 {
63 public:
64  Application (QApplication &app);
65  void init (QQmlApplicationEngine &engine);
66  void start();
67  void stop();
68  void exit();
70  void suspend();
71  void resume();
73  void installTranslations();
74  bool restartRequested() { return mRestartRequest; }
76 public:
78  bool loadMidiFile (QString filename);
80  void mobileMessage(QString msg);
82 public slots:
83  // Discover feedback loop
87 private slots:
88  // System
89  void handleApplicationStates(Qt::ApplicationState state);
90  void restartApplication();
91  void changeLocale (QString locale);
93  // Internet download
94  void cancelLoading();
95  void loadingFinished (bool success);
96  void loadInstrument (int selectedindex);
97  void newInstrumentDownloaded (QString localpath);
99  void startDownload (bool forced=false);
101  // Audio
102  void selectAudioParameters (int devIndex, int srIndex,
103  int buffersize, int packetsize);
104  void resetAudioParameters();
105  void playStartupSound();
106  void onAudioDevicesAdded(QStringList list);
107  void onAudioDevicesRemoved(QStringList list);
108  void onChangeOfAvailableAudioDevices(QStringList list);
110  void onConnectionSuccessfullyEstablished(bool success);
112  // Various
113  void hearExample(int number);
114  void emitAveragePitchProgression (double pitchProgression);
118 signals:
119  // System
120  void setQmlLocale(QVariant string);
121  void showDownloadDialog();
122  void getSettingsFromQml();
123  void sendMobileMessage(QVariant string);
125  // Instrument selection
126  void setQmlInstrumentNames (QVariant stringlist);
127  void setQmlSelectedInstrument (QVariant index);
128  void startLoadingInstrument (QString name);
130  // Audio
131  void setAudioDeviceName (QVariant name);
132  void setAudioDeviceList (QVariant list, QVariant index);
133  void setAudioSampleRates (QVariant list, QVariant index);
134  void setAudioBufferSizes (QVariant buffer, QVariant packet);
135  void connectAudioDevice (bool active);
137  // Tuning
138  void signalCircularGauge (QVariant progression);
140  // Various
141  void setSelectedExample (QVariant number);
143 private:
144  void setInstrumentSelector (int index=0);
145  QStringList updateShownInstrumentNames();
146  QString shorten(const QString &device, int truncation=30) const;
148 private:
149  // System
150  QApplication* pApplication;
152  bool mStarted;
153  QSettings mSettings;
154  QString mLocale;
156  QTranslator mQtTranslator;
157  QTranslator mAppTranslator;
179 };
181 #endif // APPLICATION_H
void stop()
Stop the application and its components.
QSettings mSettings
Definition: application.h:153
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:176
Downloader * getDownloader()
Definition: application.h:77
void playStartupSound()
Play startup sound.
Class handling Midi events.
Definition: midihandler.h:38
void setAudioSampleRates(QVariant list, QVariant index)
MidiMicrotonal mMidiMicrotonalConverter
Definition: application.h:163
bool loadMidiFile(QString filename)
Load a Midi file.
bool mSuspended
Definition: application.h:177
Class managing the generation of sound.
double mLastEmittedPitchProgression
Definition: application.h:178
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:168
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:158
Create a data log of keypress and tuning events.
Definition: logfile.h:42
Class for playing a startup soundThis module manages to play a short audio file at startup (welcome j...
Definition: startupsound.h:46
void emitAveragePitchProgression(double pitchProgression)
Emit the newly calculated average pitch progression.
QApplication * pApplication
Definition: application.h:150
void onConnectionSuccessfullyEstablished(bool success)
Private slot: on audio connection established.
void allInstrumentsDownloaded()
Private slot: All instrumenst downloaded.
QString mCurrentMidiDevice
Definition: application.h:174
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:169
QTranslator mQtTranslator
Definition: application.h:156
QStringList mAvailableMidiDevices
Definition: application.h:172
void disableScreenSaver()
Definition: application.h:115
void setSelectedExample(QVariant number)
This is the main class of the tuner module.
Definition: tuner.h:49
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:171
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:161
Touchscreen keyboard.
void resetAudioParameters()
Reset audio parameters.
bool mMidiAutomaticRecognition
Definition: application.h:175
Instrument mInstrument
Definition: application.h:166
void onAudioDevicesAdded(QStringList list)
Private slot: New audio device added (test)
void cancelLoading()
Private slot: Cancel the loading process.
bool mRestartRequest
Definition: application.h:155
SoundGenerator mSoundGenerator
Definition: application.h:167
FileHandler mFileHandler
Definition: application.h:159
void restartApplication()
Restart the application by force.
StartupSound mStartupSound
Definition: application.h:151
QStringList mAvailableMidiOutputDevices
Definition: application.h:173
void startDownload(bool forced=false)
Private slot: Start download.
void resume()
AudioOutput mAudioOutput
Definition: application.h:164
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:154
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
Module for a file-open dialog.
Definition: filehandler.h:35
int mNumberOfExample
Definition: application.h:165
void enableScreenSaver()
Definition: application.h:116
QTranslator mAppTranslator
Definition: application.h:157
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:170
void onClosedMidiLoopDetected()
Slot: Closed Midi feedback loop discovered, inhibit converter.