[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [minuet/refactoring] src: Remove drumstick-related classes from shell
From: Sandro S. Andrade <sandroandrade () kde ! org>
Date: 2016-06-30 22:43:40
Message-ID: E1bIkgO-00023i-2R () code ! kde ! org
[Download RAW message or body]
Git commit 19dc247831b49412fd05d16757476d22f2b59e89 by Sandro S. Andrade.
Committed on 30/06/2016 at 22:43.
Pushed by sandroandrade into branch 'refactoring'.
Remove drumstick-related classes from shell
M +1 -1 src/interfaces/icore.h
M +0 -6 src/shell/CMakeLists.txt
M +0 -2 src/shell/exercisecontroller.cpp
M +0 -2 src/shell/exercisecontroller.h
D +0 -515 src/shell/midisequencer.cpp
D +0 -155 src/shell/midisequencer.h
D +0 -182 src/shell/midisequenceroutputthread.cpp
D +0 -72 src/shell/midisequenceroutputthread.h
M +0 -1 src/shell/minuetmainwindow.cpp
M +0 -1 src/shell/minuetmainwindow.h
M +2 -0 src/shell/plugincontroller.cpp
M +0 -2 src/shell/qml/MinuetMenu.qml
D +0 -81 src/shell/song.cpp
D +0 -60 src/shell/song.h
http://commits.kde.org/minuet/19dc247831b49412fd05d16757476d22f2b59e89
diff --git a/src/interfaces/icore.h b/src/interfaces/icore.h
index feaf879..1a38940 100644
--- a/src/interfaces/icore.h
+++ b/src/interfaces/icore.h
@@ -45,7 +45,7 @@ class MINUETINTERFACES_EXPORT ICore : public QObject
Q_PROPERTY(IUiController * uiController READ uiController);
public:
- ~ICore() override;
+ virtual ~ICore() override;
static ICore *self();
diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt
index 33b98de..a2c6862 100644
--- a/src/shell/CMakeLists.txt
+++ b/src/shell/CMakeLists.txt
@@ -7,9 +7,6 @@ set(minuetshell_LIB_SRCS
exercisecontroller.cpp
minuetmainwindow.cpp
wizard.cpp
- midisequencer.cpp
- song.cpp
- midisequenceroutputthread.cpp
)
ki18n_wrap_ui(minuetshell_LIB_SRCS
@@ -58,9 +55,6 @@ install(FILES
exercisecontroller.h
minuetmainwindow.h
wizard.h
- midisequencer.h
- song.h
- midisequenceroutputthread.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/minuet/shell
COMPONENT Devel
)
diff --git a/src/shell/exercisecontroller.cpp b/src/shell/exercisecontroller.cpp
index e36df6b..77b32d6 100644
--- a/src/shell/exercisecontroller.cpp
+++ b/src/shell/exercisecontroller.cpp
@@ -22,8 +22,6 @@
#include "exercisecontroller.h"
-#include "midisequencer.h"
-
#include <KLocalizedString>
#include <QDir>
diff --git a/src/shell/exercisecontroller.h b/src/shell/exercisecontroller.h
index c571180..02f6881 100644
--- a/src/shell/exercisecontroller.h
+++ b/src/shell/exercisecontroller.h
@@ -30,8 +30,6 @@
#include "minuetshellexport.h"
-class MidiSequencer;
-
namespace Minuet
{
diff --git a/src/shell/midisequencer.cpp b/src/shell/midisequencer.cpp
deleted file mode 100644
index 67447d3..0000000
--- a/src/shell/midisequencer.cpp
+++ /dev/null
@@ -1,515 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org>
-**
-** This program is free software; you can redistribute it and/or
-** modify it under the terms of the GNU General Public License as
-** published by the Free Software Foundation; either version 2 of
-** the License or (at your option) version 3 or any later version
-** accepted by the membership of KDE e.V. (or its successor approved
-** by the membership of KDE e.V.), which shall act as a proxy
-** defined in Section 14 of version 3 of the license.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#include "midisequencer.h"
-
-#include "minuetsettings.h"
-#include "midisequenceroutputthread.h"
-
-#include <KLocalizedString>
-#include <KMessageBox>
-
-#include <QtMath>
-#include <QLoggingCategory>
-#include <QApplication>
-
-#include <QtQml>
-
-Q_DECLARE_LOGGING_CATEGORY(MINUET)
-
-#include <drumstick/qsmf.h>
-#include <drumstick/alsaclient.h>
-
-MidiSequencer::MidiSequencer(QObject *parent) :
- QObject(parent),
- m_tick(0),
- m_song(0),
- m_eventSchedulingMode(FROM_ENGINE),
- m_state(StoppedState),
- m_playMode(ScalePlayMode)
-{
- qmlRegisterUncreatableType<MidiSequencer>("org.kde.minuet", 1, 0, \
"MidiSequencer", "MidiSequencer can't be instantiated");
- // MidiClient configuration
- m_client = new drumstick::MidiClient(this);
- try {
- m_client->open();
- } catch (const drumstick::SequencerError &err) {
- KMessageBox::error(qobject_cast<QWidget*>(this->parent()), i18n("Fatal error \
from the ALSA sequencer: \"%1\". "
- "This usually happens when the kernel doesn't have ALSA support, "
- "or the device node (/dev/snd/seq) doesn't exists, "
- "or the kernel module (snd_seq) is not loaded, "
- "or the user isn't a member of audio group. "
- "Please check your ALSA/MIDI configuration."
- , err.qstrError()),
- i18n("Minuet startup"));
- m_eventSchedulingMode = DAMAGED;
- return;
- }
- m_client->setClientName(QStringLiteral("MinuetSequencer"));
- m_client->setPoolOutput(50);
- // Connection for events generated when playing a MIDI
- connect(m_client, &drumstick::MidiClient::eventReceived, this, \
&MidiSequencer::eventReceived, Qt::QueuedConnection);
- m_client->setRealTimeInput(false);
- m_client->startSequencerInput();
-
- // Output port configuration
- m_outputPort = new drumstick::MidiPort(this);
- m_outputPort->attach(m_client);
- m_outputPort->setPortName(QStringLiteral("Minuet Sequencer Output Port"));
- m_outputPort->setCapability(SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ);
- m_outputPort->setPortType(SND_SEQ_PORT_TYPE_APPLICATION | \
SND_SEQ_PORT_TYPE_MIDI_GENERIC);
- m_outputPortId = m_outputPort->getPortId();
-
- // Input port configuration
- m_inputPort = new drumstick::MidiPort(this);
- m_inputPort->attach(m_client);
- m_inputPort->setPortName(QStringLiteral("Minuet Sequencer Input Port"));
- m_inputPort->setCapability(SND_SEQ_PORT_CAP_WRITE | \
SND_SEQ_PORT_CAP_SUBS_WRITE);
- m_inputPort->setPortType(SND_SEQ_PORT_TYPE_APPLICATION);
- m_inputPortId = m_inputPort->getPortId();
-
- // MidiQueue configuration
- m_queue = m_client->createQueue();
- m_queueId = m_queue->getId();
-
- // SMFReader configuration
- m_smfReader = new drumstick::QSmf(this);
- // Connections for events generated when reading a MIDI file
- connect(m_smfReader, &drumstick::QSmf::signalSMFHeader, this, \
&MidiSequencer::SMFHeader);
- connect(m_smfReader, &drumstick::QSmf::signalSMFNoteOn, this, \
&MidiSequencer::SMFNoteOn);
- connect(m_smfReader, &drumstick::QSmf::signalSMFNoteOff, this, \
&MidiSequencer::SMFNoteOff);
- connect(m_smfReader, &drumstick::QSmf::signalSMFKeyPress, this, \
&MidiSequencer::SMFKeyPress);
- connect(m_smfReader, &drumstick::QSmf::signalSMFCtlChange, this, \
&MidiSequencer::SMFCtlChange);
- connect(m_smfReader, &drumstick::QSmf::signalSMFPitchBend, this, \
&MidiSequencer::SMFPitchBend);
- connect(m_smfReader, &drumstick::QSmf::signalSMFProgram, this, \
&MidiSequencer::SMFProgram);
- connect(m_smfReader, &drumstick::QSmf::signalSMFChanPress, this, \
&MidiSequencer::SMFChanPress);
- connect(m_smfReader, &drumstick::QSmf::signalSMFSysex, this, \
&MidiSequencer::SMFSysex);
- connect(m_smfReader, &drumstick::QSmf::signalSMFText, this, \
&MidiSequencer::SMFText);
- connect(m_smfReader, &drumstick::QSmf::signalSMFTempo, this, \
&MidiSequencer::SMFTempo);
- connect(m_smfReader, &drumstick::QSmf::signalSMFTimeSig, this, \
&MidiSequencer::SMFTimeSig);
- connect(m_smfReader, &drumstick::QSmf::signalSMFKeySig, this, \
&MidiSequencer::SMFKeySig);
- connect(m_smfReader, &drumstick::QSmf::signalSMFError, this, \
&MidiSequencer::SMFError);
-
- // OutputThread
- m_midiSequencerOutputThread = new MidiSequencerOutputThread(m_client, \
m_outputPortId);
- connect(m_midiSequencerOutputThread, &MidiSequencerOutputThread::stopped, this, \
&MidiSequencer::outputThreadStopped);
- connect(m_midiSequencerOutputThread, &MidiSequencerOutputThread::finished, this, \
&MidiSequencer::resetMidiPlayer);
-
- // Subscribe to Minuet's virtual piano
- try {
- m_outputPort->subscribeTo(QStringLiteral("MinuetSequencer:1"));
- } catch (const drumstick::SequencerError &err) {
-// qCDebug(MINUET) << "Subscribe error";
- throw err;
- }
- setPlaybackLabel(QStringLiteral("00:00.00"));
-}
-
-MidiSequencer::~MidiSequencer()
-{
- m_client->stopSequencerInput();
- m_outputPort->detach();
- m_inputPort->detach();
- m_client->close();
- delete m_midiSequencerOutputThread;
- delete m_song;
-}
-
-void MidiSequencer::subscribeTo(const QString &portName)
-{
- try {
- if (!m_currentSubscribedPort.isEmpty()) {
-// qCDebug(MINUET) << "Unsubscribing to" << m_currentSubscribedPort;
- m_outputPort->unsubscribeTo(m_currentSubscribedPort);
- }
-// qCDebug(MINUET) << "Subscribing to" << portName;
- m_outputPort->subscribeTo(portName);
- m_currentSubscribedPort = portName;
- } catch (const drumstick::SequencerError &err) {
-// qCDebug(MINUET) << "Subscribe error";
- throw err;
- }
-}
-
-void MidiSequencer::openFile(const QString &fileName)
-{
- m_tick = 0;
- if (m_song) delete m_song;
- m_song = new Song();
- m_eventSchedulingMode = FROM_ENGINE;
- m_smfReader->readFromFile(fileName);
- m_song->sort();
- m_midiSequencerOutputThread->setSong(m_song);
-}
-
-void MidiSequencer::clearSong()
-{
- if(m_eventSchedulingMode == EXPLICIT)
- {
- stop();
- m_song->clear();
- }
-}
-
-void MidiSequencer::generateSong(QJsonArray selectedOptions)
-{
- Song *song = new Song;
- song->setHeader(0, 1, 60);
- song->setInitialTempo(600000);
- setSong(song);
- appendEvent(SMFTempo(600000), 0);
-
- unsigned int barStart = 0;
- if (m_playMode == RhythmPlayMode) {
- appendEvent(SMFNoteOn(9, 80, 120), 0);
- appendEvent(SMFNoteOn(9, 80, 120), 60);
- appendEvent(SMFNoteOn(9, 80, 120), 120);
- appendEvent(SMFNoteOn(9, 80, 120), 180);
- barStart = 240;
- }
-
- for (int i = 0; i < selectedOptions.size(); ++i) {
- QString sequence = \
selectedOptions[i].toObject()[QStringLiteral("sequence")].toString();
-
- unsigned int chosenRootNote = \
selectedOptions[i].toObject()[QStringLiteral("rootNote")].toString().toInt();
- if (m_playMode != RhythmPlayMode) {
- appendEvent(SMFNoteOn(1, chosenRootNote, 120), barStart);
- appendEvent(SMFNoteOff(1, chosenRootNote, 120), barStart + 60);
-
- unsigned int j = 1;
- drumstick::SequencerEvent *ev;
- foreach(const QString &additionalNote, sequence.split(' ')) {
- appendEvent(ev = SMFNoteOn(1,
- chosenRootNote + additionalNote.toInt(),
- 120),
- (m_playMode == ScalePlayMode) ? \
barStart+60*j:barStart);
- ev->setTag(0);
- appendEvent(ev = SMFNoteOff(1,
- chosenRootNote + additionalNote.toInt(),
- 120),
- (m_playMode == ScalePlayMode) ? \
barStart+60*(j+1):barStart+60);
- ev->setTag(0);
- ++j;
- }
- barStart += 60;
- }
- else {
- appendEvent(SMFNoteOn(9, 80, 120), barStart);
- foreach(QString additionalNote, sequence.split(' ')) { // \
krazy:exclude=foreach
- appendEvent(SMFNoteOn(9, 37, 120), barStart);
- float dotted = 1;
- if (additionalNote.endsWith('.')) {
- dotted = 1.5;
- additionalNote.chop(1);
- }
- barStart += dotted*60*(4.0/additionalNote.toInt());
- }
- }
- }
- if (m_playMode == RhythmPlayMode) {
- appendEvent(SMFNoteOn(9, 80, 120), barStart);
- }
-}
-
-void MidiSequencer::setPlayMode(PlayMode playMode)
-{
- m_playMode = playMode;
-}
-
-void MidiSequencer::appendEvent(drumstick::SequencerEvent *ev, unsigned long tick)
-{
- ev->setSource(m_outputPortId);
- if (ev->getSequencerType() != SND_SEQ_EVENT_TEMPO)
- ev->setSubscribers();
- ev->scheduleTick(m_queueId, tick, false);
- ev->setTag(1);
- m_song->append(ev);
- if (tick > m_tick)
- m_tick = tick;
-}
-
-QStringList MidiSequencer::availableOutputPorts() const
-{
- QStringList availableOutputPorts;
- QListIterator<drumstick::PortInfo> it(m_client->getAvailableOutputs());
- while(it.hasNext()) {
- drumstick::PortInfo p = it.next();
- availableOutputPorts << \
QStringLiteral("%1:%2").arg(p.getClientName()).arg(p.getPort());
- }
- return availableOutputPorts;
-}
-
-MidiSequencer::EventSchedulingMode MidiSequencer::schedulingMode() const
-{
- return m_eventSchedulingMode;
-}
-
-void MidiSequencer::resetMidiPlayer()
-{
- setPlaybackLabel(QStringLiteral("00:00.00"));
- setState(StoppedState);
-}
-
-int MidiSequencer::pitch() const
-{
- return m_midiSequencerOutputThread->pitch();
-}
-
-unsigned int MidiSequencer::volume() const
-{
- return m_midiSequencerOutputThread->volume();
-}
-
-unsigned int MidiSequencer::tempo() const
-{
- return m_queue->getTempo().getRealBPM();
-}
-
-QString MidiSequencer::playbackLabel() const
-{
- return m_playbackLabel;
-}
-
-MidiSequencer::State MidiSequencer::state() const
-{
- return m_state;
-}
-
-void MidiSequencer::play()
-{
- if (m_song && !m_song->isEmpty() && !m_midiSequencerOutputThread->isRunning()) {
- if (m_eventSchedulingMode == EXPLICIT) {
- if(m_midiSequencerOutputThread->getInitialPosition() == 0 || \
!m_midiSequencerOutputThread->hasNext())
- m_midiSequencerOutputThread->setSong(m_song);
- }
- m_midiSequencerOutputThread->start();
- setState(PlayingState);
- }
-}
-
-void MidiSequencer::pause()
-{
- if (m_midiSequencerOutputThread->isRunning()) {
- m_midiSequencerOutputThread->stop();
- m_midiSequencerOutputThread->setPosition(m_queue->getStatus().getTickTime());
- }
- setState(PausedState);
-}
-
-void MidiSequencer::stop()
-{
- m_midiSequencerOutputThread->stop();
- m_midiSequencerOutputThread->resetPosition();
- emit allNotesOff();
- setPlaybackLabel(QStringLiteral("00:00.00"));
- setState(StoppedState);
-}
-
-void MidiSequencer::setPitch(int pitch)
-{
- if (m_midiSequencerOutputThread->pitch() != pitch) {
- m_midiSequencerOutputThread->setPitch(pitch);
- emit pitchChanged();
- emit allNotesOff();
- }
-}
-
-void MidiSequencer::setVolume(unsigned int volume)
-{
- if (m_midiSequencerOutputThread->volume() != volume) {
- m_midiSequencerOutputThread->setVolume(volume);
- emit volumeChanged();
- }
-}
-
-void MidiSequencer::setTempo(unsigned int tempo)
-{
- float tempoFactor = (tempo*tempo + 100.0*tempo + 20000.0) / 40000.0;
- m_midiSequencerOutputThread->setTempoFactor(tempoFactor);
-
- drumstick::QueueTempo queueTempo = m_queue->getTempo();
- queueTempo.setTempoFactor(tempoFactor);
- m_queue->setTempo(queueTempo);
- m_client->drainOutput();
- emit tempoChanged();
-}
-
-void MidiSequencer::setPlaybackLabel(QString playbackLabel)
-{
- if (m_playbackLabel != playbackLabel) {
- m_playbackLabel = playbackLabel;
- emit playbackLabelChanged();
- }
-}
-
-void MidiSequencer::setState(State state)
-{
- m_state = state;
- emit stateChanged();
-}
-
-void MidiSequencer::setSong(Song *song)
-{
- delete m_song;
- m_song = song;
- m_eventSchedulingMode = EXPLICIT;
-}
-
-void MidiSequencer::SMFHeader(int format, int ntrks, int division)
-{
- m_song->setHeader(format, ntrks, division);
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFNoteOn(int chan, int pitch, int vel)
-{
- drumstick::SequencerEvent *ev = new drumstick::NoteOnEvent(chan, pitch, vel);
- if (m_eventSchedulingMode == FROM_ENGINE) appendEvent(ev);
- return ev;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFNoteOff(int chan, int pitch, int vel)
-{
- drumstick::SequencerEvent *ev = new drumstick::NoteOffEvent(chan, pitch, vel);
- if (m_eventSchedulingMode == FROM_ENGINE) appendEvent(ev);
- return ev;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFKeyPress(int chan, int pitch, int \
press)
-{
- drumstick::SequencerEvent *ev = new drumstick::KeyPressEvent(chan, pitch, \
press);
- if (m_eventSchedulingMode == FROM_ENGINE) appendEvent(ev);
- return ev;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFCtlChange(int chan, int ctl, int value)
-{
- drumstick::SequencerEvent *ev = new drumstick::ControllerEvent(chan, ctl, \
value);
- if (m_eventSchedulingMode == FROM_ENGINE) appendEvent(ev);
- return ev;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFPitchBend(int chan, int value)
-{
- drumstick::SequencerEvent *ev =new drumstick::PitchBendEvent(chan, value);
- if (m_eventSchedulingMode == FROM_ENGINE) appendEvent(ev);
- return ev;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFProgram(int chan, int patch)
-{
- drumstick::SequencerEvent *ev = new drumstick::ProgramChangeEvent(chan, patch);
- if (m_eventSchedulingMode == FROM_ENGINE) appendEvent(ev);
- return ev;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFChanPress(int chan, int press)
-{
- drumstick::SequencerEvent *ev = new drumstick::ChanPressEvent(chan, press);
- if (m_eventSchedulingMode == FROM_ENGINE) appendEvent(ev);
- return ev;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFSysex(const QByteArray &data)
-{
- drumstick::SequencerEvent *ev = new drumstick::SysExEvent(data);
- if (m_eventSchedulingMode == FROM_ENGINE) appendEvent(ev);
- return ev;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFText(int typ, const QString &data)
-{
- Q_UNUSED(typ);
- Q_UNUSED(data);
- return 0;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFTempo(int tempo)
-{
- if (m_song->initialTempo() == 0)
- m_song->setInitialTempo(tempo);
- drumstick::SequencerEvent *ev = new drumstick::TempoEvent(m_queueId, tempo);
- if (m_eventSchedulingMode == FROM_ENGINE) appendEvent(ev);
- return ev;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFTimeSig(int b0, int b1, int b2, int b3)
-{
- Q_UNUSED(b0);
- Q_UNUSED(b1);
- Q_UNUSED(b2);
- Q_UNUSED(b3);
- return 0;
-}
-
-drumstick::SequencerEvent *MidiSequencer::SMFKeySig(int b0, int b1)
-{
- Q_UNUSED(b0);
- Q_UNUSED(b1);
- return 0;
-}
-
-void MidiSequencer::SMFError(const QString &errorStr)
-{
- Q_UNUSED(errorStr);
-}
-
-void MidiSequencer::eventReceived(drumstick::SequencerEvent *ev)
-{
- static QChar fill('0');
- drumstick::KeyEvent *kev;
- if (!(kev = static_cast<drumstick::KeyEvent*>(ev)))
- return;
- if (kev->getSequencerType() == SND_SEQ_EVENT_NOTEON && kev->getTag() == 1)
- emit noteOn(kev->getChannel(), kev->getKey(), kev->getVelocity());
- if (kev->getSequencerType() == SND_SEQ_EVENT_NOTEOFF && kev->getTag() == 1)
- emit noteOff(kev->getChannel(), kev->getKey(), kev->getVelocity());
-
- if (m_tick != 0 && m_midiSequencerOutputThread->isRunning()) {
- const snd_seq_real_time_t *rt = m_queue->getStatus().getRealtime();
- int mins = rt->tv_sec / 60;
- int secs = rt->tv_sec % 60;
- int cnts = qFloor( rt->tv_nsec / 1.0e7 );
- setPlaybackLabel(QStringLiteral("%1:%2.%3").arg(mins,2,10,fill).arg(secs,2,10,fill).arg(cnts,2,10,fill));
- }
-}
-
-void MidiSequencer::outputThreadStopped()
-{
- for (int channel = 0; channel < 16; ++channel) {
- drumstick::ControllerEvent ev1(channel, MIDI_CTL_ALL_NOTES_OFF, 0);
- ev1.setSource(m_outputPortId);
- ev1.setSubscribers();
- ev1.setDirect();
- m_client->outputDirect(&ev1);
- drumstick::ControllerEvent ev2(channel, MIDI_CTL_ALL_SOUNDS_OFF, 0);
- ev2.setSource(m_outputPortId);
- ev2.setSubscribers();
- ev2.setDirect();
- m_client->outputDirect(&ev2);
- }
- m_client->drainOutput();
-}
-
-void MidiSequencer::appendEvent(drumstick::SequencerEvent *ev)
-{
- appendEvent(ev, m_smfReader->getCurrentTime());
-}
diff --git a/src/shell/midisequencer.h b/src/shell/midisequencer.h
deleted file mode 100644
index 2f0d414..0000000
--- a/src/shell/midisequencer.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org>
-**
-** This program is free software; you can redistribute it and/or
-** modify it under the terms of the GNU General Public License as
-** published by the Free Software Foundation; either version 2 of
-** the License or (at your option) version 3 or any later version
-** accepted by the membership of KDE e.V. (or its successor approved
-** by the membership of KDE e.V.), which shall act as a proxy
-** defined in Section 14 of version 3 of the license.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef MIDISEQUENCER_H
-#define MIDISEQUENCER_H
-
-#include "song.h"
-
-#include <QObject>
-
-#include <drumstick/alsaqueue.h>
-
-namespace drumstick {
- class QSmf;
- class MidiClient;
- class MidiPort;
- class SequencerEvent;
-}
-
-class MidiSequencerOutputThread;
-
-class MidiSequencer : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int pitch READ pitch WRITE setPitch NOTIFY pitchChanged)
- Q_PROPERTY(unsigned int volume READ volume WRITE setVolume NOTIFY volumeChanged)
- Q_PROPERTY(unsigned int tempo READ tempo WRITE setTempo NOTIFY tempoChanged)
- Q_PROPERTY(QString playbackLabel READ playbackLabel WRITE setPlaybackLabel \
NOTIFY playbackLabelChanged)
- Q_ENUMS(State)
- Q_PROPERTY(State state READ state NOTIFY stateChanged)
- Q_ENUMS(PlayMode)
-
-public:
- explicit MidiSequencer(QObject *parent = 0);
- virtual ~MidiSequencer();
-
- enum EventSchedulingMode {
- FROM_ENGINE = 0,
- EXPLICIT,
- DAMAGED
- };
- enum State {
- StoppedState = 0,
- PlayingState,
- PausedState
- };
- enum PlayMode {
- ScalePlayMode = 0,
- ChordPlayMode,
- RhythmPlayMode
- };
-
- void subscribeTo(const QString &portName);
- void openFile(const QString &fileName);
- void appendEvent(drumstick::SequencerEvent *ev, unsigned long tick);
- QStringList availableOutputPorts() const;
- EventSchedulingMode schedulingMode() const;
-
- int pitch() const;
- unsigned int volume() const;
- unsigned int tempo() const;
- QString playbackLabel() const;
- State state() const;
-
-Q_SIGNALS:
- void noteOn(int chan, int pitch, int vel);
- void noteOff(int chan, int pitch, int vel);
- void allNotesOff();
- void pitchChanged();
- void volumeChanged();
- void tempoChanged();
- void playbackLabelChanged();
- void stateChanged();
-
-public Q_SLOTS:
- void play();
- void pause();
- void stop();
- void setPitch(int pitch);
- void setVolume(unsigned int volume);
- void setTempo(unsigned int tempo);
- void setPlaybackLabel(QString playbackLabel);
- void setState(State state);
- void setSong(Song *song);
- void clearSong();
- void generateSong(QJsonArray selectedOptions);
- void setPlayMode(PlayMode playMode);
-
- // Slots for events generated when reading a MIDI file
- void SMFHeader(int format, int ntrks, int division);
- drumstick::SequencerEvent *SMFNoteOn(int chan, int pitch, int vel);
- drumstick::SequencerEvent *SMFNoteOff(int chan, int pitch, int vel);
- drumstick::SequencerEvent *SMFKeyPress(int chan, int pitch, int press);
- drumstick::SequencerEvent *SMFCtlChange(int chan, int ctl, int value);
- drumstick::SequencerEvent *SMFPitchBend(int chan, int value);
- drumstick::SequencerEvent *SMFProgram(int chan, int patch);
- drumstick::SequencerEvent *SMFChanPress(int chan, int press);
- drumstick::SequencerEvent *SMFSysex(const QByteArray &data);
- drumstick::SequencerEvent *SMFText(int typ, const QString &data);
- drumstick::SequencerEvent *SMFTempo(int tempo);
- drumstick::SequencerEvent *SMFTimeSig(int b0, int b1, int b2, int b3);
- drumstick::SequencerEvent *SMFKeySig(int b0, int b1);
- void SMFError(const QString &errorStr);
-
-private Q_SLOTS:
- // Slots for events generated when playing a MIDI
- void eventReceived(drumstick::SequencerEvent *ev);
-
- void outputThreadStopped();
- void resetMidiPlayer();
-
-private:
- void appendEvent(drumstick::SequencerEvent *ev);
-
-private:
- int m_outputPortId;
- int m_inputPortId;
- int m_queueId;
- unsigned long m_tick;
- Song *m_song;
- drumstick::MidiPort *m_outputPort;
- drumstick::MidiPort *m_inputPort;
- drumstick::QSmf *m_smfReader;
- drumstick::MidiQueue *m_queue;
- drumstick::MidiClient *m_client;
- MidiSequencerOutputThread *m_midiSequencerOutputThread;
- EventSchedulingMode m_eventSchedulingMode;
- QString m_currentSubscribedPort;
- QString m_playbackLabel;
- State m_state;
- PlayMode m_playMode;
-};
-
-#endif // MIDISEQUENCER_H
-
diff --git a/src/shell/midisequenceroutputthread.cpp \
b/src/shell/midisequenceroutputthread.cpp deleted file mode 100644
index d8783e4..0000000
--- a/src/shell/midisequenceroutputthread.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org>
-**
-** This program is free software; you can redistribute it and/or
-** modify it under the terms of the GNU General Public License as
-** published by the Free Software Foundation; either version 2 of
-** the License or (at your option) version 3 or any later version
-** accepted by the membership of KDE e.V. (or its successor approved
-** by the membership of KDE e.V.), which shall act as a proxy
-** defined in Section 14 of version 3 of the license.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#include "midisequenceroutputthread.h"
-
-#include "song.h"
-
-#include <drumstick/alsaqueue.h>
-
-#include <cmath>
-
-MidiSequencerOutputThread::MidiSequencerOutputThread(drumstick::MidiClient *client, \
int portId) :
- drumstick::SequencerOutputThread(client, portId),
- m_client(client),
- m_song(0),
- m_songPosition(0),
- m_lastEvent(0),
- m_volume(100),
- m_pitchShift(0),
- m_tempoFactor(1.0),
- m_songIterator(0)
-{
- for (int chan = 0; chan < MIDI_CHANNELS; ++chan)
- m_channelVolume[chan] = 100;
-}
-
-MidiSequencerOutputThread::~MidiSequencerOutputThread()
-{
- if (isRunning())
- stop();
- if (m_songIterator != 0)
- delete m_songIterator;
- if (m_lastEvent != 0)
- delete m_lastEvent;
-}
-
-bool MidiSequencerOutputThread::hasNext()
-{
- return m_songIterator->hasNext();
-}
-
-drumstick::SequencerEvent *MidiSequencerOutputThread::nextEvent()
-{
- if (m_lastEvent != 0)
- delete m_lastEvent;
-
- m_lastEvent = m_songIterator->next()->clone();
- switch (m_lastEvent->getSequencerType()) {
- case SND_SEQ_EVENT_NOTE:
- case SND_SEQ_EVENT_NOTEON:
- case SND_SEQ_EVENT_NOTEOFF:
- case SND_SEQ_EVENT_KEYPRESS: {
- drumstick::KeyEvent *kev = \
static_cast<drumstick::KeyEvent*>(m_lastEvent);
- if (kev->getChannel() != MIDI_GM_DRUM_CHANNEL)
- kev->setKey(kev->getKey() + m_pitchShift);
- }
- break;
- case SND_SEQ_EVENT_CONTROLLER: {
- drumstick::ControllerEvent *cev = \
static_cast<drumstick::ControllerEvent*>(m_lastEvent);
- if (cev->getParam() == MIDI_CTL_MSB_MAIN_VOLUME) {
- int chan = cev->getChannel();
- int value = cev->getValue();
- m_channelVolume[chan] = value;
- value = floor(value * m_volume / 100.0);
- if (value < 0) value = 0;
- if (value > 127) value = 127;
- cev->setValue(value);
- }
- }
- break;
- }
- return m_lastEvent;
-}
-
-void MidiSequencerOutputThread::setSong(Song *song)
-{
- m_song = song;
- if (m_songIterator)
- delete m_songIterator;
- m_songIterator = new QListIterator<drumstick::SequencerEvent *>(*song);
- m_songPosition = 0;
- drumstick::QueueTempo firstTempo = m_Queue->getTempo();
- firstTempo.setPPQ(m_song->division());
- firstTempo.setTempo(m_song->initialTempo());
- firstTempo.setTempoFactor(m_tempoFactor);
- m_Queue->setTempo(firstTempo);
-}
-
-void MidiSequencerOutputThread::setVolume(unsigned int volume)
-{
- m_volume = volume;
- for(int chan = 0; chan < MIDI_CHANNELS; ++chan) {
- int value = m_channelVolume[chan];
- value = floor(value * m_volume / 100.0);
- if (value < 0) value = 0;
- if (value > 127) value = 127;
- sendControllerEvent(chan, MIDI_CTL_MSB_MAIN_VOLUME, value);
- }
-}
-
-unsigned int MidiSequencerOutputThread::volume() const
-{
- return m_volume;
-}
-
-void MidiSequencerOutputThread::setPitch(int value)
-{
- bool playing = isRunning();
- if (playing) {
- stop();
- unsigned int pos = m_Queue->getStatus().getTickTime();
- m_Queue->clear();
- allNotesOff();
- setPosition(pos);
- }
- m_pitchShift = value;
- if (playing)
- start();
-}
-
-int MidiSequencerOutputThread::pitch() const
-{
- return m_pitchShift;
-}
-
-void MidiSequencerOutputThread::setTempoFactor(float value)
-{
- m_tempoFactor = value;
-}
-
-void MidiSequencerOutputThread::setPosition(unsigned int pos)
-{
- m_songPosition = pos;
- m_songIterator->toFront();
- while (m_songIterator->hasNext() && (m_songIterator->next()->getTick() < pos)) { \
};
- if (m_songIterator->hasPrevious())
- m_songIterator->previous();
-}
-
-void MidiSequencerOutputThread::resetPosition()
-{
- if ((m_song != NULL) && (m_songIterator != NULL)) {
- m_songIterator->toFront();
- m_songPosition = 0;
- }
-}
-
-void MidiSequencerOutputThread::allNotesOff()
-{
- for(int chan = 0; chan < MIDI_CHANNELS; ++chan) {
- sendControllerEvent(chan, MIDI_CTL_ALL_NOTES_OFF, 0);
- sendControllerEvent(chan, MIDI_CTL_ALL_SOUNDS_OFF, 0);
- }
-}
-
-void MidiSequencerOutputThread::sendControllerEvent(int chan, int control, int \
value)
-{
- drumstick::ControllerEvent ev(chan, control, value);
- ev.setSource(m_PortId);
- ev.setSubscribers();
- ev.setDirect();
- sendSongEvent(&ev);
-}
diff --git a/src/shell/midisequenceroutputthread.h \
b/src/shell/midisequenceroutputthread.h deleted file mode 100644
index cd15f50..0000000
--- a/src/shell/midisequenceroutputthread.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org>
-**
-** This program is free software; you can redistribute it and/or
-** modify it under the terms of the GNU General Public License as
-** published by the Free Software Foundation; either version 2 of
-** the License or (at your option) version 3 or any later version
-** accepted by the membership of KDE e.V. (or its successor approved
-** by the membership of KDE e.V.), which shall act as a proxy
-** defined in Section 14 of version 3 of the license.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef MIDISEQUENCEROUTPUTTHREAD_H
-#define MIDISEQUENCEROUTPUTTHREAD_H
-
-#include <drumstick/playthread.h>
-
-namespace drumstick {
- class MidiClient;
-}
-
-class Song;
-
-class MidiSequencerOutputThread : public drumstick::SequencerOutputThread
-{
- Q_OBJECT
-
-public:
- MidiSequencerOutputThread(drumstick::MidiClient *client, int portId);
- virtual ~MidiSequencerOutputThread();
-
- // Virtual methods from drumstick::SequencerOutputThread
- virtual bool hasNext();
- virtual drumstick::SequencerEvent *nextEvent();
- virtual unsigned int getInitialPosition() { return m_songPosition; }
-
- void setSong(Song *song);
- void setPitch(int value);
- int pitch() const;
- void setVolume(unsigned int volume);
- unsigned int volume() const;
- void setPosition(unsigned int pos);
- void setTempoFactor(float value);
- void resetPosition();
-
-private:
- void allNotesOff();
- void sendControllerEvent(int chan, int control, int value);
-
-private:
- drumstick::MidiClient *m_client;
- Song *m_song;
- unsigned int m_songPosition;
- drumstick::SequencerEvent *m_lastEvent;
- unsigned int m_volume;
- int m_channelVolume[MIDI_CHANNELS];
- int m_pitchShift;
- float m_tempoFactor;
- QListIterator<drumstick::SequencerEvent *>* m_songIterator;
-};
-
-#endif // MIDISEQUENCEROUTPUTTHREAD_H
diff --git a/src/shell/minuetmainwindow.cpp b/src/shell/minuetmainwindow.cpp
index e82f63f..dc2b2a9 100644
--- a/src/shell/minuetmainwindow.cpp
+++ b/src/shell/minuetmainwindow.cpp
@@ -23,7 +23,6 @@
#include "minuetmainwindow.h"
#include "wizard.h"
-#include "exercisecontroller.h"
#include <KActionCollection>
#include <KMessageBox>
diff --git a/src/shell/minuetmainwindow.h b/src/shell/minuetmainwindow.h
index 3f560ef..f554dca 100644
--- a/src/shell/minuetmainwindow.h
+++ b/src/shell/minuetmainwindow.h
@@ -25,7 +25,6 @@
#include "ui_settingsmidi.h"
#include "minuetsettings.h"
-#include "midisequencer.h"
#include <KXmlGuiWindow>
diff --git a/src/shell/plugincontroller.cpp b/src/shell/plugincontroller.cpp
index 8b3c061..74efd13 100644
--- a/src/shell/plugincontroller.cpp
+++ b/src/shell/plugincontroller.cpp
@@ -49,6 +49,8 @@ PluginController::PluginController(QObject *parent)
PluginController::~PluginController()
{
+ qDeleteAll(m_loadedPlugins.values().begin(), m_loadedPlugins.values().end());
+ m_loadedPlugins.clear();
}
bool PluginController::initialize(Core *core)
diff --git a/src/shell/qml/MinuetMenu.qml b/src/shell/qml/MinuetMenu.qml
index 7c56146..6fb1fe9 100644
--- a/src/shell/qml/MinuetMenu.qml
+++ b/src/shell/qml/MinuetMenu.qml
@@ -24,8 +24,6 @@ import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.1
-import org.kde.plasma.core 2.0 as PlasmaCore
-
Item {
id: minuetMenu
diff --git a/src/shell/song.cpp b/src/shell/song.cpp
deleted file mode 100644
index 61d99ec..0000000
--- a/src/shell/song.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org>
-**
-** This program is free software; you can redistribute it and/or
-** modify it under the terms of the GNU General Public License as
-** published by the Free Software Foundation; either version 2 of
-** the License or (at your option) version 3 or any later version
-** accepted by the membership of KDE e.V. (or its successor approved
-** by the membership of KDE e.V.), which shall act as a proxy
-** defined in Section 14 of version 3 of the license.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#include "song.h"
-
-#include <drumstick/alsaevent.h>
-
-static inline bool eventLessThan(const drumstick::SequencerEvent *s1, const \
drumstick::SequencerEvent *s2)
-{
- return s1->getTick() < s2->getTick();
-}
-
-Song::Song() :
- QList<drumstick::SequencerEvent *>(),
- m_format(0),
- m_ntrks(0),
- m_division(0),
- m_initialTempo(0)
-{
-}
-
-Song::~Song()
-{
- clear();
-}
-
-void Song::sort()
-{
- qStableSort(begin(), end(), eventLessThan);
-}
-
-void Song::clear()
-{
- while (!isEmpty())
- delete takeFirst();
- m_fileName.clear();
- m_format = 0;
- m_ntrks = 0;
- m_division = 0;
-}
-
-void Song::setHeader(int format, int ntrks, int division)
-{
- m_format = format;
- m_ntrks = ntrks;
- m_division = division;
-}
-
-void Song::setInitialTempo(int initialTempo)
-{
- m_initialTempo = initialTempo;
-}
-
-void Song::setDivision(int division)
-{
- m_division = division;
-}
-
-void Song::setFileName(const QString &fileName)
-{
- m_fileName = fileName;
-}
diff --git a/src/shell/song.h b/src/shell/song.h
deleted file mode 100644
index d11ba20..0000000
--- a/src/shell/song.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org>
-**
-** This program is free software; you can redistribute it and/or
-** modify it under the terms of the GNU General Public License as
-** published by the Free Software Foundation; either version 2 of
-** the License or (at your option) version 3 or any later version
-** accepted by the membership of KDE e.V. (or its successor approved
-** by the membership of KDE e.V.), which shall act as a proxy
-** defined in Section 14 of version 3 of the license.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef SONG_H
-#define SONG_H
-
-#include <QList>
-#include <QString>
-
-namespace drumstick {
- class SequencerEvent;
-}
-
-class Song : public QList<drumstick::SequencerEvent *>
-{
-public:
- Song();
- virtual ~Song();
-
- void clear();
- void sort();
- void setHeader(int format, int ntrks, int division);
- void setInitialTempo(int initialTempo);
- void setDivision(int division);
- void setFileName(const QString &fileName);
-
- int format() const { return m_format; }
- int tracks() const { return m_ntrks; }
- int division() const { return m_division; }
- int initialTempo() const { return m_initialTempo; }
- QString fileName() const { return m_fileName; }
-
-private:
- int m_format;
- int m_ntrks;
- int m_division;
- int m_initialTempo;
- QString m_fileName;
-};
-
-#endif // SONG_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic