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.9KB

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