Option to enable PortMidi on Linux

This commit is contained in:
Peter Jonas 2016-08-08 23:25:42 +01:00
parent d39279b5ce
commit 8c74814da3
No known key found for this signature in database
GPG key ID: 0B81879C782D49F1
6 changed files with 49 additions and 76 deletions

View file

@ -82,6 +82,7 @@ endif (APPLE)
# Disable components not supported on Linux/BSD
if (NOT APPLE AND NOT MINGW)
set(NIX_NOT_AVAIL "Not available on Linux/BSD")
option(BUILD_PORTMIDI "PortMidi disabled on Linux. (It uses ALSA but it's better to use ALSA directly)" OFF)
endif (NOT APPLE AND NOT MINGW)
option(AEOLUS "Enable pipe organ synthesizer" OFF)
@ -101,6 +102,7 @@ option(BUILD_JACK "Build with support for ${JACK_LONGNAME} audio backend. JAC
option(BUILD_PULSEAUDIO "Build with support for PulseAudio audio backend." ON)
option(BUILD_ALSA "Build with support for ALSA audio backend." ON)
option(BUILD_PORTAUDIO "Build with support for PortAudio audio backend." ON)
option(BUILD_PORTMIDI "Build with support for PortAudio's MIDI features." ${BUILD_PORTAUDIO}) # PortAudio required
option(BUILD_PCH "Build using precompiled headers." OFF)
if (APPLE)
@ -312,25 +314,31 @@ ENDIF(BUILD_JACK)
if (BUILD_PORTAUDIO)
if (MINGW)
set ( USE_PORTAUDIO 1 )
set ( USE_PORTMIDI 1 )
else (MINGW)
PKGCONFIG1 (portaudio-2.0 19 PORTAUDIO_INCDIR PORTAUDIO_LIBDIR PORTAUDIO_LIB PORTAUDIO_CPP)
if (PORTAUDIO_INCDIR)
message(STATUS "PortAudio found. PortAudio support enabled. INCDIR ${PORTAUDIO_INCDIR}, LIBDIR ${PORTAUDIO_LIBDIR}, LIB ${PORTAUDIO_LIB}")
message("PortAudio found. PortAudio support enabled. INCDIR ${PORTAUDIO_INCDIR}, LIBDIR ${PORTAUDIO_LIBDIR}, LIB ${PORTAUDIO_LIB}")
set ( USE_PORTAUDIO 1 )
else (PORTAUDIO_INCDIR)
message(SEND_ERROR "Error: PortAudio support requested (BUILD_PORTAUDIO=${BUILD_PORTAUDIO}), but portaudio-2.0 version 19 was not found (package portaudio19-dev)")
endif (PORTAUDIO_INCDIR)
if (APPLE)
set (USE_PORTMIDI 1)
else (APPLE)
set (USE_PORTMIDI 0)
endif (APPLE)
endif (MINGW)
else (BUILD_PORTAUDIO)
message(STATUS "PortAudio support disabled")
endif (BUILD_PORTAUDIO)
##
## PortMidi
##
if (BUILD_PORTMIDI)
if (NOT BUILD_PORTAUDIO)
message(SEND_ERROR "Error: PortMidi support requested (BUILD_PORTMIDI=${BUILD_PORTMIDI}), but PortAudio support is disabled (BUILD_PORTAUDIO=${BUILD_PORTAUDIO}). PortMidi requires PortAudio.")
endif (NOT BUILD_PORTAUDIO)
set (USE_PORTMIDI 1)
else (BUILD_PORTMIDI)
message(STATUS "PortMidi support disabled")
endif (BUILD_PORTMIDI)
if (APPLE)
if(SOUNDFONT3)
@ -543,9 +551,9 @@ add_subdirectory(fonttools EXCLUDE_FROM_ALL)
add_subdirectory(manual)
add_subdirectory(demos)
if (USE_PORTMIDI)
if (USE_PORTMIDI AND (MINGW OR APPLE))
subdirs (thirdparty/portmidi)
endif (USE_PORTMIDI)
endif (USE_PORTMIDI AND (MINGW OR APPLE))
if (AEOLUS)
subdirs (aeolus)

View file

@ -150,7 +150,7 @@ if (MINGW)
set (resource_file ${PROJECT_BINARY_DIR}/resfile.o)
else (MINGW)
if (USE_ALSA)
set (AUDIO ${AUDIO} alsa.cpp mididriver.cpp)
set (AUDIO ${AUDIO} alsa.cpp)
endif (USE_ALSA)
endif (MINGW)
@ -174,6 +174,10 @@ if (USE_JACK)
set (AUDIO ${AUDIO} jackaudio.cpp jackweakapi.cpp)
endif (USE_JACK)
if (USE_ALSA OR USE_PORTMIDI)
set (AUDIO ${AUDIO} mididriver.cpp)
endif (USE_ALSA OR USE_PORTMIDI)
if (${CMAKE_SYSTEM} MATCHES "GNU-0.3")
# Include some cmake support file
INCLUDE (Platform/GNU)
@ -484,6 +488,15 @@ else (MINGW)
target_link_libraries(mscore ${PORTAUDIO_LIB})
endif (USE_PORTAUDIO)
if (USE_PORTMIDI)
if (APPLE)
set(PORTMIDI_LIB portmidi)
else (APPLE)
set(PORTMIDI_LIB -lportmidi -lporttime) # Remove -lporttime on RPM-based systems where PortTime is part of PortMidi.
endif (APPLE)
target_link_libraries(mscore ${PORTMIDI_LIB})
endif (USE_PORTMIDI)
if (USE_PULSEAUDIO)
target_link_libraries(mscore ${PULSEAUDIO_LIBRARY})
endif (USE_PULSEAUDIO)
@ -502,9 +515,6 @@ else (MINGW)
endif (OMR)
if (APPLE)
if (USE_PORTMIDI)
target_link_libraries(mscore portmidi)
endif (USE_PORTMIDI)
target_link_libraries(mscore ${OsxFrameworks})
else (APPLE)
target_link_libraries(mscore rt)

View file

@ -31,7 +31,10 @@
#include <portaudio.h>
#include "mididriver.h"
#ifdef USE_PORTMIDI
#include "pm.h"
#endif
namespace Ms {

View file

@ -23,7 +23,11 @@
#include <mmsystem.h>
#endif
#include "portmidi/porttime/porttime.h"
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
#include "portmidi/porttime/porttime.h"
#else
#include <porttime.h>
#endif
#include "preferences.h"
#include "pm.h"
@ -32,66 +36,6 @@
namespace Ms {
//---------------------------------------------------------
// Port
//---------------------------------------------------------
Port::Port()
{
type = ZERO_TYPE;
}
Port::Port(unsigned char client, unsigned char port)
{
_alsaPort = port;
_alsaClient = client;
type = ALSA_TYPE;
}
//---------------------------------------------------------
// setZero
//---------------------------------------------------------
void Port::setZero()
{
type = ZERO_TYPE;
}
//---------------------------------------------------------
// isZero
//---------------------------------------------------------
bool Port::isZero() const
{
return type == ZERO_TYPE;
}
//---------------------------------------------------------
// operator==
//---------------------------------------------------------
bool Port::operator==(const Port& p) const
{
if (type == ALSA_TYPE)
return _alsaPort == p._alsaPort && _alsaClient == p._alsaClient;
else
return true;
}
//---------------------------------------------------------
// operator<
//---------------------------------------------------------
bool Port::operator<(const Port& p) const
{
if (type == ALSA_TYPE) {
if (_alsaPort != p._alsaPort)
return _alsaPort < p._alsaPort;
return _alsaClient < p._alsaClient;
}
return false;
}
//---------------------------------------------------------
// PortMidiDriver
//---------------------------------------------------------
@ -135,7 +79,7 @@ bool PortMidiDriver::init()
PmError error = Pm_OpenInput(&inputStream,
inputId,
(void*)DRIVER_INFO, INPUT_BUFFER_SIZE,
((long (*)(void*)) Pt_Time),
((PmTimeProcPtr) Pt_Time),
(void*)TIME_INFO);
if (error != pmNoError) {
const char* p = Pm_GetErrorText(error);

View file

@ -24,7 +24,11 @@
#include "config.h"
#include "mididriver.h"
#include "portmidi/pm_common/portmidi.h"
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
#include "portmidi/pm_common/portmidi.h"
#else
#include <portmidi.h>
#endif
namespace Ms {

View file

@ -31,7 +31,11 @@
#include "scoreview.h"
#include "libmscore/sym.h"
#include "pa.h"
#ifdef USE_PORTMIDI
#include "pm.h"
#endif
#include "libmscore/page.h"
#include "file.h"
#include "libmscore/mscore.h"