summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2008-06-25 20:37:05 +0000
committerWerner Schweer <ws.seh.de>2008-06-25 20:37:05 +0000
commit594aaeb36e159dca372ad2e5c50f928047fa8275 (patch)
treed41f134a978486deca9c083cbc33d52443b584e8
parent48869220e072b5c9c1a8d896969bed98cf9794cb (diff)
add jack midi input
-rw-r--r--muse/CMakeLists.txt2
-rw-r--r--muse/doc/man/de/CMakeLists.txt8
-rw-r--r--muse/muse/audio.cpp3
-rw-r--r--muse/muse/audiodev.h3
-rw-r--r--muse/muse/jack.cpp17
-rw-r--r--muse/muse/jackaudio.h2
-rw-r--r--muse/muse/midiinport.cpp39
-rw-r--r--muse/muse/midiinport.h2
-rw-r--r--muse/muse/muse.cpp5
-rw-r--r--muse/synti/mus/mus.cpp2
10 files changed, 52 insertions, 31 deletions
diff --git a/muse/CMakeLists.txt b/muse/CMakeLists.txt
index e0de0c81..8404f25f 100644
--- a/muse/CMakeLists.txt
+++ b/muse/CMakeLists.txt
@@ -231,8 +231,6 @@ else (ENABLE_DSSI)
message("DSSI disabled")
endif (ENABLE_DSSI)
-
-
if (ENABLE_VST)
message("VST support enabled")
set (VST_SUPPORT TRUE)
diff --git a/muse/doc/man/de/CMakeLists.txt b/muse/doc/man/de/CMakeLists.txt
index 0c70dd3b..ac009499 100644
--- a/muse/doc/man/de/CMakeLists.txt
+++ b/muse/doc/man/de/CMakeLists.txt
@@ -18,8 +18,8 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=============================================================================
-add_custom_command (
- OUTPUT man-de.pdf
+add_custom_target (
+ manual
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/man-de.tex
${CMAKE_CURRENT_SOURCE_DIR}/projekte.tex
@@ -35,10 +35,6 @@ add_custom_command (
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
-add_custom_target ( manual
- DEPENDS man-de.pdf
- )
-
install_files ( /share/${MusE_INSTALL_NAME}/doc/ .pdf
${CMAKE_CURRENT_BINARY_DIR}/man-de.pdf )
diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp
index dd68c6bc..c4121e47 100644
--- a/muse/muse/audio.cpp
+++ b/muse/muse/audio.cpp
@@ -281,9 +281,6 @@ void Audio::process(unsigned frames, int jackState)
{
_seqTime.lastFrameTime = audioDriver->lastFrameTime();
- extern int watchAudio;
- ++watchAudio; // make a simple watchdog happy
-
//
// process messages from gui
//
diff --git a/muse/muse/audiodev.h b/muse/muse/audiodev.h
index 55830c14..56479c71 100644
--- a/muse/muse/audiodev.h
+++ b/muse/muse/audiodev.h
@@ -23,6 +23,8 @@
#include "driver.h"
+class MidiInPort;
+
//---------------------------------------------------------
// AudioDevice
//---------------------------------------------------------
@@ -50,6 +52,7 @@ class AudioDriver : public Driver {
virtual void setFreewheel(bool f) = 0;
virtual void graphChanged() {}
virtual void startMidiCycle(Port) {}
+ virtual void collectMidiEvents(MidiInPort*, Port) {}
};
#endif
diff --git a/muse/muse/jack.cpp b/muse/muse/jack.cpp
index cde57418..7c1368b1 100644
--- a/muse/muse/jack.cpp
+++ b/muse/muse/jack.cpp
@@ -26,6 +26,7 @@
#include "song.h"
#include "jackaudio.h"
#include "track.h"
+#include "midiinport.h"
#ifdef VST_SUPPORT
#include <fst.h>
@@ -929,3 +930,19 @@ void JackAudio::startMidiCycle(Port port)
#endif
}
+//---------------------------------------------------------
+// collectMidiEvents
+//---------------------------------------------------------
+
+void JackAudio::collectMidiEvents(MidiInPort* track, Port port)
+ {
+ void* port_buf = jack_port_get_buffer(port.jackPort(), segmentSize);
+ jack_midi_event_t event;
+ jack_nframes_t eventCount = jack_midi_get_event_count(port_buf);
+ for (jack_nframes_t i = 0; i < eventCount; ++i) {
+ jack_midi_event_get(&event, port_buf, i);
+ track->eventReceived(&event);
+ }
+ }
+
+
diff --git a/muse/muse/jackaudio.h b/muse/muse/jackaudio.h
index 0322b3b8..7a7d5474 100644
--- a/muse/muse/jackaudio.h
+++ b/muse/muse/jackaudio.h
@@ -22,6 +22,7 @@
#define __JACKAUDIO_H__
#include "audiodev.h"
+class MidiInPort;
//---------------------------------------------------------
// JackAudio
@@ -81,6 +82,7 @@ class JackAudio : public AudioDriver {
virtual unsigned lastFrameTime() const { return jack_last_frame_time(_client); }
virtual unsigned frameTime() const { return jack_frame_time(_client); }
virtual unsigned curFrame() const { return pos.frame; }
+ virtual void collectMidiEvents(MidiInPort*, Port);
};
#endif
diff --git a/muse/muse/midiinport.cpp b/muse/muse/midiinport.cpp
index dd39ec33..8953725d 100644
--- a/muse/muse/midiinport.cpp
+++ b/muse/muse/midiinport.cpp
@@ -26,8 +26,8 @@
#include "audiodev.h"
#include "audio.h"
#include "gconfig.h"
-
#include "midiinport.h"
+#include "jackaudio.h"
//---------------------------------------------------------
// MidiInPort
@@ -56,8 +56,6 @@ MidiInPort::~MidiInPort()
void MidiInPort::setName(const QString& s)
{
Track::setName(s);
-// if (!alsaPort(0).isZero())
-// midiDriver->setPortName(alsaPort(), s);
if (!jackPort(0).isZero())
audioDriver->setPortName(jackPort(), s);
}
@@ -88,16 +86,16 @@ void MidiInPort::read(QDomNode node)
}
}
-#if 0
//---------------------------------------------------------
// midiReceived
// called from midiSeq context
//---------------------------------------------------------
-void MidiInPort::eventReceived(snd_seq_event_t* ev)
+void MidiInPort::eventReceived(jack_midi_event_t* ev)
{
MidiEvent event;
event.setB(0);
+
//
// move all events 2*segmentSize into the future to get
// jitterfree playback
@@ -107,16 +105,22 @@ void MidiInPort::eventReceived(snd_seq_event_t* ev)
// ^ ^ ^
// catch process play
//
- event.setTime(audioDriver->frameTime() + 2 * segmentSize);
+ event.setTime(audioDriver->frameTime() + ev->time);
- switch(ev->type) {
- case SND_SEQ_EVENT_NOTEON:
- event.setChannel(ev->data.note.channel);
+ switch(*(ev->buffer) & 0xf0) {
+ case 0x90:
+ event.setChannel(*(ev->buffer) & 0xf);
event.setType(ME_NOTEON);
- event.setA(ev->data.note.note);
- event.setB(ev->data.note.velocity);
+ event.setA(*(ev->buffer + 1));
+ event.setB(*(ev->buffer + 2));
break;
-
+ case 0x80:
+ event.setChannel(*(ev->buffer) & 0xf);
+ event.setType(ME_NOTEOFF);
+ event.setA(*(ev->buffer + 1));
+ event.setB(*(ev->buffer + 2));
+ break;
+#if 0
case SND_SEQ_EVENT_KEYPRESS:
event.setChannel(ev->data.note.channel);
event.setType(ME_POLYAFTER);
@@ -163,6 +167,9 @@ void MidiInPort::eventReceived(snd_seq_event_t* ev)
event.setA(ev->data.control.param);
event.setB(ev->data.control.value);
break;
+#endif
+ default:
+ return; // ignore
}
if (midiInputTrace) {
@@ -190,7 +197,6 @@ void MidiInPort::eventReceived(snd_seq_event_t* ev)
printf("MusE: eventReceived(): fifo overflow\n");
}
}
-#endif
//---------------------------------------------------------
// afterProcess
@@ -210,6 +216,13 @@ void MidiInPort::afterProcess()
void MidiInPort::beforeProcess()
{
+ if (!jackPort(0).isZero())
+ audioDriver->collectMidiEvents(this, jackPort(0));
+
+// Port _jackPort[MAX_CHANNELS];
+ // collect jack midi events
+// void eventReceived(snd_seq_event_t*);
+
tmpRecordCount = recordFifo.getSize();
}
diff --git a/muse/muse/midiinport.h b/muse/muse/midiinport.h
index c1fdf3ac..899ee0a8 100644
--- a/muse/muse/midiinport.h
+++ b/muse/muse/midiinport.h
@@ -50,7 +50,7 @@ class MidiInPort : public MidiTrackBase {
virtual bool isMute() const { return _mute; }
virtual Part* newPart(Part*, bool) { return 0; }
-// void eventReceived(snd_seq_event_t*);
+ void eventReceived(jack_midi_event_t*);
virtual void getEvents(unsigned from, unsigned to, int channel, MidiEventList* dst);
void beforeProcess();
diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp
index c025491e..52767384 100644
--- a/muse/muse/muse.cpp
+++ b/muse/muse/muse.cpp
@@ -67,8 +67,6 @@
extern void initMidiInstruments();
-static pthread_t watchdogThread;
-
#define PROJECT_LIST_LEN 6
static QString* projectList[PROJECT_LIST_LEN];
@@ -82,7 +80,6 @@ extern void exitJackAudio();
QStyle* smallStyle;
-int watchAudio, watchAudioPrefetch, watchMidi;
pthread_t splashThread;
MusE* muse;
@@ -166,8 +163,6 @@ void MusE::seqStop()
audio->stop();
audioWriteback->stop(true);
audioPrefetch->stop(true);
- if (realTimePriority)
- pthread_cancel(watchdogThread);
audioState = AUDIO_STOP;
}
diff --git a/muse/synti/mus/mus.cpp b/muse/synti/mus/mus.cpp
index adbf153b..a112b450 100644
--- a/muse/synti/mus/mus.cpp
+++ b/muse/synti/mus/mus.cpp
@@ -25,7 +25,7 @@
#include "config.h"
#include "libsynti/mess.h"
-#include "driver/jackaudio.h"
+#include "jackaudio.h"
#include <jack/midiport.h>
static const char* versionString = "1.0";