Import portmidi-217
PortMidi is a library for real time input and output of MIDI data. Support for sndio is incomplete, only output is implemented for now. ok jca@, ratchov@
This commit is contained in:
parent
14e412f735
commit
c030f0cdc9
36
audio/portmidi/Makefile
Normal file
36
audio/portmidi/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2019/03/23 13:30:08 rapha Exp $
|
||||
|
||||
COMMENT = library for real time input and output of MIDI data
|
||||
|
||||
DISTNAME = portmidi-src-217
|
||||
PKGNAME = portmidi-217
|
||||
|
||||
SHARED_LIBS = portmidi 0.0
|
||||
|
||||
CATEGORIES = audio
|
||||
|
||||
HOMEPAGE = http://portmedia.sourceforge.net/
|
||||
|
||||
# ISC
|
||||
PERMIT_PACKAGE_CDROM = Yes
|
||||
|
||||
WANTLIB = pthread sndio
|
||||
|
||||
MASTER_SITES = ${MASTER_SITE_SOURCEFORGE:=portmedia/}
|
||||
EXTRACT_SUFX = .zip
|
||||
|
||||
MODULES = devel/cmake
|
||||
|
||||
CONFIGURE_ARGS+= -DPROJECT_BINARY_DIR=Release \
|
||||
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${WRKBUILD}/Release \
|
||||
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${WRKBUILD}/Release \
|
||||
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${WRKBUILD}/Release
|
||||
|
||||
NO_TEST = Yes
|
||||
|
||||
WRKDIST = ${WRKDIR}/portmidi
|
||||
|
||||
post-extract:
|
||||
cp -rf ${FILESDIR}/* ${WRKSRC}/
|
||||
|
||||
.include <bsd.port.mk>
|
2
audio/portmidi/distinfo
Normal file
2
audio/portmidi/distinfo
Normal file
@ -0,0 +1,2 @@
|
||||
SHA256 (portmidi-src-217.zip) = COmokr2AvbERUhP7ctwpp78v8QizeBgFhqpl88/ULg8=
|
||||
SIZE (portmidi-src-217.zip) = 1030830
|
171
audio/portmidi/files/pm_sndio/pmsndio.c
Normal file
171
audio/portmidi/files/pm_sndio/pmsndio.c
Normal file
@ -0,0 +1,171 @@
|
||||
/* pmsndio.c -- PortMidi os-dependent code */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sndio.h>
|
||||
#include "portmidi.h"
|
||||
#include "pmutil.h"
|
||||
#include "pminternal.h"
|
||||
|
||||
|
||||
PmDeviceID pm_default_input_device_id = -1;
|
||||
PmDeviceID pm_default_output_device_id = -1;
|
||||
|
||||
extern pm_fns_node pm_sndio_in_dictionary;
|
||||
extern pm_fns_node pm_sndio_out_dictionary;
|
||||
|
||||
void pm_init()
|
||||
{
|
||||
// Add output devices
|
||||
pm_add_device("SNDIO",
|
||||
"default",
|
||||
FALSE,
|
||||
(void *)0,
|
||||
&pm_sndio_out_dictionary);
|
||||
pm_add_device("SNDIO",
|
||||
"midi/0",
|
||||
FALSE,
|
||||
(void *)1,
|
||||
&pm_sndio_out_dictionary);
|
||||
|
||||
// this is set when we return to Pm_Initialize, but we need it
|
||||
// now in order to (successfully) call Pm_CountDevices()
|
||||
pm_initialized = TRUE;
|
||||
pm_default_output_device_id = 0;
|
||||
}
|
||||
|
||||
void pm_term(void)
|
||||
{
|
||||
}
|
||||
|
||||
PmDeviceID Pm_GetDefaultInputDeviceID() {
|
||||
Pm_Initialize();
|
||||
return pm_default_input_device_id;
|
||||
}
|
||||
|
||||
PmDeviceID Pm_GetDefaultOutputDeviceID() {
|
||||
Pm_Initialize();
|
||||
return pm_default_output_device_id;
|
||||
}
|
||||
|
||||
void *pm_alloc(size_t s) { return malloc(s); }
|
||||
|
||||
void pm_free(void *ptr) { free(ptr); }
|
||||
|
||||
/* midi_message_length -- how many bytes in a message? */
|
||||
static int midi_message_length(PmMessage message)
|
||||
{
|
||||
message &= 0xff;
|
||||
if (message < 0x80) {
|
||||
return 0;
|
||||
} else if (message < 0xf0) {
|
||||
static const int length[] = {3, 3, 3, 3, 2, 2, 3};
|
||||
return length[(message - 0x80) >> 4];
|
||||
} else {
|
||||
static const int length[] = {
|
||||
-1, 2, 3, 2, 0, 0, 1, -1, 1, 0, 1, 1, 1, 0, 1, 1};
|
||||
return length[message - 0xf0];
|
||||
}
|
||||
}
|
||||
|
||||
static PmError sndio_out_open(PmInternal *midi, void *driverInfo)
|
||||
{
|
||||
const char *device = descriptors[midi->device_id].pub.name;
|
||||
struct mio_hdl *mio;
|
||||
|
||||
mio = mio_open(device, MIO_OUT, 0);
|
||||
if (!mio) {
|
||||
fprintf(stderr, "mio_open failed\n");
|
||||
return pmHostError;
|
||||
}
|
||||
midi->descriptor = mio;
|
||||
|
||||
return pmNoError;
|
||||
}
|
||||
static PmError sndio_out_close(PmInternal *midi)
|
||||
{
|
||||
mio_close(midi->descriptor);
|
||||
return pmNoError;
|
||||
}
|
||||
static PmError sndio_abort(PmInternal *midi)
|
||||
{
|
||||
mio_close(midi->descriptor);
|
||||
return pmNoError;
|
||||
}
|
||||
static PmTimestamp sndio_synchronize(PmInternal *midi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static PmError sndio_write_byte(PmInternal *midi, unsigned char byte,
|
||||
PmTimestamp timestamp)
|
||||
{
|
||||
size_t w = mio_write(midi->descriptor, &byte, 1);
|
||||
if (w != 1) {
|
||||
fprintf(stderr, "mio_write failed\n");
|
||||
return pmHostError;
|
||||
}
|
||||
return pmNoError;
|
||||
}
|
||||
static PmError sndio_write_short(PmInternal *midi, PmEvent *event)
|
||||
{
|
||||
int bytes = midi_message_length(event->message);
|
||||
PmMessage msg = event->message;
|
||||
int i;
|
||||
for (i = 0; i < bytes; i++) {
|
||||
unsigned char byte = msg;
|
||||
sndio_write_byte(midi, byte, event->timestamp);
|
||||
msg >>= 8;
|
||||
}
|
||||
|
||||
return pmNoError;
|
||||
}
|
||||
static PmError sndio_write_flush(PmInternal *midi, PmTimestamp timestamp)
|
||||
{
|
||||
return pmNoError;
|
||||
}
|
||||
PmError sndio_sysex(PmInternal *midi, PmTimestamp timestamp)
|
||||
{
|
||||
return pmNoError;
|
||||
}
|
||||
static unsigned int sndio_has_host_error(PmInternal *midi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static void sndio_get_host_error(PmInternal *midi, char *msg, unsigned int len)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
pm_fns_node pm_sndio_in_dictionary = {
|
||||
none_write_short,
|
||||
none_sysex,
|
||||
none_sysex,
|
||||
none_write_byte,
|
||||
none_write_short,
|
||||
none_write_flush,
|
||||
sndio_synchronize,
|
||||
sndio_in_open,
|
||||
sndio_abort,
|
||||
sndio_in_close,
|
||||
sndio_poll,
|
||||
sndio_has_host_error,
|
||||
sndio_get_host_error
|
||||
};
|
||||
*/
|
||||
|
||||
pm_fns_node pm_sndio_out_dictionary = {
|
||||
sndio_write_short,
|
||||
sndio_sysex,
|
||||
sndio_sysex,
|
||||
sndio_write_byte,
|
||||
sndio_write_short,
|
||||
sndio_write_flush,
|
||||
sndio_synchronize,
|
||||
sndio_out_open,
|
||||
sndio_abort,
|
||||
sndio_out_close,
|
||||
none_poll,
|
||||
sndio_has_host_error,
|
||||
sndio_get_host_error
|
||||
};
|
||||
|
5
audio/portmidi/files/pm_sndio/pmsndio.h
Normal file
5
audio/portmidi/files/pm_sndio/pmsndio.h
Normal file
@ -0,0 +1,5 @@
|
||||
/* pmsndio.h */
|
||||
|
||||
extern PmDeviceID pm_default_input_device_id;
|
||||
extern PmDeviceID pm_default_output_device_id;
|
||||
|
11
audio/portmidi/files/portmidi.pc.in
Normal file
11
audio/portmidi/files/portmidi.pc.in
Normal file
@ -0,0 +1,11 @@
|
||||
prefix=@DEST_DIR@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: libportmidi
|
||||
Description: Portable midi I/O
|
||||
Version: 217
|
||||
|
||||
Libs: -L${libdir} -lportmidi
|
||||
Cflags: -I${includedir}
|
18
audio/portmidi/patches/patch-CMakeLists_txt
Normal file
18
audio/portmidi/patches/patch-CMakeLists_txt
Normal file
@ -0,0 +1,18 @@
|
||||
$OpenBSD: patch-CMakeLists_txt,v 1.1.1.1 2019/03/23 13:30:08 rapha Exp $
|
||||
|
||||
Index: CMakeLists.txt
|
||||
--- CMakeLists.txt.orig
|
||||
+++ CMakeLists.txt
|
||||
@@ -73,5 +73,11 @@ add_subdirectory(pm_test)
|
||||
add_subdirectory(pm_dylib)
|
||||
|
||||
# Cannot figure out how to make an xcode Java application with CMake
|
||||
-add_subdirectory(pm_java)
|
||||
+#add_subdirectory(pm_java)
|
||||
|
||||
+set(DEST_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
+CONFIGURE_FILE("portmidi.pc.in" "portmidi.pc" @ONLY)
|
||||
+install(FILES
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/portmidi.pc"
|
||||
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig"
|
||||
+)
|
57
audio/portmidi/patches/patch-pm_common_CMakeLists_txt
Normal file
57
audio/portmidi/patches/patch-pm_common_CMakeLists_txt
Normal file
@ -0,0 +1,57 @@
|
||||
$OpenBSD: patch-pm_common_CMakeLists_txt,v 1.1.1.1 2019/03/23 13:30:08 rapha Exp $
|
||||
|
||||
Index: pm_common/CMakeLists.txt
|
||||
--- pm_common/CMakeLists.txt.orig
|
||||
+++ pm_common/CMakeLists.txt
|
||||
@@ -66,21 +66,12 @@ if(UNIX)
|
||||
set(JAVA_INCLUDE_PATHS ${JAVAVM_LIB}/Headers)
|
||||
message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
|
||||
else(APPLE)
|
||||
- # LINUX settings...
|
||||
- include(FindJNI)
|
||||
- message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
|
||||
- message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
|
||||
- message(STATUS "JAVA_INCLUDE_PATH2 is " ${JAVA_INCLUDE_PATH2})
|
||||
- message(STATUS "JAVA_JVM_LIBRARY is " ${JAVA_JVM_LIBRARY})
|
||||
- set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
|
||||
- # libjvm.so is found relative to JAVA_INCLUDE_PATH:
|
||||
- set(JAVAVM_LIB ${JAVA_JVM_LIBRARY}/libjvm.so)
|
||||
|
||||
- set(LINUXSRC pmlinuxalsa pmlinux finddefault)
|
||||
- prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
|
||||
+ set(LINUXSRC pmsndio)
|
||||
+ prepend_path(LIBSRC ../pm_sndio/ ${LINUXSRC})
|
||||
list(APPEND LIBSRC ../porttime/ptlinux)
|
||||
|
||||
- set(PM_NEEDED_LIBS pthread asound)
|
||||
+ set(PM_NEEDED_LIBS pthread sndio)
|
||||
endif(APPLE)
|
||||
else(UNIX)
|
||||
if(WIN32)
|
||||
@@ -99,7 +90,6 @@ else(UNIX)
|
||||
set(PM_NEEDED_LIBS winmm.lib)
|
||||
endif(WIN32)
|
||||
endif(UNIX)
|
||||
-set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVA_JVM_LIBRARY})
|
||||
|
||||
# this completes the list of library sources by adding shared code
|
||||
list(APPEND LIBSRC pmutil portmidi)
|
||||
@@ -109,17 +99,10 @@ add_library(portmidi-static ${LIBSRC})
|
||||
set_target_properties(portmidi-static PROPERTIES OUTPUT_NAME "portmidi_s")
|
||||
target_link_libraries(portmidi-static ${PM_NEEDED_LIBS})
|
||||
|
||||
-# define the jni library
|
||||
-include_directories(${JAVA_INCLUDE_PATHS})
|
||||
|
||||
-set(JNISRC ${LIBSRC} ../pm_java/pmjni/pmjni.c)
|
||||
-add_library(pmjni SHARED ${JNISRC})
|
||||
-target_link_libraries(pmjni ${JNI_EXTRA_LIBS})
|
||||
-set_target_properties(pmjni PROPERTIES EXECUTABLE_EXTENSION "jnilib")
|
||||
-
|
||||
# install the libraries (Linux and Mac OS X command line)
|
||||
if(UNIX)
|
||||
- INSTALL(TARGETS portmidi-static pmjni
|
||||
+ INSTALL(TARGETS portmidi-static
|
||||
LIBRARY DESTINATION /usr/local/lib
|
||||
ARCHIVE DESTINATION /usr/local/lib)
|
||||
# .h files installed by pm_dylib/CMakeLists.txt, so don't need them here
|
39
audio/portmidi/patches/patch-pm_dylib_CMakeLists_txt
Normal file
39
audio/portmidi/patches/patch-pm_dylib_CMakeLists_txt
Normal file
@ -0,0 +1,39 @@
|
||||
$OpenBSD: patch-pm_dylib_CMakeLists_txt,v 1.1.1.1 2019/03/23 13:30:08 rapha Exp $
|
||||
|
||||
Index: pm_dylib/CMakeLists.txt
|
||||
--- pm_dylib/CMakeLists.txt.orig
|
||||
+++ pm_dylib/CMakeLists.txt
|
||||
@@ -62,30 +62,11 @@ if(UNIX)
|
||||
set(INSTALL_NAME_DIR "/usr/local/lib")
|
||||
message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
|
||||
else(APPLE)
|
||||
- # LINUX settings...
|
||||
- include(FindJNI)
|
||||
- # message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
|
||||
- # message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
|
||||
- # note: should use JAVA_JVM_LIB_PATH, but it is not set properly
|
||||
- # note: user might need to set JAVA_INCLUDE_PATH manually
|
||||
- #
|
||||
- # this will probably break on BSD and other Unix systems; the fix
|
||||
- # depends on whether FindJNI can find Java or not. If yes, then
|
||||
- # we should try to rely on automatically set JAVA_INCLUDE_PATH and
|
||||
- # JAVA_INCLUDE_PATH2; if no, then we need to make both JAVA_INCLUDE_PATH
|
||||
- # and JAVA_INCLUDE_PATH2 set by user (will need clear documentation
|
||||
- # because JAVA_INCLUDE_PATH2 is pretty obscure)
|
||||
- set(JAVA_INCLUDE_PATH ${JAVA_INCLUDE_PATH-UNKNOWN}
|
||||
- CACHE STRING "where to find Java SDK include directory")
|
||||
- set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH}/linux)
|
||||
- # libjvm.so is found relative to JAVA_INCLUDE_PATH:
|
||||
- set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../jre/lib/i386/client/libjvm.so)
|
||||
-
|
||||
- set(LINUXSRC pmlinuxalsa pmlinux finddefault)
|
||||
- prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
|
||||
+ set(LINUXSRC pmsndio)
|
||||
+ prepend_path(LIBSRC ../pm_sndio/ ${LINUXSRC})
|
||||
list(APPEND LIBSRC ../porttime/ptlinux)
|
||||
|
||||
- set(PM_NEEDED_LIBS pthread asound)
|
||||
+ set(PM_NEEDED_LIBS pthread sndio)
|
||||
endif(APPLE)
|
||||
else(UNIX)
|
||||
if(WIN32)
|
11
audio/portmidi/patches/patch-pm_test_CMakeLists_txt
Normal file
11
audio/portmidi/patches/patch-pm_test_CMakeLists_txt
Normal file
@ -0,0 +1,11 @@
|
||||
$OpenBSD: patch-pm_test_CMakeLists_txt,v 1.1.1.1 2019/03/23 13:30:08 rapha Exp $
|
||||
|
||||
Index: pm_test/CMakeLists.txt
|
||||
--- pm_test/CMakeLists.txt.orig
|
||||
+++ pm_test/CMakeLists.txt
|
||||
@@ -1,4 +1,5 @@
|
||||
# pm_test
|
||||
+cmake_policy(SET CMP0037 OLD)
|
||||
|
||||
# set the build directory to be in portmidi, not in portmidi/pm_test
|
||||
# this is required for Xcode:
|
49
audio/portmidi/patches/patch-porttime_ptlinux_c
Normal file
49
audio/portmidi/patches/patch-porttime_ptlinux_c
Normal file
@ -0,0 +1,49 @@
|
||||
$OpenBSD: patch-porttime_ptlinux_c,v 1.1.1.1 2019/03/23 13:30:08 rapha Exp $
|
||||
|
||||
Index: porttime/ptlinux.c
|
||||
--- porttime/ptlinux.c.orig
|
||||
+++ porttime/ptlinux.c
|
||||
@@ -31,14 +31,13 @@ CHANGE LOG
|
||||
#include "porttime.h"
|
||||
#include "sys/time.h"
|
||||
#include "sys/resource.h"
|
||||
-#include "sys/timeb.h"
|
||||
#include "pthread.h"
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
static int time_started_flag = FALSE;
|
||||
-static struct timeb time_offset = {0, 0, 0, 0};
|
||||
+static struct timespec time_offset = {0, 0};
|
||||
static pthread_t pt_thread_pid;
|
||||
static int pt_thread_created = FALSE;
|
||||
|
||||
@@ -79,7 +78,7 @@ static void *Pt_CallbackProc(void *p)
|
||||
PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
|
||||
{
|
||||
if (time_started_flag) return ptNoError;
|
||||
- ftime(&time_offset); /* need this set before process runs */
|
||||
+ clock_gettime(CLOCK_MONOTONIC, &time_offset); /* need this set before process runs */
|
||||
if (callback) {
|
||||
int res;
|
||||
pt_callback_parameters *parms = (pt_callback_parameters *)
|
||||
@@ -120,12 +119,12 @@ int Pt_Started()
|
||||
|
||||
PtTimestamp Pt_Time()
|
||||
{
|
||||
- long seconds, milliseconds;
|
||||
- struct timeb now;
|
||||
- ftime(&now);
|
||||
- seconds = now.time - time_offset.time;
|
||||
- milliseconds = now.millitm - time_offset.millitm;
|
||||
- return seconds * 1000 + milliseconds;
|
||||
+ long seconds, nanoseconds;
|
||||
+ struct timespec now;
|
||||
+ clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
+ seconds = now.tv_sec - time_offset.tv_sec;
|
||||
+ nanoseconds = now.tv_nsec - time_offset.tv_nsec;
|
||||
+ return seconds * 1000 + nanoseconds / 1000000;
|
||||
}
|
||||
|
||||
|
3
audio/portmidi/pkg/DESCR
Normal file
3
audio/portmidi/pkg/DESCR
Normal file
@ -0,0 +1,3 @@
|
||||
PortMidi is a computer library for real time input and output of MIDI data.
|
||||
It is designed to be portable to many different operating systems. PortMidi is
|
||||
part of the PortMusic project.
|
6
audio/portmidi/pkg/PLIST
Normal file
6
audio/portmidi/pkg/PLIST
Normal file
@ -0,0 +1,6 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2019/03/23 13:30:08 rapha Exp $
|
||||
include/portmidi.h
|
||||
include/porttime.h
|
||||
@lib lib/libportmidi.so.${LIBportmidi_VERSION}
|
||||
lib/libportmidi_s.a
|
||||
lib/pkgconfig/portmidi.pc
|
Loading…
x
Reference in New Issue
Block a user