The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
9.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. #ifdef JUCE_AUDIO_DEVICES_H_INCLUDED
  18. /* When you add this cpp file to your project, you mustn't include it in a file where you've
  19. already included any other headers - just put it inside a file on its own, possibly with your config
  20. flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
  21. header files that the compiler may be using.
  22. */
  23. #error "Incorrect use of JUCE cpp file"
  24. #endif
  25. #define JUCE_CORE_INCLUDE_OBJC_HELPERS 1
  26. #define JUCE_CORE_INCLUDE_COM_SMART_PTR 1
  27. #define JUCE_CORE_INCLUDE_JNI_HELPERS 1
  28. #define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1
  29. #define JUCE_EVENTS_INCLUDE_WIN32_MESSAGE_WINDOW 1
  30. #ifndef JUCE_USE_WINRT_MIDI
  31. #define JUCE_USE_WINRT_MIDI 0
  32. #endif
  33. #if JUCE_USE_WINRT_MIDI
  34. #define JUCE_EVENTS_INCLUDE_WINRT_WRAPPER 1
  35. #endif
  36. #include "juce_audio_devices.h"
  37. #include "audio_io/juce_SampleRateHelpers.cpp"
  38. #include "midi_io/juce_MidiDevices.cpp"
  39. //==============================================================================
  40. #if JUCE_MAC || JUCE_IOS
  41. #include <juce_audio_basics/native/juce_CoreAudioTimeConversions_mac.h>
  42. #include <juce_audio_basics/native/juce_AudioWorkgroup_mac.h>
  43. #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
  44. #include <juce_audio_basics/midi/ump/juce_UMP.h>
  45. #include "midi_io/ump/juce_UMPBytestreamInputHandler.h"
  46. #include "midi_io/ump/juce_UMPU32InputHandler.h"
  47. #endif
  48. #if JUCE_MAC
  49. #define Point CarbonDummyPointName
  50. #define Component CarbonDummyCompName
  51. #import <CoreAudio/AudioHardware.h>
  52. #import <CoreMIDI/MIDIServices.h>
  53. #import <AudioToolbox/AudioServices.h>
  54. #undef Point
  55. #undef Component
  56. #include "native/juce_CoreAudio_mac.cpp"
  57. #include "native/juce_CoreMidi_mac.mm"
  58. #elif JUCE_IOS
  59. #import <AudioToolbox/AudioToolbox.h>
  60. #import <AVFoundation/AVFoundation.h>
  61. #import <CoreMIDI/MIDIServices.h>
  62. #if TARGET_OS_SIMULATOR
  63. #import <CoreMIDI/MIDINetworkSession.h>
  64. #endif
  65. #if JUCE_MODULE_AVAILABLE_juce_graphics
  66. #include <juce_graphics/native/juce_CoreGraphicsHelpers_mac.h>
  67. #endif
  68. #include "native/juce_Audio_ios.cpp"
  69. #include "native/juce_CoreMidi_mac.mm"
  70. //==============================================================================
  71. #elif JUCE_WINDOWS
  72. #if JUCE_WASAPI
  73. #include <mmreg.h>
  74. #include "native/juce_WASAPI_windows.cpp"
  75. #endif
  76. #if JUCE_DIRECTSOUND
  77. #include "native/juce_DirectSound_windows.cpp"
  78. #endif
  79. #if JUCE_USE_WINRT_MIDI && (JUCE_MSVC || JUCE_CLANG)
  80. /* If you cannot find any of the header files below then you are probably
  81. attempting to use the Windows 10 Bluetooth Low Energy API. For this to work you
  82. need to install version 10.0.14393.0 of the Windows Standalone SDK and you may
  83. need to add the path to the WinRT headers to your build system. This path should
  84. have the form "C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\winrt".
  85. Also please note that Microsoft's Bluetooth MIDI stack has multiple issues, so
  86. this API is EXPERIMENTAL - use at your own risk!
  87. */
  88. #include <windows.devices.h>
  89. #include <windows.devices.midi.h>
  90. #include <windows.devices.enumeration.h>
  91. JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4265)
  92. #include <wrl/event.h>
  93. JUCE_END_IGNORE_WARNINGS_MSVC
  94. JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4467)
  95. #include <robuffer.h>
  96. JUCE_END_IGNORE_WARNINGS_MSVC
  97. #endif
  98. #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
  99. #include "native/juce_Midi_windows.cpp"
  100. #if JUCE_ASIO
  101. /* This is very frustrating - we only need to use a handful of definitions from
  102. a couple of the header files in Steinberg's ASIO SDK, and it'd be easy to copy
  103. about 30 lines of code into this cpp file to create a fully stand-alone ASIO
  104. implementation...
  105. ..unfortunately that would break Steinberg's license agreement for use of
  106. their SDK, so I'm not allowed to do this.
  107. This means that anyone who wants to use JUCE's ASIO abilities will have to:
  108. 1) Agree to Steinberg's licensing terms and download the ASIO SDK
  109. (see http://www.steinberg.net/en/company/developers.html).
  110. 2) Enable this code with a global definition #define JUCE_ASIO 1.
  111. 3) Make sure that your header search path contains the iasiodrv.h file that
  112. comes with the SDK. (Only about a handful of the SDK header files are actually
  113. needed - so to simplify things, you could just copy these into your JUCE directory).
  114. */
  115. #include <iasiodrv.h>
  116. #include "native/juce_ASIO_windows.cpp"
  117. #endif
  118. //==============================================================================
  119. #elif JUCE_LINUX || JUCE_BSD
  120. #if JUCE_ALSA
  121. /* Got an include error here? If so, you've either not got ALSA installed, or you've
  122. not got your paths set up correctly to find its header files.
  123. The package you need to install to get ASLA support is "libasound2-dev".
  124. If you don't have the ALSA library and don't want to build JUCE with audio support,
  125. just set the JUCE_ALSA flag to 0.
  126. */
  127. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wzero-length-array")
  128. #include <alsa/asoundlib.h>
  129. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  130. #include "native/juce_ALSA_linux.cpp"
  131. #endif
  132. #if JUCE_JACK
  133. /* Got an include error here? If so, you've either not got jack-audio-connection-kit
  134. installed, or you've not got your paths set up correctly to find its header files.
  135. The package you need to install to get JACK support is "libjack-dev".
  136. If you don't have the jack-audio-connection-kit library and don't want to build
  137. JUCE with low latency audio support, just set the JUCE_JACK flag to 0.
  138. */
  139. #include <jack/jack.h>
  140. #include "native/juce_JackAudio_linux.cpp"
  141. #endif
  142. #if (JUCE_LINUX && JUCE_BELA)
  143. /* Got an include error here? If so, you've either not got the bela headers
  144. installed, or you've not got your paths set up correctly to find its header
  145. files.
  146. */
  147. #include <Bela.h>
  148. #include <Midi.h>
  149. #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
  150. #include "native/juce_Bela_linux.cpp"
  151. #endif
  152. #undef SIZEOF
  153. #if ! JUCE_BELA
  154. #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
  155. #include "native/juce_Midi_linux.cpp"
  156. #endif
  157. //==============================================================================
  158. #elif JUCE_ANDROID
  159. namespace juce
  160. {
  161. using RealtimeThreadFactory = pthread_t (*) (void* (*) (void*), void*);
  162. RealtimeThreadFactory getAndroidRealtimeThreadFactory();
  163. } // namespace juce
  164. #include "native/juce_Audio_android.cpp"
  165. #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
  166. #include "native/juce_Midi_android.cpp"
  167. #if JUCE_USE_ANDROID_OPENSLES || JUCE_USE_ANDROID_OBOE
  168. #include "native/juce_HighPerformanceAudioHelpers_android.h"
  169. #if JUCE_USE_ANDROID_OPENSLES
  170. #include <SLES/OpenSLES.h>
  171. #include <SLES/OpenSLES_Android.h>
  172. #include <SLES/OpenSLES_AndroidConfiguration.h>
  173. #include "native/juce_OpenSL_android.cpp"
  174. #endif
  175. #if JUCE_USE_ANDROID_OBOE
  176. #if JUCE_USE_ANDROID_OPENSLES
  177. #error "Oboe cannot be enabled at the same time as openSL! Please disable JUCE_USE_ANDROID_OPENSLES"
  178. #endif
  179. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter",
  180. "-Wzero-as-null-pointer-constant",
  181. "-Winconsistent-missing-destructor-override",
  182. "-Wshadow-field-in-constructor",
  183. "-Wshadow-field",
  184. "-Wsign-conversion",
  185. "-Wswitch-enum")
  186. #include <oboe/Oboe.h>
  187. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  188. #include "native/juce_Oboe_android.cpp"
  189. #endif
  190. #else
  191. // No audio library, so no way to create realtime threads.
  192. namespace juce
  193. {
  194. RealtimeThreadFactory getAndroidRealtimeThreadFactory() { return nullptr; }
  195. }
  196. #endif
  197. #endif
  198. #if ! JUCE_SYSTEMAUDIOVOL_IMPLEMENTED
  199. namespace juce
  200. {
  201. // None of these methods are available. (On Windows you might need to enable WASAPI for this)
  202. float JUCE_CALLTYPE SystemAudioVolume::getGain() { jassertfalse; return 0.0f; }
  203. bool JUCE_CALLTYPE SystemAudioVolume::setGain (float) { jassertfalse; return false; }
  204. bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { jassertfalse; return false; }
  205. bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; }
  206. }
  207. #endif
  208. #include "audio_io/juce_AudioDeviceManager.cpp"
  209. #include "audio_io/juce_AudioIODevice.cpp"
  210. #include "audio_io/juce_AudioIODeviceType.cpp"
  211. #include "midi_io/juce_MidiMessageCollector.cpp"
  212. #include "sources/juce_AudioSourcePlayer.cpp"
  213. #include "sources/juce_AudioTransportSource.cpp"