Skip to content

Commit

Permalink
ALSA: Add experimental MIDI support
Browse files Browse the repository at this point in the history
Fix incorrect SendMessageToAllChannels resulting in not all channels being stopped.
  • Loading branch information
Ghabry committed Jul 13, 2021
1 parent 3a19bb6 commit acdf5fa
Show file tree
Hide file tree
Showing 9 changed files with 792 additions and 17 deletions.
30 changes: 26 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -669,10 +669,32 @@ if(${PLAYER_AUDIO_BACKEND} MATCHES "^(SDL2|libretro)$")
set(PLAYER_HAS_AUDIO ON)
target_compile_definitions(${PROJECT_NAME} PUBLIC SUPPORT_AUDIO=1)

if (WIN32 OR APPLE)
option(PLAYER_WITH_NATIVE_MIDI "Play MIDI audio using the API of the operating system." ON)
if(PLAYER_WITH_NATIVE_MIDI)
target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_NATIVE_MIDI=1)
if(${PLAYER_AUDIO_BACKEND} STREQUAL "libretro")
elseif(WIN32 OR APPLE)
set(SUPPORT_NATIVE_MIDI ON)
elseif(UNIX)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.12)
find_package(ALSA)
if(ALSA_FOUND)
set(SUPPORT_NATIVE_MIDI ON)
endif()
endif()
endif()

CMAKE_DEPENDENT_OPTION(PLAYER_WITH_NATIVE_MIDI "Play MIDI audio using the API of the operating system" ON "SUPPORT_NATIVE_MIDI" OFF)
if(PLAYER_WITH_NATIVE_MIDI)
target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_NATIVE_MIDI=1)
if(ALSA_FOUND)
target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_ALSA=1)
target_sources(${PROJECT_NAME} PRIVATE
src/platform/linux/midiout_device_alsa.cpp
src/platform/linux/midiout_device_alsa.h
)
target_link_libraries(${PROJECT_NAME} ALSA::ALSA)
find_package(Threads)
if(Threads_FOUND)
target_link_libraries(${PROJECT_NAME} Threads::Threads)
endif()
endif()
endif()

Expand Down
24 changes: 19 additions & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ libeasyrpg_player_a_SOURCES = \
src/audio_decoder.h \
src/audio_decoder_base.cpp \
src/audio_decoder_base.h \
src/audio_decoder_midi.cpp
src/audio_decoder_midi.h
src/audio_decoder_midi.cpp \
src/audio_decoder_midi.h \
src/audio_generic.cpp \
src/audio_generic.h \
src/audio_generic_midiout.cpp \
Expand Down Expand Up @@ -436,10 +436,18 @@ libeasyrpg_player_a_SOURCES += \
src/dr_wav.h
endif

if HAVE_ALSA
libeasyrpg_player_a_SOURCES += \
src/platform/linux/midiout_device_alsa.cpp \
src/platform/linux/midiout_device_alsa.h
endif

if MACOS
libeasyrpg_player_a_SOURCES += \
src/platform/macos/utils.h \
src/platform/macos/utils.mm
src/platform/macos/utils.mm \
src/platform/macos/midiout_device_coreaudio.cpp \
src/platform/macos/midiout_device_coreaudio.h
endif

# These are only taken in by the legacy homebrew Makefiles
Expand Down Expand Up @@ -476,6 +484,8 @@ EXTRA_DIST += \
src/platform/wii/wii_input_buttons.cpp \
src/platform/opendingux/opendingux_input_buttons.cpp \
src/platform/psp/psp_input_buttons.cpp \
src/platform/windows/midiout_device_win32.cpp \
src/platform/windows/midiout_device_win32.h \
src/platform/windows/utils.cpp \
src/platform/windows/utils.h

Expand All @@ -498,7 +508,9 @@ libeasyrpg_player_a_CXXFLAGS = \
$(LIBXMP_CFLAGS) \
$(LIBSPEEXDSP_CFLAGS) \
$(FLUIDSYNTH_CFLAGS) \
$(FLUIDLITE_CFLAGS)
$(FLUIDLITE_CFLAGS) \
$(ALSA_CFLAGS) \
$(PTHREAD_CFLAGS)

libeasyrpg_player_a_OBJCXXFLAGS = $(libeasyrpg_player_a_CXXFLAGS)

Expand All @@ -521,7 +533,9 @@ easyrpg_player_LDADD = libeasyrpg-player.a \
$(LIBXMP_LIBS) \
$(LIBSPEEXDSP_LIBS) \
$(FLUIDSYNTH_LIBS) \
$(FLUIDLITE_LIBS)
$(FLUIDLITE_LIBS) \
$(ALSA_LIBS) \
$(PTHREAD_LIBS)

if MACOS
easyrpg_player_LDFLAGS = -framework Foundation
Expand Down
Loading

0 comments on commit acdf5fa

Please sign in to comment.