From b703eab295330e6f81564fbb39a10a1a2fdd2f54 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Sun, 27 Dec 2009 11:30:35 +0000 Subject: moved old qt4 branch --- .../midiplugins/metronom/CMakeLists.txt | 46 ++++++ .../midiplugins/metronom/metronom.cpp | 167 +++++++++++++++++++++ muse_qt4_evolution/midiplugins/metronom/metronom.h | 53 +++++++ .../midiplugins/metronom/metronomgui.cpp | 75 +++++++++ .../midiplugins/metronom/metronomgui.h | 36 +++++ .../midiplugins/metronom/metronomgui.ui | 150 ++++++++++++++++++ 6 files changed, 527 insertions(+) create mode 100644 muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt create mode 100644 muse_qt4_evolution/midiplugins/metronom/metronom.cpp create mode 100644 muse_qt4_evolution/midiplugins/metronom/metronom.h create mode 100644 muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp create mode 100644 muse_qt4_evolution/midiplugins/metronom/metronomgui.h create mode 100644 muse_qt4_evolution/midiplugins/metronom/metronomgui.ui (limited to 'muse_qt4_evolution/midiplugins/metronom') diff --git a/muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt b/muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt new file mode 100644 index 00000000..5153e6d4 --- /dev/null +++ b/muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt @@ -0,0 +1,46 @@ +#============================================================================= +# MusE +# Linux Music Editor +# $Id:$ +# +# Copyright (C) 2002-2006 by Werner Schweer and others +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2. +# +# 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, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#============================================================================= + +QT4_WRAP_CPP ( metronom_mocs metronomgui.h ) +QT4_WRAP_UI ( metronom_uis metronomgui.ui ) + +add_library ( metronom SHARED + metronom.cpp + metronomgui.cpp + metronomgui.h + ${metronom_mocs} + ${metronom_uis} + ) +target_link_libraries( metronom + midiplugin + ${QT_LIBRARIES} + ) + +# - tell cmake to name target metronom.so instead of +# libmetronom.so +# - use precompiled header files +# +set_target_properties ( metronom + PROPERTIES PREFIX "" + COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all-pic.h" + ) + +install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/midiplugins/ metronom ) + diff --git a/muse_qt4_evolution/midiplugins/metronom/metronom.cpp b/muse_qt4_evolution/midiplugins/metronom/metronom.cpp new file mode 100644 index 00000000..ece1e466 --- /dev/null +++ b/muse_qt4_evolution/midiplugins/metronom/metronom.cpp @@ -0,0 +1,167 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: metronom.cpp,v 1.3 2005/11/16 17:55:59 wschweer Exp $ +// +// metronom - midi metronom +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "metronomgui.h" +#include "metronom.h" +#include "midi.h" +#include "midievent.h" + +//--------------------------------------------------------- +// Metronom +//--------------------------------------------------------- + +Metronom::Metronom(const char* name, const MempiHost* h) + : Mempi(name, h) + { + gui = 0; + } + +//--------------------------------------------------------- +// Metronom +//--------------------------------------------------------- + +Metronom::~Metronom() + { + if (gui) + delete gui; + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +bool Metronom::init() + { + nextTick = 0; + lastTo = 0; + data.measureNote = 63; + data.measureVelo = 127; + data.beatNote = 63; + data.beatVelo = 70; + + gui = new MetronomGui(this, 0); + gui->hide(); + gui->setWindowTitle(QString(name())); + + return false; + } + +//--------------------------------------------------------- +// getGeometry +//--------------------------------------------------------- + +void Metronom::getGeometry(int* x, int* y, int* w, int* h) const + { + QPoint pos(gui->pos()); + QSize size(gui->size()); + *x = pos.x(); + *y = pos.y(); + *w = size.width(); + *h = size.height(); + } + +//--------------------------------------------------------- +// setGeometry +//--------------------------------------------------------- + +void Metronom::setGeometry(int x, int y, int w, int h) + { + gui->resize(QSize(w, h)); + gui->move(QPoint(x, y)); + } + +//--------------------------------------------------------- +// process +//--------------------------------------------------------- + +void Metronom::process(unsigned from, unsigned to, MidiEventList* /*il*/, MidiEventList* ol) + { + if (from == to) { + nextTick = 0; + return; + } + if (lastTo != from) { // seek? +// printf(" seek? %d-%d\n", lastTo, from); + nextTick = 0; + } + lastTo = to; + if (nextTick > to) + return; + while (nextTick < to) { + int bar, beat; + unsigned tick; + if (nextTick < from) { + host->bar(from, &bar, &beat, &tick); + if (tick) + nextTick = host->bar2tick(bar, beat+1, 0); + else + nextTick = from; + } + host->bar(nextTick, &bar, &beat, &tick); + bool isMeasure = beat == 0; + + MidiEvent ev(nextTick, 0, ME_NOTEON, data.beatNote, data.beatVelo); + if (isMeasure) { + ev.setA(data.measureNote); + ev.setB(data.measureVelo); + } + ol->insert(ev); // insert note on + ev.setB(0); + ev.setTime(nextTick + 10); + ev.setB(0); + ol->insert(ev); // insert note off + + nextTick = host->bar2tick(bar, beat+1, 0); + } + } + +//--------------------------------------------------------- +// getInitData +//--------------------------------------------------------- + +void Metronom::getInitData(int* n, const unsigned char** p) const + { + *n = sizeof(data); + *p = (unsigned char*)&data; + } + +//--------------------------------------------------------- +// setInitData +//--------------------------------------------------------- + +void Metronom::setInitData(int n, const unsigned char* p) + { + memcpy((void*)&data, p, n); + if (gui) + gui->init(); + } + +//--------------------------------------------------------- +// inst +//--------------------------------------------------------- + +static Mempi* instantiate(const char* name, const MempiHost* h) + { + return new Metronom(name, h); + } + +extern "C" { + static MEMPI descriptor = { + "Metronom", + "MusE Simple Midi Metronom", + "0.1", // version string + MEMPI_GENERATOR, + MEMPI_MAJOR_VERSION, MEMPI_MINOR_VERSION, + instantiate + }; + + const MEMPI* mempi_descriptor() { return &descriptor; } + } + diff --git a/muse_qt4_evolution/midiplugins/metronom/metronom.h b/muse_qt4_evolution/midiplugins/metronom/metronom.h new file mode 100644 index 00000000..3d570613 --- /dev/null +++ b/muse_qt4_evolution/midiplugins/metronom/metronom.h @@ -0,0 +1,53 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: metronom.h,v 1.3 2005/06/12 09:22:51 wschweer Exp $ +// +// metronom - simple midi metronom +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __METRONOM_H__ +#define __METRONOM_H__ + +#include "../libmidiplugin/mempi.h" + +//--------------------------------------------------------- +// metronom - simple midi metronom +//--------------------------------------------------------- + +class Metronom : public Mempi { + + protected: + struct InitData { + char measureNote; + char measureVelo; + char beatNote; + char beatVelo; + } data; + MetronomGui* gui; + friend class MetronomGui; + + unsigned int nextTick; + unsigned int lastTo; + + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*); + + public: + Metronom(const char* name, const MempiHost*); + ~Metronom(); + virtual bool init(); + + virtual bool hasGui() const { return true; } + virtual bool guiVisible() const { return gui->isVisible(); } + virtual void showGui(bool val) { gui->setShown(val); } + virtual void getGeometry(int* x, int* y, int* w, int* h) const; + virtual void setGeometry(int, int, int, int); + + virtual void getInitData(int*, const unsigned char**) const; + virtual void setInitData(int, const unsigned char*); + }; + +#endif + diff --git a/muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp b/muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp new file mode 100644 index 00000000..e6705f7c --- /dev/null +++ b/muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp @@ -0,0 +1,75 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: metronomgui.cpp,v 1.2 2005/10/05 17:02:03 lunar_shuttle Exp $ +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "metronomgui.h" +#include "metronom.h" + +//--------------------------------------------------------- +// MidiMetronomConfig +//--------------------------------------------------------- + +MetronomGui::MetronomGui(Metronom* f, QWidget* parent) + : QDialog(parent) + { + setupUi(this); + metronom = f; + init(); + connect(beatNote, SIGNAL(valueChanged(int)), SLOT(beatNoteChanged(int))); + connect(measureVelocity, SIGNAL(valueChanged(int)), SLOT(measureVelocityChanged(int))); + connect(measureNote, SIGNAL(valueChanged(int)), SLOT(measureNoteChanged(int))); + connect(beatVelocity, SIGNAL(valueChanged(int)), SLOT(beatVelocityChanged(int))); + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +void MetronomGui::init() + { + beatNote->setValue(metronom->data.beatNote); + measureNote->setValue(metronom->data.measureNote); + beatVelocity->setValue(metronom->data.beatVelo); + measureVelocity->setValue(metronom->data.measureVelo); + } + +//--------------------------------------------------------- +// beatNoteChanged +//--------------------------------------------------------- + +void MetronomGui::beatNoteChanged(int val) + { + metronom->data.beatNote = val; + } + +//--------------------------------------------------------- +// measureVelocityChanged +//--------------------------------------------------------- + +void MetronomGui::measureVelocityChanged(int val) + { + metronom->data.measureVelo = val; + } + +//--------------------------------------------------------- +// measureNoteChanged +//--------------------------------------------------------- + +void MetronomGui::measureNoteChanged(int val) + { + metronom->data.measureNote = val; + } + +//--------------------------------------------------------- +// beatVelocityChanged +//--------------------------------------------------------- + +void MetronomGui::beatVelocityChanged(int val) + { + metronom->data.beatVelo = val; + } + diff --git a/muse_qt4_evolution/midiplugins/metronom/metronomgui.h b/muse_qt4_evolution/midiplugins/metronom/metronomgui.h new file mode 100644 index 00000000..cceea61d --- /dev/null +++ b/muse_qt4_evolution/midiplugins/metronom/metronomgui.h @@ -0,0 +1,36 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: metronomgui.h,v 1.3 2005/10/05 17:02:03 lunar_shuttle Exp $ +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __METRONOMGUI_H__ +#define __METRONOMGUI_H__ + +#include "ui_metronomgui.h" + +class Metronom; + +//--------------------------------------------------------- +// MetronomGui +//--------------------------------------------------------- + +class MetronomGui : public QDialog, public Ui::MetronomBase { + Q_OBJECT + Metronom* metronom; + + private slots: + void beatNoteChanged(int); + void measureVelocityChanged(int); + void measureNoteChanged(int); + void beatVelocityChanged(int); + + public: + MetronomGui(Metronom*, QWidget* parent=0); + void init(); + }; + +#endif + diff --git a/muse_qt4_evolution/midiplugins/metronom/metronomgui.ui b/muse_qt4_evolution/midiplugins/metronom/metronomgui.ui new file mode 100644 index 00000000..188735d4 --- /dev/null +++ b/muse_qt4_evolution/midiplugins/metronom/metronomgui.ui @@ -0,0 +1,150 @@ + + + + + MetronomBase + + + + 0 + 0 + 429 + 164 + + + + + 3 + 5 + 0 + 0 + + + + MusE: Midi Metronome + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + + 0 + 0 + 0 + 0 + + + + + ZappedChancellor + 48 + 75 + false + true + false + false + + + + Metronome + + + Metronome + + + M + + + Qt::AlignCenter + + + + + + + 0 + + + 6 + + + + + Measure Note + + + + + + + Measure Velocity + + + + + + + Beat Velocity + + + + + + + Beat Note + + + + + + + 127 + + + + + + + 127 + + + + + + + 127 + + + + + + + 127 + + + + + + + + + + + qPixmapFromMimeSource + + + -- cgit v1.2.3