Audio plugin host https://kx.studio/carla
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.

juce_audio_devices.cpp 8.7KB

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