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.

255 lines
9.1KB

  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/midi/ump/juce_UMP.h>
  42. #include "midi_io/ump/juce_UMPBytestreamInputHandler.h"
  43. #include "midi_io/ump/juce_UMPU32InputHandler.h"
  44. #endif
  45. #if JUCE_MAC
  46. #define Point CarbonDummyPointName
  47. #define Component CarbonDummyCompName
  48. #import <CoreAudio/AudioHardware.h>
  49. #import <CoreMIDI/MIDIServices.h>
  50. #import <AudioToolbox/AudioServices.h>
  51. #undef Point
  52. #undef Component
  53. #include "native/juce_mac_CoreAudio.cpp"
  54. #include "native/juce_mac_CoreMidi.mm"
  55. #elif JUCE_IOS
  56. #import <AudioToolbox/AudioToolbox.h>
  57. #import <AVFoundation/AVFoundation.h>
  58. #import <CoreMIDI/MIDIServices.h>
  59. #if TARGET_OS_SIMULATOR
  60. #import <CoreMIDI/MIDINetworkSession.h>
  61. #endif
  62. #include "native/juce_ios_Audio.cpp"
  63. #include "native/juce_mac_CoreMidi.mm"
  64. //==============================================================================
  65. #elif JUCE_WINDOWS
  66. #if JUCE_WASAPI
  67. #include <mmreg.h>
  68. #include "native/juce_win32_WASAPI.cpp"
  69. #endif
  70. #if JUCE_DIRECTSOUND
  71. #include "native/juce_win32_DirectSound.cpp"
  72. #endif
  73. #if JUCE_USE_WINRT_MIDI && (JUCE_MSVC || JUCE_CLANG)
  74. /* If you cannot find any of the header files below then you are probably
  75. attempting to use the Windows 10 Bluetooth Low Energy API. For this to work you
  76. need to install version 10.0.14393.0 of the Windows Standalone SDK and you may
  77. need to add the path to the WinRT headers to your build system. This path should
  78. have the form "C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\winrt".
  79. Also please note that Microsoft's Bluetooth MIDI stack has multiple issues, so
  80. this API is EXPERIMENTAL - use at your own risk!
  81. */
  82. #include <windows.devices.h>
  83. #include <windows.devices.midi.h>
  84. #include <windows.devices.enumeration.h>
  85. JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4265)
  86. #include <wrl/event.h>
  87. JUCE_END_IGNORE_WARNINGS_MSVC
  88. JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4467)
  89. #include <robuffer.h>
  90. JUCE_END_IGNORE_WARNINGS_MSVC
  91. #endif
  92. #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
  93. #include "native/juce_win32_Midi.cpp"
  94. #if JUCE_ASIO
  95. /* This is very frustrating - we only need to use a handful of definitions from
  96. a couple of the header files in Steinberg's ASIO SDK, and it'd be easy to copy
  97. about 30 lines of code into this cpp file to create a fully stand-alone ASIO
  98. implementation...
  99. ..unfortunately that would break Steinberg's license agreement for use of
  100. their SDK, so I'm not allowed to do this.
  101. This means that anyone who wants to use JUCE's ASIO abilities will have to:
  102. 1) Agree to Steinberg's licensing terms and download the ASIO SDK
  103. (see http://www.steinberg.net/en/company/developers.html).
  104. 2) Enable this code with a global definition #define JUCE_ASIO 1.
  105. 3) Make sure that your header search path contains the iasiodrv.h file that
  106. comes with the SDK. (Only about a handful of the SDK header files are actually
  107. needed - so to simplify things, you could just copy these into your JUCE directory).
  108. */
  109. #include <iasiodrv.h>
  110. #include "native/juce_win32_ASIO.cpp"
  111. #endif
  112. //==============================================================================
  113. #elif JUCE_LINUX || JUCE_BSD
  114. #if JUCE_ALSA
  115. /* Got an include error here? If so, you've either not got ALSA installed, or you've
  116. not got your paths set up correctly to find its header files.
  117. The package you need to install to get ASLA support is "libasound2-dev".
  118. If you don't have the ALSA library and don't want to build JUCE with audio support,
  119. just set the JUCE_ALSA flag to 0.
  120. */
  121. #include <alsa/asoundlib.h>
  122. #include "native/juce_linux_ALSA.cpp"
  123. #endif
  124. #if JUCE_JACK
  125. /* Got an include error here? If so, you've either not got jack-audio-connection-kit
  126. installed, or you've not got your paths set up correctly to find its header files.
  127. The package you need to install to get JACK support is "libjack-dev".
  128. If you don't have the jack-audio-connection-kit library and don't want to build
  129. JUCE with low latency audio support, just set the JUCE_JACK flag to 0.
  130. */
  131. #include <jack/jack.h>
  132. #include "native/juce_linux_JackAudio.cpp"
  133. #endif
  134. #if (JUCE_LINUX && JUCE_BELA)
  135. /* Got an include error here? If so, you've either not got the bela headers
  136. installed, or you've not got your paths set up correctly to find its header
  137. files.
  138. */
  139. #include <Bela.h>
  140. #include <Midi.h>
  141. #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
  142. #include "native/juce_linux_Bela.cpp"
  143. #endif
  144. #undef SIZEOF
  145. #if ! JUCE_BELA
  146. #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
  147. #include "native/juce_linux_Midi.cpp"
  148. #endif
  149. //==============================================================================
  150. #elif JUCE_ANDROID
  151. namespace juce
  152. {
  153. using RealtimeThreadFactory = pthread_t (*) (void* (*) (void*), void*);
  154. RealtimeThreadFactory getAndroidRealtimeThreadFactory();
  155. } // namespace juce
  156. #include "native/juce_android_Audio.cpp"
  157. #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
  158. #include "native/juce_android_Midi.cpp"
  159. #if JUCE_USE_ANDROID_OPENSLES || JUCE_USE_ANDROID_OBOE
  160. #include "native/juce_android_HighPerformanceAudioHelpers.h"
  161. #if JUCE_USE_ANDROID_OPENSLES
  162. #include <SLES/OpenSLES.h>
  163. #include <SLES/OpenSLES_Android.h>
  164. #include <SLES/OpenSLES_AndroidConfiguration.h>
  165. #include "native/juce_android_OpenSL.cpp"
  166. #endif
  167. #if JUCE_USE_ANDROID_OBOE
  168. #if JUCE_USE_ANDROID_OPENSLES
  169. #error "Oboe cannot be enabled at the same time as openSL! Please disable JUCE_USE_ANDROID_OPENSLES"
  170. #endif
  171. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter",
  172. "-Wzero-as-null-pointer-constant",
  173. "-Winconsistent-missing-destructor-override",
  174. "-Wshadow-field-in-constructor",
  175. "-Wshadow-field")
  176. #include <oboe/Oboe.h>
  177. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  178. #include "native/juce_android_Oboe.cpp"
  179. #endif
  180. #else
  181. // No audio library, so no way to create realtime threads.
  182. namespace juce
  183. {
  184. RealtimeThreadFactory getAndroidRealtimeThreadFactory() { return nullptr; }
  185. }
  186. #endif
  187. #endif
  188. #if ! JUCE_SYSTEMAUDIOVOL_IMPLEMENTED
  189. namespace juce
  190. {
  191. // None of these methods are available. (On Windows you might need to enable WASAPI for this)
  192. float JUCE_CALLTYPE SystemAudioVolume::getGain() { jassertfalse; return 0.0f; }
  193. bool JUCE_CALLTYPE SystemAudioVolume::setGain (float) { jassertfalse; return false; }
  194. bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { jassertfalse; return false; }
  195. bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; }
  196. }
  197. #endif
  198. #include "audio_io/juce_AudioDeviceManager.cpp"
  199. #include "audio_io/juce_AudioIODevice.cpp"
  200. #include "audio_io/juce_AudioIODeviceType.cpp"
  201. #include "midi_io/juce_MidiMessageCollector.cpp"
  202. #include "sources/juce_AudioSourcePlayer.cpp"
  203. #include "sources/juce_AudioTransportSource.cpp"