summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-05-24 13:39:39 +0000
committerFlorian Jung <flo@windfisch.org>2011-05-24 13:39:39 +0000
commit50e54c9b95c39badcd1f30443f30a74a7eb69ea3 (patch)
tree80c9cfa61cb4b9b76dc22f2774551258024d8224 /muse2
parentef0aa8834d71587f7c417bb36d865ed1c8919a0b (diff)
improved step recording and minor fixes
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog7
-rw-r--r--muse2/awl/pitchedit.cpp4
-rw-r--r--muse2/awl/pitchedit.h4
-rw-r--r--muse2/muse/conf.cpp3
-rw-r--r--muse2/muse/driver/jackmidi.cpp8
-rw-r--r--muse2/muse/globals.cpp1
-rw-r--r--muse2/muse/globals.h1
-rw-r--r--muse2/muse/mididev.cpp10
-rw-r--r--muse2/muse/midiedit/prcanvas.cpp72
-rw-r--r--muse2/muse/midiedit/prcanvas.h2
-rw-r--r--muse2/muse/mplugins/mrconfig.cpp7
-rw-r--r--muse2/muse/mplugins/mrconfig.h1
-rw-r--r--muse2/muse/mplugins/mrconfigbase.ui42
13 files changed, 135 insertions, 27 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index b16462d8..61f1509f 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,10 @@
+24.05.2011:
+ - fixed y-stretch (flo93)
+ - cleaned up step-rec and midi-in buttons and stuff (flo93)
+ - steprec now supports a "insert rest" key, which can be set (flo93)
+ under Midi -> Input Plugins -> Remote Control
+ - song->midiNote now also delivers note off events (flo93)
+ - fixed pitch-spinbox (flo93)
23.05.2011: (all changes made by flo93, except one)
Function-related changes:
- made all the stuff in the "functions" menu global
diff --git a/muse2/awl/pitchedit.cpp b/muse2/awl/pitchedit.cpp
index 93f4b310..71486be8 100644
--- a/muse2/awl/pitchedit.cpp
+++ b/muse2/awl/pitchedit.cpp
@@ -54,7 +54,7 @@ void PitchEdit::keyPressEvent(QKeyEvent* ev)
// mapValueToText
//---------------------------------------------------------
-QString PitchEdit::mapValueToText(int v)
+QString PitchEdit::textFromValue(int v) const
{
if (deltaMode) {
QString s;
@@ -69,7 +69,7 @@ QString PitchEdit::mapValueToText(int v)
// mapTextToValue
//---------------------------------------------------------
-int PitchEdit::mapTextToValue(bool* ok)
+int PitchEdit::valueFromText(bool* ok) const
{
printf("AwlPitchEdit: mapTextToValue: not impl.\n");
if (ok)
diff --git a/muse2/awl/pitchedit.h b/muse2/awl/pitchedit.h
index bdcfc4c4..f9b5b24e 100644
--- a/muse2/awl/pitchedit.h
+++ b/muse2/awl/pitchedit.h
@@ -37,8 +37,8 @@ class PitchEdit : public QSpinBox {
bool deltaMode;
protected:
- virtual QString mapValueToText(int v);
- virtual int mapTextToValue(bool* ok);
+ virtual QString textFromValue(int v) const;
+ virtual int valueFromText(bool* ok) const;
virtual void keyPressEvent(QKeyEvent*);
signals:
diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp
index e7eef503..56cbc321 100644
--- a/muse2/muse/conf.cpp
+++ b/muse2/muse/conf.cpp
@@ -481,6 +481,8 @@ static void readSeqConfiguration(Xml& xml)
rcGotoLeftMarkNote = xml.parseInt();
else if (tag == "rcPlay")
rcPlayNote = xml.parseInt();
+ else if (tag == "rcSteprec")
+ rcSteprecNote = xml.parseInt();
else
xml.unknown("Seq");
break;
@@ -1061,6 +1063,7 @@ static void writeSeqConfiguration(int level, Xml& xml, bool writePortInfo)
xml.intTag(level, "rcRecord", rcRecordNote);
xml.intTag(level, "rcGotoLeft", rcGotoLeftMarkNote);
xml.intTag(level, "rcPlay", rcPlayNote);
+ xml.intTag(level, "rcSteprec", rcSteprecNote);
if (writePortInfo) {
//
diff --git a/muse2/muse/driver/jackmidi.cpp b/muse2/muse/driver/jackmidi.cpp
index c950e096..1765fabb 100644
--- a/muse2/muse/driver/jackmidi.cpp
+++ b/muse2/muse/driver/jackmidi.cpp
@@ -974,13 +974,17 @@ void MidiJackDevice::recordEvent(MidiRecordEvent& event)
}
//
- // transfer noteOn events to gui for step recording and keyboard
- // remote control
+ // transfer noteOn and Off events to gui for step recording and keyboard
+ // remote control (changed by flo93: added noteOff-events)
//
if (typ == ME_NOTEON) {
int pv = ((event.dataA() & 0xff)<<8) + (event.dataB() & 0xff);
song->putEvent(pv);
}
+ else if (typ == ME_NOTEOFF) {
+ int pv = ((event.dataA() & 0xff)<<8) + (0x00); //send an event with velo=0
+ song->putEvent(pv);
+ }
//if(_recordFifo.put(MidiPlayEvent(event)))
// printf("MidiJackDevice::recordEvent: fifo overflow\n");
diff --git a/muse2/muse/globals.cpp b/muse2/muse/globals.cpp
index f8ae4454..00c0f0a9 100644
--- a/muse2/muse/globals.cpp
+++ b/muse2/muse/globals.cpp
@@ -347,6 +347,7 @@ unsigned char rcStopNote = 28;
unsigned char rcRecordNote = 31;
unsigned char rcGotoLeftMarkNote = 33;
unsigned char rcPlayNote = 29;
+unsigned char rcSteprecNote = 36;
bool automation = true;
QObject* gRoutingPopupMenuMaster = 0;
diff --git a/muse2/muse/globals.h b/muse2/muse/globals.h
index 894f1baf..984571e2 100644
--- a/muse2/muse/globals.h
+++ b/muse2/muse/globals.h
@@ -167,6 +167,7 @@ extern unsigned char rcStopNote;
extern unsigned char rcRecordNote;
extern unsigned char rcGotoLeftMarkNote;
extern unsigned char rcPlayNote;
+extern unsigned char rcSteprecNote;
extern bool midiSeqRunning;
extern bool automation;
diff --git a/muse2/muse/mididev.cpp b/muse2/muse/mididev.cpp
index b5445b71..b13f571b 100644
--- a/muse2/muse/mididev.cpp
+++ b/muse2/muse/mididev.cpp
@@ -315,7 +315,7 @@ void MidiDevice::recordEvent(MidiRecordEvent& event)
if (filterEvent(event, midiRecordType, false))
return;
-
+
if (!applyMidiInputTransformation(event)) {
if (midiInputTrace)
printf(" midi input transformation: event filtered\n");
@@ -323,13 +323,17 @@ void MidiDevice::recordEvent(MidiRecordEvent& event)
}
//
- // transfer noteOn events to gui for step recording and keyboard
- // remote control
+ // transfer noteOn and Off events to gui for step recording and keyboard
+ // remote control (changed by flo93: added noteOff-events)
//
if (typ == ME_NOTEON) {
int pv = ((event.dataA() & 0xff)<<8) + (event.dataB() & 0xff);
song->putEvent(pv);
}
+ else if (typ == ME_NOTEOFF) {
+ int pv = ((event.dataA() & 0xff)<<8) + (0x00); //send an event with velo=0
+ song->putEvent(pv);
+ }
///if(_recBufFlipped)
/// _recordEvents2.add(event); // add event to secondary list of recorded events
diff --git a/muse2/muse/midiedit/prcanvas.cpp b/muse2/muse/midiedit/prcanvas.cpp
index 1706681e..c9f66737 100644
--- a/muse2/muse/midiedit/prcanvas.cpp
+++ b/muse2/muse/midiedit/prcanvas.cpp
@@ -15,6 +15,8 @@
#include <QDropEvent>
#include <QMouseEvent>
+#include <set>
+
#include <values.h>
#include <stdio.h>
#include <math.h>
@@ -84,6 +86,7 @@ PianoCanvas::PianoCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy)
colorMode = 0;
playedPitch = -1;
_steprec = false;
+ for (int i=0;i<128;i++) noteHeldDown[i]=false;
chordTimer = new QTimer(this);
chordTimer->setSingleShot(true);
@@ -1053,13 +1056,30 @@ void PianoCanvas::cmd(int cmd)
//---------------------------------------------------------
// midiNote
//---------------------------------------------------------
-
void PianoCanvas::midiNote(int pitch, int velo)
{
+ if (debugMsg) printf("PianoCanvas::midiNote: pitch=%i, velo=%i\n", pitch, velo);
+
+ if (velo)
+ noteHeldDown[pitch]=true;
+ else
+ noteHeldDown[pitch]=false;
+
+ if (heavyDebugMsg)
+ {
+ printf(" held down notes are: ");
+ for (int i=0;i<128;i++)
+ if (noteHeldDown[i])
+ printf("%i ",i);
+ printf("\n");
+ }
+
if (_steprec && curPart
&& !audio->isPlaying() && velo && pos[0] >= start_tick
&& pos[0] < end_tick
&& !(globalKeyState & Qt::AltModifier)) {
+
+ if (pitch!=rcSteprecNote) {
chordTimer->stop();
//len has been changed by flo: set to raster() instead of quant()
@@ -1128,6 +1148,56 @@ void PianoCanvas::midiNote(int pitch, int velo)
chordTimer->start();
}
}
+ else { // equals if (pitch==rcSteprecNote)
+ bool held_notes=false;
+ for (int i=0;i<128;i++)
+ if (noteHeldDown[i]) { held_notes=true; break; }
+
+ if (held_notes)
+ {
+ chordTimer->stop();
+
+ unsigned tick = pos[0];
+
+ // extend len of last note(s)
+ using std::set;
+
+ set<Event*> extend_set;
+ EventList* events = curPart->events();
+ for (iEvent i = events->begin(); i != events->end(); ++i) {
+ Event& ev = i->second;
+ if (!ev.isNote())
+ continue;
+
+ if (noteHeldDown[ev.pitch()] && ((ev.tick() + ev.lenTick()) == tick))
+ extend_set.insert(&ev);
+ }
+ for (set<Event*>::iterator it=extend_set.begin(); it!=extend_set.end(); it++)
+ {
+ Event& ev=**it;
+ Event e = ev.clone();
+ e.setLenTick(ev.lenTick() + editor->rasterStep(tick));
+ // Indicate do undo, and do not do port controller values and clone parts.
+ audio->msgChangeEvent(ev, e, curPart, true, false, false);
+ }
+
+ if (! (globalKeyState & Qt::ShiftModifier)) {
+ chordTimer_setToTick = tick + editor->rasterStep(tick);
+ chordTimer->start();
+ }
+ return;
+
+ }
+ else // equals if (!held_notes)
+ {
+ chordTimer->stop();
+
+ //simply proceed, inserting a rest
+ Pos p(pos[0] + editor->rasterStep(pos[0]), true);
+ song->setPos(0, p, true, false, true);
+ }
+ }
+ }
}
void PianoCanvas::chordTimerTimedOut()
diff --git a/muse2/muse/midiedit/prcanvas.h b/muse2/muse/midiedit/prcanvas.h
index a5fea173..e90ac613 100644
--- a/muse2/muse/midiedit/prcanvas.h
+++ b/muse2/muse/midiedit/prcanvas.h
@@ -43,7 +43,7 @@ class PianoCanvas : public EventCanvas {
QTimer* chordTimer;
unsigned chordTimer_setToTick;
-
+ bool noteHeldDown[128];
bool _steprec;
Q_OBJECT
diff --git a/muse2/muse/mplugins/mrconfig.cpp b/muse2/muse/mplugins/mrconfig.cpp
index f64384af..1a55c826 100644
--- a/muse2/muse/mplugins/mrconfig.cpp
+++ b/muse2/muse/mplugins/mrconfig.cpp
@@ -26,12 +26,14 @@ MRConfig::MRConfig(QWidget* parent, Qt::WFlags fl)
sb2->setValue(rcRecordNote);
sb3->setValue(rcGotoLeftMarkNote);
sb4->setValue(rcPlayNote);
+ steprec_box->setValue(rcSteprecNote);
connect(b1, SIGNAL(toggled(bool)), SLOT(setRcEnable(bool)));
connect(sb1, SIGNAL(valueChanged(int)), SLOT(setRcStopNote(int)));
connect(sb2, SIGNAL(valueChanged(int)), SLOT(setRcRecordNote(int)));
connect(sb3, SIGNAL(valueChanged(int)), SLOT(setRcGotoLeftMarkNote(int)));
connect(sb4, SIGNAL(valueChanged(int)), SLOT(setRcPlayNote(int)));
+ connect(steprec_box, SIGNAL(valueChanged(int)), SLOT(setRcSteprecNote(int)));
}
//---------------------------------------------------------
@@ -69,3 +71,8 @@ void MRConfig::setRcPlayNote(int val)
rcPlayNote = val;
}
+void MRConfig::setRcSteprecNote(int val)
+ {
+ rcSteprecNote = val;
+ }
+
diff --git a/muse2/muse/mplugins/mrconfig.h b/muse2/muse/mplugins/mrconfig.h
index e829c15c..5e4b38af 100644
--- a/muse2/muse/mplugins/mrconfig.h
+++ b/muse2/muse/mplugins/mrconfig.h
@@ -32,6 +32,7 @@ class MRConfig : public QWidget, public Ui::MRConfigBase {
void setRcRecordNote(int);
void setRcGotoLeftMarkNote(int);
void setRcPlayNote(int);
+ void setRcSteprecNote(int);
public:
MRConfig(QWidget* parent=0, Qt::WFlags fl = 0);
diff --git a/muse2/muse/mplugins/mrconfigbase.ui b/muse2/muse/mplugins/mrconfigbase.ui
index ed04c334..18050c78 100644
--- a/muse2/muse/mplugins/mrconfigbase.ui
+++ b/muse2/muse/mplugins/mrconfigbase.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>298</width>
- <height>249</height>
+ <height>267</height>
</rect>
</property>
<property name="windowTitle">
@@ -95,19 +95,29 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="PitchEdit" name="sb1" native="true"/>
+ <widget class="Awl::PitchEdit" name="sb1"/>
</item>
<item row="1" column="1">
- <widget class="PitchEdit" name="sb2" native="true"/>
+ <widget class="Awl::PitchEdit" name="sb2"/>
</item>
<item row="2" column="1">
- <widget class="PitchEdit" name="sb3" native="true"/>
+ <widget class="Awl::PitchEdit" name="sb3"/>
</item>
<item row="3" column="1">
- <widget class="PitchEdit" name="sb4" native="true"/>
+ <widget class="Awl::PitchEdit" name="sb4"/>
</item>
- <item row="0" column="2">
- <spacer name="Spacer1">
+ <item row="4" column="1">
+ <widget class="Awl::PitchEdit" name="steprec_box"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Insert rest (step rec) </string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <spacer name="Spacer4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -122,8 +132,8 @@
</property>
</spacer>
</item>
- <item row="1" column="2">
- <spacer name="Spacer2">
+ <item row="2" column="2">
+ <spacer name="Spacer3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -138,8 +148,8 @@
</property>
</spacer>
</item>
- <item row="2" column="2">
- <spacer name="Spacer3">
+ <item row="1" column="2">
+ <spacer name="Spacer2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -154,8 +164,8 @@
</property>
</spacer>
</item>
- <item row="3" column="2">
- <spacer name="Spacer4">
+ <item row="0" column="2">
+ <spacer name="Spacer1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -178,9 +188,9 @@
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
- <class>PitchEdit</class>
- <extends>QWidget</extends>
- <header>pitchedit.h</header>
+ <class>Awl::PitchEdit</class>
+ <extends>QSpinBox</extends>
+ <header>awl/pitchedit.h</header>
</customwidget>
</customwidgets>
<includes>