#ifndef MAINWINDOW_H | |||||
#define MAINWINDOW_H | |||||
#include <QMainWindow> | |||||
#include <QGraphicsView> | |||||
/* MAINWINDOW_H | |||||
* CLASS DECLARATION | |||||
* | |||||
* CHANGLOG: | |||||
* NAME: | CHANGES: | DATE: | | |||||
* Mewes, Lars | Neuerstellung | 24.09.2021 | | |||||
* Mewes, Lars | Änderung auf QTabWidget (statt QSplitter) + Midi-Versuche | 28.09.2021 | | |||||
* | | | | |||||
* | | | | |||||
* | |||||
* DESCRIPTION: | |||||
* Diese Klasse ist die "Hauptklasse" und besitzt die Farbtonskala "ColorScale", die QGraphicsViews sowie die Klaviatur und den Quintenzirkel | |||||
* | |||||
* TO-DOs: | |||||
* | |||||
* | |||||
*/ | |||||
#include <QGraphicsScene> | |||||
#include <QTabWidget> | |||||
#include <QPlainTextEdit> | |||||
#include <QThread> | |||||
#include "RtMidi.h" | |||||
#include "MidiListener.h" | |||||
#include "PianoKeyBoard.h" | |||||
#include "Tone.h" | |||||
#include "ColorScale.h" | |||||
#include "CircleOfFifths.h" | |||||
class MainWindow : public QMainWindow | |||||
{ | |||||
Q_OBJECT | |||||
QTabWidget * tabWidget; | |||||
QGraphicsView * gV_Keyboard; | |||||
QGraphicsView * gV_CircleOfFifths; | |||||
QGraphicsView * gV_Demo; | |||||
QPlainTextEdit * midiLog; | |||||
PianoKeyBoard * pianoKeyBoard; | |||||
CircleOfFifths * circleOfFifths; | |||||
QGraphicsScene * scene_Demo; | |||||
QThread midiThread; | |||||
MidiListener * midiPiano; | |||||
void lightShowDemonstration(int b1, int b2, int b3); | |||||
public slots: | |||||
void handleMidiMessage(int b1, int b2, int b3); | |||||
signals: | |||||
void startMidiListener(int Port = 1); | |||||
void nextMidiMessage(); | |||||
void stopMidi(); | |||||
public: | |||||
RtMidiIn * midiin = nullptr; | |||||
MainWindow(QWidget *parent = nullptr); | |||||
virtual ~MainWindow(); | |||||
ColorScale colorScale; | |||||
}; | |||||
#endif // MAINWINDOW_H |
#include "MidiListener.h" | |||||
#include <vector> | |||||
#include <QString> | |||||
void MidiListener::start(int Port){ | |||||
midiin = new RtMidiIn(RtMidi::Api::LINUX_ALSA, "Scrjabin"); | |||||
try { | |||||
midiin->openPort(Port); | |||||
} | |||||
catch ( RtMidiError &error ) { | |||||
error.printMessage(); | |||||
} | |||||
emit newMidiMessage(0,0,0); | |||||
}; | |||||
void MidiListener::listen(){ | |||||
std::vector<unsigned char> message; | |||||
// Don't ignore sysex, timing, or active sensing messages. | |||||
midiin->ignoreTypes( false, false, false ); | |||||
midiin->getMessage( &message ); | |||||
if ( message.size() == 3 ) | |||||
emit newMidiMessage(message[0], message[1], message[2]); | |||||
else | |||||
emit newMidiMessage(0,0,0); | |||||
}; | |||||
void MidiListener::stop(){ | |||||
delete midiin; | |||||
this->disconnect(); | |||||
this->~MidiListener(); | |||||
} | |||||
MidiListener::~MidiListener(){ | |||||
} |
#pragma once | |||||
#include "RtMidi.h" | |||||
#include <iostream> | |||||
#include <QObject> | |||||
class MidiListener: public QObject{ | |||||
Q_OBJECT | |||||
RtMidiIn * midiin; | |||||
public: | |||||
~MidiListener(); | |||||
public slots: | |||||
void start(int Port = 0); | |||||
void listen(); | |||||
void stop(); | |||||
signals: | |||||
void newMidiMessage(int b1, int b2, int b3); | |||||
}; |
#include "PianoKey.h" | |||||
#include <QBrush> | |||||
PianoKey::PianoKey(Tone *tone): tone(tone){ | |||||
if(tone->getFlatTone()){ | |||||
setRect(-350+tone->getKeyboardPosition()*100,0, 100, 700); | |||||
} | |||||
else{ | |||||
setRect(-350+75+tone->getKeyboardPosition()*100,0, 50, 500); | |||||
setZValue(1); | |||||
} | |||||
setBrush(QBrush(tone->getColor())); | |||||
}; | |||||
PianoKey::~PianoKey(){}; | |||||
Tone * PianoKey::getTone()const{ | |||||
return tone; | |||||
}; | |||||
//SLOTS: | |||||
void PianoKey::redraw(){ | |||||
setBrush(QBrush(tone->getColor())); | |||||
}; | |||||
/* PIANOKEY_H | |||||
* CLASS DECLARATION | |||||
* | |||||
* CHANGLOG: | |||||
* NAME: | CHANGES: | DATE: | | |||||
* Mewes, Lars | Neuerstellung | 24.09.2021 | | |||||
* | | | | |||||
* | | | | |||||
* | | | | |||||
* | |||||
* DESCRIPTION: | |||||
* Diese Klasse enthält analog zu "CircleElement" alle Bestandteile einer Klaviertaste. | |||||
* | |||||
* TO-DOs: | |||||
* Beschriftung auf den Tasten ergänzen | |||||
* | |||||
*/ | |||||
#pragma once | |||||
#include <QGraphicsRectItem> | |||||
#include <QString> | |||||
#include "Tone.h" | |||||
class PianoKey: public QObject, public QGraphicsRectItem{ | |||||
Q_OBJECT | |||||
Tone * tone; | |||||
public: | |||||
PianoKey(QString _tone, int pos, QColor _col, bool flatTone = true); | |||||
PianoKey(Tone * tone); | |||||
virtual ~PianoKey(); | |||||
Tone * getTone()const; | |||||
public slots: | |||||
void redraw(); | |||||
}; |