summaryrefslogtreecommitdiff
path: root/muse2/muse
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-05-25 18:26:02 +0000
committerFlorian Jung <flo@windfisch.org>2011-05-25 18:26:02 +0000
commita1db21404d203bec7353099a9947778735271bfd (patch)
tree9d967018aa9d95596879d11cb651f6fa6a808bfe /muse2/muse
parent3948032d0a2e439069d9a6859f7f35eebb54944d (diff)
added step-recording support to the score editor
moved clefTypes to avoid compile-horror updated templates due to the new toolbar
Diffstat (limited to 'muse2/muse')
-rw-r--r--muse2/muse/arranger/tlist.cpp13
-rw-r--r--muse2/muse/cleftypes.h13
-rw-r--r--muse2/muse/functions.cpp1
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp77
-rw-r--r--muse2/muse/midiedit/scoreedit.h21
-rw-r--r--muse2/muse/track.cpp6
-rw-r--r--muse2/muse/track.h8
7 files changed, 112 insertions, 27 deletions
diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp
index b1033a2a..9e4db5ba 100644
--- a/muse2/muse/arranger/tlist.cpp
+++ b/muse2/muse/arranger/tlist.cpp
@@ -44,7 +44,6 @@
#include "midiedit/drummap.h"
#include "synth.h"
#include "config.h"
-#include "scoreedit.h"
#include "popupmenu.h"
#ifdef DSSI_SUPPORT
@@ -365,11 +364,11 @@ void TList::paint(const QRect& r)
case COL_CLEF:
if (track->isMidiTrack()) {
QString s = tr("no clef");
- if (((MidiTrack*)track)->getClef() == ScoreEdit::trebleClef)
+ if (((MidiTrack*)track)->getClef() == trebleClef)
s=tr("Treble");
- else if (((MidiTrack*)track)->getClef() == ScoreEdit::bassClef)
+ else if (((MidiTrack*)track)->getClef() == bassClef)
s=tr("Bass");
- else if (((MidiTrack*)track)->getClef() == ScoreEdit::grandStaff)
+ else if (((MidiTrack*)track)->getClef() == grandStaff)
s=tr("Grand");
p.drawText(r, Qt::AlignVCenter|Qt::AlignLeft, s);
}
@@ -1086,13 +1085,13 @@ void TList::mousePressEvent(QMouseEvent* ev)
if (act) {
switch (act->data().toInt()) {
case 0:
- ((MidiTrack*)t)->setClef(ScoreEdit::trebleClef);
+ ((MidiTrack*)t)->setClef(trebleClef);
break;
case 1:
- ((MidiTrack*)t)->setClef(ScoreEdit::bassClef);
+ ((MidiTrack*)t)->setClef(bassClef);
break;
case 2:
- ((MidiTrack*)t)->setClef(ScoreEdit::grandStaff);
+ ((MidiTrack*)t)->setClef(grandStaff);
break;
default:
break;
diff --git a/muse2/muse/cleftypes.h b/muse2/muse/cleftypes.h
new file mode 100644
index 00000000..8c14a6d3
--- /dev/null
+++ b/muse2/muse/cleftypes.h
@@ -0,0 +1,13 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// cleftypes.h
+// (C) Copyright 2011 Florian Jung (flo93@users.sourceforge.net)
+//=========================================================
+
+#ifndef __CLEFTYPES_H__
+#define __CLEFTYPES_H__
+
+enum clefTypes { trebleClef, bassClef, grandStaff };
+
+#endif
diff --git a/muse2/muse/functions.cpp b/muse2/muse/functions.cpp
index 89a66fa7..5677bcfd 100644
--- a/muse2/muse/functions.cpp
+++ b/muse2/muse/functions.cpp
@@ -12,6 +12,7 @@
#include "audio.h"
#include "gconfig.h"
+#include <values.h>
#include <iostream>
#include <QMessageBox>
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index c090ea32..f8d2a3ba 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -211,6 +211,23 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
undo_tools->addActions(undoRedo->actions());
addToolBar(undo_tools);
+ QToolBar* steprec_tools=addToolBar(tr("Step recording tools"));
+ steprec_tools->setObjectName("Step recording tools");
+ srec = new QToolButton();
+ srec->setToolTip(tr("Step Record"));
+ srec->setIcon(*steprecIcon);
+ srec->setCheckable(true);
+ steprec_tools->addWidget(srec);
+ connect(srec, SIGNAL(toggled(bool)), SLOT(set_steprec(bool)));
+
+ midiin = new QToolButton();
+ midiin->setToolTip(tr("Midi Input"));
+ midiin->setIcon(*midiinIcon);
+ midiin->setCheckable(true);
+ steprec_tools->addWidget(midiin);
+ connect(midiin, SIGNAL(toggled(bool)), score_canvas, SLOT(set_midiin(bool)));
+
+
edit_tools = new EditToolBar(this, PointerTool | PencilTool | RubberTool);
addToolBar(edit_tools);
edit_tools->set(PointerTool);
@@ -457,6 +474,15 @@ ScoreEdit::~ScoreEdit()
}
+void ScoreEdit::set_steprec(bool flag)
+{
+ score_canvas->set_steprec(flag);
+ if (flag == false)
+ midiin->setChecked(false);
+}
+
+
+
void ScoreEdit::velo_box_changed()
{
emit velo_changed(velo_spinbox->value());
@@ -714,6 +740,8 @@ void ScoreEdit::writeStatus(int level, Xml& xml) const
xml.strTag(level, "name", name);
xml.intTag(level, "tool", edit_tools->curTool());
+ xml.intTag(level, "steprec", srec->isChecked());
+ xml.intTag(level, "midiin", midiin->isChecked());
xml.intTag(level, "quantPower", score_canvas->quant_power2());
xml.intTag(level, "pxPerWhole", score_canvas->pixels_per_whole());
xml.intTag(level, "newNoteVelo", velo_spinbox->value());
@@ -806,6 +834,10 @@ void ScoreEdit::readStatus(Xml& xml)
set_name(xml.parse1());
else if (tag == "tool")
edit_tools->set(xml.parseInt());
+ else if (tag == "midiin")
+ midiin->setChecked(xml.parseInt());
+ else if (tag == "steprec")
+ srec->setChecked(xml.parseInt());
else if (tag == "quantPower")
quant_combobox->setCurrentIndex(xml.parseInt()-1);
else if (tag == "pxPerWhole")
@@ -936,13 +968,13 @@ void ScoreCanvas::add_staves(PartList* pl, bool all_in_one)
if (all_in_one)
{
- ScoreEdit::clefTypes clef=((MidiTrack*)pl->begin()->second->track())->getClef();
+ clefTypes clef=((MidiTrack*)pl->begin()->second->track())->getClef();
staff.parts.clear();
for (ciPart part_it=pl->begin(); part_it!=pl->end(); part_it++)
{
if (((MidiTrack*)part_it->second->track())->getClef() != clef)
- clef=ScoreEdit::grandStaff;
+ clef=grandStaff;
staff.parts.insert(part_it->second);
}
@@ -950,19 +982,19 @@ void ScoreCanvas::add_staves(PartList* pl, bool all_in_one)
switch (clef)
{
- case ScoreEdit::trebleClef:
+ case trebleClef:
staff.type=NORMAL;
staff.clef=VIOLIN;
staves.push_back(staff);
break;
- case ScoreEdit::bassClef:
+ case bassClef:
staff.type=NORMAL;
staff.clef=BASS;
staves.push_back(staff);
break;
- case ScoreEdit::grandStaff:
+ case grandStaff:
staff.type=GRAND_TOP;
staff.clef=VIOLIN;
staves.push_back(staff);
@@ -994,19 +1026,19 @@ void ScoreCanvas::add_staves(PartList* pl, bool all_in_one)
switch (((MidiTrack*)(*track_it))->getClef())
{
- case ScoreEdit::trebleClef:
+ case trebleClef:
staff.type=NORMAL;
staff.clef=VIOLIN;
staves.push_back(staff);
break;
- case ScoreEdit::bassClef:
+ case bassClef:
staff.type=NORMAL;
staff.clef=BASS;
staves.push_back(staff);
break;
- case ScoreEdit::grandStaff:
+ case grandStaff:
staff.type=GRAND_TOP;
staff.clef=VIOLIN;
staves.push_back(staff);
@@ -1036,6 +1068,12 @@ ScoreCanvas::ScoreCanvas(ScoreEdit* pr, QWidget* parent_widget) : View(parent_wi
init_pixmaps();
+ srec=false;
+ midiin=false;
+ for (int i=0;i<128;i++) held_notes[i]=false;
+ steprec=new StepRec(held_notes);
+ connect(song, SIGNAL(midiNote(int, int)), SLOT(midi_note(int,int)));
+
x_pos=0;
x_left=0;
y_pos=0;
@@ -4254,6 +4292,27 @@ void staff_t::apply_lasso(QRect rect, set<Event*>& already_processed)
}
}
+void ScoreCanvas::set_steprec(bool flag)
+{
+ srec=flag;
+}
+
+void ScoreCanvas::set_midiin(bool flag)
+{
+ midiin=flag;
+}
+
+void ScoreCanvas::midi_note(int pitch, int velo)
+{
+ if (velo)
+ held_notes[pitch]=true;
+ else
+ held_notes[pitch]=false;
+
+ if ( midiin && srec && selected_part && !audio->isPlaying() && velo )
+ steprec->record(selected_part,pitch,quant_ticks(),quant_ticks(),velo,globalKeyState&Qt::ControlModifier,globalKeyState&Qt::ShiftModifier);
+}
+
//the following assertions are made:
// pix_quarter.width() == pix_half.width()
@@ -4280,7 +4339,7 @@ void staff_t::apply_lasso(QRect rect, set<Event*>& already_processed)
* between, for example, when a cis is tied to a des
*
* CURRENT TODO
- * o maybe support step-recording in score editor as well?
+ * x nothing atm
*
* IMPORTANT TODO
* o do partial recalculating; recalculating can take pretty long
diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h
index 2ce8d645..71b672a9 100644
--- a/muse2/muse/midiedit/scoreedit.h
+++ b/muse2/muse/midiedit/scoreedit.h
@@ -22,6 +22,7 @@
#include <QActionGroup>
#include <QGridLayout>
#include <QByteArray>
+#include <QToolButton>
#include <values.h>
#include "noteinfo.h"
@@ -32,6 +33,8 @@
#include "part.h"
#include "keyevent.h"
#include "mtscale_flo.h"
+#include "steprec.h"
+#include "cleftypes.h"
#include <set>
#include <map>
@@ -72,9 +75,6 @@ class EditToolBar;
class ScoreEdit : public TopWin
{
Q_OBJECT
- public:
- enum clefTypes { trebleClef, bassClef, grandStaff };
-
private:
virtual void closeEvent(QCloseEvent*);
virtual void resizeEvent(QResizeEvent*);
@@ -110,6 +110,9 @@ class ScoreEdit : public TopWin
QAction* color_black_action;
QAction* color_velo_action;
QAction* color_part_action;
+
+ QToolButton* srec;
+ QToolButton* midiin;
QScrollBar* xscroll;
QScrollBar* yscroll;
@@ -133,6 +136,7 @@ class ScoreEdit : public TopWin
void menu_command(int);
void velo_box_changed();
void velo_off_box_changed();
+ void set_steprec(bool);
signals:
void deleted(unsigned long);
@@ -616,6 +620,8 @@ class ScoreCanvas : public View
list<staff_t> staves;
+ StepRec* steprec;
+
// the drawing area is split into a "preamble" containing clef,
// key and time signature, and the "item's area" containing the
// actual items (notes, bars, rests, etc.)
@@ -668,7 +674,10 @@ class ScoreCanvas : public View
bool undo_started;
int undo_flags;
-
+
+ bool srec;
+ bool midiin;
+ bool held_notes[128];
enum {COLOR_MODE_BLACK, COLOR_MODE_PART, COLOR_MODE_VELO} coloring_mode;
bool preamble_contains_keysig;
@@ -696,6 +705,7 @@ class ScoreCanvas : public View
void config_changed();
void deselect_all();
+ void midi_note(int pitch, int velo);
public slots:
void x_scroll_event(int);
@@ -715,6 +725,9 @@ class ScoreCanvas : public View
void set_velo(int);
void set_velo_off(int);
+
+ void set_steprec(bool);
+ void set_midiin(bool);
signals:
void xscroll_changed(int);
diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp
index 5dab4c09..5f358375 100644
--- a/muse2/muse/track.cpp
+++ b/muse2/muse/track.cpp
@@ -369,7 +369,7 @@ MidiTrack::MidiTrack()
init();
_events = new EventList;
_mpevents = new MPEventList;
- clefType=ScoreEdit::trebleClef;
+ clefType=trebleClef;
}
//MidiTrack::MidiTrack(const MidiTrack& mt)
@@ -389,7 +389,7 @@ MidiTrack::MidiTrack(const MidiTrack& mt, bool cloneParts)
len = mt.len;
compression = mt.compression;
_recEcho = mt.recEcho();
- clefType=ScoreEdit::trebleClef;
+ clefType=trebleClef;
}
MidiTrack::~MidiTrack()
@@ -959,7 +959,7 @@ void MidiTrack::read(Xml& xml)
else if (tag == "automation")
setAutomationType(AutomationType(xml.parseInt()));
else if (tag == "clef")
- clefType = (ScoreEdit::clefTypes)xml.parseInt();
+ clefType = (clefTypes)xml.parseInt();
else if (Track::readProperties(xml, tag)) {
// version 1.0 compatibility:
if (tag == "track" && xml.majorVersion() == 1 && xml.minorVersion() == 0)
diff --git a/muse2/muse/track.h b/muse2/muse/track.h
index d1dc3a6f..50870166 100644
--- a/muse2/muse/track.h
+++ b/muse2/muse/track.h
@@ -20,7 +20,7 @@
#include "route.h"
#include "ctrl.h"
#include "globaldefs.h"
-#include "scoreedit.h"
+#include "cleftypes.h"
class Pipeline;
class Xml;
@@ -209,7 +209,7 @@ class MidiTrack : public Track {
EventList* _events; // tmp Events during midi import
MPEventList* _mpevents; // tmp Events druring recording
static bool _isVisible;
- ScoreEdit::clefTypes clefType;
+ clefTypes clefType;
public:
MidiTrack();
@@ -276,8 +276,8 @@ class MidiTrack : public Track {
static void setVisible(bool t) { _isVisible = t; }
static bool visible() { return _isVisible; }
- void setClef(ScoreEdit::clefTypes i) { clefType = i; }
- ScoreEdit::clefTypes getClef() { return clefType; }
+ void setClef(clefTypes i) { clefType = i; }
+ clefTypes getClef() { return clefType; }
};
//---------------------------------------------------------