├── soxr ├── src │ ├── samplerate.h │ ├── libsoxr.src.in │ ├── libsoxr-dev.src.in │ ├── soxr.pc.in │ ├── soxr-lsr.pc.in │ ├── simd-dev.h │ ├── rate32.c │ ├── rate64.c │ ├── rate32s.c │ ├── simd.h │ ├── half-fir.h │ ├── fft4g32s.c │ ├── fft4g32.c │ ├── rdft.h │ ├── fft4g64.c │ ├── avfft32.c │ ├── avfft32s.c │ ├── data-io.h │ ├── fft4g.h │ ├── poly-fir0.h │ ├── internal.h │ ├── pffft32s.c │ ├── pffft32.c │ ├── filter.h │ ├── aliases.h │ ├── rint.h │ ├── ccrw2.h │ ├── half_coefs.h │ ├── simd.c │ ├── fft4g_cache.h │ ├── fifo.h │ ├── soxr-lsr.h │ └── poly-fir.h ├── AUTHORS ├── TODO ├── tests │ ├── README │ ├── scripts │ ├── large-ratio-test │ ├── time-test │ ├── cmp-test.cmake │ ├── bandwidth-test │ ├── phase-test │ ├── eg-test │ ├── io-test │ ├── q-test │ ├── CMakeLists.txt │ ├── vector-cmp.c │ ├── vector-gen.c │ └── 1-delay-clear.c ├── cmake │ └── Modules │ │ ├── TestBigEndian.cmake │ │ ├── FindLibAVCodec.cmake │ │ └── FindSIMD.cmake ├── examples │ ├── README │ ├── examples-common.h │ ├── CMakeLists.txt │ ├── 1a-lsr.c │ ├── 1-single-block.c │ ├── 2-stream.C │ └── 5-variable-rate.c ├── deinstall.cmake.in ├── LICENCE ├── soxr-config.h.in ├── NEWS ├── README └── INSTALL ├── xxhash ├── CMakeLists.txt └── LICENSE ├── .gitignore ├── lib ├── inputdev │ ├── CafeProPad.cpp │ ├── RevolutionPad.cpp │ ├── HIDDeviceBSD.cpp │ ├── HIDListenerUWP.cpp │ ├── HIDListenerBSD.cpp │ ├── HIDDeviceUWP.cpp │ ├── IHIDDevice.hpp │ ├── GenericPad.cpp │ ├── NintendoPowerA.cpp │ ├── DeviceBase.cpp │ ├── DeviceSignature.cpp │ ├── IOKitPointer.hpp │ └── DeviceFinder.cpp ├── audiodev │ ├── MIDICommon.cpp │ ├── MIDICommon.hpp │ ├── Common.hpp │ ├── LtRtProcessing.hpp │ └── AudioSubmix.hpp ├── x11 │ ├── XlibCommon.hpp │ ├── ApplicationWayland.hpp │ └── WindowWayland.cpp ├── graphicsdev │ ├── Common.cpp │ └── GLX.cpp ├── mac │ └── CocoaCommon.hpp ├── win │ ├── UWPCommon.hpp │ └── WinCommon.hpp ├── Common.hpp └── CFPointer.hpp ├── include └── boo │ ├── inputdev │ ├── CafeProPad.hpp │ ├── RevolutionPad.hpp │ ├── GenericPad.hpp │ ├── IHIDListener.hpp │ ├── NintendoPowerA.hpp │ ├── XInputPad.hpp │ ├── DeviceSignature.hpp │ ├── DeviceToken.hpp │ ├── DolphinSmashAdapter.hpp │ ├── DeviceBase.hpp │ └── DeviceFinder.hpp │ ├── boo.hpp │ ├── audiodev │ ├── MIDIDecoder.hpp │ ├── IMIDIReader.hpp │ ├── IAudioSubmix.hpp │ ├── IMIDIPort.hpp │ ├── MIDIEncoder.hpp │ └── IAudioVoice.hpp │ ├── ThreadLocalPtr.hpp │ ├── UWPViewProvider.hpp │ ├── IGraphicsContext.hpp │ ├── BooObject.hpp │ ├── graphicsdev │ ├── IGraphicsCommandQueue.hpp │ ├── nx_compiler.hpp │ ├── Metal.hpp │ ├── GL.hpp │ ├── D3D.hpp │ └── NX.hpp │ └── IApplication.hpp ├── .gitmodules ├── test └── CMakeLists.txt ├── InputDeviceClasses.cpp ├── LICENSE ├── README.md ├── FindIPP.cmake └── GLEW-LICENSE /soxr/src/samplerate.h: -------------------------------------------------------------------------------- 1 | #include "soxr-lsr.h" 2 | -------------------------------------------------------------------------------- /soxr/AUTHORS: -------------------------------------------------------------------------------- 1 | Rob Sykes 2 | -------------------------------------------------------------------------------- /soxr/src/libsoxr.src.in: -------------------------------------------------------------------------------- 1 | set(TARGET_LIBS "@TARGET_LIBS@") 2 | -------------------------------------------------------------------------------- /xxhash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(xxhash xxhash.c xxhash.h) 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | cmake-build-*/ 4 | build/ 5 | out/ -------------------------------------------------------------------------------- /lib/inputdev/CafeProPad.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/inputdev/CafeProPad.hpp" 2 | -------------------------------------------------------------------------------- /include/boo/inputdev/CafeProPad.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace boo {} 4 | -------------------------------------------------------------------------------- /lib/inputdev/RevolutionPad.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/inputdev/RevolutionPad.hpp" 2 | -------------------------------------------------------------------------------- /include/boo/inputdev/RevolutionPad.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace boo {} 4 | -------------------------------------------------------------------------------- /soxr/TODO: -------------------------------------------------------------------------------- 1 | * SOXR_ALLOW_ALIASING 2 | * Explicit flush API fn, perhaps. 3 | * More SIMD. 4 | -------------------------------------------------------------------------------- /soxr/tests/README: -------------------------------------------------------------------------------- 1 | A few tests on the pass-band performance; not a comprehensive test suite. 2 | -------------------------------------------------------------------------------- /soxr/src/libsoxr-dev.src.in: -------------------------------------------------------------------------------- 1 | set(TARGET_HEADERS "@TARGET_HEADERS@") 2 | set(TARGET_PCS "@TARGET_PCS@") 3 | -------------------------------------------------------------------------------- /soxr/src/soxr.pc.in: -------------------------------------------------------------------------------- 1 | Name: ${PROJECT_NAME} 2 | Description: ${DESCRIPTION_SUMMARY} 3 | Version: ${PROJECT_VERSION} 4 | Libs: -L${LIB_INSTALL_DIR} -l${PROJECT_NAME} 5 | Cflags: -I${INCLUDE_INSTALL_DIR} 6 | -------------------------------------------------------------------------------- /soxr/src/soxr-lsr.pc.in: -------------------------------------------------------------------------------- 1 | Name: ${LSR} 2 | Description: ${DESCRIPTION_SUMMARY} (with libsamplerate-like bindings) 3 | Version: ${PROJECT_VERSION} 4 | Libs: -L${LIB_INSTALL_DIR} -l${LSR} 5 | Cflags: -I${INCLUDE_INSTALL_DIR} 6 | -------------------------------------------------------------------------------- /soxr/src/simd-dev.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #define PFFT_MACROS_ONLY 5 | #include "pffft.c" 6 | -------------------------------------------------------------------------------- /lib/audiodev/MIDICommon.cpp: -------------------------------------------------------------------------------- 1 | #include "lib/audiodev/MIDICommon.hpp" 2 | 3 | #include "boo/audiodev/IMIDIPort.hpp" 4 | 5 | namespace boo { 6 | 7 | IMIDIPort::~IMIDIPort() {} 8 | IMIDIIn::~IMIDIIn() {} 9 | IMIDIOut::~IMIDIOut() {} 10 | IMIDIInOut::~IMIDIInOut() {} 11 | 12 | } // namespace boo 13 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "glslang"] 2 | path = glslang 3 | url = https://github.com/KhronosGroup/glslang.git 4 | branch = master 5 | [submodule "logvisor"] 6 | path = logvisor 7 | url = ../logvisor.git 8 | branch = master 9 | [submodule "optick"] 10 | path = optick 11 | url = https://github.com/AxioDL/optick.git 12 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(booTest WIN32 main.cpp) 2 | target_link_libraries(booTest boo) 3 | 4 | if (COMMAND add_nro_target) 5 | set_target_properties(booTest PROPERTIES SUFFIX ".elf") 6 | add_nro_target(booTest booTest "Antidote/Jackoalan" "1.0.0") 7 | endif() 8 | 9 | if(COMMAND add_sanitizers) 10 | add_sanitizers(booTest) 11 | endif() -------------------------------------------------------------------------------- /soxr/src/rate32.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #define sample_t float 5 | #define RATE_SIMD 0 6 | #define RDFT_CB _soxr_rdft32_cb 7 | #define RATE_CB _soxr_rate32_cb 8 | #define RATE_ID "single-precision" 9 | #include "rate.h" 10 | -------------------------------------------------------------------------------- /soxr/src/rate64.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #define sample_t double 5 | #define RATE_SIMD 0 6 | #define RDFT_CB _soxr_rdft64_cb 7 | #define RATE_CB _soxr_rate64_cb 8 | #define RATE_ID "double-precision" 9 | #include "rate.h" 10 | -------------------------------------------------------------------------------- /soxr/src/rate32s.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #define sample_t float 5 | #define RATE_SIMD 1 6 | #define RDFT_CB _soxr_rdft32s_cb 7 | #define RATE_CB _soxr_rate32s_cb 8 | #define RATE_ID "single-precision-SIMD" 9 | #include "rate.h" 10 | -------------------------------------------------------------------------------- /soxr/tests/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net 5 | # Licence for this file: LGPL v2.1 See LICENCE for details. 6 | 7 | ../../tests/bandwidth-test 8 | ../../tests/eg-test 9 | ../../tests/io-test 10 | ../../tests/large-ratio-test 11 | ../../tests/phase-test 12 | ../../tests/q-test 13 | ../../tests/time-test 14 | -------------------------------------------------------------------------------- /lib/x11/XlibCommon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace boo { 6 | 7 | struct XlibCursors { 8 | Cursor m_pointer; 9 | Cursor m_weArrow; 10 | Cursor m_nsArrow; 11 | Cursor m_ibeam; 12 | Cursor m_crosshairs; 13 | Cursor m_wait; 14 | Cursor m_nwseResize; 15 | Cursor m_neswResize; 16 | Cursor m_hand; 17 | Cursor m_notAllowed; 18 | }; 19 | extern XlibCursors X_CURSORS; 20 | 21 | } // namespace boo 22 | -------------------------------------------------------------------------------- /include/boo/boo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "DeferredWindowEvents.hpp" 4 | #include "IApplication.hpp" 5 | #include "IWindow.hpp" 6 | #include "inputdev/DeviceFinder.hpp" 7 | #include "inputdev/DolphinSmashAdapter.hpp" 8 | #include "inputdev/DualshockPad.hpp" 9 | #include "inputdev/GenericPad.hpp" 10 | #include "inputdev/NintendoPowerA.hpp" 11 | #include "graphicsdev/IGraphicsCommandQueue.hpp" 12 | #include "graphicsdev/IGraphicsDataFactory.hpp" 13 | -------------------------------------------------------------------------------- /lib/graphicsdev/Common.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace boo { 8 | 9 | void UpdateGammaLUT(ITextureD* tex, float gamma) { 10 | void* data = tex->map(65536 * 2); 11 | for (int i = 0; i < 65536; ++i) { 12 | float level = std::pow(i / 65535.f, gamma); 13 | reinterpret_cast(data)[i] = level * 65535.f; 14 | } 15 | tex->unmap(); 16 | } 17 | 18 | } // namespace boo 19 | -------------------------------------------------------------------------------- /include/boo/audiodev/MIDIDecoder.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace boo { 7 | class IMIDIReader; 8 | 9 | class MIDIDecoder { 10 | IMIDIReader& m_out; 11 | uint8_t m_status = 0; 12 | 13 | public: 14 | MIDIDecoder(IMIDIReader& out) : m_out(out) {} 15 | std::vector::const_iterator receiveBytes(std::vector::const_iterator begin, 16 | std::vector::const_iterator end); 17 | }; 18 | 19 | } // namespace boo 20 | -------------------------------------------------------------------------------- /lib/audiodev/MIDICommon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace boo { 4 | 5 | enum class Status { 6 | NoteOff = 0x80, 7 | NoteOn = 0x90, 8 | NotePressure = 0xA0, 9 | ControlChange = 0xB0, 10 | ProgramChange = 0xC0, 11 | ChannelPressure = 0xD0, 12 | PitchBend = 0xE0, 13 | SysEx = 0xF0, 14 | TimecodeQuarterFrame = 0xF1, 15 | SongPositionPointer = 0xF2, 16 | SongSelect = 0xF3, 17 | TuneRequest = 0xF6, 18 | SysExTerm = 0xF7, 19 | TimingClock = 0xF8, 20 | Start = 0xFA, 21 | Continue = 0xFB, 22 | Stop = 0xFC, 23 | ActiveSensing = 0xFE, 24 | Reset = 0xFF, 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /soxr/src/simd.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #if !defined simd_included 5 | #define simd_included 6 | 7 | #include 8 | 9 | void * _soxr_simd_aligned_malloc(size_t); 10 | void * _soxr_simd_aligned_calloc(size_t, size_t); 11 | void _soxr_simd_aligned_free(void *); 12 | 13 | void _soxr_ordered_convolve_simd(int n, void * not_used, float * a, const float * b); 14 | void _soxr_ordered_partial_convolve_simd(int n, float * a, const float * b); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/audiodev/Common.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "boo/audiodev/IAudioVoice.hpp" 5 | #include "lib/Common.hpp" 6 | 7 | namespace boo { 8 | 9 | /** Pertinent information from audio backend about optimal mixed-audio representation */ 10 | struct AudioVoiceEngineMixInfo { 11 | double m_sampleRate = 32000.0; 12 | soxr_datatype_t m_sampleFormat = SOXR_FLOAT32_I; 13 | unsigned m_bitsPerSample = 32; 14 | AudioChannelSet m_channels = AudioChannelSet::Stereo; 15 | ChannelMap m_channelMap = {2, {AudioChannel::FrontLeft, AudioChannel::FrontRight}}; 16 | size_t m_periodFrames = 160; 17 | }; 18 | 19 | } // namespace boo 20 | -------------------------------------------------------------------------------- /lib/inputdev/HIDDeviceBSD.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/inputdev/IHIDListener.hpp" 2 | #include "boo/inputdev/DeviceFinder.hpp" 3 | 4 | namespace boo { 5 | 6 | class HIDListenerBSD final : public IHIDListener { 7 | DeviceFinder& m_finder; 8 | 9 | public: 10 | HIDListenerBSD(DeviceFinder& finder) : m_finder(finder) {} 11 | ~HIDListenerBSD() override = default; 12 | 13 | bool startScanning() override { return false; } 14 | bool stopScanning() override { return false; } 15 | 16 | bool scanNow() override { return false; } 17 | }; 18 | 19 | IHIDListener* IHIDListenerNew(DeviceFinder& finder) { return new HIDListenerBSD(finder); } 20 | } // namespace boo 21 | -------------------------------------------------------------------------------- /lib/inputdev/HIDListenerUWP.cpp: -------------------------------------------------------------------------------- 1 | #define _CRT_SECURE_NO_WARNINGS 1 /* STFU MSVC */ 2 | 3 | #include "boo/inputdev/IHIDListener.hpp" 4 | #include "boo/inputdev/DeviceFinder.hpp" 5 | 6 | namespace boo { 7 | 8 | class HIDListenerUWP : public IHIDListener { 9 | public: 10 | HIDListenerUWP(DeviceFinder& finder) {} 11 | 12 | /* Automatic device scanning */ 13 | bool startScanning() override { return false; } 14 | bool stopScanning() override { return false; } 15 | 16 | /* Manual device scanning */ 17 | bool scanNow() override { return false; } 18 | }; 19 | 20 | std::unique_ptr IHIDListenerNew(DeviceFinder& finder) { return std::make_unique(finder); } 21 | 22 | } // namespace boo 23 | -------------------------------------------------------------------------------- /soxr/tests/large-ratio-test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net 5 | # Licence for this file: LGPL v2.1 See LICENCE for details. 6 | 7 | # Tests interpolating then decimating be the same, large ratio. 8 | 9 | tool=../examples/3-options-input-fn 10 | q=6 11 | ratio=2e4 12 | srate=8000 13 | nrate=`expr $srate / 2` 14 | 15 | rm -f lr.png 16 | 17 | ../tests/vector-gen $srate 0 8 $nrate .9375 1.s32 18 | 19 | $tool 1 $ratio 1 2 1 $q < 1.s32 | $tool $ratio 1 1 1 2 $q > 2.s32 20 | 21 | sox -M -r $srate -c1 1.s32 -r $srate -c1 2.s32 -n spectrogram -hwd -Z-10 -z180 -o lr.png -c "large-ratio-test q:$q ratio:$ratio" 22 | 23 | rm [12].s32 24 | -------------------------------------------------------------------------------- /soxr/cmake/Modules/TestBigEndian.cmake: -------------------------------------------------------------------------------- 1 | # SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | # Licence for this file: LGPL v2.1 See LICENCE for details. 3 | 4 | # - Macro to determine endian type 5 | # test_big_endian (VARIABLE) 6 | # VARIABLE - variable to store the result to 7 | 8 | macro (test_big_endian VARIABLE) 9 | if ("${HAVE_${VARIABLE}}" MATCHES "^${HAVE_${VARIABLE}}$") 10 | include (CheckCSourceRuns) 11 | check_c_source_runs ("int main() {union {long i; char c[sizeof(long)];} 12 | const u = {1}; return !!u.c[0];}" HAVE_${VARIABLE}) 13 | set (${VARIABLE} "${HAVE_${VARIABLE}}" CACHE INTERNAL "1 if system is big endian" FORCE) 14 | endif () 15 | endmacro () 16 | -------------------------------------------------------------------------------- /lib/graphicsdev/GLX.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/graphicsdev/glxew.h" 2 | #include 3 | 4 | namespace boo { 5 | static logvisor::Module Log("boo::GLX"); 6 | 7 | void GLXExtensionCheck() { 8 | if (!GLXEW_SGI_video_sync) 9 | Log.report(logvisor::Fatal, FMT_STRING("GLX_SGI_video_sync not available")); 10 | if (!GLXEW_EXT_swap_control && !GLXEW_MESA_swap_control && !GLXEW_SGI_swap_control) 11 | Log.report(logvisor::Fatal, FMT_STRING("swap_control not available")); 12 | } 13 | 14 | void GLXEnableVSync(Display* disp, GLXWindow drawable) { 15 | if (GLXEW_EXT_swap_control) 16 | glXSwapIntervalEXT(disp, drawable, 1); 17 | else if (GLXEW_MESA_swap_control) 18 | glXSwapIntervalMESA(1); 19 | else if (GLXEW_SGI_swap_control) 20 | glXSwapIntervalSGI(1); 21 | } 22 | 23 | } // namespace boo 24 | -------------------------------------------------------------------------------- /InputDeviceClasses.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/inputdev/DeviceSignature.hpp" 2 | #include "boo/inputdev/DolphinSmashAdapter.hpp" 3 | #include "boo/inputdev/DualshockPad.hpp" 4 | #include "boo/inputdev/GenericPad.hpp" 5 | #include "boo/inputdev/XInputPad.hpp" 6 | #include "boo/inputdev/NintendoPowerA.hpp" 7 | 8 | namespace boo { 9 | 10 | const DeviceSignature BOO_DEVICE_SIGS[] = {DEVICE_SIG(DolphinSmashAdapter, 0x57e, 0x337, DeviceType::USB), 11 | DEVICE_SIG(DualshockPad, 0x54c, 0x268, DeviceType::HID), 12 | DEVICE_SIG(GenericPad, 0, 0, DeviceType::HID), 13 | DEVICE_SIG(NintendoPowerA, 0x20D6, 0xA711, DeviceType::USB), 14 | DEVICE_SIG(XInputPad, 0, 0, DeviceType::XInput), 15 | DEVICE_SIG_SENTINEL()}; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /soxr/src/half-fir.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Down-sample by a factor of 2 using a FIR with odd length (LEN).*/ 5 | /* Input must be preceded and followed by LEN >> 1 samples. */ 6 | 7 | #define _ sum += (input[-(2*j +1)] + input[(2*j +1)]) * COEFS[j], ++j; 8 | static void FUNCTION(stage_t * p, fifo_t * output_fifo) 9 | { 10 | sample_t const * input = stage_read_p(p); 11 | int i, num_out = (stage_occupancy(p) + 1) / 2; 12 | sample_t * output = fifo_reserve(output_fifo, num_out); 13 | 14 | for (i = 0; i < num_out; ++i, input += 2) { 15 | int j = 0; 16 | sample_t sum = input[0] * .5f; 17 | CONVOLVE 18 | output[i] = sum; 19 | } 20 | fifo_read(&p->fifo, 2 * num_out, NULL); 21 | } 22 | #undef _ 23 | #undef COEFS 24 | #undef CONVOLVE 25 | #undef FUNCTION 26 | -------------------------------------------------------------------------------- /include/boo/inputdev/GenericPad.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "boo/inputdev/DeviceBase.hpp" 6 | #include "boo/inputdev/HIDParser.hpp" 7 | 8 | namespace boo { 9 | 10 | struct IGenericPadCallback { 11 | virtual void controllerConnected() {} 12 | virtual void controllerDisconnected() {} 13 | virtual void valueUpdate(const HIDMainItem& item, int32_t value) {} 14 | }; 15 | 16 | class GenericPad final : public TDeviceBase { 17 | HIDParser m_parser; 18 | 19 | public: 20 | GenericPad(DeviceToken* token); 21 | ~GenericPad() override; 22 | 23 | void deviceDisconnected() override; 24 | void initialCycle() override; 25 | void receivedHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) override; 26 | 27 | void enumerateValues(const std::function& valueCB) const; 28 | }; 29 | 30 | } // namespace boo 31 | -------------------------------------------------------------------------------- /soxr/examples/README: -------------------------------------------------------------------------------- 1 | SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | 3 | These simple examples show the different ways that an application may 4 | interface with soxr. Note that real-world applications may also have to 5 | deal with file-formats, codecs, (more sophisticated) dithering, etc., which 6 | are not covered here. 7 | 8 | With the library installed, the examples may be built using commands similar 9 | to the following. On unix-like systems: 10 | 11 | cc 1-single-block.c -lsoxr 12 | cc 1a-lsr.c -lsoxr-lsr 13 | 14 | or, with MSVC on MS-Windows: 15 | 16 | cl 1-single-block.c -I"C:/Program Files/soxr/include" "C:/Program Files/soxr/lib/soxr.lib" 17 | cl 1a-lsr.c -I"C:/Program Files/soxr/include" "C:/Program Files/soxr/lib/soxr-lsr.lib" 18 | 19 | IDEs may hide such commands behind configuration screens and build menus -- 20 | where applicable, consult your IDE's user-manual. 21 | -------------------------------------------------------------------------------- /soxr/src/fft4g32s.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #include "filter.h" 5 | #include "simd.h" 6 | 7 | static void * null(void) {return 0;} 8 | static void nothing(void) {} 9 | static void forward (int length, void * setup, float * H) {lsx_safe_rdft_f(length, 1, H); (void)setup;} 10 | static void backward(int length, void * setup, float * H) {lsx_safe_rdft_f(length, -1, H); (void)setup;} 11 | static int multiplier(void) {return 2;} 12 | 13 | typedef void (* fn_t)(void); 14 | fn_t _soxr_rdft32s_cb[] = { 15 | (fn_t)null, 16 | (fn_t)null, 17 | (fn_t)nothing, 18 | (fn_t)forward, 19 | (fn_t)forward, 20 | (fn_t)backward, 21 | (fn_t)backward, 22 | (fn_t)_soxr_ordered_convolve_simd, 23 | (fn_t)_soxr_ordered_partial_convolve_simd, 24 | (fn_t)multiplier, 25 | (fn_t)nothing, 26 | }; 27 | -------------------------------------------------------------------------------- /soxr/cmake/Modules/FindLibAVCodec.cmake: -------------------------------------------------------------------------------- 1 | # SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | # Licence for this file: LGPL v2.1 See LICENCE for details. 3 | 4 | # - Find AVCODEC 5 | # Find the native installation of this package: includes and libraries. 6 | # 7 | # AVCODEC_INCLUDES - where to find headers for this package. 8 | # AVCODEC_LIBRARIES - List of libraries when using this package. 9 | # AVCODEC_FOUND - True if this package can be found. 10 | 11 | if (AVCODEC_INCLUDES) 12 | set (AVCODEC_FIND_QUIETLY TRUE) 13 | endif (AVCODEC_INCLUDES) 14 | 15 | find_path (AVCODEC_INCLUDES libavcodec/avcodec.h) 16 | 17 | find_library (AVCODEC_LIBRARIES NAMES avcodec) 18 | 19 | include (FindPackageHandleStandardArgs) 20 | find_package_handle_standard_args ( 21 | AVCODEC DEFAULT_MSG AVCODEC_LIBRARIES AVCODEC_INCLUDES) 22 | 23 | mark_as_advanced (AVCODEC_LIBRARIES AVCODEC_INCLUDES) 24 | -------------------------------------------------------------------------------- /soxr/tests/time-test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net 5 | # Licence for this file: LGPL v2.1 See LICENCE for details. 6 | 7 | # Tests rate conversion time for qualities 0..7 & variable-rate. 8 | 9 | tool=./3-options-input-fn 10 | ext=f32; e=0 11 | c=2 12 | q1=0; q2=7 13 | rates="48000 77773 96000" 14 | 15 | for rate0 in $rates; do 16 | rate1=$rate0 17 | rate2=44100 18 | for n in 1 2; do 19 | rate1n=`expr $rate1 / 2` 20 | sox -r $rate1 -n -c $c 0.$ext synth 5: sin 0:$rate1n gain -1 21 | 22 | for q in `seq $q1 $q2`; do 23 | echo $rate1 '-->' $rate2 c=$c q=$q 24 | time $tool $rate1 $rate2 $c $e $e $q < 0.$ext > /dev/null; 25 | done 26 | 27 | echo $rate1 '-->' $rate2 c=$c q=v 28 | time $tool $rate1 $rate2 $c $e $e 4 20 < 0.$ext > /dev/null 29 | 30 | rate1=44100 31 | rate2=$rate0 32 | done 33 | done 34 | 35 | rm 0.$ext 36 | -------------------------------------------------------------------------------- /lib/mac/CocoaCommon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #if __APPLE__ 3 | 4 | #if !__has_feature(objc_arc) 5 | #error ARC Required 6 | #endif 7 | 8 | #if BOO_HAS_METAL 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | namespace boo { 17 | class IWindow; 18 | struct MetalContext { 19 | id m_dev = nullptr; 20 | id m_q = nullptr; 21 | struct Window { 22 | CAMetalLayer* m_metalLayer = nullptr; 23 | std::mutex m_resizeLock; 24 | bool m_needsResize; 25 | CGSize m_size; 26 | }; 27 | std::unordered_map m_windows; 28 | uint32_t m_sampleCount = 1; 29 | uint32_t m_anisotropy = 1; 30 | MTLPixelFormat m_pixelFormat = MTLPixelFormatBGRA8Unorm; 31 | }; 32 | } // namespace boo 33 | 34 | #else 35 | namespace boo { 36 | struct MetalContext {}; 37 | } // namespace boo 38 | #endif 39 | 40 | #endif // __APPLE__ 41 | -------------------------------------------------------------------------------- /soxr/src/fft4g32.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #include "filter.h" 5 | #define FFT4G_FLOAT 6 | #include "fft4g.c" 7 | 8 | static void * null(void) {return 0;} 9 | static void forward (int length, void * setup, double * H) {lsx_safe_rdft_f(length, 1, H); (void)setup;} 10 | static void backward(int length, void * setup, double * H) {lsx_safe_rdft_f(length, -1, H); (void)setup;} 11 | static int multiplier(void) {return 2;} 12 | static void nothing(void) {} 13 | 14 | typedef void (* fn_t)(void); 15 | fn_t _soxr_rdft32_cb[] = { 16 | (fn_t)null, 17 | (fn_t)null, 18 | (fn_t)nothing, 19 | (fn_t)forward, 20 | (fn_t)forward, 21 | (fn_t)backward, 22 | (fn_t)backward, 23 | (fn_t)_soxr_ordered_convolve_f, 24 | (fn_t)_soxr_ordered_partial_convolve_f, 25 | (fn_t)multiplier, 26 | (fn_t)nothing, 27 | }; 28 | -------------------------------------------------------------------------------- /include/boo/ThreadLocalPtr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __SWITCH__ 4 | 5 | #if _WIN32 6 | #else 7 | #include 8 | #endif 9 | 10 | /** Multiplatform TLS-pointer wrapper (for compilers without proper thread_local support) */ 11 | template 12 | class ThreadLocalPtr { 13 | #if _WIN32 14 | DWORD m_key; 15 | 16 | public: 17 | ThreadLocalPtr() { m_key = TlsAlloc(); } 18 | ~ThreadLocalPtr() { TlsFree(m_key); } 19 | T* get() const { return static_cast(TlsGetValue(m_key)); } 20 | void reset(T* v = nullptr) { TlsSetValue(m_key, LPVOID(v)); } 21 | #else 22 | pthread_key_t m_key; 23 | 24 | public: 25 | ThreadLocalPtr() { pthread_key_create(&m_key, nullptr); } 26 | ~ThreadLocalPtr() { pthread_key_delete(m_key); } 27 | T* get() const { return static_cast(pthread_getspecific(m_key)); } 28 | void reset(T* v = nullptr) { pthread_setspecific(m_key, v); } 29 | #endif 30 | T* operator->() { return get(); } 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /soxr/src/rdft.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | void ORDERED_CONVOLVE(int n, void * not_used, DFT_FLOAT * a, const DFT_FLOAT * b) 5 | { 6 | int i; 7 | a[0] *= b[0]; 8 | a[1] *= b[1]; 9 | for (i = 2; i < n; i += 2) { 10 | DFT_FLOAT tmp = a[i]; 11 | a[i ] = b[i ] * tmp - b[i+1] * a[i+1]; 12 | a[i+1] = b[i+1] * tmp + b[i ] * a[i+1]; 13 | } 14 | (void)not_used; 15 | } 16 | 17 | void ORDERED_PARTIAL_CONVOLVE(int n, DFT_FLOAT * a, const DFT_FLOAT * b) 18 | { 19 | int i; 20 | a[0] *= b[0]; 21 | for (i = 2; i < n; i += 2) { 22 | DFT_FLOAT tmp = a[i]; 23 | a[i ] = b[i ] * tmp - b[i+1] * a[i+1]; 24 | a[i+1] = b[i+1] * tmp + b[i ] * a[i+1]; 25 | } 26 | a[1] = b[i] * a[i] - b[i+1] * a[i+1]; 27 | } 28 | 29 | #undef ORDERED_CONVOLVE 30 | #undef ORDERED_PARTIAL_CONVOLVE 31 | #undef DFT_FLOAT 32 | -------------------------------------------------------------------------------- /soxr/tests/cmp-test.cmake: -------------------------------------------------------------------------------- 1 | # SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | # Licence for this file: LGPL v2.1 See LICENCE for details. 3 | 4 | if (${bits} STREQUAL 24) 5 | set (quality 45) 6 | else () 7 | set (quality 44) 8 | endif () 9 | 10 | set (output ${from}-${to}-${quality}.s32) 11 | 12 | execute_process(COMMAND ${EXAMPLES_BIN}3-options-input-fn ${from} ${to} 1 2 2 ${quality} a 13 | INPUT_FILE ref-${from}.s32 14 | OUTPUT_FILE ${output} 15 | ERROR_VARIABLE test_error 16 | RESULT_VARIABLE test_result) 17 | 18 | if (test_result) 19 | message (FATAL_ERROR "Resampling failure: ${test_error}") 20 | endif () 21 | 22 | execute_process(COMMAND ${BIN}vector-cmp ref-${to}.s32 ${output} ${to} ${leader} ${len} ${bits} 98 23 | OUTPUT_VARIABLE test_output 24 | RESULT_VARIABLE test_result) 25 | 26 | if (test_result) 27 | message (FATAL_ERROR ${test_output}) 28 | else () 29 | message (STATUS ${test_output}) 30 | endif () 31 | -------------------------------------------------------------------------------- /soxr/src/fft4g64.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #include "filter.h" 5 | #include "fft4g.c" 6 | #include "soxr-config.h" 7 | 8 | #if HAVE_DOUBLE_PRECISION 9 | static void * null(void) {return 0;} 10 | static void nothing(void) {} 11 | static void forward (int length, void * setup, double * H) {lsx_safe_rdft(length, 1, H); (void)setup;} 12 | static void backward(int length, void * setup, double * H) {lsx_safe_rdft(length, -1, H); (void)setup;} 13 | static int multiplier(void) {return 2;} 14 | 15 | typedef void (* fn_t)(void); 16 | fn_t _soxr_rdft64_cb[] = { 17 | (fn_t)null, 18 | (fn_t)null, 19 | (fn_t)nothing, 20 | (fn_t)forward, 21 | (fn_t)forward, 22 | (fn_t)backward, 23 | (fn_t)backward, 24 | (fn_t)_soxr_ordered_convolve, 25 | (fn_t)_soxr_ordered_partial_convolve, 26 | (fn_t)multiplier, 27 | (fn_t)nothing, 28 | }; 29 | #endif 30 | -------------------------------------------------------------------------------- /soxr/src/avfft32.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #include 5 | #include 6 | #include "filter.h" 7 | 8 | static void * forward_setup(int len) {return av_rdft_init((int)(log(len)/log(2)+.5),DFT_R2C);} 9 | static void * backward_setup(int len) {return av_rdft_init((int)(log(len)/log(2)+.5),IDFT_C2R);} 10 | static void rdft(int length, void * setup, float * h) {av_rdft_calc(setup, h); (void)length;} 11 | static int multiplier(void) {return 2;} 12 | static void nothing(void) {} 13 | 14 | typedef void (* fn_t)(void); 15 | fn_t _soxr_rdft32_cb[] = { 16 | (fn_t)forward_setup, 17 | (fn_t)backward_setup, 18 | (fn_t)av_rdft_end, 19 | (fn_t)rdft, 20 | (fn_t)rdft, 21 | (fn_t)rdft, 22 | (fn_t)rdft, 23 | (fn_t)_soxr_ordered_convolve_f, 24 | (fn_t)_soxr_ordered_partial_convolve_f, 25 | (fn_t)multiplier, 26 | (fn_t)nothing, 27 | }; 28 | -------------------------------------------------------------------------------- /soxr/src/avfft32s.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #include 5 | #include 6 | #include "simd.h" 7 | 8 | static void * forward_setup(int len) {return av_rdft_init((int)(log(len)/log(2)+.5),DFT_R2C);} 9 | static void * backward_setup(int len) {return av_rdft_init((int)(log(len)/log(2)+.5),IDFT_C2R);} 10 | static void rdft(int length, void * setup, float * h) {av_rdft_calc(setup, h); (void)length;} 11 | static int multiplier(void) {return 2;} 12 | static void nothing(void) {} 13 | 14 | typedef void (* fn_t)(void); 15 | fn_t _soxr_rdft32s_cb[] = { 16 | (fn_t)forward_setup, 17 | (fn_t)backward_setup, 18 | (fn_t)av_rdft_end, 19 | (fn_t)rdft, 20 | (fn_t)rdft, 21 | (fn_t)rdft, 22 | (fn_t)rdft, 23 | (fn_t)_soxr_ordered_convolve_simd, 24 | (fn_t)_soxr_ordered_partial_convolve_simd, 25 | (fn_t)multiplier, 26 | (fn_t)nothing, 27 | }; 28 | -------------------------------------------------------------------------------- /soxr/deinstall.cmake.in: -------------------------------------------------------------------------------- 1 | # SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | # Licence for this file: LGPL v2.1 See LICENCE for details. 3 | 4 | if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 5 | message (FATAL_ERROR "Cannot find install manifest") 6 | endif () 7 | 8 | file (READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 9 | string (REGEX REPLACE "\n" ";" files "${files}") 10 | foreach (file ${files}) 11 | set (dest "$ENV{DESTDIR}${file}") 12 | message (STATUS "Deinstalling \"${dest}\"") 13 | if (EXISTS "${dest}" OR IS_SYMLINK "${dest}") 14 | execute_process ( 15 | COMMAND "@CMAKE_COMMAND@" -E remove "${dest}" 16 | OUTPUT_VARIABLE rm_out 17 | RESULT_VARIABLE rm_retval 18 | ) 19 | if (NOT ${rm_retval} EQUAL 0) 20 | message (FATAL_ERROR "Problem when removing \"${dest}\"") 21 | endif () 22 | else () 23 | message (STATUS "File \"${dest}\" does not exist.") 24 | endif () 25 | endforeach () 26 | -------------------------------------------------------------------------------- /lib/inputdev/HIDListenerBSD.cpp: -------------------------------------------------------------------------------- 1 | #include "IHIDDevice.hpp" 2 | #include "boo/inputdev/DeviceToken.hpp" 3 | #include "boo/inputdev/DeviceBase.hpp" 4 | 5 | namespace boo { 6 | 7 | class HIDDeviceBSD final : public IHIDDevice { 8 | DeviceToken& m_token; 9 | DeviceBase& m_devImp; 10 | 11 | void _deviceDisconnected() {} 12 | bool _sendUSBInterruptTransfer(const uint8_t* data, size_t length) { return false; } 13 | size_t _receiveUSBInterruptTransfer(uint8_t* data, size_t length) { return 0; } 14 | bool _sendHIDReport(const uint8_t* data, size_t length, uint16_t message) { return false; } 15 | size_t _recieveReport(const uint8_t* data, size_t length, uint16_t message) { return 0; } 16 | 17 | public: 18 | HIDDeviceBSD(DeviceToken& token, DeviceBase& devImp) : m_token(token), m_devImp(devImp) {} 19 | ~HIDDeviceBSD() override = default; 20 | }; 21 | 22 | std::shared_ptr IHIDDeviceNew(DeviceToken& token, const std::shared_ptr& devImp) { 23 | return std::make_shared(token, devImp); 24 | } 25 | } // namespace boo 26 | -------------------------------------------------------------------------------- /soxr/src/data-io.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #if !defined soxr_data_io_included 5 | #define soxr_data_io_included 6 | 7 | #include "soxr.h" 8 | 9 | void _soxr_deinterleave( 10 | double * * dest, 11 | soxr_datatype_t data_type, 12 | void const * * src0, 13 | size_t n, 14 | unsigned ch); 15 | 16 | void _soxr_deinterleave_f( 17 | float * * dest, 18 | soxr_datatype_t data_type, 19 | void const * * src0, 20 | size_t n, 21 | unsigned ch); 22 | 23 | size_t /* clips */ _soxr_interleave( 24 | soxr_datatype_t data_type, 25 | void * * dest, 26 | double const * const * src, 27 | size_t n, 28 | unsigned ch, 29 | unsigned long * seed); 30 | 31 | size_t /* clips */ _soxr_interleave_f( 32 | soxr_datatype_t data_type, 33 | void * * dest, 34 | float const * const * src, 35 | size_t n, 36 | unsigned ch, 37 | unsigned long * seed); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/boo/inputdev/IHIDListener.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "boo/inputdev/DeviceToken.hpp" 9 | 10 | namespace boo { 11 | class DeviceFinder; 12 | 13 | using TDeviceTokens = std::unordered_map>; 14 | using TInsertedDeviceToken = std::pair; 15 | 16 | class IHIDListener { 17 | public: 18 | virtual ~IHIDListener() = default; 19 | 20 | /* Automatic device scanning */ 21 | virtual bool startScanning() = 0; 22 | virtual bool stopScanning() = 0; 23 | 24 | /* Manual device scanning */ 25 | virtual bool scanNow() = 0; 26 | 27 | #if _WIN32 && !WINDOWS_STORE 28 | /* External listener implementation (for Windows) */ 29 | virtual bool _extDevConnect(const char* path) = 0; 30 | virtual bool _extDevDisconnect(const char* path) = 0; 31 | #endif 32 | }; 33 | 34 | /* Platform-specific constructor */ 35 | std::unique_ptr IHIDListenerNew(DeviceFinder& finder); 36 | 37 | } // namespace boo 38 | -------------------------------------------------------------------------------- /lib/inputdev/HIDDeviceUWP.cpp: -------------------------------------------------------------------------------- 1 | #define _CRT_SECURE_NO_WARNINGS 1 /* STFU MSVC */ 2 | 3 | #include "lib/inputdev/IHIDDevice.hpp" 4 | 5 | #include "boo/inputdev/DeviceToken.hpp" 6 | #include "boo/inputdev/DeviceBase.hpp" 7 | 8 | namespace boo { 9 | 10 | class HIDDeviceUWP : public IHIDDevice { 11 | public: 12 | HIDDeviceUWP(DeviceToken& token, const std::shared_ptr& devImp) {} 13 | 14 | void _deviceDisconnected() override {} 15 | bool _sendUSBInterruptTransfer(const uint8_t* data, size_t length) override { return false; } 16 | size_t _receiveUSBInterruptTransfer(uint8_t* data, size_t length) override { return 0; } 17 | bool _sendHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) override { return false; } 18 | size_t _receiveHIDReport(uint8_t* data, size_t length, HIDReportType tp, uint32_t message) override { return false; } 19 | void _startThread() override {} 20 | }; 21 | 22 | std::shared_ptr IHIDDeviceNew(DeviceToken& token, const std::shared_ptr& devImp) { 23 | return std::make_shared(token, devImp); 24 | } 25 | 26 | } // namespace boo 27 | -------------------------------------------------------------------------------- /soxr/tests/bandwidth-test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net 5 | # Licence for this file: LGPL v2.1 See LICENCE for details. 6 | 7 | # Tests varying bandwidth. 8 | 9 | 10 | 11 | tool=./3-options-input-fn 12 | 13 | spec="spectrogram -z120 -Z-20 -wd -ho" 14 | ext=f32; e=0 15 | rate1=48000 16 | rate2=44100 17 | 18 | for n in 1 2; do 19 | 20 | rate1n=`expr $rate1 / 2` 21 | 22 | #sox -r $rate1 -n 0.$ext synth 1s sq pad .03 .03 gain -1 23 | sox -r $rate1 -n 0.$ext synth 8 sin 0:$rate1n gain -1 24 | 25 | for pass in `seq 79 5 99`; do 26 | f=bw1-$rate2-p`printf %02u $pass` 27 | $tool $rate1 $rate2 1 $e $e 4 0 $pass < 0.$ext | sox -c1 -r$rate2 -t $ext - -n $spec $f.png -c "bw-test pass:$pass stop:100" 28 | done 29 | 30 | for pass in `seq 79 5 99`; do 31 | f=bw2-$rate2-p`printf %02u $pass` 32 | stop=`expr 200 - $pass` 33 | $tool $rate1 $rate2 1 $e $e 4 0 $pass $stop < 0.$ext | sox -c1 -r$rate2 -t $ext - -n $spec $f.png -c "bw-test pass:$pass stop:$stop" 34 | done 35 | 36 | r=$rate1; rate1=$rate2; rate2=$r 37 | 38 | done 39 | 40 | rm 0.$ext 41 | -------------------------------------------------------------------------------- /lib/inputdev/IHIDDevice.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "boo/inputdev/DeviceBase.hpp" 6 | #include "boo/inputdev/DeviceToken.hpp" 7 | 8 | #if _WIN32 9 | #include 10 | #endif 11 | 12 | namespace boo { 13 | 14 | class IHIDDevice : public std::enable_shared_from_this { 15 | friend class DeviceBase; 16 | friend struct DeviceSignature; 17 | virtual void _deviceDisconnected() = 0; 18 | virtual bool _sendUSBInterruptTransfer(const uint8_t* data, size_t length) = 0; 19 | virtual size_t _receiveUSBInterruptTransfer(uint8_t* data, size_t length) = 0; 20 | #if _WIN32 21 | #if !WINDOWS_STORE 22 | virtual const PHIDP_PREPARSED_DATA _getReportDescriptor() = 0; 23 | #endif 24 | #else 25 | virtual std::vector _getReportDescriptor() = 0; 26 | #endif 27 | virtual bool _sendHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) = 0; 28 | virtual size_t _receiveHIDReport(uint8_t* data, size_t length, HIDReportType tp, uint32_t message) = 0; 29 | virtual void _startThread() = 0; 30 | 31 | public: 32 | virtual ~IHIDDevice() = default; 33 | }; 34 | 35 | } // namespace boo 36 | -------------------------------------------------------------------------------- /soxr/src/fft4g.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | void lsx_cdft(int, int, double *, int *, double *); 5 | void lsx_rdft(int, int, double *, int *, double *); 6 | void lsx_ddct(int, int, double *, int *, double *); 7 | void lsx_ddst(int, int, double *, int *, double *); 8 | void lsx_dfct(int, double *, double *, int *, double *); 9 | void lsx_dfst(int, double *, double *, int *, double *); 10 | 11 | void lsx_cdft_f(int, int, float *, int *, float *); 12 | void lsx_rdft_f(int, int, float *, int *, float *); 13 | void lsx_ddct_f(int, int, float *, int *, float *); 14 | void lsx_ddst_f(int, int, float *, int *, float *); 15 | void lsx_dfct_f(int, float *, float *, int *, float *); 16 | void lsx_dfst_f(int, float *, float *, int *, float *); 17 | 18 | #define dft_br_len(l) (2ul + (1ul << (int)(log(l / 2 + .5) / log(2.)) / 2)) 19 | #define dft_sc_len(l) ((unsigned long)l / 2) 20 | 21 | /* Over-allocate h by 2 to use these macros */ 22 | #define LSX_PACK(h, n) h[1] = h[n] 23 | #define LSX_UNPACK(h, n) h[n] = h[1], h[n + 1] = h[1] = 0; 24 | -------------------------------------------------------------------------------- /soxr/LICENCE: -------------------------------------------------------------------------------- 1 | SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | 3 | This library is free software; you can redistribute it and/or modify it 4 | under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation; either version 2.1 of the License, or (at 6 | your option) any later version. 7 | 8 | This library is distributed in the hope that it will be useful, but 9 | WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 11 | General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with this library; if not, write to the Free Software Foundation, 15 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | 18 | Notes 19 | 20 | 1. Re software in the `examples' directory: works that are not resampling 21 | examples but are based on the given examples -- for example, applications using 22 | the library -- shall not be considered to be derivative works of the examples. 23 | 24 | 2. If building with pffft.c, see the licence embedded in that file. 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2015-2018 Boo Contributors 4 | Original Authors: Jack Andersen and Phillip "Antidote" Stephens 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /soxr/tests/phase-test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net 5 | # Licence for this file: LGPL v2.1 See LICENCE for details. 6 | 7 | # Tests varying phase-response. 8 | 9 | tool=./3-options-input-fn 10 | spec="spectrogram -z160 -Z-20 -X 2000 -wd -ho" 11 | ext=f32; e=0 12 | rate1=48000 13 | rate2=44100 14 | 15 | for n in 1 2; do 16 | sox -r $rate1 -n 0.$ext synth 1s sq pad .03 .03 gain -1 17 | 18 | # Test the following combinations: 19 | names=(linear-phase intermediate-phase maximum-phase minimum-phase) 20 | filters=(standard-filter steep-filter) 21 | 22 | for q in `seq 0 7`; do 23 | f=ph-$rate2-q$q 24 | name=${names[`expr $q % 4 || true`]} 25 | filter=${filters[`expr $q / 4 || true`]} 26 | $tool $rate1 $rate2 1 $e $e $q'6' < 0.$ext | sox -c1 -r$rate2 -t $ext - -n $spec $f.png -c "ph-test $filter $name" 27 | done 28 | 29 | # Test specific phase-response percentages: 30 | for q in `seq 0 20 100`; do 31 | f=ph-$rate2-p`printf %03u $q` 32 | $tool $rate1 $rate2 1 $e $e 46 0 0 0 $q < 0.$ext | sox -c1 -r$rate2 -t $ext - -n $spec $f.png -c "ph-test phase:${q}%" 33 | done 34 | 35 | r=$rate1; rate1=$rate2; rate2=$r 36 | done 37 | 38 | rm 0.$ext 39 | -------------------------------------------------------------------------------- /include/boo/UWPViewProvider.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "boo/IApplication.hpp" 4 | 5 | namespace boo { 6 | 7 | #if WINDOWS_STORE 8 | using namespace Windows::ApplicationModel::Core; 9 | 10 | ref struct ViewProvider sealed : IFrameworkViewSource { 11 | internal : ViewProvider(boo::IApplicationCallback& appCb, std::string_view uniqueName, std::string_view friendlyName, 12 | std::string_view pname, Platform::Array ^ params, bool singleInstance) 13 | : m_appCb(appCb) 14 | , m_uniqueName(uniqueName) 15 | , m_friendlyName(friendlyName) 16 | , m_pname(pname) 17 | , m_singleInstance(singleInstance) { 18 | char selfPath[1024]; 19 | GetModuleFileNameW(nullptr, selfPath, 1024); 20 | m_args.reserve(params->Length + 1); 21 | m_args.emplace_back(selfPath); 22 | for (Platform::String ^ str : params) 23 | m_args.emplace_back(str->Data()); 24 | } 25 | 26 | public: 27 | virtual IFrameworkView ^ CreateView(); 28 | 29 | internal : boo::IApplicationCallback& m_appCb; 30 | std::string m_uniqueName; 31 | std::string m_friendlyName; 32 | std::string m_pname; 33 | std::vector m_args; 34 | bool m_singleInstance; 35 | }; 36 | #endif 37 | 38 | } // namespace boo 39 | -------------------------------------------------------------------------------- /soxr/src/poly-fir0.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Resample using a non-interpolated poly-phase FIR with length LEN.*/ 5 | /* Input must be followed by LEN-1 samples. */ 6 | 7 | #define _ sum += (coef(p->shared->poly_fir_coefs, 0, FIR_LENGTH, rem, 0, j)) *at[j], ++j; 8 | 9 | static void FUNCTION(stage_t * p, fifo_t * output_fifo) 10 | { 11 | sample_t const * input = stage_read_p(p); 12 | int i, num_in = stage_occupancy(p), max_num_out = 1 + (int)(num_in*p->out_in_ratio); 13 | sample_t * output = fifo_reserve(output_fifo, max_num_out); 14 | 15 | for (i = 0; p->at.integer < num_in * p->L; ++i, p->at.integer += p->step.integer) { 16 | int div = p->at.integer / p->L, rem = p->at.integer % p->L; 17 | sample_t const * at = input + div; 18 | sample_t sum = 0; 19 | int j = 0; 20 | CONVOLVE 21 | output[i] = sum; 22 | } 23 | assert(max_num_out - i >= 0); 24 | fifo_trim_by(output_fifo, max_num_out - i); 25 | fifo_read(&p->fifo, p->at.integer / p->L, NULL); 26 | p->at.integer = p->at.integer % p->L; 27 | } 28 | 29 | #undef _ 30 | #undef CONVOLVE 31 | #undef FIR_LENGTH 32 | #undef FUNCTION 33 | -------------------------------------------------------------------------------- /soxr/tests/eg-test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net 5 | # Licence for this file: LGPL v2.1 See LICENCE for details. 6 | 7 | # Exercises each example programme. 8 | 9 | 10 | 11 | len=8 12 | #vg="valgrind --leak-check=full --show-reachable=yes" 13 | 14 | 15 | 16 | # Exercise example 1: 17 | $vg ./1-single-block 18 | 19 | 20 | 21 | # Check that examples 2-4 can convert 96k<->44k1 and that results are same for each: 22 | ir=96000 23 | or=44100 24 | for i in 1 2; do 25 | prev="" 26 | sox -r $ir -n 0.f32 synth $len sin 0+`expr $ir / 2` 27 | for f in `find . -type f -executable -name "[2-4]*"`; do 28 | $vg $f $ir $or < 0.f32 > $f.f32 29 | test x$prev != x && cmp $f.f32 $prev 30 | prev=$f.f32 31 | done 32 | or=96000 33 | ir=44100 34 | done 35 | rm *.f32 36 | 37 | 38 | 39 | # Exercise VR making sure that varied internal stage reconfigurations occur: 40 | variations=(slow-sweep fast-changing) 41 | signals=(sine-wave saw-tooth-wave) 42 | for n in 0 1 2 3; do 43 | signal=${signals[`expr $n % 2 || true`]} 44 | variation=${variations[`expr $n / 2 || true`]} 45 | $vg ./5-variable-rate $n | sox -tf32 -r44100 -c1 - -n spectrogram -z130 -hwd -o v$n.png -X 50 -c "variation:$variation signal:$signal" 46 | vg="" 47 | done 48 | -------------------------------------------------------------------------------- /soxr/src/internal.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #if !defined soxr_internal_included 5 | #define soxr_internal_included 6 | 7 | #include "soxr-config.h" 8 | 9 | #undef min 10 | #undef max 11 | #define min(a, b) ((a) <= (b) ? (a) : (b)) 12 | #define max(a, b) ((a) >= (b) ? (a) : (b)) 13 | 14 | #define range_limit(x, lower, upper) (min(max(x, lower), upper)) 15 | #define linear_to_dB(x) (log10(x) * 20) 16 | #define array_length(a) (sizeof(a)/sizeof(a[0])) 17 | #define AL(a) array_length(a) 18 | #define iAL(a) (int)AL(a) 19 | #define sqr(a) ((a) * (a)) 20 | 21 | #ifdef __GNUC__ 22 | #define UNUSED __attribute__ ((unused)) 23 | #else 24 | #define UNUSED 25 | #endif 26 | 27 | #if defined NDEBUG || SOXR_SILENT 28 | #ifdef __GNUC__ 29 | void lsx_dummy(char const *, ...); 30 | #else 31 | static __inline void lsx_dummy(char const * x, ...) {} 32 | #endif 33 | #define lsx_debug if(0) lsx_dummy 34 | #else 35 | #include 36 | #include 37 | UNUSED static void lsx_debug(char const * fmt, ...) 38 | { 39 | va_list args; 40 | va_start(args, fmt); 41 | vfprintf(stderr, fmt, args); 42 | fputc('\n', stderr); 43 | va_end(args); 44 | } 45 | #endif 46 | #endif 47 | -------------------------------------------------------------------------------- /soxr/soxr-config.h.in: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #if !defined soxr_config_included 5 | #define soxr_config_included 6 | 7 | #define HAVE_SINGLE_PRECISION @HAVE_SINGLE_PRECISION@ 8 | #define HAVE_DOUBLE_PRECISION @HAVE_DOUBLE_PRECISION@ 9 | #define HAVE_AVFFT @HAVE_AVFFT@ 10 | #define HAVE_SIMD @HAVE_SIMD@ 11 | #define HAVE_FENV_H @HAVE_FENV_H@ 12 | #define HAVE_LRINT @HAVE_LRINT@ 13 | #define WORDS_BIGENDIAN @WORDS_BIGENDIAN@ 14 | 15 | #include 16 | 17 | #undef bool 18 | #undef false 19 | #undef true 20 | #define bool int 21 | #define false 0 22 | #define true 1 23 | 24 | #undef int16_t 25 | #undef int32_t 26 | #undef int64_t 27 | #undef uint32_t 28 | #undef uint64_t 29 | #define int16_t short 30 | #if LONG_MAX > 2147483647L 31 | #define int32_t int 32 | #define int64_t long 33 | #elif LONG_MAX < 2147483647L 34 | #error this library requires that 'long int' has at least 32-bits 35 | #else 36 | #define int32_t long 37 | #if defined _MSC_VER 38 | #define int64_t __int64 39 | #else 40 | #define int64_t long long 41 | #endif 42 | #endif 43 | #define uint32_t unsigned int32_t 44 | #define uint64_t unsigned int64_t 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /soxr/examples/examples-common.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Common includes etc. for the examples. */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef _WIN32 16 | /* Work-around for broken file-I/O on MS-Windows: */ 17 | #include 18 | #include 19 | #define USE_STD_STDIO _setmode(_fileno(stdout), _O_BINARY), \ 20 | _setmode(_fileno(stdin ), _O_BINARY); 21 | /* Sometimes missing, so ensure that it is defined: */ 22 | #undef M_PI 23 | #define M_PI 3.14159265358979323846 24 | #else 25 | #define USE_STD_STDIO 26 | #endif 27 | 28 | #undef int16_t 29 | #define int16_t short 30 | 31 | #undef int32_t 32 | #if LONG_MAX > 2147483647L 33 | #define int32_t int 34 | #elif LONG_MAX < 2147483647L 35 | #error this programme requires that 'long int' has at least 32-bits 36 | #else 37 | #define int32_t long 38 | #endif 39 | 40 | #undef min 41 | #undef max 42 | #define min(x,y) ((x)<(y)?(x):(y)) 43 | #define max(x,y) ((x)>(y)?(x):(y)) 44 | 45 | #define AL(a) (sizeof(a)/sizeof((a)[0])) /* Array Length */ 46 | -------------------------------------------------------------------------------- /soxr/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | # Licence for this file: LGPL v2.1 See LICENCE for details. 3 | 4 | if (${BUILD_EXAMPLES}) 5 | project (soxr) # Adds c++ compiler 6 | file (GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/[1-9]-*.[cC]) 7 | elseif (${BUILD_TESTS}) 8 | file (GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/3*.c) 9 | endif () 10 | 11 | if (${BUILD_EXAMPLES} OR ${BUILD_TESTS}) 12 | if (${WITH_LSR_BINDINGS}) 13 | set (LSR_SOURCES 1a-lsr.c) 14 | endif () 15 | endif () 16 | 17 | if (NOT BUILD_SHARED_LIBS AND OPENMP_FOUND) 18 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_C_FLAGS}") 19 | endif () 20 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROJECT_C_FLAGS}") 21 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROJECT_CXX_FLAGS}") 22 | link_libraries (soxr) 23 | 24 | foreach (fe ${SOURCES} ${LSR_SOURCES}) 25 | get_filename_component (f ${fe} NAME_WE) 26 | add_executable (${f} ${fe}) 27 | if (${f} STREQUAL "1a-lsr") 28 | target_link_libraries (${f} soxr-lsr) 29 | endif () 30 | endforeach () 31 | 32 | if (${BUILD_TESTS} AND ${WITH_LSR_BINDINGS}) 33 | add_test (lsr-bindings ${BIN}1a-lsr) 34 | endif () 35 | 36 | file (GLOB INSTALL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.[cCh]) 37 | install (FILES ${INSTALL_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/README DESTINATION ${DOC_INSTALL_DIR}/examples) 38 | -------------------------------------------------------------------------------- /soxr/tests/io-test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net 5 | # Licence for this file: LGPL v2.1 See LICENCE for details. 6 | 7 | # Tests IO 8 | 9 | 10 | 11 | ir=65537 12 | or=44100 13 | len=16 14 | f=1/32768 15 | g=32768:0 16 | tool=./3-options-input-fn 17 | 18 | types=(f32 f64 s32 s16) 19 | 20 | zs=(180 180 180 180 180 120 120 120 120) 21 | 22 | do_one() { 23 | $tool $ir $or $c $1 $2 $3 < $c.${types[$1]} | 24 | sox -t ${types[`expr $2 % 4`]} -r $or -c $c - -n spectrogram -X50 -hwk -z${zs[$n]} -o io$c$n.png -c "io-test i:${types[$1]} o:${types[`expr $2 % 4`]} ($2) q:$3" 25 | n=`expr $n + 1` 26 | } 27 | 28 | j=3; test z$1 != z && j=$1 29 | 30 | for c in `seq 1 $j`; do 31 | for n in `seq 0 3`; do 32 | sox -r $ir -n $c.${types[$n]} synth $len sin $f gain -.1 33 | done 34 | 35 | n=0 36 | do_one 1 2 5 37 | do_one 2 0 5 38 | for m in `seq 0 3`; do do_one $m $m 5; done 39 | do_one 3 2 3 40 | do_one 0 3 3 41 | do_one 0 11 3 42 | 43 | f="$f sin $g" 44 | g=0+32768 45 | done 46 | 47 | rm ?.[sf][0-9][0-9] 48 | 49 | 50 | 51 | # Check conversion between differing I/O types, but no rate-change: 52 | 53 | for i in 1 2 3; do 54 | prev="" 55 | sox -n -c $i 0.f32 synth $len gain -.1 56 | $tool 1 1 $i 0 2 < 0.f32 | $tool 1 1 $i 2 0 > 1.f32 57 | cmp [01].f32 58 | done 59 | rm *.f32 60 | -------------------------------------------------------------------------------- /xxhash/LICENSE: -------------------------------------------------------------------------------- 1 | xxHash Library 2 | Copyright (c) 2012-2014, Yann Collet 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, this 12 | list of conditions and the following disclaimer in the documentation and/or 13 | other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /include/boo/inputdev/NintendoPowerA.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DeviceBase.hpp" 3 | #include "boo/System.hpp" 4 | 5 | namespace boo { 6 | struct NintendoPowerAState { 7 | uint8_t y : 1; 8 | uint8_t b : 1; 9 | uint8_t a : 1; 10 | uint8_t x : 1; 11 | uint8_t l : 1; 12 | uint8_t r : 1; 13 | uint8_t zl : 1; 14 | uint8_t zr : 1; 15 | uint8_t minus : 1; 16 | uint8_t plus : 1; 17 | uint8_t stickL : 1; 18 | uint8_t stickR : 1; 19 | uint8_t home : 1; 20 | uint8_t capture : 1; 21 | uint8_t dPad; 22 | uint8_t leftX; 23 | uint8_t leftY; 24 | uint8_t rightX; 25 | uint8_t rightY; 26 | bool operator==(const NintendoPowerAState& other) const; 27 | bool operator!=(const NintendoPowerAState& other) const; 28 | }; 29 | 30 | class NintendoPowerA; 31 | struct INintendoPowerACallback { 32 | virtual void controllerDisconnected() {} 33 | virtual void controllerUpdate(const NintendoPowerAState& state) {} 34 | }; 35 | 36 | class NintendoPowerA final : public TDeviceBase { 37 | NintendoPowerAState m_last{}; 38 | void deviceDisconnected() override; 39 | void initialCycle() override; 40 | void transferCycle() override; 41 | void finalCycle() override; 42 | void receivedHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) override; 43 | 44 | public: 45 | explicit NintendoPowerA(DeviceToken*); 46 | ~NintendoPowerA() override; 47 | }; 48 | } // namespace boo 49 | -------------------------------------------------------------------------------- /soxr/src/pffft32s.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #include "pffft.c" 5 | 6 | static void * setup(int len) {return pffft_new_setup(len, PFFFT_REAL);} 7 | static void forward (int length, void * setup, float * h, float * scratch) {pffft_transform (setup, h, h, scratch, PFFFT_FORWARD); (void)length;} 8 | static void oforward (int length, void * setup, float * h, float * scratch) {pffft_transform_ordered(setup, h, h, scratch, PFFFT_FORWARD); (void)length;} 9 | static void backward (int length, void * setup, float * H, float * scratch) {pffft_transform (setup, H, H, scratch, PFFFT_BACKWARD);(void)length;} 10 | static void obackward(int length, void * setup, float * H, float * scratch) {pffft_transform_ordered(setup, H, H, scratch, PFFFT_BACKWARD);(void)length;} 11 | static void convolve(int length, void * setup, float * H, float const * with) { pffft_zconvolve(setup, H, with, H); (void)length;} 12 | static int multiplier(void) {return 1;} 13 | 14 | typedef void (* fn_t)(void); 15 | fn_t _soxr_rdft32s_cb[] = { 16 | (fn_t)setup, 17 | (fn_t)setup, 18 | (fn_t)pffft_destroy_setup, 19 | (fn_t)forward, 20 | (fn_t)oforward, 21 | (fn_t)backward, 22 | (fn_t)obackward, 23 | (fn_t)convolve, 24 | (fn_t)_soxr_ordered_partial_convolve_simd, 25 | (fn_t)multiplier, 26 | (fn_t)pffft_reorder_back, 27 | }; 28 | -------------------------------------------------------------------------------- /include/boo/audiodev/IMIDIReader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace boo { 7 | 8 | class IMIDIReader { 9 | public: 10 | virtual void noteOff(uint8_t chan, uint8_t key, uint8_t velocity) = 0; 11 | virtual void noteOn(uint8_t chan, uint8_t key, uint8_t velocity) = 0; 12 | virtual void notePressure(uint8_t chan, uint8_t key, uint8_t pressure) = 0; 13 | virtual void controlChange(uint8_t chan, uint8_t control, uint8_t value) = 0; 14 | virtual void programChange(uint8_t chan, uint8_t program) = 0; 15 | virtual void channelPressure(uint8_t chan, uint8_t pressure) = 0; 16 | virtual void pitchBend(uint8_t chan, int16_t pitch) = 0; 17 | 18 | virtual void allSoundOff(uint8_t chan) = 0; 19 | virtual void resetAllControllers(uint8_t chan) = 0; 20 | virtual void localControl(uint8_t chan, bool on) = 0; 21 | virtual void allNotesOff(uint8_t chan) = 0; 22 | virtual void omniMode(uint8_t chan, bool on) = 0; 23 | virtual void polyMode(uint8_t chan, bool on) = 0; 24 | 25 | virtual void sysex(const void* data, size_t len) = 0; 26 | virtual void timeCodeQuarterFrame(uint8_t message, uint8_t value) = 0; 27 | virtual void songPositionPointer(uint16_t pointer) = 0; 28 | virtual void songSelect(uint8_t song) = 0; 29 | virtual void tuneRequest() = 0; 30 | 31 | virtual void startSeq() = 0; 32 | virtual void continueSeq() = 0; 33 | virtual void stopSeq() = 0; 34 | 35 | virtual void reset() = 0; 36 | }; 37 | 38 | } // namespace boo 39 | -------------------------------------------------------------------------------- /lib/inputdev/GenericPad.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/inputdev/GenericPad.hpp" 2 | #include "boo/inputdev/DeviceToken.hpp" 3 | 4 | namespace boo { 5 | 6 | GenericPad::GenericPad(DeviceToken* token) : TDeviceBase(dev_typeid(GenericPad), token) {} 7 | 8 | GenericPad::~GenericPad() {} 9 | 10 | void GenericPad::deviceDisconnected() { 11 | std::lock_guard lk(m_callbackLock); 12 | if (m_callback) 13 | m_callback->controllerDisconnected(); 14 | } 15 | 16 | void GenericPad::initialCycle() { 17 | #if _WIN32 18 | #if !WINDOWS_STORE 19 | const PHIDP_PREPARSED_DATA reportDesc = getReportDescriptor(); 20 | m_parser.Parse(reportDesc); 21 | #endif 22 | #else 23 | std::vector reportDesc = getReportDescriptor(); 24 | m_parser.Parse(reportDesc.data(), reportDesc.size()); 25 | #endif 26 | std::lock_guard lk(m_callbackLock); 27 | if (m_callback) 28 | m_callback->controllerConnected(); 29 | } 30 | 31 | void GenericPad::receivedHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) { 32 | std::lock_guard lk(m_callbackLock); 33 | if (length == 0 || tp != HIDReportType::Input || !m_callback) 34 | return; 35 | std::function func = [this](const HIDMainItem& item, int32_t value) { 36 | m_callback->valueUpdate(item, value); 37 | return true; 38 | }; 39 | m_parser.ScanValues(func, data, length); 40 | } 41 | 42 | void GenericPad::enumerateValues(const std::function& valueCB) const { 43 | m_parser.EnumerateValues(valueCB); 44 | } 45 | 46 | } // namespace boo 47 | -------------------------------------------------------------------------------- /lib/inputdev/NintendoPowerA.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/inputdev/NintendoPowerA.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include "boo/inputdev/DeviceSignature.hpp" 7 | 8 | namespace boo { 9 | NintendoPowerA::NintendoPowerA(DeviceToken* token) 10 | : TDeviceBase(dev_typeid(NintendoPowerA), token) {} 11 | 12 | NintendoPowerA::~NintendoPowerA() = default; 13 | 14 | void NintendoPowerA::deviceDisconnected() { 15 | std::lock_guard lk{m_callbackLock}; 16 | if (m_callback != nullptr) { 17 | m_callback->controllerDisconnected(); 18 | } 19 | } 20 | 21 | void NintendoPowerA::initialCycle() {} 22 | 23 | void NintendoPowerA::transferCycle() { 24 | std::array payload; 25 | const size_t recvSz = receiveUSBInterruptTransfer(payload.data(), payload.size()); 26 | if (recvSz != payload.size()) { 27 | return; 28 | } 29 | 30 | NintendoPowerAState state; 31 | std::memcpy(&state, payload.data(), sizeof(state)); 32 | 33 | std::lock_guard lk{m_callbackLock}; 34 | if (state != m_last && m_callback != nullptr) { 35 | m_callback->controllerUpdate(state); 36 | } 37 | m_last = state; 38 | } 39 | 40 | void NintendoPowerA::finalCycle() {} 41 | 42 | void NintendoPowerA::receivedHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) {} 43 | 44 | bool NintendoPowerAState::operator==(const NintendoPowerAState& other) const { 45 | return std::memcmp(this, &other, sizeof(NintendoPowerAState)) == 0; 46 | } 47 | 48 | bool NintendoPowerAState::operator!=(const NintendoPowerAState& other) const { return !operator==(other); } 49 | 50 | } // namespace boo 51 | -------------------------------------------------------------------------------- /include/boo/IGraphicsContext.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace boo { 7 | struct IGraphicsCommandQueue; 8 | struct IGraphicsDataFactory; 9 | 10 | class IGraphicsContext { 11 | friend class WindowCocoa; 12 | friend class WindowXCB; 13 | virtual void _setCallback([[maybe_unused]] class IWindowCallback* cb) {} 14 | 15 | public: 16 | enum class EGraphicsAPI { 17 | Invalid = 0, 18 | OpenGL3_3 = 1, 19 | OpenGL4_2 = 2, 20 | Vulkan = 3, 21 | D3D11 = 4, 22 | Metal = 6, 23 | GX = 7, 24 | GX2 = 8, 25 | NX = 9 26 | }; 27 | 28 | enum class EPixelFormat { 29 | Invalid = 0, 30 | RGBA8 = 1, /* Default */ 31 | RGBA16 = 2, 32 | RGBA8_Z24 = 3, 33 | RGBAF32 = 4, 34 | RGBAF32_Z24 = 5 35 | }; 36 | 37 | virtual ~IGraphicsContext() = default; 38 | 39 | virtual EGraphicsAPI getAPI() const = 0; 40 | virtual EPixelFormat getPixelFormat() const = 0; 41 | virtual void setPixelFormat(EPixelFormat pf) = 0; 42 | virtual bool initializeContext(void* handle) = 0; 43 | virtual void makeCurrent() = 0; 44 | virtual void postInit() = 0; 45 | virtual void present() = 0; 46 | 47 | virtual IGraphicsCommandQueue* getCommandQueue() = 0; 48 | virtual IGraphicsDataFactory* getDataFactory() = 0; 49 | 50 | /* Creates a new context on current thread!! Call from main client thread */ 51 | virtual IGraphicsDataFactory* getMainContextDataFactory() = 0; 52 | 53 | /* Creates a new context on current thread!! Call from client loading thread */ 54 | virtual IGraphicsDataFactory* getLoadContextDataFactory() = 0; 55 | }; 56 | 57 | } // namespace boo 58 | -------------------------------------------------------------------------------- /soxr/src/pffft32.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #define _soxr_simd_aligned_free free 5 | #define _soxr_simd_aligned_malloc malloc 6 | #define PFFFT_SIMD_DISABLE 7 | #include "pffft.c" 8 | #include "filter.h" 9 | 10 | static void * setup(int len) {return pffft_new_setup(len, PFFFT_REAL);} 11 | static void delete_setup(void * setup) {pffft_destroy_setup(setup);} 12 | static void forward (int length, void * setup, float * h, float * scratch) {pffft_transform (setup, h, h, scratch, PFFFT_FORWARD); (void)length;} 13 | static void oforward (int length, void * setup, float * h, float * scratch) {pffft_transform_ordered(setup, h, h, scratch, PFFFT_FORWARD); (void)length;} 14 | static void backward (int length, void * setup, float * H, float * scratch) {pffft_transform (setup, H, H, scratch, PFFFT_BACKWARD);(void)length;} 15 | static void obackward(int length, void * setup, float * H, float * scratch) {pffft_transform_ordered(setup, H, H, scratch, PFFFT_BACKWARD);(void)length;} 16 | static void convolve(int length, void * setup, float * H, float const * with) { pffft_zconvolve(setup, H, with, H); (void)length;} 17 | static int multiplier(void) {return 1;} 18 | 19 | typedef void (* fn_t)(void); 20 | fn_t _soxr_rdft32_cb[] = { 21 | (fn_t)setup, 22 | (fn_t)setup, 23 | (fn_t)delete_setup, 24 | (fn_t)forward, 25 | (fn_t)oforward, 26 | (fn_t)backward, 27 | (fn_t)obackward, 28 | (fn_t)convolve, 29 | (fn_t)_soxr_ordered_partial_convolve_f, 30 | (fn_t)multiplier, 31 | (fn_t)pffft_reorder_back, 32 | }; 33 | -------------------------------------------------------------------------------- /soxr/examples/1a-lsr.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Example 1a: Variant of example 1 using libsamplerate-like bindings. */ 5 | 6 | #include 7 | #include "examples-common.h" 8 | 9 | float in[] = { /* Input: 12 cycles of a sine wave with freq. = irate/4 */ 10 | 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 11 | 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1}; 12 | 13 | int main(int argc, char const * arg[]) 14 | { 15 | double irate = argc > 1? atof(arg[1]) : 1; /* Default to upsampling */ 16 | double orate = argc > 2? atof(arg[2]) : 2; /* by a factor of 2. */ 17 | 18 | size_t olen = (size_t)(AL(in) * orate / irate + .5); /* Assay output len. */ 19 | float * out = (float *)malloc(sizeof(*out) * olen); /* Allocate output buf. */ 20 | 21 | int error, i = 0; 22 | SRC_DATA data; 23 | 24 | data.data_in = in; 25 | data.data_out = out; 26 | data.input_frames = AL(in); 27 | data.output_frames = (int)olen; 28 | data.src_ratio = orate / irate; 29 | error = src_simple(&data, SRC_SINC_FASTEST, 1); 30 | 31 | while (i++ < data.output_frames_gen) /* Print out the resampled data, */ 32 | printf("%5.2f%c", out[i-1], " \n"[!(i&7) || i == data.output_frames_gen]); 33 | printf("%-26s %s\n", arg[0], src_strerror(error)); /* and reported result. */ 34 | 35 | if (argc > 3) /* Library version check: */ 36 | printf("runtime=%s\n", src_get_version()); 37 | 38 | free(out); /* Tidy up. */ 39 | return !!error; 40 | } 41 | -------------------------------------------------------------------------------- /soxr/tests/q-test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net 5 | # Licence for this file: LGPL v2.1 See LICENCE for details. 6 | 7 | # Tests conversion qualities 0..7 & variable-rate. 8 | 9 | 10 | 11 | tool=./3-options-input-fn 12 | ext=f64; e=1 13 | c=1 14 | q1=0; q2=7 15 | rates=48000 16 | zs=(50 87 87 87 111 135 159 180 95) 17 | 18 | zz() { 19 | echo "spectrogram -z${zs[$1]} -Z-30 -wd -ho" 20 | } 21 | 22 | for rate0 in $rates; do 23 | 24 | rate1=$rate0 25 | rate2=44100 26 | 27 | for n in 1 2; do 28 | 29 | rate1n=`expr $rate1 / 2` 30 | 31 | 32 | 33 | # Convert sweep, for spectrogram: 34 | 35 | sox -r $rate1 -n -c $c 0.$ext synth 8 sin 0:$rate1n gain -1 36 | 37 | for q in `seq $q1 $q2`; do 38 | f=qa-$rate1-$rate2-$q 39 | $tool $rate1 $rate2 $c $e $e $q 0 < 0.$ext | sox -c$c -r$rate2 -t $ext - -n $(zz $q) $f.png -c $f 40 | done 41 | q=8 42 | f=qa-$rate1-$rate2-v 43 | $tool $rate1 $rate2 $c $e $e 4 20 < 0.$ext | sox -c$c -r$rate2 -t $ext - -n $(zz $q) $f.png -c $f 44 | 45 | 46 | 47 | # Convert impulse, for spectrogram: 48 | 49 | #: << : 50 | sox -r $rate1 -n 0.$ext synth 1s sq pad .03 .03 gain -1 51 | 52 | for q in `seq $q1 $q2`; do 53 | f=qb-$rate1-$rate2-$q 54 | $tool $rate1 $rate2 1 $e $e $q 0 < 0.$ext | sox -c1 -r$rate2 -t $ext - $f.wav 55 | done 56 | q=8 57 | f=qb-$rate1-$rate2-v 58 | $tool $rate1 $rate2 1 $e $e 4 20 < 0.$ext | sox -c1 -r$rate2 -t $ext - $f.wav 59 | 60 | # Combine impuse responses into multi-channel file (for inspection in Audacity): 61 | sox -M qb-$rate1-$rate2-?.wav q$rate1-$rate2.wav 62 | 63 | rm qb-$rate1-$rate2-?.wav 64 | : 65 | 66 | rate1=44100 67 | rate2=$rate0 68 | 69 | done 70 | done 71 | 72 | rm 0.$ext 73 | -------------------------------------------------------------------------------- /include/boo/audiodev/IAudioSubmix.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "boo/BooObject.hpp" 7 | 8 | namespace boo { 9 | struct IAudioVoice; 10 | struct IAudioVoiceCallback; 11 | struct ChannelMap; 12 | struct IAudioSubmixCallback; 13 | 14 | enum class SubmixFormat { Int16, Int32, Float }; 15 | 16 | struct IAudioSubmix : IObj { 17 | /** Reset channel-levels to silence; unbind all submixes */ 18 | virtual void resetSendLevels() = 0; 19 | 20 | /** Set channel-levels for target submix (AudioChannel enum for array index) */ 21 | virtual void setSendLevel(IAudioSubmix* submix, float level, bool slew) = 0; 22 | 23 | /** Gets fixed sample rate of submix this way */ 24 | virtual double getSampleRate() const = 0; 25 | 26 | /** Gets fixed sample format of submix this way */ 27 | virtual SubmixFormat getSampleFormat() const = 0; 28 | }; 29 | 30 | struct IAudioSubmixCallback { 31 | /** Client-provided claim to implement / is ready to call applyEffect() */ 32 | virtual bool canApplyEffect() const = 0; 33 | 34 | /** Client-provided effect solution for interleaved, master sample-rate audio */ 35 | virtual void applyEffect(int16_t* audio, size_t frameCount, const ChannelMap& chanMap, double sampleRate) const = 0; 36 | virtual void applyEffect(int32_t* audio, size_t frameCount, const ChannelMap& chanMap, double sampleRate) const = 0; 37 | virtual void applyEffect(float* audio, size_t frameCount, const ChannelMap& chanMap, double sampleRate) const = 0; 38 | 39 | /** Notify of output sample rate changes (for instance, changing the default audio device on Windows) */ 40 | virtual void resetOutputSampleRate(double sampleRate) = 0; 41 | }; 42 | 43 | } // namespace boo 44 | -------------------------------------------------------------------------------- /include/boo/inputdev/XInputPad.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "boo/System.hpp" 6 | #include "boo/inputdev/DeviceBase.hpp" 7 | #include "boo/inputdev/DeviceSignature.hpp" 8 | 9 | namespace boo { 10 | 11 | struct XInputPadState { 12 | uint16_t wButtons; 13 | uint8_t bLeftTrigger; 14 | uint8_t bRightTrigger; 15 | int16_t sThumbLX; 16 | int16_t sThumbLY; 17 | int16_t sThumbRX; 18 | int16_t sThumbRY; 19 | }; 20 | 21 | enum class EXInputMotor : uint8_t { 22 | None = 0, 23 | Right = 1 << 0, 24 | Left = 1 << 1, 25 | }; 26 | ENABLE_BITWISE_ENUM(EXInputMotor) 27 | 28 | class XInputPad; 29 | struct IXInputPadCallback { 30 | virtual void controllerDisconnected() {} 31 | virtual void controllerUpdate(XInputPad& pad, const XInputPadState&) {} 32 | }; 33 | 34 | class XInputPad final : public TDeviceBase { 35 | friend class HIDListenerWinUSB; 36 | uint16_t m_rumbleRequest[2] = {}; 37 | uint16_t m_rumbleState[2] = {}; 38 | 39 | public: 40 | XInputPad(DeviceToken* token) : TDeviceBase(dev_typeid(XInputPad), token) {} 41 | void deviceDisconnected() override { 42 | std::lock_guard lk(m_callbackLock); 43 | if (m_callback) 44 | m_callback->controllerDisconnected(); 45 | } 46 | void startRumble(EXInputMotor motors, uint16_t intensity) { 47 | if (True(motors & EXInputMotor::Left)) 48 | m_rumbleRequest[0] = intensity; 49 | if (True(motors & EXInputMotor::Right)) 50 | m_rumbleRequest[1] = intensity; 51 | } 52 | void stopRumble(EXInputMotor motors) { 53 | if (True(motors & EXInputMotor::Left)) 54 | m_rumbleRequest[0] = 0; 55 | if (True(motors & EXInputMotor::Right)) 56 | m_rumbleRequest[1] = 0; 57 | } 58 | }; 59 | 60 | } // namespace boo 61 | -------------------------------------------------------------------------------- /soxr/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | # Licence for this file: LGPL v2.1 See LICENCE for details. 3 | 4 | add_definitions (${PROJECT_C_FLAGS}) 5 | link_libraries (soxr) 6 | 7 | file (GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c) 8 | foreach (fe ${SOURCES}) 9 | get_filename_component (f ${fe} NAME_WE) 10 | add_executable (${f} ${fe}) 11 | endforeach () 12 | 13 | enable_testing () 14 | 15 | set (sweep_to_freq 22050) 16 | set (leader 1) 17 | set (len 16) 18 | math (EXPR base_rate "${sweep_to_freq} + ${sweep_to_freq}") 19 | 20 | macro (add_vector r) 21 | set (output ${CMAKE_CURRENT_BINARY_DIR}/ref-${r}.s32) 22 | add_custom_command (OUTPUT ${output} DEPENDS vector-gen ${CMAKE_CURRENT_LIST_FILE} 23 | COMMAND vector-gen ${r} ${leader} ${len} ${sweep_to_freq} 1 ${output}) 24 | set (vectors ${output} ${vectors}) 25 | endmacro () 26 | 27 | macro (add_cmp_test from to bits) 28 | set (name ${bits}-bit-perfect-${from}-${to}) 29 | add_test (NAME ${name} COMMAND ${CMAKE_COMMAND} -Dbits=${bits} -DBIN=${BIN} -DEXAMPLES_BIN=${EXAMPLES_BIN} -Dleader=${leader} -Dto=${to} 30 | -Dfrom=${from} -Dlen=${len} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmp-test.cmake) 31 | add_vector (${from}) 32 | add_vector (${to}) 33 | endmacro () 34 | 35 | unset (test_bits) 36 | if (WITH_SINGLE_PRECISION) 37 | set (test_bits 20) 38 | endif () 39 | if (WITH_DOUBLE_PRECISION) 40 | set (test_bits ${test_bits} 24) 41 | endif () 42 | 43 | foreach (b ${test_bits}) 44 | foreach (r 96000 65537) 45 | add_cmp_test (${base_rate} ${r} ${b}) 46 | add_cmp_test (${r} ${base_rate} ${b}) 47 | endforeach () 48 | endforeach () 49 | 50 | add_custom_target (test-vectors ALL DEPENDS ${vectors}) 51 | 52 | add_test (1-delay-clear ${BIN}1-delay-clear) 53 | -------------------------------------------------------------------------------- /include/boo/audiodev/IMIDIPort.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace boo { 10 | struct IAudioVoiceEngine; 11 | using ReceiveFunctor = std::function&&, double time)>; 12 | 13 | class IMIDIPort { 14 | bool m_virtual; 15 | 16 | protected: 17 | IAudioVoiceEngine* m_parent; 18 | IMIDIPort(IAudioVoiceEngine* parent, bool virt) : m_virtual(virt), m_parent(parent) {} 19 | 20 | public: 21 | virtual ~IMIDIPort(); 22 | bool isVirtual() const { return m_virtual; } 23 | virtual std::string description() const = 0; 24 | void _disown() { m_parent = nullptr; } 25 | }; 26 | 27 | class IMIDIReceiver { 28 | public: 29 | ReceiveFunctor m_receiver; 30 | IMIDIReceiver(ReceiveFunctor&& receiver) : m_receiver(std::move(receiver)) {} 31 | }; 32 | 33 | class IMIDIIn : public IMIDIPort, public IMIDIReceiver { 34 | protected: 35 | IMIDIIn(IAudioVoiceEngine* parent, bool virt, ReceiveFunctor&& receiver) 36 | : IMIDIPort(parent, virt), IMIDIReceiver(std::move(receiver)) {} 37 | 38 | public: 39 | ~IMIDIIn() override; 40 | }; 41 | 42 | class IMIDIOut : public IMIDIPort { 43 | protected: 44 | IMIDIOut(IAudioVoiceEngine* parent, bool virt) : IMIDIPort(parent, virt) {} 45 | 46 | public: 47 | ~IMIDIOut() override; 48 | virtual size_t send(const void* buf, size_t len) const = 0; 49 | }; 50 | 51 | class IMIDIInOut : public IMIDIPort, public IMIDIReceiver { 52 | protected: 53 | IMIDIInOut(IAudioVoiceEngine* parent, bool virt, ReceiveFunctor&& receiver) 54 | : IMIDIPort(parent, virt), IMIDIReceiver(std::move(receiver)) {} 55 | 56 | public: 57 | ~IMIDIInOut() override; 58 | virtual size_t send(const void* buf, size_t len) const = 0; 59 | }; 60 | 61 | } // namespace boo 62 | -------------------------------------------------------------------------------- /soxr/tests/vector-cmp.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Utility used to help test the library; not for general consumption. 5 | * 6 | * Compare two swept-sine files. */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "../src/rint.h" 12 | 13 | int main(int bit, char const * arg[]) 14 | { 15 | FILE * f1 = fopen(arg[1], "rb"), 16 | * f2 = fopen(arg[2], "rb"); 17 | double rate = atof (arg[3]), /* Rate for this vector */ 18 | leader_len = atof (arg[4]), /* Leader length in seconds */ 19 | len = atof (arg[5]), /* Sweep length (excl. leader_len) */ 20 | expect_bits= atof (arg[6]), 21 | expect_bw = atof (arg[7]); 22 | 23 | int32_t s1, s2; 24 | long count = 0; 25 | static long thresh[32]; 26 | double bw, prev = 0; 27 | 28 | for (; fread(&s1, sizeof(s1), 1, f1) == 1 && 29 | fread(&s2, sizeof(s2), 1, f2) == 1; ++count) { 30 | long diff = abs((int)(s1 - s2)); 31 | for (bit = 0; diff && bit < 32; bit++, diff >>= 1) 32 | if ((diff & 1) && !thresh[bit]) 33 | thresh[bit] = count + 1; 34 | } 35 | 36 | if (count != (long)((leader_len + len) * rate + .5)) { 37 | printf("incorrect file length\n"); 38 | exit(1); 39 | } 40 | 41 | for (bit = 0; bit < 32; ++bit) { 42 | bw = ((double)thresh[bit] - 1) / rate - leader_len; 43 | if (bit && bw >= 0 && (bw - prev) * 100 / len < .08) { 44 | --bit; 45 | break; 46 | } 47 | prev = bw; 48 | } 49 | bit = 32 - bit; 50 | bw = bw * 100 / len; 51 | printf("Bit perfect to %i bits, from DC to %.2f%% nyquist.\n", bit, bw); 52 | return !(bit >= expect_bits && bw >= expect_bw); 53 | } 54 | -------------------------------------------------------------------------------- /include/boo/inputdev/DeviceSignature.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace boo { 11 | 12 | enum class DeviceType { None = 0, USB = 1, Bluetooth = 2, HID = 3, XInput = 4 }; 13 | 14 | class DeviceToken; 15 | class DeviceBase; 16 | 17 | #define dev_typeid(type) std::hash()(#type) 18 | 19 | struct DeviceSignature { 20 | using TDeviceSignatureSet = std::vector; 21 | using TFactoryLambda = std::function(DeviceToken*)>; 22 | 23 | const char* m_name = nullptr; 24 | uint64_t m_typeHash = 0; 25 | unsigned m_vid = 0; 26 | unsigned m_pid = 0; 27 | TFactoryLambda m_factory; 28 | DeviceType m_type{}; 29 | DeviceSignature() : m_typeHash(dev_typeid(DeviceSignature)) {} /* Sentinel constructor */ 30 | DeviceSignature(const char* name, uint64_t typeHash, unsigned vid, unsigned pid, TFactoryLambda&& factory, 31 | DeviceType type = DeviceType::None) 32 | : m_name(name), m_typeHash(typeHash), m_vid(vid), m_pid(pid), m_factory(factory), m_type(type) {} 33 | static bool DeviceMatchToken(const DeviceToken& token, const TDeviceSignatureSet& sigSet); 34 | static std::shared_ptr DeviceNew(DeviceToken& token); 35 | }; 36 | 37 | #define DEVICE_SIG(name, vid, pid, type) \ 38 | DeviceSignature(#name, dev_typeid(name), vid, pid, \ 39 | [](DeviceToken* tok) -> std::shared_ptr { return std::make_shared(tok); }, type) 40 | #define DEVICE_SIG_SENTINEL() DeviceSignature() 41 | 42 | extern const DeviceSignature BOO_DEVICE_SIGS[]; 43 | 44 | } // namespace boo 45 | -------------------------------------------------------------------------------- /soxr/src/filter.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #if !defined soxr_filter_included 5 | #define soxr_filter_included 6 | 7 | #include "aliases.h" 8 | 9 | double lsx_bessel_I_0(double x); 10 | void lsx_init_fft_cache(void); 11 | void lsx_clear_fft_cache(void); 12 | void lsx_init_fft_cache_f(void); 13 | void lsx_clear_fft_cache_f(void); 14 | #define lsx_is_power_of_2(x) !(x < 2 || (x & (x - 1))) 15 | void lsx_safe_rdft(int len, int type, double * d); 16 | void lsx_safe_cdft(int len, int type, double * d); 17 | void lsx_safe_rdft_f(int len, int type, float * d); 18 | void lsx_safe_cdft_f(int len, int type, float * d); 19 | void lsx_ordered_convolve(int n, void * not_used, double * a, const double * b); 20 | void lsx_ordered_convolve_f(int n, void * not_used, float * a, const float * b); 21 | void lsx_ordered_partial_convolve(int n, double * a, const double * b); 22 | void lsx_ordered_partial_convolve_f(int n, float * a, const float * b); 23 | 24 | double lsx_kaiser_beta(double att, double tr_bw); 25 | double * lsx_make_lpf(int num_taps, double Fc, double beta, double rho, 26 | double scale); 27 | void lsx_kaiser_params(double att, double Fc, double tr_bw, double * beta, int * num_taps); 28 | double * lsx_design_lpf( 29 | double Fp, /* End of pass-band */ 30 | double Fs, /* Start of stop-band */ 31 | double Fn, /* Nyquist freq; e.g. 0.5, 1, PI; < 0: dummy run */ 32 | double att, /* Stop-band attenuation in dB */ 33 | int * num_taps, /* 0: value will be estimated */ 34 | int k, /* >0: number of phases; <0: num_taps ≡ 1 (mod -k) */ 35 | double beta); /* <0: value will be estimated */ 36 | void lsx_fir_to_phase(double * * h, int * len, 37 | int * post_len, double phase0); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /soxr/tests/vector-gen.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Utility used to help test the library; not for general consumption. 5 | * 6 | * Generate a swept sine to a file, with faded `lead-in' section. */ 7 | 8 | #define QUAD 0 9 | 10 | #if QUAD 11 | #include 12 | #endif 13 | 14 | #include "../examples/examples-common.h" 15 | 16 | #if QUAD 17 | #define modf modfq 18 | #define cos cosq 19 | #define sin sinq 20 | #undef M_PI 21 | #define M_PI M_PIq 22 | #define real __float128 23 | #define atof(x) strtoflt128(x, 0) 24 | #else 25 | #define real double 26 | #include "rint.h" 27 | #endif 28 | 29 | int main(int i, char const * argv[]) 30 | { 31 | real rate = atof(argv[1]), /* Rate for this vector */ 32 | lead_in_len = atof(argv[2]), /* Lead-in length in seconds */ 33 | len = atof(argv[3]), /* Sweep length (excl. lead_in_len) */ 34 | sweep_to_freq = atof(argv[4]), /* Sweep from DC to this freq. */ 35 | multiplier = atof(argv[5]), /* For headroom */ 36 | f1 = -sweep_to_freq / len * lead_in_len, f2 = sweep_to_freq, 37 | n1 = rate * -lead_in_len, n2 = rate * len, 38 | m = (f2 - f1) / (n2 - n1) / 2, dummy; 39 | FILE * file = fopen(argv[6], "wb"); 40 | i = (int)n1; 41 | if (!file || i != n1) 42 | exit(1); 43 | for (; i < (int)(n2 + .5); ++i) { 44 | double d1 = multiplier * sin(2 * M_PI * modf(i * m * i / rate, &dummy)); 45 | double d = i < 0? d1 * (1 - cos(M_PI * (i + n1) / n1)) * .5 : d1; 46 | #if QUAD 47 | size_t actual = fwrite(&d, sizeof(d), 1, file); 48 | #else 49 | int32_t out = rint32(d * (32768. * 65536 - 1)); 50 | size_t actual = fwrite(&out, sizeof(out), 1, file); 51 | #endif 52 | if (actual != 1) 53 | return 1; 54 | } 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /include/boo/audiodev/MIDIEncoder.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "boo/audiodev/IMIDIReader.hpp" 7 | 8 | namespace boo { 9 | 10 | template 11 | class MIDIEncoder : public IMIDIReader { 12 | Sender& m_sender; 13 | uint8_t m_status = 0; 14 | 15 | void _sendMessage(const uint8_t* data, size_t len); 16 | 17 | template 18 | void _sendMessage(const ContiguousContainer& container) { 19 | _sendMessage(std::data(container), std::size(container)); 20 | } 21 | 22 | void _sendContinuedValue(uint32_t val); 23 | 24 | public: 25 | MIDIEncoder(Sender& sender) : m_sender(sender) {} 26 | 27 | void noteOff(uint8_t chan, uint8_t key, uint8_t velocity) override; 28 | void noteOn(uint8_t chan, uint8_t key, uint8_t velocity) override; 29 | void notePressure(uint8_t chan, uint8_t key, uint8_t pressure) override; 30 | void controlChange(uint8_t chan, uint8_t control, uint8_t value) override; 31 | void programChange(uint8_t chan, uint8_t program) override; 32 | void channelPressure(uint8_t chan, uint8_t pressure) override; 33 | void pitchBend(uint8_t chan, int16_t pitch) override; 34 | 35 | void allSoundOff(uint8_t chan) override; 36 | void resetAllControllers(uint8_t chan) override; 37 | void localControl(uint8_t chan, bool on) override; 38 | void allNotesOff(uint8_t chan) override; 39 | void omniMode(uint8_t chan, bool on) override; 40 | void polyMode(uint8_t chan, bool on) override; 41 | 42 | void sysex(const void* data, size_t len) override; 43 | void timeCodeQuarterFrame(uint8_t message, uint8_t value) override; 44 | void songPositionPointer(uint16_t pointer) override; 45 | void songSelect(uint8_t song) override; 46 | void tuneRequest() override; 47 | 48 | void startSeq() override; 49 | void continueSeq() override; 50 | void stopSeq() override; 51 | 52 | void reset() override; 53 | }; 54 | 55 | } // namespace boo 56 | -------------------------------------------------------------------------------- /lib/x11/ApplicationWayland.hpp: -------------------------------------------------------------------------------- 1 | #ifndef APPLICATION_UNIX_CPP 2 | #error This file may only be included from CApplicationUnix.cpp 3 | #endif 4 | 5 | #include "boo/IApplication.hpp" 6 | 7 | #include 8 | DBusConnection* RegisterDBus(const char* appName, bool& isFirst); 9 | 10 | namespace boo { 11 | 12 | std::shared_ptr _WindowWaylandNew(std::string_view title); 13 | 14 | class ApplicationWayland final : public IApplication { 15 | IApplicationCallback& m_callback; 16 | const std::string m_uniqueName; 17 | const std::string m_friendlyName; 18 | const std::string m_pname; 19 | const std::vector m_args; 20 | bool m_singleInstance; 21 | 22 | void _deletedWindow([[maybe_unused]] IWindow* window) override {} 23 | 24 | public: 25 | ApplicationWayland(IApplicationCallback& callback, std::string_view uniqueName, std::string_view friendlyName, 26 | std::string_view pname, const std::vector& args, std::string_view gfxApi, 27 | uint32_t samples, uint32_t anisotropy, bool deepColor, bool singleInstance) 28 | : m_callback(callback) 29 | , m_uniqueName(uniqueName) 30 | , m_friendlyName(friendlyName) 31 | , m_pname(pname) 32 | , m_args(args) 33 | , m_singleInstance(singleInstance) { 34 | (void)m_callback; 35 | (void)m_singleInstance; 36 | } 37 | 38 | EPlatformType getPlatformType() const override { return EPlatformType::Wayland; } 39 | 40 | int run() override { return 0; } 41 | 42 | std::string_view getUniqueName() const override { return m_uniqueName; } 43 | 44 | std::string_view getFriendlyName() const override { return m_friendlyName; } 45 | 46 | std::string_view getProcessName() const override { return m_pname; } 47 | 48 | const std::vector& getArgs() const override { return m_args; } 49 | 50 | std::shared_ptr newWindow(std::string_view title) override { return _WindowWaylandNew(title); } 51 | }; 52 | 53 | } // namespace boo 54 | -------------------------------------------------------------------------------- /soxr/src/aliases.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #if defined SOXR_LIB 5 | 6 | #define lsx_bessel_I_0 _soxr_bessel_I_0 7 | #define lsx_cdft_f _soxr_cdft_f 8 | #define lsx_cdft _soxr_cdft 9 | #define lsx_clear_fft_cache_f _soxr_clear_fft_cache_f 10 | #define lsx_clear_fft_cache _soxr_clear_fft_cache 11 | #define lsx_ddct_f _soxr_ddct_f 12 | #define lsx_ddct _soxr_ddct 13 | #define lsx_ddst_f _soxr_ddst_f 14 | #define lsx_ddst _soxr_ddst 15 | #define lsx_design_lpf _soxr_design_lpf 16 | #define lsx_dfct_f _soxr_dfct_f 17 | #define lsx_dfct _soxr_dfct 18 | #define lsx_dfst_f _soxr_dfst_f 19 | #define lsx_dfst _soxr_dfst 20 | #define lsx_fir_to_phase _soxr_fir_to_phase 21 | #define lsx_init_fft_cache_f _soxr_init_fft_cache_f 22 | #define lsx_init_fft_cache _soxr_init_fft_cache 23 | #define lsx_kaiser_beta _soxr_kaiser_beta 24 | #define lsx_kaiser_params _soxr_kaiser_params 25 | #define lsx_make_lpf _soxr_make_lpf 26 | #define lsx_ordered_convolve_f _soxr_ordered_convolve_f 27 | #define lsx_ordered_convolve _soxr_ordered_convolve 28 | #define lsx_ordered_partial_convolve_f _soxr_ordered_partial_convolve_f 29 | #define lsx_ordered_partial_convolve _soxr_ordered_partial_convolve 30 | #define lsx_rdft_f _soxr_rdft_f 31 | #define lsx_rdft _soxr_rdft 32 | #define lsx_safe_cdft_f _soxr_safe_cdft_f 33 | #define lsx_safe_cdft _soxr_safe_cdft 34 | #define lsx_safe_rdft_f _soxr_safe_rdft_f 35 | #define lsx_safe_rdft _soxr_safe_rdft 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /soxr/src/rint.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #if !defined soxr_rint_included 5 | #define soxr_rint_included 6 | 7 | #include "soxr-config.h" 8 | 9 | 10 | 11 | #if HAVE_LRINT && LONG_MAX == 2147483647L 12 | #include 13 | #define FPU_RINT32 14 | #define rint32 lrint 15 | #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__) 16 | #define FPU_RINT32 17 | static __inline int32_t rint32(double input) { 18 | int32_t result; 19 | __asm__ __volatile__("fistpl %0": "=m"(result): "t"(input): "st"); 20 | return result; 21 | } 22 | #elif defined __GNUC__ && defined __arm__ 23 | #define FPU_RINT32 24 | static __inline int32_t rint32(double input) { 25 | register int32_t result; 26 | __asm__ __volatile__ ("ftosid %0, %P1": "=w"(result): "w"(input)); 27 | return result; 28 | } 29 | #elif defined _MSC_VER && defined _M_IX86 /* FIXME need solution for MSVC x64 */ 30 | #define FPU_RINT32 31 | static __inline int32_t rint32(double input) { 32 | int32_t result; 33 | _asm { 34 | fld input 35 | fistp result 36 | } 37 | return result; 38 | } 39 | #else 40 | #define rint32(x) (int32_t)((x) < 0? x - .5 : x + .5) 41 | #endif 42 | 43 | 44 | 45 | #if defined __GNUC__ && (defined __i386__ || defined __x86_64__) 46 | #define FPU_RINT16 47 | static __inline int16_t rint16(double input) { 48 | int16_t result; 49 | __asm__ __volatile__("fistps %0": "=m"(result): "t"(input): "st"); 50 | return result; 51 | } 52 | #elif defined _MSC_VER && defined _M_IX86 /* FIXME need solution for MSVC x64 */ 53 | #define FPU_RINT16 54 | static __inline int16_t rint16(double input) { 55 | int16_t result; 56 | _asm { 57 | fld input 58 | fistp result 59 | } 60 | return result; 61 | } 62 | #else 63 | #define rint16(x) (int16_t)((x) < 0? x - .5 : x + .5) 64 | #endif 65 | 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /soxr/NEWS: -------------------------------------------------------------------------------- 1 | Version 0.1.2 (2015-09-05) 2 | * Fix conversion failure when I/O types differ but I/O rates don't. 3 | * Fix #defines for interpolation order selection. 4 | * Fix ineffectual SOXR_MINIMUM_PHASE and SOXR_INTERMEDIATE_PHASE in 5 | soxr_quality_spec recipe. 6 | * Fix soxr_delay() returning a negative number after end-of-input has been 7 | indicated. 8 | * Fix crash when using soxr_process() after calling soxr_clear(). 9 | * Be more POSIX compliant w.r.t. errno in the examples; fixes erroneous 10 | reporting of errors on FreeBSD. 11 | * Quality improvement for variable-rate. 12 | * Various fixes/improvements to build/tests/documentation. 13 | 14 | Version 0.1.1 (2013-03-03) 15 | * Minor fixes/improvements to build/tests. 16 | * Fix crash (e.g. with k3b) when null error pointer passed to src_create (lsr 17 | bindings only). 18 | * Fix broken resampling in many cases with SIMD and anti_aliasing_pc < 100. 19 | * For clarity, renamed and slightly changed usage of three parameters in 20 | soxr_quality_spec_t (ABI compatible, API incompatible). An application not 21 | setting these parameters directly need make no change; otherwise, changes 22 | should be made per the following example (as shown, compatibility with both 23 | old/new APIs is maintained). See also the comments on these parameters in 24 | soxr.h. N.B. ABI compatibility with the 0.1.0 API may be removed in a 25 | future release. 26 | #if !defined SOXR_VERSION /* Deprecated, 0.1.0 API */ 27 | q_spec.phase = minimum_phase? 0 : 50; 28 | q_spec.bw_pc = cutoff * 100; 29 | q_spec.anti_aliasing_pc = anti_aliasing * 100; 30 | #else /* 0.1.1 API */ Explanation: 31 | q_spec.phase_response = minimum_phase? 0 : 50; Renamed. 32 | q_spec.passband_end = cutoff; Renamed, no longer %. 33 | q_spec.stopband_begin = 2 - anti_aliasing; Renamed, no longer %, no 34 | #endif longer mirrored in Fs. 35 | 36 | Version 0.1.0 (2013-01-19) 37 | * First public release. 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Boo Mascot
Charlie 4 |
5 |

6 | 7 | ### Boo 8 | 9 | **Boo** is a cross-platform windowing and event manager similar to 10 | SDL or SFML, with additional 3D rendering functionality. 11 | 12 | The primary focus of Boo is 2D/3D rendering using polygon-rasterization 13 | APIs like OpenGL or Direct3D. It exposes a unified command-queue API for 14 | calling the underlying graphics API. 15 | 16 | The only per-platform responsibility of the client code is providing the 17 | shaders' source. Drawing, resource-management and state-switching are 18 | performed using the unified API; these may be written once for all platforms. 19 | 20 | Boo also features a unified audio API for mixing voices and performing variable 21 | sample-rate-conversion. All audio computation occurs on the CPU, synchronously 'pumped' 22 | by the client each frame-iteration. 23 | 24 | Client code is entered via the `appMain` method supplied in a callback object. 25 | This code executes on a dedicated thread with graphics command context available. 26 | The API may be used to synchronize loops on the client thread with the display 27 | refresh-rate. 28 | 29 | #### Supported Graphics Backends 30 | 31 | * OpenGL 3.3+ 32 | * Direct3D 11 33 | * Metal 1.1 (OS X 10.11 only for now, iOS coming soon) 34 | * Vulkan 35 | 36 | #### Supported Audio Backends 37 | 38 | * **[Windows]** WASAPI 39 | * **[OS X]** Audio Queue Services 40 | * **[Linux]** ALSA 41 | 42 | #### Pro Logic II Encoding Support 43 | 44 | The Boo audio engine supports real-time Pro Logic II surround matrixing for 5.1 client mixes. 45 | Call `IAudioVoiceEngine::enableLtRt(true);` to enable this functionality. 46 | 47 | **Note:** Before building Boo, the [Intel Integrated Performance Primitives](https://software.intel.com/en-us/intel-ipp) 48 | must be installed for full surround-sound encoding capabilities. Without this library, only the left, right, and center 49 | channels will be encoded. The surround channels are phase-shifted 90-degrees using the Hilbert functions in the library. 50 | -------------------------------------------------------------------------------- /include/boo/inputdev/DeviceToken.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "boo/inputdev/DeviceBase.hpp" 7 | #include "boo/inputdev/DeviceSignature.hpp" 8 | 9 | namespace boo { 10 | 11 | class DeviceToken { 12 | friend struct DeviceSignature; 13 | friend class HIDListenerWinUSB; 14 | DeviceType m_devType; 15 | unsigned m_vendorId; 16 | unsigned m_productId; 17 | std::string m_vendorName; 18 | std::string m_productName; 19 | std::string m_devPath; 20 | 21 | friend class DeviceBase; 22 | std::shared_ptr m_connectedDev; 23 | 24 | friend class DeviceFinder; 25 | void _deviceClose() { 26 | if (m_connectedDev) 27 | m_connectedDev->_deviceDisconnected(); 28 | m_connectedDev = NULL; 29 | } 30 | 31 | public: 32 | DeviceToken(const DeviceToken&) = delete; 33 | DeviceToken(DeviceToken&& other) noexcept = default; 34 | DeviceToken(DeviceType devType, unsigned vid, unsigned pid, const char* vname, const char* pname, const char* path) 35 | : m_devType(devType), m_vendorId(vid), m_productId(pid), m_devPath(path), m_connectedDev(NULL) { 36 | if (vname) 37 | m_vendorName = vname; 38 | if (pname) 39 | m_productName = pname; 40 | } 41 | 42 | DeviceToken& operator=(const DeviceToken&) = delete; 43 | DeviceToken& operator=(DeviceToken&&) noexcept = default; 44 | 45 | bool operator==(const DeviceToken& rhs) const { return m_devPath == rhs.m_devPath; } 46 | bool operator<(const DeviceToken& rhs) const { return m_devPath < rhs.m_devPath; } 47 | 48 | DeviceType getDeviceType() const { return m_devType; } 49 | unsigned getVendorId() const { return m_vendorId; } 50 | unsigned getProductId() const { return m_productId; } 51 | std::string_view getVendorName() const { return m_vendorName; } 52 | std::string_view getProductName() const { return m_productName; } 53 | std::string_view getDevicePath() const { return m_devPath; } 54 | bool isDeviceOpen() const { return (m_connectedDev != NULL); } 55 | std::shared_ptr openAndGetDevice() { 56 | if (!m_connectedDev) 57 | m_connectedDev = DeviceSignature::DeviceNew(*this); 58 | return m_connectedDev; 59 | } 60 | }; 61 | 62 | } // namespace boo 63 | -------------------------------------------------------------------------------- /lib/audiodev/LtRtProcessing.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "boo/System.hpp" 7 | #include "boo/audiodev/IAudioVoice.hpp" 8 | #include "lib/audiodev/Common.hpp" 9 | 10 | #if INTEL_IPP 11 | #include "ipp.h" 12 | #endif 13 | 14 | namespace boo { 15 | 16 | #if INTEL_IPP 17 | #define USE_LPF 0 18 | 19 | #if USE_LPF 20 | class FIRFilter12k { 21 | IppsFIRSpec_32f* m_firSpec; 22 | Ipp8u* m_firBuffer; 23 | Ipp32f* m_dlySrc; 24 | Ipp32f* m_inBuf; 25 | 26 | public: 27 | explicit FIRFilter12k(int windowFrames, double sampleRate); 28 | ~FIRFilter12k(); 29 | void Process(Ipp32f* buf, int windowFrames); 30 | }; 31 | #endif 32 | 33 | class WindowedHilbert { 34 | #if USE_LPF 35 | FIRFilter12k m_fir; 36 | #endif 37 | IppsHilbertSpec* m_spec; 38 | Ipp8u* m_buffer; 39 | int m_windowFrames, m_halfFrames; 40 | int m_bufIdx = 0; 41 | Ipp32f* m_inputBuf; 42 | Ipp32fc* m_outputBuf; 43 | Ipp32fc* m_output[4]; 44 | Ipp32f* m_hammingTable; 45 | void _AddWindow(); 46 | 47 | public: 48 | explicit WindowedHilbert(int windowFrames, double sampleRate); 49 | ~WindowedHilbert(); 50 | void AddWindow(const float* input, int stride); 51 | void AddWindow(const int32_t* input, int stride); 52 | void AddWindow(const int16_t* input, int stride); 53 | template 54 | void Output(T* output, float lCoef, float rCoef) const; 55 | }; 56 | #endif 57 | 58 | class LtRtProcessing { 59 | AudioVoiceEngineMixInfo m_inMixInfo; 60 | int m_windowFrames; 61 | int m_halfFrames; 62 | int m_outputOffset; 63 | int m_bufferTail = 0; 64 | int m_bufferHead = 0; 65 | std::unique_ptr m_16Buffer; 66 | std::unique_ptr m_32Buffer; 67 | std::unique_ptr m_fltBuffer; 68 | #if INTEL_IPP 69 | WindowedHilbert m_hilbertSL, m_hilbertSR; 70 | #endif 71 | template 72 | T* _getInBuf(); 73 | template 74 | T* _getOutBuf(); 75 | 76 | public: 77 | LtRtProcessing(int _5msFrames, const AudioVoiceEngineMixInfo& mixInfo); 78 | template 79 | void Process(const T* input, T* output, int frameCount); 80 | const AudioVoiceEngineMixInfo& inMixInfo() const { return m_inMixInfo; } 81 | }; 82 | 83 | } // namespace boo 84 | -------------------------------------------------------------------------------- /soxr/examples/1-single-block.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Example 1: `One-shot' resample a single block of data in memory. 5 | * 6 | * N.B. See example 2 for how to resample a stream (of blocks). 7 | * 8 | * Optional arguments are: INPUT-RATE OUTPUT-RATE 9 | * 10 | * With the default arguments, the output should produce lines similar to the 11 | * following: 12 | * 13 | * 0.00 0.71 1.00 0.71 -0.00 -0.71 -1.00 -0.71 14 | * 15 | * Gibbs effect may be seen at the ends of the resampled signal; this is because 16 | * unlike a `real-world' signal, the synthetic input signal is not band-limited. 17 | */ 18 | 19 | #include 20 | #include "examples-common.h" 21 | 22 | const float in[] = { /* Input: 12 cycles of a sine wave with freq. = irate/4 */ 23 | 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 24 | 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1, 0,1,0,-1}; 25 | 26 | int main(int argc, char const * arg[]) 27 | { 28 | double irate = argc > 1? atof(arg[1]) : 1; /* Default to upsampling */ 29 | double orate = argc > 2? atof(arg[2]) : 2; /* by a factor of 2. */ 30 | 31 | size_t olen = (size_t)(AL(in) * orate / irate + .5); /* Assay output len. */ 32 | float * out = malloc(sizeof(*out) * olen); /* Allocate output buffer. */ 33 | size_t odone; 34 | 35 | soxr_error_t error = soxr_oneshot(irate, orate, 1, /* Rates and # of chans. */ 36 | in, AL(in), NULL, /* Input. */ 37 | out, olen, &odone, /* Output. */ 38 | NULL, NULL, NULL); /* Default configuration.*/ 39 | 40 | unsigned i = 0; /* Print out the resampled data, */ 41 | while (i++ < odone) 42 | printf("%5.2f%c", out[i-1], " \n"[!(i&7) || i == odone]); 43 | printf("%-26s %s\n", arg[0], soxr_strerror(error)); /* and reported result. */ 44 | 45 | if (argc > 3) /* Library version check: */ 46 | printf("runtime=%s API="SOXR_THIS_VERSION_STR"\n", soxr_version()); 47 | 48 | free(out); /* Tidy up. */ 49 | return !!error; 50 | } 51 | -------------------------------------------------------------------------------- /soxr/tests/1-delay-clear.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Test 1: exercises soxr_delay and soxr_clear */ 5 | 6 | #ifdef NDEBUG /* N.B. assert used with active statements so enable always. */ 7 | #undef NDEBUG /* Must undef above assert.h or other that might include it. */ 8 | #endif 9 | 10 | #include 11 | #include "../examples/examples-common.h" 12 | 13 | #define ranqd1(x) ((x) = 1664525 * (x) + 1013904223) /* int32_t x */ 14 | #define franqd1(x) (float)(ranqd1(x) * (1. / (65536. * 32768.))) /* [-1,1) */ 15 | 16 | #define irate 9600 17 | #define orate 4410 18 | 19 | int main(int argc, char const * arg[]) 20 | { 21 | soxr_error_t error; 22 | int32_t ran = 0; 23 | int j; 24 | 25 | soxr_t soxr = soxr_create(irate, orate, 1, &error, NULL, NULL, NULL); 26 | assert(!error); 27 | 28 | for (j=0; j<2; ++j) { 29 | float ibuf[irate], out[orate+2], obuf[orate+2], * ibuf1 = ibuf; 30 | size_t ilen = AL(ibuf)-1, olen = AL(obuf), i, odone = 0, odone0, odone1=0; 31 | soxr_quality_spec_t q_spec = soxr_quality_spec(SOXR_HQ, 0); 32 | 33 | for (i=0; i= 0); 45 | fprintf(stderr, "%5u %5u %5u\n", 46 | (unsigned)ilen, max_out_samples, (unsigned)odone); 47 | assert(max_out_samples+odone==odone0); 48 | error = soxr_process(soxr, ibuf1, ilen, NULL, obuf+odone, olen, &odone1); 49 | assert(!error); 50 | odone += odone1; 51 | ibuf1 = NULL, ilen = 0; 52 | olen = min(100, AL(obuf)-odone); 53 | } 54 | assert(odone==odone0); 55 | 56 | for (i=0; i 16 | 17 | typedef struct { 18 | int readcount, writecount; /* initial value = 0 */ 19 | omp_lock_t mutex_1, mutex_2, mutex_3, w, r; /* initial value = 1 */ 20 | } ccrw2_t; /* Problem #2: `writers-preference' */ 21 | 22 | #define ccrw2_become_reader(p) do {\ 23 | omp_set_lock(&p.mutex_3);\ 24 | omp_set_lock(&p.r);\ 25 | omp_set_lock(&p.mutex_1);\ 26 | if (++p.readcount == 1) omp_set_lock(&p.w);\ 27 | omp_unset_lock(&p.mutex_1);\ 28 | omp_unset_lock(&p.r);\ 29 | omp_unset_lock(&p.mutex_3);\ 30 | } while (0) 31 | #define ccrw2_cease_reading(p) do {\ 32 | omp_set_lock(&p.mutex_1);\ 33 | if (!--p.readcount) omp_unset_lock(&p.w);\ 34 | omp_unset_lock(&p.mutex_1);\ 35 | } while (0) 36 | #define ccrw2_become_writer(p) do {\ 37 | omp_set_lock(&p.mutex_2);\ 38 | if (++p.writecount == 1) omp_set_lock(&p.r);\ 39 | omp_unset_lock(&p.mutex_2);\ 40 | omp_set_lock(&p.w);\ 41 | } while (0) 42 | #define ccrw2_cease_writing(p) do {\ 43 | omp_unset_lock(&p.w);\ 44 | omp_set_lock(&p.mutex_2);\ 45 | if (!--p.writecount) omp_unset_lock(&p.r);\ 46 | omp_unset_lock(&p.mutex_2);\ 47 | } while (0) 48 | #define ccrw2_init(p) do {\ 49 | omp_init_lock(&p.mutex_1);\ 50 | omp_init_lock(&p.mutex_2);\ 51 | omp_init_lock(&p.mutex_3);\ 52 | omp_init_lock(&p.w);\ 53 | omp_init_lock(&p.r);\ 54 | } while (0) 55 | #define ccrw2_clear(p) do {\ 56 | omp_destroy_lock(&p.r);\ 57 | omp_destroy_lock(&p.w);\ 58 | omp_destroy_lock(&p.mutex_3);\ 59 | omp_destroy_lock(&p.mutex_2);\ 60 | omp_destroy_lock(&p.mutex_1);\ 61 | } while (0) 62 | 63 | #else 64 | 65 | typedef int ccrw2_t; 66 | #define ccrw2_become_reader(x) (void)(x) 67 | #define ccrw2_cease_reading(x) (void)(x) 68 | #define ccrw2_become_writer(x) (void)(x) 69 | #define ccrw2_cease_writing(x) (void)(x) 70 | #define ccrw2_init(x) (void)(x) 71 | #define ccrw2_clear(x) (void)(x) 72 | 73 | #endif /* _OPENMP */ 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /soxr/src/half_coefs.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #if defined __GNUC__ 5 | #pragma GCC system_header 6 | #elif defined __SUNPRO_C 7 | #pragma disable_warn 8 | #elif defined _MSC_VER 9 | #pragma warning(push, 1) 10 | #endif 11 | 12 | static const sample_t half_fir_coefs_8[] = { 13 | 0.3115465451887802, -0.08734497241282892, 0.03681452335604365, 14 | -0.01518925831569441, 0.005454118437408876, -0.001564400922162005, 15 | 0.0003181701445034203, -3.48001341225749e-5, 16 | }; 17 | 18 | static const sample_t half_fir_coefs_9[] = { 19 | 0.3122703613711853, -0.08922155288172305, 0.03913974805854332, 20 | -0.01725059723447163, 0.006858970092378141, -0.002304518467568703, 21 | 0.0006096426006051062, -0.0001132393923815236, 1.119795386287666e-5, 22 | }; 23 | 24 | static const sample_t half_fir_coefs_10[] = { 25 | 0.3128545521327376, -0.09075671986104322, 0.04109637155154835, 26 | -0.01906629512749895, 0.008184039342054333, -0.0030766775017262, 27 | 0.0009639607022414314, -0.0002358552746579827, 4.025184282444155e-5, 28 | -3.629779111541012e-6, 29 | }; 30 | 31 | static const sample_t half_fir_coefs_11[] = { 32 | 0.3133358837508807, -0.09203588680609488, 0.04276515428384758, 33 | -0.02067356614745591, 0.00942253142371517, -0.003856330993895144, 34 | 0.001363470684892284, -0.0003987400965541919, 9.058629923971627e-5, 35 | -1.428553070915318e-5, 1.183455238783835e-6, 36 | }; 37 | 38 | static const sample_t half_fir_coefs_12[] = { 39 | 0.3137392991811407, -0.0931182192961332, 0.0442050575271454, 40 | -0.02210391200618091, 0.01057473015666001, -0.00462766983973885, 41 | 0.001793630226239453, -0.0005961819959665878, 0.0001631475979359577, 42 | -3.45557865639653e-5, 5.06188341942088e-6, -3.877010943315563e-7, 43 | }; 44 | 45 | static const sample_t half_fir_coefs_13[] = { 46 | 0.3140822554324578, -0.0940458550886253, 0.04545990399121566, 47 | -0.02338339450796002, 0.01164429409071052, -0.005380686021429845, 48 | 0.002242915773871009, -0.000822047600000082, 0.0002572510962395222, 49 | -6.607320708956279e-5, 1.309926399120154e-5, -1.790719575255006e-6, 50 | 1.27504961098836e-7, 51 | }; 52 | 53 | #if defined __SUNPRO_C 54 | #pragma enable_warn 55 | #elif defined _MSC_VER 56 | #pragma warning(pop) 57 | #endif 58 | -------------------------------------------------------------------------------- /include/boo/BooObject.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace boo { 6 | 7 | class IObj { 8 | std::atomic_int m_refCount = {0}; 9 | 10 | protected: 11 | virtual ~IObj() = default; 12 | 13 | public: 14 | void increment() noexcept { m_refCount.fetch_add(1, std::memory_order_relaxed); } 15 | void decrement() noexcept { 16 | if (m_refCount.fetch_sub(1, std::memory_order_release) == 1) { 17 | std::atomic_thread_fence(std::memory_order_acquire); 18 | delete this; 19 | } 20 | } 21 | }; 22 | 23 | template 24 | class ObjToken { 25 | SubCls* m_obj = nullptr; 26 | 27 | public: 28 | ObjToken() noexcept = default; 29 | ObjToken(SubCls* obj) noexcept : m_obj(obj) { 30 | if (m_obj) 31 | m_obj->increment(); 32 | } 33 | ObjToken(const ObjToken& other) noexcept : m_obj(other.m_obj) { 34 | if (m_obj) 35 | m_obj->increment(); 36 | } 37 | ObjToken(ObjToken&& other) noexcept : m_obj(other.m_obj) { other.m_obj = nullptr; } 38 | ObjToken& operator=(SubCls* obj) noexcept { 39 | if (m_obj) 40 | m_obj->decrement(); 41 | m_obj = obj; 42 | if (m_obj) 43 | m_obj->increment(); 44 | return *this; 45 | } 46 | ObjToken& operator=(const ObjToken& other) noexcept { 47 | if (m_obj) 48 | m_obj->decrement(); 49 | m_obj = other.m_obj; 50 | if (m_obj) 51 | m_obj->increment(); 52 | return *this; 53 | } 54 | ObjToken& operator=(ObjToken&& other) noexcept { 55 | if (m_obj) 56 | m_obj->decrement(); 57 | m_obj = other.m_obj; 58 | other.m_obj = nullptr; 59 | return *this; 60 | } 61 | ~ObjToken() noexcept { 62 | if (m_obj) 63 | m_obj->decrement(); 64 | } 65 | SubCls* get() const noexcept { return m_obj; } 66 | SubCls* operator->() const noexcept { return m_obj; } 67 | SubCls& operator*() const noexcept { return *m_obj; } 68 | template 69 | T* cast() const noexcept { 70 | return static_cast(m_obj); 71 | } 72 | explicit operator bool() const noexcept { return m_obj != nullptr; } 73 | constexpr bool operator==(const ObjToken& other) const noexcept { return m_obj == other.m_obj; } 74 | constexpr bool operator!=(const ObjToken& other) const noexcept { return !(*this == other); } 75 | void reset() noexcept { 76 | if (m_obj) 77 | m_obj->decrement(); 78 | m_obj = nullptr; 79 | } 80 | }; 81 | 82 | } // namespace boo 83 | -------------------------------------------------------------------------------- /soxr/src/simd.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "simd.h" 8 | #include "simd-dev.h" 9 | 10 | #define SIMD_ALIGNMENT (sizeof(float) * 4) 11 | 12 | void * _soxr_simd_aligned_malloc(size_t size) 13 | { 14 | char * p1 = 0, * p = malloc(size + SIMD_ALIGNMENT); 15 | if (p) { 16 | p1 = (char *)((size_t)(p + SIMD_ALIGNMENT) & ~(SIMD_ALIGNMENT - 1)); 17 | *((void * *)p1 - 1) = p; 18 | } 19 | return p1; 20 | } 21 | 22 | 23 | 24 | void * _soxr_simd_aligned_calloc(size_t nmemb, size_t size) 25 | { 26 | void * p = _soxr_simd_aligned_malloc(nmemb * size); 27 | if (p) 28 | memset(p, 0, nmemb * size); 29 | return p; 30 | } 31 | 32 | 33 | 34 | void _soxr_simd_aligned_free(void * p1) 35 | { 36 | if (p1) 37 | free(*((void * *)p1 - 1)); 38 | } 39 | 40 | 41 | 42 | void _soxr_ordered_convolve_simd(int n, void * not_used, float * a, const float * b) 43 | { 44 | int i; 45 | float ab0, ab1; 46 | v4sf * /*RESTRICT*/ va = (v4sf *)a; 47 | v4sf const * RESTRICT vb = (v4sf const *)b; 48 | assert(VALIGNED(a) && VALIGNED(b)); 49 | ab0 = a[0] * b[0], ab1 = a[1] * b[1]; 50 | for (i = 0; i < n / 4; i += 2) { 51 | v4sf a1r = va[i+0], a1i = va[i+1]; 52 | v4sf b1r = vb[i+0], b1i = vb[i+1]; 53 | UNINTERLEAVE2(a1r, a1i, a1r, a1i); 54 | UNINTERLEAVE2(b1r, b1i, b1r, b1i); 55 | VCPLXMUL(a1r, a1i, b1r, b1i); 56 | INTERLEAVE2(a1r, a1i, a1r, a1i); 57 | va[i+0] = a1r, va[i+1] = a1i; 58 | } 59 | a[0] = ab0, a[1] = ab1; 60 | (void)not_used; 61 | } 62 | 63 | 64 | 65 | void _soxr_ordered_partial_convolve_simd(int n, float * a, const float * b) 66 | { 67 | int i; 68 | float ab0; 69 | v4sf * /*RESTRICT*/ va = (v4sf *)a; 70 | v4sf const * RESTRICT vb = (v4sf const *)b; 71 | assert(VALIGNED(a) && VALIGNED(b)); 72 | ab0 = a[0] * b[0]; 73 | for (i = 0; i < n / 4; i += 2) { 74 | v4sf a1r = va[i+0], a1i = va[i+1]; 75 | v4sf b1r = vb[i+0], b1i = vb[i+1]; 76 | UNINTERLEAVE2(a1r, a1i, a1r, a1i); 77 | UNINTERLEAVE2(b1r, b1i, b1r, b1i); 78 | VCPLXMUL(a1r, a1i, b1r, b1i); 79 | INTERLEAVE2(a1r, a1i, a1r, a1i); 80 | va[i+0] = a1r, va[i+1] = a1i; 81 | } 82 | a[0] = ab0; 83 | a[1] = b[n] * a[n] - b[n+1] * a[n+1]; 84 | } 85 | -------------------------------------------------------------------------------- /include/boo/graphicsdev/IGraphicsCommandQueue.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "boo/BooObject.hpp" 8 | #include "boo/IWindow.hpp" 9 | #include "boo/graphicsdev/IGraphicsDataFactory.hpp" 10 | 11 | namespace boo { 12 | 13 | struct IGraphicsCommandQueue { 14 | virtual ~IGraphicsCommandQueue() = default; 15 | 16 | using Platform = IGraphicsDataFactory::Platform; 17 | virtual Platform platform() const = 0; 18 | virtual const char* platformName() const = 0; 19 | 20 | virtual void setShaderDataBinding(const ObjToken& binding) = 0; 21 | virtual void setRenderTarget(const ObjToken& target) = 0; 22 | virtual void setRenderTarget(const ObjToken& target, int face) = 0; 23 | virtual void setViewport(const SWindowRect& rect, float znear = 0.f, float zfar = 1.f) = 0; 24 | virtual void setScissor(const SWindowRect& rect) = 0; 25 | 26 | virtual void resizeRenderTexture(const ObjToken& tex, size_t width, size_t height) = 0; 27 | virtual void resizeRenderTexture(const ObjToken& tex, size_t width, size_t mips) = 0; 28 | virtual void generateMipmaps(const ObjToken& tex) = 0; 29 | virtual void schedulePostFrameHandler(std::function&& func) = 0; 30 | 31 | virtual void setClearColor(const float rgba[4]) = 0; 32 | virtual void clearTarget(bool render = true, bool depth = true) = 0; 33 | 34 | virtual void draw(size_t start, size_t count) = 0; 35 | virtual void drawIndexed(size_t start, size_t count, size_t baseVertex = 0) = 0; 36 | virtual void drawInstances(size_t start, size_t count, size_t instCount, size_t startInst = 0) = 0; 37 | virtual void drawInstancesIndexed(size_t start, size_t count, size_t instCount, size_t startInst = 0) = 0; 38 | 39 | virtual void resolveBindTexture(const ObjToken& texture, const SWindowRect& rect, bool tlOrigin, 40 | int bindIdx, bool color, bool depth, bool clearDepth = false) = 0; 41 | virtual void resolveDisplay(const ObjToken& source) = 0; 42 | virtual void execute() = 0; 43 | 44 | #ifdef BOO_GRAPHICS_DEBUG_GROUPS 45 | virtual void pushDebugGroup(const char* name, const std::array& color = {1.f, 1.f, 1.f, 1.f}) = 0; 46 | virtual void popDebugGroup() = 0; 47 | #endif 48 | 49 | virtual void startRenderer() = 0; 50 | virtual void stopRenderer() = 0; 51 | }; 52 | 53 | } // namespace boo 54 | -------------------------------------------------------------------------------- /lib/win/UWPCommon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "lib/win/WinCommon.hpp" 4 | 5 | struct Boo3DAppContextUWP : Boo3DAppContext { 6 | bool isFullscreen(const boo::IWindow* window) { 7 | #if _WIN32_WINNT_WIN10 8 | if (m_ctx12.m_dev) { 9 | D3D12Context::Window& win = m_ctx12.m_windows[window]; 10 | BOOL isFScr; 11 | win.m_swapChain->GetFullscreenState(&isFScr, nullptr); 12 | return isFScr != 0; 13 | } 14 | #endif 15 | if (m_ctx11.m_dev) { 16 | D3D11Context::Window& win = m_ctx11.m_windows[window]; 17 | BOOL isFScr; 18 | win.m_swapChain->GetFullscreenState(&isFScr, nullptr); 19 | return isFScr != 0; 20 | } 21 | return false; 22 | } 23 | 24 | bool setFullscreen(boo::IWindow* window, bool fs) { 25 | #if _WIN32_WINNT_WIN10 26 | if (m_ctx12.m_dev) { 27 | D3D12Context::Window& win = m_ctx12.m_windows[window]; 28 | BOOL isFScr; 29 | win.m_swapChain->GetFullscreenState(&isFScr, nullptr); 30 | if (fs && isFScr) 31 | return false; 32 | else if (!fs && !isFScr) 33 | return false; 34 | 35 | if (fs) { 36 | ComPtr out; 37 | win.m_swapChain->GetContainingOutput(&out); 38 | DXGI_OUTPUT_DESC outDesc; 39 | out->GetDesc(&outDesc); 40 | 41 | win.m_swapChain->SetFullscreenState(true, nullptr); 42 | DXGI_MODE_DESC mdesc = {UINT(outDesc.DesktopCoordinates.right - outDesc.DesktopCoordinates.left), 43 | UINT(outDesc.DesktopCoordinates.bottom - outDesc.DesktopCoordinates.top)}; 44 | win.m_swapChain->ResizeTarget(&mdesc); 45 | } else 46 | win.m_swapChain->SetFullscreenState(false, nullptr); 47 | return true; 48 | } 49 | #endif 50 | if (m_ctx11.m_dev) { 51 | D3D11Context::Window& win = m_ctx11.m_windows[window]; 52 | BOOL isFScr; 53 | win.m_swapChain->GetFullscreenState(&isFScr, nullptr); 54 | if (fs && isFScr) 55 | return false; 56 | else if (!fs && !isFScr) 57 | return false; 58 | 59 | if (fs) { 60 | ComPtr out; 61 | win.m_swapChain->GetContainingOutput(&out); 62 | DXGI_OUTPUT_DESC outDesc; 63 | out->GetDesc(&outDesc); 64 | 65 | win.m_fsdesc.Width = outDesc.DesktopCoordinates.right; 66 | win.m_fsdesc.Height = outDesc.DesktopCoordinates.bottom; 67 | } 68 | win.m_fs = fs; 69 | win.m_needsFSTransition = true; 70 | return true; 71 | } 72 | return false; 73 | } 74 | }; 75 | -------------------------------------------------------------------------------- /FindIPP.cmake: -------------------------------------------------------------------------------- 1 | # - Find Intel IPP 2 | # Find the IPP libraries 3 | # Options: 4 | # 5 | # IPP_STATIC: true if using static linking 6 | # IPP_MULTI_THREADED: true if using multi-threaded static linking 7 | # 8 | # This module defines the following variables: 9 | # 10 | # IPP_FOUND : True if IPP_INCLUDE_DIR are found 11 | # IPP_INCLUDE_DIR : where to find ipp.h, etc. 12 | # IPP_INCLUDE_DIRS: set when IPP_INCLUDE_DIR found 13 | # IPP_LIBRARIES : the library to link against. 14 | 15 | set(IPP_STATIC ON) 16 | 17 | include(FindPackageHandleStandardArgs) 18 | 19 | if(WIN32) 20 | set(IPP_OLD_ROOT "$ENV{PROGRAMFILES\(X86\)}/IntelSWTools/compilers_and_libraries/windows/ipp") 21 | set(IPP_NEW_ROOT "$ENV{PROGRAMFILES\(X86\)}/Intel/oneAPI/ipp/latest") 22 | else() 23 | set(IPP_OLD_ROOT "/opt/intel/ipp") 24 | set(IPP_NEW_ROOT "/opt/intel/oneapi/ipp/latest") 25 | endif() 26 | 27 | if (EXISTS "${IPP_OLD_ROOT}" AND NOT EXISTS "${IPP_NEW_ROOT}") 28 | set(IPP_ROOT "${IPP_OLD_ROOT}" CACHE PATH "Folder contains IPP") 29 | else() 30 | set(IPP_ROOT "${IPP_NEW_ROOT}" CACHE PATH "Folder contains IPP") 31 | endif() 32 | 33 | # Find header file dir 34 | find_path(IPP_INCLUDE_DIR ipp.h 35 | PATHS ${IPP_ROOT}/include) 36 | 37 | # Find libraries 38 | 39 | # Handle suffix 40 | set(_IPP_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) 41 | 42 | if(WIN32) 43 | set(CMAKE_FIND_LIBRARY_SUFFIXES .lib) 44 | set(IPP_LIBNAME_SUFFIX mt) 45 | else() 46 | if(IPP_STATIC) 47 | set(CMAKE_FIND_LIBRARY_SUFFIXES .a) 48 | else() 49 | set(CMAKE_FIND_LIBRARY_SUFFIXES .so) 50 | endif() 51 | set(IPP_LIBNAME_SUFFIX "") 52 | endif() 53 | 54 | macro(find_ipp_library IPP_COMPONENT) 55 | string(TOLOWER ${IPP_COMPONENT} IPP_COMPONENT_LOWER) 56 | 57 | find_library(IPP_LIB_${IPP_COMPONENT} ipp${IPP_COMPONENT_LOWER}${IPP_LIBNAME_SUFFIX} 58 | PATHS ${IPP_ROOT}/lib/intel64/ ${IPP_ROOT}/lib) 59 | endmacro() 60 | 61 | # IPP components 62 | # Core 63 | find_ipp_library(CORE) 64 | # Signal Processing 65 | find_ipp_library(S) 66 | # Vector Math 67 | find_ipp_library(VM) 68 | 69 | set(IPP_LIBRARY 70 | ${IPP_LIB_S} 71 | ${IPP_LIB_VM} 72 | ${IPP_LIB_CORE}) 73 | 74 | set(CMAKE_FIND_LIBRARY_SUFFIXES ${_IPP_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) 75 | 76 | find_package_handle_standard_args(IPP DEFAULT_MSG 77 | IPP_INCLUDE_DIR IPP_LIBRARY) 78 | 79 | if (IPP_FOUND) 80 | set(IPP_INCLUDE_DIRS ${IPP_INCLUDE_DIR}) 81 | set(IPP_LIBRARIES ${IPP_LIBRARY}) 82 | endif() 83 | 84 | -------------------------------------------------------------------------------- /lib/inputdev/DeviceBase.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/inputdev/DeviceBase.hpp" 2 | #include "boo/inputdev/DeviceToken.hpp" 3 | #include "lib/inputdev/IHIDDevice.hpp" 4 | 5 | namespace boo { 6 | 7 | DeviceBase::DeviceBase(uint64_t typeHash, DeviceToken* token) : m_typeHash(typeHash), m_token(token) {} 8 | 9 | void DeviceBase::_deviceDisconnected() { 10 | deviceDisconnected(); 11 | m_token = nullptr; 12 | if (m_hidDev) { 13 | m_hidDev->_deviceDisconnected(); 14 | m_hidDev.reset(); 15 | } 16 | } 17 | 18 | void DeviceBase::closeDevice() { 19 | if (m_token) 20 | m_token->_deviceClose(); 21 | } 22 | 23 | void DeviceBase::vdeviceError(fmt::string_view error, fmt::format_args args) { 24 | fmt::vprint(error, args); 25 | } 26 | 27 | bool DeviceBase::sendUSBInterruptTransfer(const uint8_t* data, size_t length) { 28 | if (m_hidDev) 29 | return m_hidDev->_sendUSBInterruptTransfer(data, length); 30 | return false; 31 | } 32 | 33 | size_t DeviceBase::receiveUSBInterruptTransfer(uint8_t* data, size_t length) { 34 | if (m_hidDev) 35 | return m_hidDev->_receiveUSBInterruptTransfer(data, length); 36 | return false; 37 | } 38 | 39 | unsigned DeviceBase::getVendorId() const { 40 | if (m_token) 41 | return m_token->getVendorId(); 42 | return -1; 43 | } 44 | 45 | unsigned DeviceBase::getProductId() const { 46 | if (m_token) 47 | return m_token->getProductId(); 48 | return -1; 49 | } 50 | 51 | std::string_view DeviceBase::getVendorName() const { 52 | if (m_token) 53 | return m_token->getVendorName(); 54 | return {}; 55 | } 56 | 57 | std::string_view DeviceBase::getProductName() const { 58 | if (m_token) 59 | return m_token->getProductName(); 60 | return {}; 61 | } 62 | 63 | #if _WIN32 64 | #if !WINDOWS_STORE 65 | PHIDP_PREPARSED_DATA DeviceBase::getReportDescriptor() const { 66 | if (m_hidDev) 67 | return m_hidDev->_getReportDescriptor(); 68 | return {}; 69 | } 70 | #endif 71 | #else 72 | std::vector DeviceBase::getReportDescriptor() const { 73 | if (m_hidDev) 74 | return m_hidDev->_getReportDescriptor(); 75 | return {}; 76 | } 77 | #endif 78 | 79 | bool DeviceBase::sendHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) { 80 | if (m_hidDev) 81 | return m_hidDev->_sendHIDReport(data, length, tp, message); 82 | return false; 83 | } 84 | 85 | size_t DeviceBase::receiveHIDReport(uint8_t* data, size_t length, HIDReportType tp, uint32_t message) { 86 | if (m_hidDev) 87 | return m_hidDev->_receiveHIDReport(data, length, tp, message); 88 | return 0; 89 | } 90 | 91 | } // namespace boo 92 | -------------------------------------------------------------------------------- /soxr/src/fft4g_cache.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | static int * LSX_FFT_BR; 5 | static DFT_FLOAT * LSX_FFT_SC; 6 | static int FFT_LEN = -1; 7 | static ccrw2_t FFT_CACHE_CCRW; 8 | 9 | void LSX_INIT_FFT_CACHE(void) 10 | { 11 | if (FFT_LEN >= 0) 12 | return; 13 | assert(LSX_FFT_BR == NULL); 14 | assert(LSX_FFT_SC == NULL); 15 | assert(FFT_LEN == -1); 16 | ccrw2_init(FFT_CACHE_CCRW); 17 | FFT_LEN = 0; 18 | } 19 | 20 | void LSX_CLEAR_FFT_CACHE(void) 21 | { 22 | assert(FFT_LEN >= 0); 23 | ccrw2_clear(FFT_CACHE_CCRW); 24 | free(LSX_FFT_BR); 25 | free(LSX_FFT_SC); 26 | LSX_FFT_SC = NULL; 27 | LSX_FFT_BR = NULL; 28 | FFT_LEN = -1; 29 | } 30 | 31 | static bool UPDATE_FFT_CACHE(int len) 32 | { 33 | LSX_INIT_FFT_CACHE(); 34 | assert(lsx_is_power_of_2(len)); 35 | assert(FFT_LEN >= 0); 36 | ccrw2_become_reader(FFT_CACHE_CCRW); 37 | if (len > FFT_LEN) { 38 | ccrw2_cease_reading(FFT_CACHE_CCRW); 39 | ccrw2_become_writer(FFT_CACHE_CCRW); 40 | if (len > FFT_LEN) { 41 | int old_n = FFT_LEN; 42 | FFT_LEN = len; 43 | LSX_FFT_BR = realloc(LSX_FFT_BR, dft_br_len(FFT_LEN) * sizeof(*LSX_FFT_BR)); 44 | LSX_FFT_SC = realloc(LSX_FFT_SC, dft_sc_len(FFT_LEN) * sizeof(*LSX_FFT_SC)); 45 | if (!old_n) { 46 | LSX_FFT_BR[0] = 0; 47 | #if SOXR_LIB 48 | atexit(LSX_CLEAR_FFT_CACHE); 49 | #endif 50 | } 51 | return true; 52 | } 53 | ccrw2_cease_writing(FFT_CACHE_CCRW); 54 | ccrw2_become_reader(FFT_CACHE_CCRW); 55 | } 56 | return false; 57 | } 58 | 59 | static void DONE_WITH_FFT_CACHE(bool is_writer) 60 | { 61 | if (is_writer) 62 | ccrw2_cease_writing(FFT_CACHE_CCRW); 63 | else ccrw2_cease_reading(FFT_CACHE_CCRW); 64 | } 65 | 66 | void LSX_SAFE_RDFT(int len, int type, DFT_FLOAT * d) 67 | { 68 | bool is_writer = UPDATE_FFT_CACHE(len); 69 | LSX_RDFT(len, type, d, LSX_FFT_BR, LSX_FFT_SC); 70 | DONE_WITH_FFT_CACHE(is_writer); 71 | } 72 | 73 | void LSX_SAFE_CDFT(int len, int type, DFT_FLOAT * d) 74 | { 75 | bool is_writer = UPDATE_FFT_CACHE(len); 76 | LSX_CDFT(len, type, d, LSX_FFT_BR, LSX_FFT_SC); 77 | DONE_WITH_FFT_CACHE(is_writer); 78 | } 79 | 80 | #undef UPDATE_FFT_CACHE 81 | #undef LSX_SAFE_RDFT 82 | #undef LSX_SAFE_CDFT 83 | #undef LSX_RDFT 84 | #undef LSX_INIT_FFT_CACHE 85 | #undef LSX_FFT_SC 86 | #undef LSX_FFT_BR 87 | #undef LSX_CLEAR_FFT_CACHE 88 | #undef LSX_CDFT 89 | #undef FFT_LEN 90 | #undef FFT_CACHE_CCRW 91 | #undef DONE_WITH_FFT_CACHE 92 | #undef DFT_FLOAT 93 | -------------------------------------------------------------------------------- /lib/inputdev/DeviceSignature.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/inputdev/DeviceSignature.hpp" 2 | #include "boo/inputdev/DeviceToken.hpp" 3 | #include "boo/inputdev/GenericPad.hpp" 4 | #include "lib/inputdev/IHIDDevice.hpp" 5 | 6 | namespace boo { 7 | 8 | extern const DeviceSignature BOO_DEVICE_SIGS[]; 9 | 10 | bool DeviceSignature::DeviceMatchToken(const DeviceToken& token, const TDeviceSignatureSet& sigSet) { 11 | if (token.getDeviceType() == DeviceType::HID) { 12 | uint64_t genPadHash = dev_typeid(GenericPad); 13 | bool hasGenericPad = false; 14 | for (const DeviceSignature* sig : sigSet) { 15 | if (sig->m_vid == token.getVendorId() && sig->m_pid == token.getProductId() && sig->m_type != DeviceType::HID) 16 | return false; 17 | if (sig->m_typeHash == genPadHash) 18 | hasGenericPad = true; 19 | } 20 | return hasGenericPad; 21 | } 22 | for (const DeviceSignature* sig : sigSet) { 23 | if (sig->m_vid == token.getVendorId() && sig->m_pid == token.getProductId()) 24 | return true; 25 | } 26 | return false; 27 | } 28 | 29 | std::shared_ptr IHIDDeviceNew(DeviceToken& token, const std::shared_ptr& devImp); 30 | std::shared_ptr DeviceSignature::DeviceNew(DeviceToken& token) { 31 | std::shared_ptr retval; 32 | 33 | /* Perform signature-matching to find the appropriate device-factory */ 34 | const DeviceSignature* foundSig = nullptr; 35 | const DeviceSignature* sigIter = BOO_DEVICE_SIGS; 36 | unsigned targetVid = token.getVendorId(); 37 | unsigned targetPid = token.getProductId(); 38 | while (sigIter->m_name) { 39 | if (sigIter->m_vid == targetVid && sigIter->m_pid == targetPid) { 40 | foundSig = sigIter; 41 | break; 42 | } 43 | ++sigIter; 44 | } 45 | if (!foundSig) { 46 | /* Try Generic HID devices */ 47 | if (token.getDeviceType() == DeviceType::HID) { 48 | retval = std::make_shared(&token); 49 | if (!retval) 50 | return nullptr; 51 | 52 | retval->m_hidDev = IHIDDeviceNew(token, retval); 53 | if (!retval->m_hidDev) 54 | return nullptr; 55 | retval->m_hidDev->_startThread(); 56 | 57 | return retval; 58 | } 59 | 60 | return nullptr; 61 | } 62 | if (foundSig->m_type != DeviceType::None && foundSig->m_type != token.getDeviceType()) 63 | return nullptr; 64 | 65 | retval = foundSig->m_factory(&token); 66 | if (!retval) 67 | return nullptr; 68 | 69 | retval->m_hidDev = IHIDDeviceNew(token, retval); 70 | if (!retval->m_hidDev) 71 | return nullptr; 72 | retval->m_hidDev->_startThread(); 73 | 74 | return retval; 75 | } 76 | 77 | } // namespace boo 78 | -------------------------------------------------------------------------------- /include/boo/IApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "boo/IWindow.hpp" 8 | #include "boo/System.hpp" 9 | #include "boo/inputdev/DeviceFinder.hpp" 10 | 11 | namespace boo { 12 | class IApplication; 13 | 14 | struct IApplicationCallback { 15 | virtual int appMain(IApplication*) = 0; 16 | virtual void appQuitting(IApplication*) = 0; 17 | virtual void appFilesOpen(IApplication*, const std::vector&) {} 18 | }; 19 | 20 | class IApplication { 21 | friend class WindowCocoa; 22 | friend class WindowWayland; 23 | friend class WindowXlib; 24 | friend class WindowWin32; 25 | virtual void _deletedWindow(IWindow* window) = 0; 26 | 27 | public: 28 | virtual ~IApplication() = default; 29 | 30 | enum class EPlatformType { 31 | Auto = 0, 32 | Wayland = 1, 33 | Xlib = 2, 34 | Android = 3, 35 | Cocoa = 4, 36 | CocoaTouch = 5, 37 | Win32 = 6, 38 | UWP = 7, 39 | Revolution = 8, 40 | Cafe = 9, 41 | NX = 10, 42 | Qt = 11 43 | }; 44 | virtual EPlatformType getPlatformType() const = 0; 45 | 46 | virtual int run() = 0; 47 | virtual std::string_view getUniqueName() const = 0; 48 | virtual std::string_view getFriendlyName() const = 0; 49 | virtual std::string_view getProcessName() const = 0; 50 | virtual const std::vector& getArgs() const = 0; 51 | 52 | /* Constructors/initializers for sub-objects */ 53 | virtual std::shared_ptr newWindow(std::string_view title) = 0; 54 | }; 55 | 56 | int ApplicationRun(IApplication::EPlatformType platform, IApplicationCallback& cb, std::string_view uniqueName, 57 | std::string_view friendlyName, std::string_view pname, const std::vector& args, 58 | std::string_view gfxApi = {}, uint32_t samples = 1, uint32_t anisotropy = 1, bool deepColor = false, 59 | bool singleInstance = true); 60 | extern IApplication* APP; 61 | 62 | static inline int ApplicationRun(IApplication::EPlatformType platform, IApplicationCallback& cb, 63 | std::string_view uniqueName, std::string_view friendlyName, int argc, 64 | char** argv, std::string_view gfxApi = {}, uint32_t samples = 1, 65 | uint32_t anisotropy = 1, bool deepColor = false, bool singleInstance = true) { 66 | if (APP) 67 | return 1; 68 | std::vector args; 69 | for (int i = 1; i < argc; ++i) 70 | args.push_back(argv[i]); 71 | return ApplicationRun(platform, cb, uniqueName, friendlyName, argv[0], args, gfxApi, samples, anisotropy, deepColor, 72 | singleInstance); 73 | } 74 | 75 | } // namespace boo 76 | -------------------------------------------------------------------------------- /include/boo/graphicsdev/nx_compiler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | /* These match mesa's internal stages */ 6 | enum class nx_shader_stage { 7 | NONE = -1, 8 | VERTEX = 0, 9 | TESS_CTRL = 1, 10 | TESS_EVAL = 2, 11 | GEOMETRY = 3, 12 | FRAGMENT = 4, 13 | COMPUTE = 5, 14 | }; 15 | 16 | struct standalone_options { 17 | int glsl_version; 18 | int dump_ast; 19 | int dump_hir; 20 | int dump_lir; 21 | int dump_builder; 22 | int do_link; 23 | int just_log; 24 | }; 25 | 26 | class nx_compiler; 27 | class nx_shader_stage_object { 28 | friend class nx_compiler; 29 | nx_compiler* m_parent = nullptr; 30 | struct gl_shader* m_shader = nullptr; 31 | nx_shader_stage_object(nx_compiler& parent) : m_parent(&parent) {} 32 | 33 | public: 34 | nx_shader_stage_object() = default; 35 | nx_shader_stage_object(const nx_shader_stage_object&); 36 | nx_shader_stage_object& operator=(const nx_shader_stage_object&); 37 | ~nx_shader_stage_object() { reset(); } 38 | void reset(); 39 | operator bool() const; 40 | nx_shader_stage stage() const; 41 | const char* info_log() const; 42 | }; 43 | 44 | class nx_linked_shader { 45 | friend class nx_compiler; 46 | nx_compiler* m_parent = nullptr; 47 | struct gl_shader_program* m_program = nullptr; 48 | nx_linked_shader(nx_compiler& parent) : m_parent(&parent) {} 49 | 50 | public: 51 | nx_linked_shader() = default; 52 | nx_linked_shader(const nx_linked_shader&); 53 | nx_linked_shader& operator=(const nx_linked_shader&); 54 | ~nx_linked_shader() { reset(); } 55 | void reset(); 56 | operator bool() const { return m_program != nullptr; } 57 | const struct gl_shader_program* program() const { return m_program; } 58 | }; 59 | 60 | class nx_compiler { 61 | friend class nx_shader_stage_object; 62 | friend class nx_linked_shader; 63 | struct pipe_screen* m_screen = nullptr; 64 | struct st_context* m_st = nullptr; 65 | struct standalone_options m_options = {}; 66 | bool m_ownsCtx = false; 67 | void compile_shader(struct gl_context* ctx, struct gl_shader* shader); 68 | 69 | public: 70 | nx_compiler(); 71 | ~nx_compiler(); 72 | bool initialize(struct pipe_screen* screen, struct st_context* st, const struct standalone_options* o = nullptr); 73 | bool initialize(const struct standalone_options* o = nullptr); 74 | nx_shader_stage_object compile(nx_shader_stage type, const char* source); 75 | nx_linked_shader link(unsigned num_stages, const nx_shader_stage_object** stages, std::string* infoLog = nullptr); 76 | std::pair, size_t> offline_link(unsigned num_stages, const nx_shader_stage_object** stages, 77 | std::string* infoLog = nullptr); 78 | }; 79 | -------------------------------------------------------------------------------- /include/boo/inputdev/DolphinSmashAdapter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "boo/System.hpp" 8 | #include "boo/inputdev/DeviceBase.hpp" 9 | 10 | namespace boo { 11 | 12 | enum class EDolphinControllerType { 13 | None = 0, 14 | Normal = 0x10, 15 | Wavebird = 0x20, 16 | }; 17 | ENABLE_BITWISE_ENUM(EDolphinControllerType) 18 | 19 | enum class EDolphinControllerButtons { 20 | Start = 1 << 0, 21 | Z = 1 << 1, 22 | R = 1 << 2, 23 | L = 1 << 3, 24 | A = 1 << 8, 25 | B = 1 << 9, 26 | X = 1 << 10, 27 | Y = 1 << 11, 28 | Left = 1 << 12, 29 | Right = 1 << 13, 30 | Down = 1 << 14, 31 | Up = 1 << 15 32 | }; 33 | ENABLE_BITWISE_ENUM(EDolphinControllerButtons) 34 | 35 | struct DolphinControllerState { 36 | std::array m_leftStick{}; 37 | std::array m_rightStick{}; 38 | std::array m_analogTriggers{}; 39 | uint16_t m_btns = 0; 40 | void reset() { 41 | m_leftStick = {}; 42 | m_rightStick = {}; 43 | m_analogTriggers = {}; 44 | m_btns = 0; 45 | } 46 | void clamp(); 47 | }; 48 | 49 | struct IDolphinSmashAdapterCallback { 50 | virtual void controllerConnected([[maybe_unused]] unsigned idx, [[maybe_unused]] EDolphinControllerType type) {} 51 | virtual void controllerDisconnected([[maybe_unused]] unsigned idx) {} 52 | virtual void controllerUpdate([[maybe_unused]] unsigned idx, [[maybe_unused]] EDolphinControllerType type, 53 | [[maybe_unused]] const DolphinControllerState& state) {} 54 | }; 55 | 56 | class DolphinSmashAdapter final : public TDeviceBase { 57 | std::array m_leftStickCal{0x7f, 0}; 58 | std::array m_rightStickCal{0x7f, 0}; 59 | std::array m_triggersCal{}; 60 | uint8_t m_knownControllers = 0; 61 | uint8_t m_rumbleRequest = 0; 62 | std::array m_hardStop{}; 63 | uint8_t m_rumbleState = 0xf; /* Force initial send of stop-rumble command */ 64 | void deviceDisconnected() override; 65 | void initialCycle() override; 66 | void transferCycle() override; 67 | void finalCycle() override; 68 | 69 | public: 70 | DolphinSmashAdapter(DeviceToken* token); 71 | ~DolphinSmashAdapter() override; 72 | 73 | void setCallback(IDolphinSmashAdapterCallback* cb) { 74 | TDeviceBase::setCallback(cb); 75 | m_knownControllers = 0; 76 | } 77 | 78 | void startRumble(size_t idx) { 79 | if (idx >= m_hardStop.size()) { 80 | return; 81 | } 82 | 83 | m_rumbleRequest |= 1U << idx; 84 | } 85 | 86 | void stopRumble(size_t idx, bool hard = false) { 87 | if (idx >= m_hardStop.size()) { 88 | return; 89 | } 90 | 91 | m_rumbleRequest &= ~(1U << idx); 92 | m_hardStop[idx] = hard; 93 | } 94 | }; 95 | 96 | } // namespace boo 97 | -------------------------------------------------------------------------------- /include/boo/inputdev/DeviceBase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "boo/System.hpp" 11 | 12 | #if _WIN32 13 | #include 14 | #endif 15 | 16 | namespace boo { 17 | class DeviceToken; 18 | class IHIDDevice; 19 | 20 | enum class HIDReportType { Input, Output, Feature }; 21 | 22 | class DeviceBase : public std::enable_shared_from_this { 23 | friend class DeviceToken; 24 | friend struct DeviceSignature; 25 | friend class HIDDeviceIOKit; 26 | 27 | uint64_t m_typeHash; 28 | class DeviceToken* m_token; 29 | std::shared_ptr m_hidDev; 30 | void _deviceDisconnected(); 31 | 32 | public: 33 | DeviceBase(uint64_t typeHash, DeviceToken* token); 34 | virtual ~DeviceBase() = default; 35 | 36 | uint64_t getTypeHash() const { return m_typeHash; } 37 | 38 | void closeDevice(); 39 | 40 | /* Callbacks */ 41 | virtual void deviceDisconnected() = 0; 42 | virtual void vdeviceError(fmt::string_view error, fmt::format_args args); 43 | template > 44 | void deviceError(const S& format, Args&&... args) { 45 | vdeviceError(fmt::to_string_view(format), 46 | fmt::basic_format_args>( 47 | fmt::make_args_checked(format, args...))); 48 | } 49 | virtual void initialCycle() {} 50 | virtual void transferCycle() {} 51 | virtual void finalCycle() {} 52 | 53 | /* Low-Level API */ 54 | bool sendUSBInterruptTransfer(const uint8_t* data, size_t length); 55 | size_t receiveUSBInterruptTransfer(uint8_t* data, size_t length); 56 | 57 | inline unsigned getVendorId() const; 58 | inline unsigned getProductId() const; 59 | inline std::string_view getVendorName() const; 60 | inline std::string_view getProductName() const; 61 | 62 | /* High-Level API */ 63 | #if _WIN32 64 | #if !WINDOWS_STORE 65 | PHIDP_PREPARSED_DATA getReportDescriptor() const; 66 | #endif 67 | #else 68 | std::vector getReportDescriptor() const; 69 | #endif 70 | bool sendHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message = 0); 71 | size_t receiveHIDReport(uint8_t* data, size_t length, HIDReportType tp, 72 | uint32_t message = 0); // Prefer callback version 73 | virtual void receivedHIDReport(const uint8_t* /*data*/, size_t /*length*/, HIDReportType /*tp*/, 74 | uint32_t /*message*/) {} 75 | }; 76 | 77 | template 78 | class TDeviceBase : public DeviceBase { 79 | protected: 80 | std::mutex m_callbackLock; 81 | CB* m_callback = nullptr; 82 | 83 | public: 84 | TDeviceBase(uint64_t typeHash, DeviceToken* token) : DeviceBase(typeHash, token) {} 85 | void setCallback(CB* cb) { 86 | std::lock_guard lk(m_callbackLock); 87 | m_callback = cb; 88 | } 89 | }; 90 | 91 | } // namespace boo 92 | -------------------------------------------------------------------------------- /include/boo/inputdev/DeviceFinder.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "boo/inputdev/DeviceSignature.hpp" 9 | #include "boo/inputdev/DeviceToken.hpp" 10 | #include "boo/inputdev/IHIDListener.hpp" 11 | 12 | #ifdef _WIN32 13 | #ifndef WIN32_LEAN_AND_MEAN 14 | #define WIN32_LEAN_AND_MEAN 15 | #endif 16 | #include 17 | #endif 18 | 19 | namespace boo { 20 | 21 | class DeviceFinder { 22 | public: 23 | friend class HIDListenerIOKit; 24 | friend class HIDListenerUdev; 25 | friend class HIDListenerWinUSB; 26 | static inline DeviceFinder* instance() { return skDevFinder; } 27 | 28 | private: 29 | static class DeviceFinder* skDevFinder; 30 | 31 | /* Types this finder is interested in (immutable) */ 32 | DeviceSignature::TDeviceSignatureSet m_types; 33 | 34 | /* Platform-specific USB event registration 35 | * (for auto-scanning, NULL if not registered) */ 36 | std::unique_ptr m_listener; 37 | 38 | /* Set of presently-connected device tokens */ 39 | TDeviceTokens m_tokens; 40 | std::mutex m_tokensLock; 41 | 42 | /* Friend methods for platform-listener to find/insert/remove 43 | * tokens with type-filtering */ 44 | bool _hasToken(const std::string& path) const { 45 | return m_tokens.find(path) != m_tokens.end(); 46 | } 47 | bool _insertToken(std::unique_ptr&& token); 48 | void _removeToken(const std::string& path); 49 | 50 | public: 51 | class CDeviceTokensHandle { 52 | DeviceFinder& m_finder; 53 | 54 | public: 55 | CDeviceTokensHandle(DeviceFinder& finder) : m_finder(finder) { m_finder.m_tokensLock.lock(); } 56 | ~CDeviceTokensHandle() { m_finder.m_tokensLock.unlock(); } 57 | 58 | TDeviceTokens::iterator begin() noexcept { return m_finder.m_tokens.begin(); } 59 | TDeviceTokens::iterator end() noexcept { return m_finder.m_tokens.end(); } 60 | 61 | TDeviceTokens::const_iterator begin() const noexcept { return m_finder.m_tokens.begin(); } 62 | TDeviceTokens::const_iterator end() const noexcept { return m_finder.m_tokens.end(); } 63 | }; 64 | 65 | /* Application must specify its interested device-types */ 66 | DeviceFinder(std::unordered_set types); 67 | virtual ~DeviceFinder(); 68 | 69 | /* Get interested device-type mask */ 70 | const DeviceSignature::TDeviceSignatureSet& getTypes() const { return m_types; } 71 | 72 | /* Iterable set of tokens */ 73 | CDeviceTokensHandle getTokens() { return CDeviceTokensHandle(*this); } 74 | 75 | /* Automatic device scanning */ 76 | bool startScanning(); 77 | bool stopScanning(); 78 | 79 | /* Manual device scanning */ 80 | bool scanNow(); 81 | 82 | virtual void deviceConnected(DeviceToken&) {} 83 | virtual void deviceDisconnected(DeviceToken&, DeviceBase*) {} 84 | 85 | #if _WIN32 86 | /* Windows-specific WM_DEVICECHANGED handler */ 87 | static LRESULT winDevChangedHandler(WPARAM wParam, LPARAM lParam); 88 | #endif 89 | }; 90 | 91 | } // namespace boo 92 | -------------------------------------------------------------------------------- /soxr/README: -------------------------------------------------------------------------------- 1 | SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | 3 | The SoX Resampler library `libsoxr' performs one-dimensional sample-rate 4 | conversion -- it may be used, for example, to resample PCM-encoded audio. 5 | For higher-dimensional resampling, such as for visual-image processing, you 6 | should look elsewhere. 7 | 8 | It aims to give fast¹ and very high quality² results for any constant 9 | (rational or irrational) resampling ratio. Phase-response, preserved 10 | bandwidth, aliasing, and rejection level parameters are all configurable; 11 | alternatively, simple `preset' configurations may be selected. A 12 | variable-rate resampling mode of operation is also included. 13 | 14 | The resampler is currently available either as part of `libsox' (the audio 15 | file-format and effect library), or stand-alone as `libsoxr' (this package). 16 | The interfaces to libsox and libsoxr are slightly different, with that of 17 | libsoxr designed specifically for resampling. An application requiring 18 | support for other effects, or for reading-from or writing-to audio files or 19 | devices, should use libsox (or other libraries such as libsndfile or 20 | libavformat). 21 | 22 | Libsoxr provides a simple API that allows interfacing using the most 23 | commonly-used sample formats and buffering schemes: sample-formats may be 24 | either floating-point or integer, and multiple channels either interleaved 25 | or split in separate buffers. The API is documented in the header file 26 | `soxr.h', together with sample code found in the 'examples' directory. 27 | 28 | For compatibility with the popular `libsamplerate' library, the header file 29 | `soxr-lsr.h' is provided and may be used as an alternative API.³ Note 30 | however, that libsoxr does not provide a full emulation of libsamplerate 31 | and that using this approach, only a sub-set of libsoxr's features are 32 | available. 33 | 34 | The design was inspired by Laurent De Soras' paper `The Quest For The 35 | Perfect Resampler', http://ldesoras.free.fr/doc/articles/resampler-en.pdf; 36 | in essence, it combines Julius O. Smith's `Bandlimited Interpolation' 37 | technique (https://ccrma.stanford.edu/~jos/resample/resample.pdf) with FFT- 38 | based over-sampling. 39 | 40 | Note that for real-time resampling, libsoxr may have a higher latency 41 | than non-FFT based resamplers. For example, when using the `High Quality' 42 | configuration to resample between 44100Hz and 48000Hz, the latency is 43 | around 1000 output samples, i.e. roughly 20ms (though passband and FFT- 44 | size configuration parameters may be used to reduce this figure). 45 | 46 | For build and installation instructions, see the file `INSTALL'; for 47 | copyright and licensing information, see the file `LICENCE'. 48 | 49 | For support and new versions, see http://soxr.sourceforge.net 50 | ________ 51 | ¹ For example, multi-channel resampling can utilise multiple CPU-cores. 52 | ² Bit-perfect within practical occupied-bandwidth limits. 53 | ³ For details of that API, see http://www.mega-nerd.com/SRC/api.html. 54 | -------------------------------------------------------------------------------- /lib/Common.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "boo/BooObject.hpp" 7 | 8 | namespace boo { 9 | 10 | /** Linked-list iterator shareable by ListNode types. */ 11 | template 12 | class ListIterator { 13 | T* m_node; 14 | 15 | public: 16 | using iterator_category = std::bidirectional_iterator_tag; 17 | using value_type = T; 18 | using difference_type = std::ptrdiff_t; 19 | using pointer = T*; 20 | using reference = T&; 21 | 22 | explicit ListIterator(T* node) : m_node(node) {} 23 | T& operator*() const { return *m_node; } 24 | bool operator!=(const ListIterator& other) const { return m_node != other.m_node; } 25 | ListIterator& operator++() { 26 | m_node = m_node->m_next; 27 | return *this; 28 | } 29 | ListIterator& operator--() { 30 | m_node = m_node->m_prev; 31 | return *this; 32 | } 33 | }; 34 | 35 | /** Linked-list IObj node made part of objects participating in list. 36 | * Subclasses must implement static methods _getHeadPtr() and _getHeadLock() 37 | * to support the common list-management functionality. 38 | */ 39 | template 40 | struct ListNode : P { 41 | using iterator = ListIterator; 42 | iterator begin() { return iterator(static_cast(this)); } 43 | iterator end() { return iterator(nullptr); } 44 | 45 | H m_head; 46 | N* m_next; 47 | N* m_prev = nullptr; 48 | ListNode(H head) : m_head(head) { 49 | auto lk = N::_getHeadLock(head); 50 | m_next = N::_getHeadPtr(head); 51 | if (m_next) 52 | m_next->m_prev = static_cast(this); 53 | N::_getHeadPtr(head) = static_cast(this); 54 | } 55 | 56 | protected: 57 | ~ListNode() { 58 | if (m_prev) { 59 | if (m_next) 60 | m_next->m_prev = m_prev; 61 | m_prev->m_next = m_next; 62 | } else { 63 | if (m_next) 64 | m_next->m_prev = nullptr; 65 | N::_getHeadPtr(m_head) = m_next; 66 | } 67 | } 68 | }; 69 | 70 | static inline uint32_t flp2(uint32_t x) { 71 | x = x | (x >> 1); 72 | x = x | (x >> 2); 73 | x = x | (x >> 4); 74 | x = x | (x >> 8); 75 | x = x | (x >> 16); 76 | return x - (x >> 1); 77 | } 78 | 79 | /* When instrumenting with MemorySanitizer, external libraries 80 | * (particularly the OpenGL implementation) will report tons of false 81 | * positives. The BOO_MSAN_NO_INTERCEPT macro declares a RAII object 82 | * to temporarily suspend memory tracking so external calls can be made. 83 | */ 84 | #if defined(__has_feature) 85 | #if __has_feature(memory_sanitizer) 86 | #define BOO_MSAN 1 87 | #include 88 | struct InterceptorScope { 89 | InterceptorScope() { __msan_scoped_disable_interceptor_checks(); } 90 | ~InterceptorScope() { __msan_scoped_enable_interceptor_checks(); } 91 | }; 92 | #define BOO_MSAN_NO_INTERCEPT InterceptorScope _no_intercept; 93 | #define BOO_MSAN_UNPOISON(data, length) __msan_unpoison(data, length) 94 | #endif 95 | #endif 96 | #ifndef BOO_MSAN_NO_INTERCEPT 97 | #define BOO_MSAN_NO_INTERCEPT 98 | #endif 99 | #ifndef BOO_MSAN_UNPOISON 100 | #define BOO_MSAN_UNPOISON(data, length) 101 | #endif 102 | 103 | } // namespace boo 104 | -------------------------------------------------------------------------------- /include/boo/graphicsdev/Metal.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef __APPLE__ 3 | #if BOO_HAS_METAL 4 | 5 | #include "boo/BooObject.hpp" 6 | #include "boo/IGraphicsContext.hpp" 7 | #include "boo/System.hpp" 8 | #include "boo/graphicsdev/IGraphicsCommandQueue.hpp" 9 | #include "boo/graphicsdev/IGraphicsDataFactory.hpp" 10 | 11 | namespace boo { 12 | struct BaseGraphicsData; 13 | 14 | class MetalDataFactory : public IGraphicsDataFactory { 15 | public: 16 | class Context final : public IGraphicsDataFactory::Context { 17 | friend class MetalDataFactoryImpl; 18 | MetalDataFactory& m_parent; 19 | ObjToken m_data; 20 | Context(MetalDataFactory& parent __BooTraceArgs); 21 | ~Context(); 22 | 23 | public: 24 | Platform platform() const { return Platform::Metal; } 25 | const char* platformName() const { return "Metal"; } 26 | 27 | ObjToken newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count); 28 | ObjToken newDynamicBuffer(BufferUse use, size_t stride, size_t count); 29 | 30 | ObjToken newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt, 31 | TextureClampMode clampMode, const void* data, size_t sz); 32 | ObjToken newStaticArrayTexture(size_t width, size_t height, size_t layers, size_t mips, 33 | TextureFormat fmt, TextureClampMode clampMode, const void* data, 34 | size_t sz); 35 | ObjToken newDynamicTexture(size_t width, size_t height, TextureFormat fmt, TextureClampMode clampMode); 36 | ObjToken newRenderTexture(size_t width, size_t height, TextureClampMode clampMode, size_t colorBindCount, 37 | size_t depthBindCount); 38 | ObjToken newCubeRenderTexture(size_t width, size_t mips); 39 | 40 | ObjToken newShaderStage(const uint8_t* data, size_t size, PipelineStage stage); 41 | 42 | ObjToken newShaderPipeline(ObjToken vertex, ObjToken fragment, 43 | ObjToken geometry, ObjToken control, 44 | ObjToken evaluation, const VertexFormatInfo& vtxFmt, 45 | const AdditionalPipelineInfo& additionalInfo, bool asynchronous = true); 46 | 47 | ObjToken newShaderDataBinding( 48 | const ObjToken& pipeline, const ObjToken& vbo, 49 | const ObjToken& instVbo, const ObjToken& ibo, size_t ubufCount, 50 | const ObjToken* ubufs, const PipelineStage* ubufStages, const size_t* ubufOffs, 51 | const size_t* ubufSizes, size_t texCount, const ObjToken* texs, const int* texBindIdxs, 52 | const bool* depthBind, size_t baseVert = 0, size_t baseInst = 0); 53 | }; 54 | 55 | static std::vector CompileMetal(const char* source, PipelineStage stage); 56 | }; 57 | 58 | } // namespace boo 59 | 60 | #endif 61 | #endif // __APPLE__ 62 | -------------------------------------------------------------------------------- /include/boo/audiodev/IAudioVoice.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "boo/BooObject.hpp" 8 | 9 | namespace boo { 10 | struct IAudioSubmix; 11 | 12 | enum class AudioChannelSet { Stereo, Quad, Surround51, Surround71, Unknown = 0xff }; 13 | 14 | enum class AudioChannel { 15 | FrontLeft, 16 | FrontRight, 17 | RearLeft, 18 | RearRight, 19 | FrontCenter, 20 | LFE, 21 | SideLeft, 22 | SideRight, 23 | Unknown = 0xff 24 | }; 25 | 26 | struct ChannelMap { 27 | unsigned m_channelCount = 0; 28 | std::array m_channels{}; 29 | }; 30 | 31 | static inline unsigned ChannelCount(AudioChannelSet layout) { 32 | switch (layout) { 33 | case AudioChannelSet::Stereo: 34 | return 2; 35 | case AudioChannelSet::Quad: 36 | return 4; 37 | case AudioChannelSet::Surround51: 38 | return 6; 39 | case AudioChannelSet::Surround71: 40 | return 8; 41 | default: 42 | break; 43 | } 44 | return 0; 45 | } 46 | 47 | struct IAudioVoice : IObj { 48 | /** Set sample rate into voice (may result in audio discontinuities) */ 49 | virtual void resetSampleRate(double sampleRate) = 0; 50 | 51 | /** Reset channel-levels to silence; unbind all submixes */ 52 | virtual void resetChannelLevels() = 0; 53 | 54 | /** Set channel-levels for mono audio source (AudioChannel enum for array index) */ 55 | virtual void setMonoChannelLevels(IAudioSubmix* submix, const float coefs[8], bool slew) = 0; 56 | 57 | /** Set channel-levels for stereo audio source (AudioChannel enum for array index) */ 58 | virtual void setStereoChannelLevels(IAudioSubmix* submix, const float coefs[8][2], bool slew) = 0; 59 | 60 | /** Called by client to dynamically adjust the pitch of voices with dynamic pitch enabled */ 61 | virtual void setPitchRatio(double ratio, bool slew) = 0; 62 | 63 | /** Instructs platform to begin consuming sample data; invoking callback as needed */ 64 | virtual void start() = 0; 65 | 66 | /** Instructs platform to stop consuming sample data */ 67 | virtual void stop() = 0; 68 | }; 69 | 70 | struct IAudioVoiceCallback { 71 | /** boo calls this on behalf of the audio platform to proactively invoke potential 72 | * pitch or panning changes before processing samples */ 73 | virtual void preSupplyAudio(boo::IAudioVoice& voice, double dt) = 0; 74 | 75 | /** boo calls this on behalf of the audio platform to request more audio 76 | * frames from the client */ 77 | virtual size_t supplyAudio(IAudioVoice& voice, size_t frames, int16_t* data) = 0; 78 | 79 | /** after resampling, boo calls this for each submix that this voice targets; 80 | * client performs volume processing and bus-routing this way */ 81 | virtual void routeAudio(size_t frames, size_t channels, double dt, int busId, int16_t* in, int16_t* out) { 82 | memmove(out, in, frames * channels * 2); 83 | } 84 | 85 | virtual void routeAudio(size_t frames, size_t channels, double dt, int busId, int32_t* in, int32_t* out) { 86 | memmove(out, in, frames * channels * 4); 87 | } 88 | 89 | virtual void routeAudio(size_t frames, size_t channels, double dt, int busId, float* in, float* out) { 90 | memmove(out, in, frames * channels * 4); 91 | } 92 | }; 93 | 94 | } // namespace boo 95 | -------------------------------------------------------------------------------- /lib/inputdev/IOKitPointer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "lib/CFPointer.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /// A smart pointer that can manage the lifecycle of IOKit objects. 10 | template 11 | class IOObjectPointer { 12 | public: 13 | IOObjectPointer() : storage(0) {} 14 | 15 | IOObjectPointer(T pointer) : storage(toStorageType(pointer)) { 16 | if (storage) { 17 | IOObjectRetain(storage); 18 | } 19 | } 20 | 21 | IOObjectPointer(const IOObjectPointer& other) : storage(other.storage) { 22 | if (io_object_t ptr = storage) { 23 | IOObjectRetain(ptr); 24 | } 25 | } 26 | IOObjectPointer& operator=(const IOObjectPointer& other) { 27 | if (io_object_t pointer = storage) { 28 | IOObjectRelease(pointer); 29 | } 30 | storage = other.storage; 31 | if (io_object_t ptr = storage) { 32 | IOObjectRetain(ptr); 33 | } 34 | return *this; 35 | } 36 | 37 | IOObjectPointer(IOObjectPointer&& other) : storage(std::exchange(other.storage, 0)) {} 38 | 39 | ~IOObjectPointer() { 40 | if (io_object_t pointer = storage) { 41 | IOObjectRelease(pointer); 42 | } 43 | } 44 | 45 | static inline IOObjectPointer adopt(T ptr) { return IOObjectPointer(ptr, IOObjectPointer::Adopt); } 46 | 47 | T get() const { return fromStorageType(storage); } 48 | io_object_t* operator&() { 49 | if (io_object_t pointer = storage) { 50 | IOObjectRelease(pointer); 51 | } 52 | return &storage; 53 | } 54 | operator bool() const { return storage != 0; } 55 | 56 | private: 57 | io_object_t storage; 58 | 59 | enum AdoptTag { Adopt }; 60 | IOObjectPointer(T ptr, AdoptTag) : storage(toStorageType(ptr)) {} 61 | 62 | inline io_object_t toStorageType(io_object_t ptr) const { return (io_object_t)ptr; } 63 | 64 | inline T fromStorageType(io_object_t pointer) const { return (T)pointer; } 65 | 66 | void swap(IOObjectPointer& other) { std::swap(storage, other.storage); } 67 | }; 68 | 69 | /// A smart pointer that can manage the lifecycle of IOKit plugin objects. 70 | class IOCFPluginPointer { 71 | public: 72 | IOCFPluginPointer() : _storage(nullptr) {} 73 | 74 | IOCFPluginPointer(const IOCFPluginPointer& other) = delete; 75 | 76 | IOCFPluginPointer(IOCFPluginPointer&& other) : _storage(std::exchange(other._storage, nullptr)) {} 77 | 78 | ~IOCFPluginPointer() { 79 | if (IOCFPlugInInterface** pointer = _storage) { 80 | IODestroyPlugInInterface(pointer); 81 | } 82 | } 83 | 84 | IOCFPlugInInterface*** operator&() { 85 | if (IOCFPlugInInterface** pointer = _storage) { 86 | IODestroyPlugInInterface(pointer); 87 | } 88 | return &_storage; 89 | } 90 | 91 | HRESULT As(LPVOID* p, CFUUIDRef uuid) const { 92 | (*_storage)->AddRef(_storage); // Needed for some reason 93 | return (*_storage)->QueryInterface(_storage, CFUUIDGetUUIDBytes(uuid), p); 94 | } 95 | 96 | operator bool() const { return _storage != nullptr; } 97 | 98 | IOCFPlugInInterface** storage() const { return _storage; } 99 | 100 | private: 101 | IOCFPlugInInterface** _storage; 102 | void swap(IOCFPluginPointer& other) { std::swap(_storage, other._storage); } 103 | }; 104 | -------------------------------------------------------------------------------- /soxr/src/fifo.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | #ifndef fifo_included 5 | #define fifo_included 6 | 7 | #if !defined FIFO_SIZE_T 8 | #define FIFO_SIZE_T size_t 9 | #endif 10 | 11 | #if !defined FIFO_REALLOC 12 | #define FIFO_REALLOC(a,b,c) realloc(a,b) 13 | #undef FIFO_FREE 14 | #define FIFO_FREE free 15 | #undef FIFO_MALLOC 16 | #define FIFO_MALLOC malloc 17 | #endif 18 | 19 | typedef struct { 20 | char * data; 21 | size_t allocation; /* Number of bytes allocated for data. */ 22 | size_t item_size; /* Size of each item in data */ 23 | size_t begin; /* Offset of the first byte to read. */ 24 | size_t end; /* 1 + Offset of the last byte byte to read. */ 25 | } fifo_t; 26 | 27 | #if !defined FIFO_MIN 28 | #define FIFO_MIN 0x4000 29 | #endif 30 | 31 | #if !defined UNUSED 32 | #define UNUSED 33 | #endif 34 | 35 | UNUSED static void fifo_clear(fifo_t * f) 36 | { 37 | f->end = f->begin = 0; 38 | } 39 | 40 | UNUSED static void * fifo_reserve(fifo_t * f, FIFO_SIZE_T n0) 41 | { 42 | size_t n = (size_t)n0; 43 | n *= f->item_size; 44 | 45 | if (f->begin == f->end) 46 | fifo_clear(f); 47 | 48 | while (1) { 49 | if (f->end + n <= f->allocation) { 50 | void *p = f->data + f->end; 51 | 52 | f->end += n; 53 | return p; 54 | } 55 | if (f->begin > FIFO_MIN) { 56 | memmove(f->data, f->data + f->begin, f->end - f->begin); 57 | f->end -= f->begin; 58 | f->begin = 0; 59 | continue; 60 | } 61 | f->data = FIFO_REALLOC(f->data, f->allocation + n, f->allocation); 62 | f->allocation += n; 63 | if (!f->data) 64 | return 0; 65 | } 66 | } 67 | 68 | UNUSED static void * fifo_write(fifo_t * f, FIFO_SIZE_T n0, void const * data) 69 | { 70 | size_t n = (size_t)n0; 71 | void * s = fifo_reserve(f, n0); 72 | if (data) 73 | memcpy(s, data, n * f->item_size); 74 | return s; 75 | } 76 | 77 | UNUSED static void fifo_trim_to(fifo_t * f, FIFO_SIZE_T n0) 78 | { 79 | size_t n = (size_t)n0; 80 | n *= f->item_size; 81 | f->end = f->begin + n; 82 | } 83 | 84 | UNUSED static void fifo_trim_by(fifo_t * f, FIFO_SIZE_T n0) 85 | { 86 | size_t n = (size_t)n0; 87 | n *= f->item_size; 88 | f->end -= n; 89 | } 90 | 91 | UNUSED static FIFO_SIZE_T fifo_occupancy(fifo_t * f) 92 | { 93 | return (FIFO_SIZE_T)((f->end - f->begin) / f->item_size); 94 | } 95 | 96 | UNUSED static void * fifo_read(fifo_t * f, FIFO_SIZE_T n0, void * data) 97 | { 98 | size_t n = (size_t)n0; 99 | char * ret = f->data + f->begin; 100 | n *= f->item_size; 101 | if (n > (f->end - f->begin)) 102 | return NULL; 103 | if (data) 104 | memcpy(data, ret, (size_t)n); 105 | f->begin += n; 106 | return ret; 107 | } 108 | 109 | #define fifo_read_ptr(f) fifo_read(f, (FIFO_SIZE_T)0, NULL) 110 | 111 | UNUSED static void fifo_delete(fifo_t * f) 112 | { 113 | FIFO_FREE(f->data); 114 | } 115 | 116 | UNUSED static int fifo_create(fifo_t * f, FIFO_SIZE_T item_size) 117 | { 118 | f->item_size = (size_t)item_size; 119 | f->allocation = FIFO_MIN; 120 | fifo_clear(f); 121 | return !(f->data = FIFO_MALLOC(f->allocation)); 122 | } 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /soxr/examples/2-stream.C: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Example 2: resample a raw, single-channel, floating-point data stream from 5 | * stdin to stdout. 6 | * 7 | * The application uses the single function `soxr_process' for both input and 8 | * output to/from the resampler; compared to the `input function' approach 9 | * (illustrated in example 3) this requires that the application implements 10 | * more logic, but one less function. 11 | * 12 | * Arguments are: INPUT-RATE OUTPUT-RATE 13 | */ 14 | 15 | #include 16 | #include "examples-common.h" 17 | 18 | int main(int argc, char const * arg[]) 19 | { 20 | double const irate = argc > 1? atof(arg[1]) : 96000.; 21 | double const orate = argc > 2? atof(arg[2]) : 44100.; 22 | 23 | /* Allocate resampling input and output buffers in proportion to the input 24 | * and output rates: */ 25 | #define buf_total_len 15000 /* In samples. */ 26 | size_t const olen = (size_t)(orate * buf_total_len / (irate + orate) + .5); 27 | size_t const ilen = buf_total_len - olen; 28 | size_t const osize = sizeof(float), isize = osize; 29 | void * obuf = malloc(osize * olen); 30 | void * ibuf = malloc(isize * ilen); 31 | 32 | size_t odone, written, need_input = 1; 33 | soxr_error_t error; 34 | 35 | /* Create a stream resampler: */ 36 | soxr_t soxr = soxr_create( 37 | irate, orate, 1, /* Input rate, output rate, # of channels. */ 38 | &error, /* To report any error during creation. */ 39 | NULL, NULL, NULL); /* Use configuration defaults.*/ 40 | 41 | if (!error) { /* If all is well, run the resampler: */ 42 | USE_STD_STDIO; 43 | /* Resample in blocks: */ 44 | do { 45 | size_t ilen1 = 0; 46 | 47 | if (need_input) { 48 | 49 | /* Read one block into the buffer, ready to be resampled: */ 50 | ilen1 = fread(ibuf, isize, ilen, stdin); 51 | 52 | if (!ilen1) { /* If the is no (more) input data available, */ 53 | free(ibuf); /* set ibuf to NULL, to indicate end-of-input */ 54 | ibuf = NULL; /* to the resampler. */ 55 | } 56 | } 57 | 58 | /* Copy data from the input buffer into the resampler, and resample 59 | * to produce as much output as is possible to the given output buffer: */ 60 | error = soxr_process(soxr, ibuf, ilen1, NULL, obuf, olen, &odone); 61 | 62 | written = fwrite(obuf, osize, odone, stdout); /* Consume output.*/ 63 | 64 | /* If the actual amount of data output is less than that requested, and 65 | * we have not already reached the end of the input data, then supply some 66 | * more input next time round the loop: */ 67 | need_input = odone < olen && ibuf; 68 | 69 | } while (!error && (need_input || written)); 70 | } 71 | /* Tidy up: */ 72 | soxr_delete(soxr); 73 | free(obuf), free(ibuf); 74 | /* Diagnostics: */ 75 | fprintf(stderr, "%-26s %s; I/O: %s\n", arg[0], soxr_strerror(error), 76 | ferror(stdin) || ferror(stdout)? strerror(errno) : "no error"); 77 | return !!error; 78 | } 79 | -------------------------------------------------------------------------------- /soxr/src/soxr-lsr.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License as published by 5 | * the Free Software Foundation; either version 2.1 of the License, or (at 6 | * your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public License 14 | * along with this library; if not, write to the Free Software Foundation, 15 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | */ 17 | 18 | /* Wrapper compatible with `libsamplerate' (constant-rate). 19 | * (Libsoxr's native API can be found in soxr.h). */ 20 | 21 | #if !defined SAMPLERATE_H 22 | #define SAMPLERATE_H 23 | #if defined __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #if defined SOXR_DLL 28 | #if defined soxr_lsr_EXPORTS 29 | #define SOXR __declspec(dllexport) 30 | #else 31 | #define SOXR __declspec(dllimport) 32 | #endif 33 | #elif defined SOXR_VISIBILITY && defined __GNUC__ && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1) 34 | #define SOXR __attribute__ ((visibility("default"))) 35 | #else 36 | #define SOXR 37 | #endif 38 | 39 | typedef float SRC_SAMPLE; 40 | #if !defined SOXR_LIB 41 | enum SRC_SRCTYPE_e {SRC_SINC_BEST_QUALITY, SRC_SINC_MEDIUM_QUALITY, 42 | SRC_SINC_FASTEST, SRC_ZERO_ORDER_HOLD, SRC_LINEAR}; 43 | typedef int SRC_SRCTYPE; 44 | typedef int SRC_ERROR; 45 | typedef long (* src_callback_t)(void *, SRC_SAMPLE * *); 46 | typedef struct SRC_STATE SRC_STATE; 47 | typedef struct SRC_DATA { 48 | SRC_SAMPLE * data_in, * data_out; 49 | long input_frames, output_frames; 50 | long input_frames_used, output_frames_gen; 51 | int end_of_input; 52 | double src_ratio; 53 | } SRC_DATA; 54 | #endif 55 | SOXR SRC_STATE * src_new(SRC_SRCTYPE, int num_channels, SRC_ERROR *); 56 | SOXR SRC_ERROR src_process (SRC_STATE *, SRC_DATA *); 57 | SOXR SRC_ERROR src_set_ratio(SRC_STATE *, double); 58 | SOXR SRC_ERROR src_reset (SRC_STATE *); 59 | SOXR SRC_ERROR src_error (SRC_STATE *); 60 | SOXR SRC_STATE * src_delete (SRC_STATE *); 61 | SOXR SRC_STATE * src_callback_new( 62 | src_callback_t, SRC_SRCTYPE, int, SRC_ERROR *, void *); 63 | SOXR long src_callback_read( 64 | SRC_STATE *, double src_ratio, long, SRC_SAMPLE *); 65 | SOXR SRC_ERROR src_simple(SRC_DATA *, SRC_SRCTYPE, int); 66 | SOXR char const * src_get_name(SRC_SRCTYPE); 67 | SOXR char const * src_get_description(SRC_SRCTYPE); 68 | SOXR char const * src_get_version(void); 69 | SOXR char const * src_strerror(SRC_ERROR); 70 | SOXR int src_is_valid_ratio(double); 71 | SOXR void src_short_to_float_array(short const *, float *, int); 72 | SOXR void src_float_to_short_array(float const *, short *, int); 73 | SOXR void src_int_to_float_array(int const *, float *, int); 74 | SOXR void src_float_to_int_array(float const *, int *, int); 75 | 76 | #undef SOXR 77 | #if defined __cplusplus 78 | } 79 | #endif 80 | #endif 81 | -------------------------------------------------------------------------------- /include/boo/graphicsdev/GL.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #if BOO_HAS_GL 3 | 4 | #include 5 | 6 | #include "boo/BooObject.hpp" 7 | #include "boo/graphicsdev/IGraphicsCommandQueue.hpp" 8 | #include "boo/graphicsdev/IGraphicsDataFactory.hpp" 9 | 10 | namespace boo { 11 | struct BaseGraphicsData; 12 | 13 | struct GLContext { 14 | uint32_t m_sampleCount = 1; 15 | uint32_t m_anisotropy = 1; 16 | bool m_deepColor = false; 17 | }; 18 | 19 | class GLDataFactory : public IGraphicsDataFactory { 20 | public: 21 | class Context final : public IGraphicsDataFactory::Context { 22 | friend class GLDataFactoryImpl; 23 | GLDataFactory& m_parent; 24 | ObjToken m_data; 25 | Context(GLDataFactory& parent __BooTraceArgs); 26 | ~Context(); 27 | 28 | public: 29 | Platform platform() const override { return Platform::OpenGL; } 30 | const char* platformName() const override { return "OpenGL"; } 31 | 32 | ObjToken newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count) override; 33 | ObjToken newDynamicBuffer(BufferUse use, size_t stride, size_t count) override; 34 | 35 | ObjToken newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt, 36 | TextureClampMode clampMode, const void* data, size_t sz) override; 37 | ObjToken newStaticArrayTexture(size_t width, size_t height, size_t layers, size_t mips, 38 | TextureFormat fmt, TextureClampMode clampMode, const void* data, 39 | size_t sz) override; 40 | ObjToken newDynamicTexture(size_t width, size_t height, TextureFormat fmt, 41 | TextureClampMode clampMode) override; 42 | ObjToken newRenderTexture(size_t width, size_t height, TextureClampMode clampMode, 43 | size_t colorBindingCount, size_t depthBindingCount) override; 44 | ObjToken newCubeRenderTexture(size_t width, size_t mips) override; 45 | 46 | ObjToken newShaderStage(const uint8_t* data, size_t size, PipelineStage stage) override; 47 | 48 | ObjToken newShaderPipeline(ObjToken vertex, ObjToken fragment, 49 | ObjToken geometry, ObjToken control, 50 | ObjToken evaluation, const VertexFormatInfo& vtxFmt, 51 | const AdditionalPipelineInfo& additionalInfo, 52 | bool asynchronous = true) override; 53 | 54 | ObjToken 55 | newShaderDataBinding(const ObjToken& pipeline, const ObjToken& vbo, 56 | const ObjToken& instVbo, const ObjToken& ibo, 57 | size_t ubufCount, const ObjToken* ubufs, const PipelineStage* ubufStages, 58 | const size_t* ubufOffs, const size_t* ubufSizes, size_t texCount, 59 | const ObjToken* texs, const int* texBindIdx, const bool* depthBind, 60 | size_t baseVert = 0, size_t baseInst = 0) override; 61 | }; 62 | }; 63 | 64 | } // namespace boo 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /soxr/src/poly-fir.h: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Resample using an interpolated poly-phase FIR with length LEN.*/ 5 | /* Input must be followed by LEN-1 samples. */ 6 | 7 | #define a (coef(p->shared->poly_fir_coefs, COEF_INTERP, FIR_LENGTH, phase, 0,j)) 8 | #define b (coef(p->shared->poly_fir_coefs, COEF_INTERP, FIR_LENGTH, phase, 1,j)) 9 | #define c (coef(p->shared->poly_fir_coefs, COEF_INTERP, FIR_LENGTH, phase, 2,j)) 10 | #define d (coef(p->shared->poly_fir_coefs, COEF_INTERP, FIR_LENGTH, phase, 3,j)) 11 | #if COEF_INTERP == 0 12 | #define _ sum += a *in[j], ++j; 13 | #elif COEF_INTERP == 1 14 | #define _ sum += (b *x + a)*in[j], ++j; 15 | #elif COEF_INTERP == 2 16 | #define _ sum += ((c *x + b)*x + a)*in[j], ++j; 17 | #elif COEF_INTERP == 3 18 | #define _ sum += (((d*x + c)*x + b)*x + a)*in[j], ++j; 19 | #else 20 | #error COEF_INTERP 21 | #endif 22 | 23 | static void FUNCTION(stage_t * p, fifo_t * output_fifo) 24 | { 25 | sample_t const * input = stage_read_p(p); 26 | int i, num_in = stage_occupancy(p), max_num_out = 1 + (int)(num_in*p->out_in_ratio); 27 | sample_t * output = fifo_reserve(output_fifo, max_num_out); 28 | 29 | #if defined HI_PREC_CLOCK 30 | #if FLOAT_HI_PREC_CLOCK 31 | if (p->use_hi_prec_clock) { 32 | float_step_t at = p->at.flt; 33 | for (i = 0; (int)at < num_in; ++i, at += p->step.flt) { 34 | sample_t const * in = input + (int)at; 35 | float_step_t frac = at - (int)at; 36 | int phase = (int)(frac * (1 << PHASE_BITS)); 37 | #if COEF_INTERP > 0 38 | sample_t x = (sample_t)(frac * (1 << PHASE_BITS) - phase); 39 | #endif 40 | sample_t sum = 0; 41 | int j = 0; 42 | CONVOLVE 43 | output[i] = sum; 44 | } 45 | fifo_read(&p->fifo, (int)at, NULL); 46 | p->at.flt = at - (int)at; 47 | } else 48 | #else 49 | if (p->use_hi_prec_clock) { 50 | for (i = 0; p->at.integer < num_in; ++i, 51 | p->at.fix.ls.all += p->step.fix.ls.all, 52 | p->at.whole += p->step.whole + (p->at.fix.ls.all < p->step.fix.ls.all)) { 53 | sample_t const * in = input + p->at.integer; 54 | uint32_t frac = p->at.fraction; 55 | int phase = (int)(frac >> (32 - PHASE_BITS)); /* high-order bits */ 56 | #if COEF_INTERP > 0 /* low-order bits, scaled to [0,1) */ 57 | sample_t x = (sample_t)((frac << PHASE_BITS) * (1 / MULT32)); 58 | #endif 59 | sample_t sum = 0; 60 | int j = 0; 61 | CONVOLVE 62 | output[i] = sum; 63 | } 64 | fifo_read(&p->fifo, p->at.integer, NULL); 65 | p->at.integer = 0; 66 | } else 67 | #endif 68 | #endif 69 | { 70 | for (i = 0; p->at.integer < num_in; ++i, p->at.whole += p->step.whole) { 71 | sample_t const * in = input + p->at.integer; 72 | uint32_t frac = p->at.fraction; 73 | int phase = (int)(frac >> (32 - PHASE_BITS)); /* high-order bits */ 74 | #if COEF_INTERP > 0 /* low-order bits, scaled to [0,1) */ 75 | sample_t x = (sample_t)((frac << PHASE_BITS) * (1 / MULT32)); 76 | #endif 77 | sample_t sum = 0; 78 | int j = 0; 79 | CONVOLVE 80 | output[i] = sum; 81 | } 82 | fifo_read(&p->fifo, p->at.integer, NULL); 83 | p->at.integer = 0; 84 | } 85 | assert(max_num_out - i >= 0); 86 | fifo_trim_by(output_fifo, max_num_out - i); 87 | } 88 | 89 | #undef _ 90 | #undef a 91 | #undef b 92 | #undef c 93 | #undef d 94 | #undef COEF_INTERP 95 | #undef CONVOLVE 96 | #undef FIR_LENGTH 97 | #undef FUNCTION 98 | #undef PHASE_BITS 99 | -------------------------------------------------------------------------------- /soxr/cmake/Modules/FindSIMD.cmake: -------------------------------------------------------------------------------- 1 | # - Finds SIMD support 2 | # 3 | # The following variables are set: 4 | # SIMD_C_FLAGS - flags to add to the C compiler for this package. 5 | # SIMD_FOUND - true if support for this package is found. 6 | # 7 | #============================================================================= 8 | # Based on FindOpenMP.cmake, which is: 9 | # 10 | # Copyright 2009 Kitware, Inc. 11 | # Copyright 2008-2009 André Rigland Brodtkorb 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions are 15 | # met: 16 | # 17 | # * Redistributions of source code must retain the above copyright notice, 18 | # this list of conditions and the following disclaimer. 19 | # 20 | # * Redistributions in binary form must reproduce the above copyright notice, 21 | # this list of conditions and the following disclaimer in the documentation 22 | # and/or other materials provided with the distribution. 23 | # 24 | # * The names of Kitware, Inc., the Insight Consortium, or the names of 25 | # any consortium members, or of any contributors, may not be used to 26 | # endorse or promote products derived from this software without 27 | # specific prior written permission. 28 | # 29 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' 30 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 33 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 36 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 37 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | include (CheckCSourceCompiles) 41 | include (FindPackageHandleStandardArgs) 42 | 43 | if (WIN32) # Safety for when mixed lib/app compilers (but performance hit) 44 | set (GCC_WIN32_SIMD_OPTS "-mincoming-stack-boundary=2") 45 | endif () 46 | 47 | set (SIMD_C_FLAG_CANDIDATES 48 | # x64 49 | " " 50 | # Microsoft Visual Studio x86 51 | "/arch:SSE /fp:fast -D__SSE__" 52 | # Gcc x86 53 | "-msse -mfpmath=sse ${GCC_WIN32_SIMD_OPTS}" 54 | # Gcc x86 (old versions) 55 | "-msse -mfpmath=sse" 56 | ) 57 | 58 | set (SIMD_C_TEST_SOURCE 59 | " 60 | #include 61 | int main() 62 | { 63 | __m128 a, b; 64 | float vals[4] = {0}; 65 | a = _mm_loadu_ps (vals); 66 | b = a; 67 | b = _mm_add_ps (a,b); 68 | _mm_storeu_ps (vals,b); 69 | return 0; 70 | } 71 | ") 72 | 73 | if (DEFINED SIMD_C_FLAGS) 74 | set (SIMD_C_FLAG_CANDIDATES) 75 | endif () 76 | 77 | foreach (FLAG ${SIMD_C_FLAG_CANDIDATES}) 78 | set (SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") 79 | set (CMAKE_REQUIRED_FLAGS "${FLAG}") 80 | unset (SIMD_FLAG_DETECTED CACHE) 81 | message (STATUS "Try SIMD C flag = [${FLAG}]") 82 | check_c_source_compiles ("${SIMD_C_TEST_SOURCE}" SIMD_FLAG_DETECTED) 83 | set (CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") 84 | if (SIMD_FLAG_DETECTED) 85 | set (SIMD_C_FLAGS_INTERNAL "${FLAG}") 86 | break () 87 | endif () 88 | endforeach () 89 | 90 | set (SIMD_C_FLAGS "${SIMD_C_FLAGS_INTERNAL}" 91 | CACHE STRING "C compiler flags for SIMD vectorization") 92 | 93 | find_package_handle_standard_args (SIMD DEFAULT_MSG SIMD_C_FLAGS SIMD_C_FLAGS) 94 | mark_as_advanced (SIMD_C_FLAGS) 95 | -------------------------------------------------------------------------------- /include/boo/graphicsdev/D3D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if _WIN32 4 | 5 | #include 6 | #include 7 | 8 | #include "boo/BooObject.hpp" 9 | #include "boo/System.hpp" 10 | #include "boo/graphicsdev/IGraphicsDataFactory.hpp" 11 | 12 | using pD3DCreateBlob = HRESULT(WINAPI*)(SIZE_T Size, ID3DBlob** ppBlob); 13 | extern pD3DCreateBlob D3DCreateBlobPROC; 14 | 15 | namespace boo { 16 | struct BaseGraphicsData; 17 | 18 | class D3D11DataFactory : public IGraphicsDataFactory { 19 | public: 20 | ~D3D11DataFactory() override = default; 21 | 22 | Platform platform() const override { return Platform::D3D11; } 23 | const char* platformName() const override { return "D3D11"; } 24 | 25 | class Context final : public IGraphicsDataFactory::Context { 26 | friend class D3D11DataFactoryImpl; 27 | D3D11DataFactory& m_parent; 28 | ObjToken m_data; 29 | Context(D3D11DataFactory& parent __BooTraceArgs); 30 | ~Context(); 31 | 32 | public: 33 | Platform platform() const override { return Platform::D3D11; } 34 | const char* platformName() const override { return "D3D11"; } 35 | 36 | ObjToken newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count) override; 37 | ObjToken newDynamicBuffer(BufferUse use, size_t stride, size_t count) override; 38 | 39 | ObjToken newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt, 40 | TextureClampMode clampMode, const void* data, size_t sz) override; 41 | ObjToken newStaticArrayTexture(size_t width, size_t height, size_t layers, size_t mips, 42 | TextureFormat fmt, TextureClampMode clampMode, const void* data, 43 | size_t sz) override; 44 | ObjToken newDynamicTexture(size_t width, size_t height, TextureFormat fmt, 45 | TextureClampMode clampMode) override; 46 | ObjToken newRenderTexture(size_t width, size_t height, TextureClampMode clampMode, size_t colorBindCount, 47 | size_t depthBindCount) override; 48 | ObjToken newCubeRenderTexture(size_t width, size_t mips) override; 49 | 50 | ObjToken newShaderStage(const uint8_t* data, size_t size, PipelineStage stage) override; 51 | 52 | ObjToken newShaderPipeline(ObjToken vertex, ObjToken fragment, 53 | ObjToken geometry, ObjToken control, 54 | ObjToken evaluation, const VertexFormatInfo& vtxFmt, 55 | const AdditionalPipelineInfo& additionalInfo, 56 | bool asynchronous = true) override; 57 | 58 | ObjToken 59 | newShaderDataBinding(const ObjToken& pipeline, const ObjToken& vbo, 60 | const ObjToken& instVbo, const ObjToken& ibo, 61 | size_t ubufCount, const ObjToken* ubufs, const PipelineStage* ubufStages, 62 | const size_t* ubufOffs, const size_t* ubufSizes, size_t texCount, 63 | const ObjToken* texs, const int* bindIdxs, const bool* bindDepth, 64 | size_t baseVert = 0, size_t baseInst = 0) override; 65 | }; 66 | 67 | static std::vector CompileHLSL(const char* source, PipelineStage stage); 68 | }; 69 | 70 | } // namespace boo 71 | 72 | #endif // _WIN32 73 | -------------------------------------------------------------------------------- /lib/win/WinCommon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "boo/IWindow.hpp" 9 | 10 | namespace boo { 11 | class IWindow; 12 | } // namespace boo 13 | 14 | #if _WIN32_WINNT_WIN10 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #elif _WIN32_WINNT_WIN7 22 | #include 23 | #include 24 | #include 25 | #include 26 | #else 27 | #error Unsupported Windows target 28 | #endif 29 | 30 | #include 31 | 32 | using pD3DPERF_BeginEvent = int (WINAPI*)(D3DCOLOR col, LPCWSTR wszName); 33 | using pD3DPERF_EndEvent = int (WINAPI*)(); 34 | 35 | struct D3D12Context { 36 | ComPtr m_dxFactory; 37 | ComPtr m_dev; 38 | ComPtr m_qalloc[2]; 39 | ComPtr m_q; 40 | ComPtr m_loadqalloc; 41 | ComPtr m_loadq; 42 | ComPtr m_loadfence; 43 | UINT64 m_loadfenceval = 0; 44 | HANDLE m_loadfencehandle; 45 | ComPtr m_loadlist; 46 | ComPtr m_rs; 47 | struct Window { 48 | ComPtr m_swapChain; 49 | std::unordered_map> m_rtvHeaps; 50 | UINT m_backBuf = 0; 51 | bool m_needsResize = false; 52 | size_t width, height; 53 | }; 54 | std::unordered_map m_windows; 55 | 56 | uint32_t m_sampleCount = 1; 57 | uint32_t m_anisotropy = 1; 58 | 59 | struct RGBATex2DFBViewDesc : D3D12_SHADER_RESOURCE_VIEW_DESC { 60 | RGBATex2DFBViewDesc() { 61 | Format = DXGI_FORMAT_R8G8B8A8_UNORM; 62 | ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; 63 | Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; 64 | Texture2D = {UINT(0), UINT(1), UINT(0), 0.0f}; 65 | } 66 | } RGBATex2DFBViewDesc; 67 | }; 68 | 69 | struct D3D11Context { 70 | ComPtr m_dxFactory; 71 | ComPtr m_dev; 72 | ComPtr m_devCtx; 73 | ComPtr m_ss[5]; 74 | struct Window { 75 | ComPtr m_swapChain; 76 | ComPtr m_swapChainTex; 77 | ComPtr m_swapChainRTV; 78 | bool m_needsResize = false; 79 | size_t width, height; 80 | 81 | bool m_needsFSTransition = false; 82 | bool m_fs = false; 83 | DXGI_MODE_DESC m_fsdesc = {}; 84 | 85 | void clearRTV() { 86 | m_swapChainTex.Reset(); 87 | m_swapChainRTV.Reset(); 88 | } 89 | 90 | void setupRTV(ComPtr& sc, ID3D11Device* dev) { 91 | m_swapChain = sc; 92 | m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), &m_swapChainTex); 93 | D3D11_TEXTURE2D_DESC resDesc; 94 | m_swapChainTex->GetDesc(&resDesc); 95 | width = resDesc.Width; 96 | height = resDesc.Height; 97 | CD3D11_RENDER_TARGET_VIEW_DESC rtvDesc(D3D11_RTV_DIMENSION_TEXTURE2D, resDesc.Format); 98 | dev->CreateRenderTargetView(m_swapChainTex.Get(), &rtvDesc, &m_swapChainRTV); 99 | } 100 | }; 101 | std::unordered_map m_windows; 102 | 103 | uint32_t m_sampleCount = 1; 104 | uint32_t m_anisotropy = 1; 105 | DXGI_FORMAT m_fbFormat = DXGI_FORMAT_R8G8B8A8_UNORM; 106 | }; 107 | 108 | struct Boo3DAppContext { 109 | D3D11Context m_ctx11; 110 | 111 | void resize(boo::IWindow* window, size_t width, size_t height) { 112 | D3D11Context::Window& win = m_ctx11.m_windows[window]; 113 | win.width = width; 114 | win.height = height; 115 | win.m_needsResize = true; 116 | } 117 | }; 118 | -------------------------------------------------------------------------------- /soxr/INSTALL: -------------------------------------------------------------------------------- 1 | SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | 3 | INSTALLATION GUIDE CONTENTS 4 | 5 | * Standard build 6 | * Build customisation 7 | * Cross-compiling with mingw (linux host) 8 | * Integration with other build systems 9 | 10 | 11 | 12 | STANDARD BUILD 13 | 14 | 1. Prerequisites: 15 | 16 | Before you can build this library, you need to have available on your 17 | system: 18 | 19 | * A C-compiler with 64-bit integer support and, optionally, OpenMP, SIMD. 20 | 21 | * A 'make' utility (most compiler installations already have one of these). 22 | 23 | * CMake: http://www.cmake.org/cmake/resources/software.html 24 | 25 | 26 | 2. Build: 27 | 28 | At a command prompt, change directory (`cd') to the one containing this 29 | file, then enter: 30 | 31 | go (on MS-Windows with nmake) 32 | or 33 | ./go (on unix-like systems) 34 | 35 | This should build the library and run a few sanity tests. 36 | 37 | 38 | 3. Installation: 39 | 40 | Note that this step may need to be performed by a system 41 | adminstrator. Enter: 42 | 43 | nmake install (on MS-Windows) 44 | or 45 | cd Release; make install (on unix) 46 | 47 | 48 | 4. Configuration: 49 | 50 | To use the library you may need to set up appropriate paths to the 51 | library and its header file in your development environment. 52 | 53 | 54 | 5. Installation test 55 | 56 | To test the installation, build and run some of the example programmes 57 | (see examples/README). 58 | 59 | 60 | 61 | BUILD CUSTOMISATION 62 | 63 | If it is necessary to customise the build, then steps 2 and 3 above may be 64 | substituted as follows. Change directory to the one containing this file, 65 | then enter commands along the lines of: 66 | 67 | mkdir build 68 | cd build 69 | cmake [OPTIONS] .. 70 | make 71 | make test 72 | sudo make install 73 | 74 | To list help on the available options, enter: 75 | 76 | cmake -LH .. 77 | 78 | Options, if given, should be preceded with '-D', e.g. 79 | 80 | cmake -DWITH_SIMD:BOOL=OFF .. 81 | 82 | 83 | 84 | CROSS-COMPILING WITH MINGW (LINUX HOST) 85 | 86 | For example: 87 | 88 | mkdir build 89 | cd build 90 | cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-x86_64-mingw-w64-mingw32.cmake \ 91 | -DCMAKE_INSTALL_PREFIX=install \ 92 | -DHAVE_WORDS_BIGENDIAN_EXITCODE=1 \ 93 | -DBUILD_TESTS=0 \ 94 | -DBUILD_EXAMPLES=1 \ 95 | .. 96 | make 97 | 98 | where ~/Toolchain-x86_64-mingw-w64-mingw32.cmake might contain: 99 | 100 | SET(CMAKE_SYSTEM_NAME Windows) 101 | SET(CMAKE_C_COMPILER /usr/bin/x86_64-w64-mingw32-gcc) 102 | SET(CMAKE_CXX_COMPILER /usr/bin/x86_64-w64-mingw32-g++) 103 | SET(CMAKE_RC_COMPILER /usr/bin/x86_64-w64-mingw32-windres) 104 | SET(CMAKE_Fortran_COMPILER /usr/bin/x86_64-w64-mingw32-gfortran) 105 | SET(CMAKE_AR:FILEPATH /usr/bin/x86_64-w64-mingw32-ar) 106 | SET(CMAKE_RANLIB:FILEPATH /usr/bin/x86_64-w64-mingw32-ranlib) 107 | SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) 108 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 109 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 110 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 111 | SET(QT_BINARY_DIR /usr/x86_64-w64-mingw32/bin /usr/bin) 112 | SET(Boost_COMPILER -gcc47) 113 | 114 | 115 | 116 | INTEGRATION WITH OTHER BUILD SYSTEMS 117 | 118 | Autotools-based systems might find it useful to create a file called 119 | `configure' in the directory containing this file, consisting of the line: 120 | cmake -DBUILD_SHARED_LIBS=OFF . 121 | (or with other build options as required). 122 | 123 | For MS visual studio, see msvc/README 124 | -------------------------------------------------------------------------------- /include/boo/graphicsdev/NX.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #if BOO_HAS_NX 3 | 4 | #include 5 | 6 | #include "boo/BooObject.hpp" 7 | #include "boo/graphicsdev/IGraphicsCommandQueue.hpp" 8 | #include "boo/graphicsdev/IGraphicsDataFactory.hpp" 9 | #include "boo/graphicsdev/nx_compiler.hpp" 10 | 11 | #include 12 | 13 | struct pipe_screen; 14 | struct pipe_context; 15 | struct st_context; 16 | struct pipe_surface; 17 | 18 | namespace boo { 19 | struct BaseGraphicsData; 20 | 21 | struct NXContext { 22 | struct pipe_surface* m_windowSurfaces[2]; 23 | NvFence m_fences[2]; 24 | bool m_fence_swap; 25 | 26 | bool initialize(); 27 | bool terminate(); 28 | bool _resizeWindowSurfaces(); 29 | 30 | unsigned m_sampleCount = 1; 31 | 32 | struct pipe_screen* m_screen = nullptr; 33 | struct pipe_context* m_pctx = nullptr; 34 | struct st_context* m_st = nullptr; 35 | nx_compiler m_compiler; 36 | 37 | std::unordered_map m_samplers; 38 | std::unordered_map m_blendStates; 39 | std::unordered_map m_rasStates; 40 | std::unordered_map m_dsStates; 41 | std::unordered_map m_vtxElemStates; 42 | }; 43 | 44 | class NXDataFactory : public IGraphicsDataFactory { 45 | public: 46 | class Context final : public IGraphicsDataFactory::Context { 47 | friend class NXDataFactoryImpl; 48 | NXDataFactory& m_parent; 49 | boo::ObjToken m_data; 50 | Context(NXDataFactory& parent __BooTraceArgs); 51 | ~Context(); 52 | 53 | public: 54 | Platform platform() const { return Platform::NX; } 55 | const char* platformName() const { return "NX"; } 56 | 57 | boo::ObjToken newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count); 58 | boo::ObjToken newDynamicBuffer(BufferUse use, size_t stride, size_t count); 59 | 60 | boo::ObjToken newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt, 61 | TextureClampMode clampMode, const void* data, size_t sz); 62 | boo::ObjToken newStaticArrayTexture(size_t width, size_t height, size_t layers, size_t mips, 63 | TextureFormat fmt, TextureClampMode clampMode, const void* data, 64 | size_t sz); 65 | boo::ObjToken newDynamicTexture(size_t width, size_t height, TextureFormat fmt, 66 | TextureClampMode clampMode); 67 | boo::ObjToken newRenderTexture(size_t width, size_t height, TextureClampMode clampMode, 68 | size_t colorBindCount, size_t depthBindCount); 69 | 70 | ObjToken newShaderStage(const uint8_t* data, size_t size, PipelineStage stage); 71 | 72 | ObjToken newShaderPipeline(ObjToken vertex, ObjToken fragment, 73 | ObjToken geometry, ObjToken control, 74 | ObjToken evaluation, const VertexFormatInfo& vtxFmt, 75 | const AdditionalPipelineInfo& additionalInfo); 76 | 77 | boo::ObjToken newShaderDataBinding( 78 | const boo::ObjToken& pipeline, const boo::ObjToken& vbo, 79 | const boo::ObjToken& instVbo, const boo::ObjToken& ibo, size_t ubufCount, 80 | const boo::ObjToken* ubufs, const PipelineStage* ubufStages, const size_t* ubufOffs, 81 | const size_t* ubufSizes, size_t texCount, const boo::ObjToken* texs, const int* bindIdxs, 82 | const bool* bindDepth, size_t baseVert = 0, size_t baseInst = 0); 83 | }; 84 | }; 85 | 86 | } // namespace boo 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /GLEW-LICENSE: -------------------------------------------------------------------------------- 1 | The OpenGL Extension Wrangler Library 2 | Copyright (C) 2002-2007, Milan Ikits 3 | Copyright (C) 2002-2007, Marcelo E. Magallon 4 | Copyright (C) 2002, Lev Povalahev 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | * The name of the author may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 | THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | Mesa 3-D graphics library 32 | Version: 7.0 33 | 34 | Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a 37 | copy of this software and associated documentation files (the "Software"), 38 | to deal in the Software without restriction, including without limitation 39 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 40 | and/or sell copies of the Software, and to permit persons to whom the 41 | Software is furnished to do so, subject to the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be included 44 | in all copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 47 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 50 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 51 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 52 | 53 | 54 | Copyright (c) 2007 The Khronos Group Inc. 55 | 56 | Permission is hereby granted, free of charge, to any person obtaining a 57 | copy of this software and/or associated documentation files (the 58 | "Materials"), to deal in the Materials without restriction, including 59 | without limitation the rights to use, copy, modify, merge, publish, 60 | distribute, sublicense, and/or sell copies of the Materials, and to 61 | permit persons to whom the Materials are furnished to do so, subject to 62 | the following conditions: 63 | 64 | The above copyright notice and this permission notice shall be included 65 | in all copies or substantial portions of the Materials. 66 | 67 | THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 68 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 69 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 70 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 71 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 72 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 73 | MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 74 | 75 | -------------------------------------------------------------------------------- /lib/CFPointer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | /// A smart pointer that can manage the lifecycle of Core Foundation objects. 8 | template 9 | class CFPointer { 10 | public: 11 | CFPointer() : storage(nullptr) {} 12 | 13 | CFPointer(T pointer) : storage(toStorageType(pointer)) { 14 | if (storage) { 15 | CFRetain(storage); 16 | } 17 | } 18 | 19 | CFPointer(const CFPointer& other) : storage(other.storage) { 20 | if (CFTypeRef ptr = storage) { 21 | CFRetain(ptr); 22 | } 23 | } 24 | 25 | CFPointer(CFPointer&& other) : storage(std::exchange(other.storage, nullptr)) {} 26 | 27 | ~CFPointer() { 28 | if (CFTypeRef pointer = storage) { 29 | CFRelease(pointer); 30 | } 31 | } 32 | 33 | static inline CFPointer adopt(T CF_RELEASES_ARGUMENT ptr) { return CFPointer(ptr, CFPointer::Adopt); } 34 | 35 | T get() const { return fromStorageType(storage); } 36 | 37 | CFPointer& operator=(CFPointer other) { 38 | swap(other); 39 | return *this; 40 | } 41 | 42 | T* operator&() { 43 | if (CFTypeRef pointer = storage) { 44 | CFRelease(pointer); 45 | } 46 | return (T*)&storage; 47 | } 48 | operator bool() const { return storage != nullptr; } 49 | 50 | void reset() { 51 | if (storage) { 52 | CFRelease(storage); 53 | storage = nullptr; 54 | } 55 | } 56 | 57 | private: 58 | CFTypeRef storage; 59 | 60 | enum AdoptTag { Adopt }; 61 | CFPointer(T ptr, AdoptTag) : storage(toStorageType(ptr)) {} 62 | 63 | inline CFTypeRef toStorageType(CFTypeRef ptr) const { return (CFTypeRef)ptr; } 64 | 65 | inline T fromStorageType(CFTypeRef pointer) const { return (T)pointer; } 66 | 67 | void swap(CFPointer& other) { std::swap(storage, other.storage); } 68 | }; 69 | 70 | /// A smart pointer that can manage the lifecycle of CoreFoundation IUnknown objects. 71 | template 72 | class IUnknownPointer { 73 | public: 74 | IUnknownPointer() : _storage(nullptr) {} 75 | 76 | IUnknownPointer(T** pointer) : _storage(toStorageType(pointer)) { 77 | if (_storage) { 78 | (*pointer)->AddRef(pointer); 79 | } 80 | } 81 | 82 | IUnknownPointer(const IUnknownPointer& other) : _storage(other._storage) { 83 | if (IUnknownVTbl** ptr = _storage) { 84 | (*ptr)->AddRef(ptr); 85 | } 86 | } 87 | IUnknownPointer& operator=(const IUnknownPointer& other) { 88 | if (IUnknownVTbl** pointer = _storage) { 89 | (*pointer)->Release(pointer); 90 | } 91 | _storage = other._storage; 92 | if (IUnknownVTbl** ptr = _storage) { 93 | (*ptr)->AddRef(ptr); 94 | } 95 | return *this; 96 | } 97 | 98 | IUnknownPointer(IUnknownPointer&& other) : _storage(std::exchange(other._storage, nullptr)) {} 99 | 100 | ~IUnknownPointer() { 101 | if (IUnknownVTbl** pointer = _storage) { 102 | (*pointer)->Release(pointer); 103 | } 104 | } 105 | 106 | static inline IUnknownPointer adopt(T** ptr) { return IUnknownPointer(ptr, IUnknownPointer::Adopt); } 107 | 108 | T* get() const { return fromStorageType(_storage); } 109 | 110 | T* operator->() const { return get(); } 111 | T** storage() const { return (T**)_storage; } 112 | LPVOID* operator&() { 113 | if (IUnknownVTbl** pointer = _storage) { 114 | (*pointer)->Release(pointer); 115 | } 116 | return (LPVOID*)&_storage; 117 | } 118 | operator bool() const { return _storage != nullptr; } 119 | 120 | private: 121 | IUnknownVTbl** _storage; 122 | 123 | enum AdoptTag { Adopt }; 124 | IUnknownPointer(T** ptr, AdoptTag) : _storage(toStorageType(ptr)) {} 125 | 126 | inline IUnknownVTbl** toStorageType(T** ptr) const { return (IUnknownVTbl**)ptr; } 127 | 128 | inline T* fromStorageType(IUnknownVTbl** pointer) const { return *(T**)pointer; } 129 | 130 | void swap(IUnknownPointer& other) { std::swap(_storage, other._storage); } 131 | }; 132 | -------------------------------------------------------------------------------- /lib/audiodev/AudioSubmix.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "boo/audiodev/IAudioSubmix.hpp" 12 | #include "lib/audiodev/Common.hpp" 13 | 14 | #if defined(__x86_64__) || defined(_M_AMD64) 15 | #include 16 | #elif defined(__aarch64__) || defined(_M_ARM64) 17 | #define __SSE__ 1 18 | #include "sse2neon.h" 19 | #endif 20 | 21 | struct AudioUnitVoiceEngine; 22 | struct VSTVoiceEngine; 23 | struct WAVOutVoiceEngine; 24 | 25 | namespace boo { 26 | class BaseAudioVoiceEngine; 27 | class AudioVoice; 28 | struct AudioVoiceEngineMixInfo; 29 | /* Output gains for each mix-send/channel */ 30 | 31 | class AudioSubmix : public ListNode { 32 | friend class BaseAudioVoiceEngine; 33 | friend class AudioVoiceMono; 34 | friend class AudioVoiceStereo; 35 | friend struct WASAPIAudioVoiceEngine; 36 | friend struct ::AudioUnitVoiceEngine; 37 | friend struct ::VSTVoiceEngine; 38 | friend struct ::WAVOutVoiceEngine; 39 | 40 | /* Mixer-engine relationships */ 41 | int m_busId; 42 | bool m_mainOut; 43 | 44 | /* Callback (effect source, optional) */ 45 | IAudioSubmixCallback* m_cb; 46 | 47 | /* Slew state for output gains */ 48 | size_t m_slewFrames = 0; 49 | size_t m_curSlewFrame = 0; 50 | 51 | /* Output gains for each mix-send/channel */ 52 | std::unordered_map> m_sendGains; 53 | 54 | /* Temporary scratch buffers for accumulating submix audio */ 55 | std::vector m_scratch16; 56 | std::vector m_scratch32; 57 | std::vector m_scratchFlt; 58 | template 59 | std::vector& _getScratch(); 60 | 61 | /* Override scratch buffers with alternate destination */ 62 | int16_t* m_redirect16 = nullptr; 63 | int32_t* m_redirect32 = nullptr; 64 | float* m_redirectFlt = nullptr; 65 | template 66 | T*& _getRedirect(); 67 | 68 | /* C3-linearization support (to mitigate a potential diamond problem on 'clever' submix routes) */ 69 | bool _isDirectDependencyOf(AudioSubmix* send); 70 | std::list _linearizeC3(); 71 | static bool _mergeC3(std::list& output, std::vector>& lists); 72 | 73 | /* Fill scratch buffers with silence for new mix cycle */ 74 | template 75 | void _zeroFill(); 76 | 77 | /* Receive audio from a single voice / submix */ 78 | template 79 | T* _getMergeBuf(size_t frames); 80 | 81 | /* Mix scratch buffers into sends */ 82 | template 83 | size_t _pumpAndMix(size_t frames); 84 | 85 | void _resetOutputSampleRate(); 86 | 87 | public: 88 | static AudioSubmix*& _getHeadPtr(BaseAudioVoiceEngine* head); 89 | static std::unique_lock _getHeadLock(BaseAudioVoiceEngine* head); 90 | 91 | AudioSubmix(BaseAudioVoiceEngine& root, IAudioSubmixCallback* cb, int busId, bool mainOut); 92 | ~AudioSubmix() override; 93 | 94 | void resetSendLevels() override; 95 | void setSendLevel(IAudioSubmix* submix, float level, bool slew) override; 96 | const AudioVoiceEngineMixInfo& mixInfo() const; 97 | double getSampleRate() const override; 98 | SubmixFormat getSampleFormat() const override; 99 | }; 100 | 101 | template <> 102 | inline std::vector& AudioSubmix::_getScratch() { 103 | return m_scratch16; 104 | } 105 | template <> 106 | inline std::vector& AudioSubmix::_getScratch() { 107 | return m_scratch32; 108 | } 109 | template <> 110 | inline std::vector& AudioSubmix::_getScratch() { 111 | return m_scratchFlt; 112 | } 113 | 114 | template <> 115 | inline int16_t*& AudioSubmix::_getRedirect() { 116 | return m_redirect16; 117 | } 118 | template <> 119 | inline int32_t*& AudioSubmix::_getRedirect() { 120 | return m_redirect32; 121 | } 122 | template <> 123 | inline float*& AudioSubmix::_getRedirect() { 124 | return m_redirectFlt; 125 | } 126 | 127 | } // namespace boo 128 | -------------------------------------------------------------------------------- /soxr/examples/5-variable-rate.c: -------------------------------------------------------------------------------- 1 | /* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net 2 | * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 | 4 | /* Example 5: Variable-rate resampling. A test signal (held in a buffer) is 5 | * resampled over a wide range of octaves. Resampled data is sent to stdout as 6 | * raw, float32 samples. Choices of 2 test-signals and of 2 ways of varying 7 | * the sample-rate are combined in a command-line option: 8 | * 9 | * Usage: ./5-variable-rate [0|1|2|3] 10 | */ 11 | 12 | #include 13 | #include "examples-common.h" 14 | 15 | #define OCTAVES 5 /* Resampling range. ± */ 16 | #define OLEN 16 /* Output length in seconds. */ 17 | #define FS 44100 /* Output sampling rate in Hz. */ 18 | 19 | /* For output pos in [0,1], returns an ioratio in the 2^±OCTAVES range: */ 20 | static double ioratio(double pos, int fm) 21 | { 22 | if (fm) /* fm: non-0 for a fast-changing ioratio, 0 for a slow sweep. */ 23 | pos = .5 - cos(pos * 2 * M_PI) * .4 + sin(pos * OLEN * 20 * M_PI) * .05; 24 | return pow(2, 2 * OCTAVES * pos - OCTAVES); 25 | } 26 | 27 | int main(int argc, char *arg[]) 28 | { 29 | int opt = argc <= 1? 2 : (atoi(arg[1]) & 3), saw = opt & 1, fm = opt & 2; 30 | float ibuf[10 << OCTAVES], obuf[AL(ibuf)]; 31 | int i, wl = 2 << OCTAVES; 32 | size_t ilen = AL(ibuf), need_input = 1, written; 33 | size_t odone, total_odone, total_olen = OLEN * FS; 34 | size_t olen1 = fm? 10 : AL(obuf); /* Small block-len if fast-changing ratio */ 35 | soxr_error_t error; 36 | 37 | /* When creating a var-rate resampler, q_spec must be set as follows: */ 38 | soxr_quality_spec_t q_spec = soxr_quality_spec(SOXR_HQ, SOXR_VR); 39 | 40 | /* The ratio of the given input rate and output rates must equate to the 41 | * maximum I/O ratio that will be used: */ 42 | soxr_t soxr = soxr_create(1 << OCTAVES, 1, 1, &error, NULL, &q_spec, NULL); 43 | 44 | if (!error) { 45 | USE_STD_STDIO; 46 | 47 | /* Generate input signal, sine or saw, with wave-length = wl: */ 48 | for (i = 0; i < (int)ilen; ++i) 49 | ibuf[i] = (float)(saw? (i%wl)/(wl-1.)-.5 : .9 * sin(2 * M_PI * i / wl)); 50 | 51 | /* Set the initial resampling ratio (N.B. 3rd parameter = 0): */ 52 | soxr_set_io_ratio(soxr, ioratio(0, fm), 0); 53 | 54 | /* Resample in blocks of size olen1: */ 55 | for (total_odone = 0; !error && total_odone < total_olen;) { 56 | 57 | /* The last block might be shorter: */ 58 | size_t block_len = min(olen1, total_olen - total_odone); 59 | 60 | /* Determine the position in [0,1] of the end of the current block: */ 61 | double pos = (double)(total_odone + block_len) / (double)total_olen; 62 | 63 | /* Calculate an ioratio for this position and instruct the resampler to 64 | * move smoothly to the new value, over the course of outputting the next 65 | * 'block_len' samples (or give 0 for an instant change instead): */ 66 | soxr_set_io_ratio(soxr, ioratio(pos, fm), block_len); 67 | 68 | /* Output the block of samples, supplying input samples as needed: */ 69 | do { 70 | size_t len = need_input? ilen : 0; 71 | error = soxr_process(soxr, ibuf, len, NULL, obuf, block_len, &odone); 72 | written = fwrite(obuf, sizeof(float), odone, stdout); 73 | 74 | /* Update counters for the current block and for the total length: */ 75 | block_len -= odone; 76 | total_odone += odone; 77 | 78 | /* If soxr_process did not provide the complete block, we must call it 79 | * again, supplying more input samples: */ 80 | need_input = block_len != 0; 81 | 82 | } while (need_input && !error && written == odone); 83 | 84 | /* Now that the block for the current ioratio is complete, go back 85 | * round the main `for' loop in order to process the next block. */ 86 | } 87 | soxr_delete(soxr); 88 | } 89 | /* Diagnostics: */ 90 | fprintf(stderr, "%-26s %s; I/O: %s\n", arg[0], soxr_strerror(error), 91 | ferror(stdin) || ferror(stdout)? strerror(errno) : "no error"); 92 | return !!error; 93 | } 94 | -------------------------------------------------------------------------------- /lib/x11/WindowWayland.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/IWindow.hpp" 2 | 3 | #include "boo/IGraphicsContext.hpp" 4 | #include "boo/audiodev/IAudioVoiceEngine.hpp" 5 | 6 | #include 7 | #undef None 8 | 9 | namespace boo { 10 | 11 | struct GraphicsContextWayland : IGraphicsContext { 12 | 13 | EGraphicsAPI m_api; 14 | EPixelFormat m_pf; 15 | IWindow* m_parentWindow; 16 | 17 | public: 18 | IWindowCallback* m_callback; 19 | 20 | GraphicsContextWayland(EGraphicsAPI api, IWindow* parentWindow) 21 | : m_api(api), m_pf(EPixelFormat::RGBA8), m_parentWindow(parentWindow) {} 22 | 23 | ~GraphicsContextWayland() override = default; 24 | 25 | void _setCallback(IWindowCallback* cb) override { m_callback = cb; } 26 | 27 | EGraphicsAPI getAPI() const override { return m_api; } 28 | 29 | EPixelFormat getPixelFormat() const override { return m_pf; } 30 | 31 | void setPixelFormat(EPixelFormat pf) override { 32 | if (pf > EPixelFormat::RGBAF32_Z24) 33 | return; 34 | m_pf = pf; 35 | } 36 | 37 | bool initializeContext(void*) override { return false; } 38 | 39 | void makeCurrent() override {} 40 | 41 | void postInit() override {} 42 | 43 | IGraphicsCommandQueue* getCommandQueue() override { return nullptr; } 44 | 45 | IGraphicsDataFactory* getDataFactory() override { return nullptr; } 46 | 47 | IGraphicsDataFactory* getMainContextDataFactory() override { return nullptr; } 48 | 49 | IGraphicsDataFactory* getLoadContextDataFactory() override { return nullptr; } 50 | 51 | void present() override {} 52 | }; 53 | 54 | struct WindowWayland : IWindow { 55 | GraphicsContextWayland m_gfxCtx; 56 | 57 | WindowWayland(std::string_view title) : m_gfxCtx(IGraphicsContext::EGraphicsAPI::OpenGL3_3, this) {} 58 | 59 | ~WindowWayland() override = default; 60 | 61 | void setCallback(IWindowCallback* cb) override {} 62 | 63 | void closeWindow() override {} 64 | 65 | void showWindow() override {} 66 | 67 | void hideWindow() override {} 68 | 69 | std::string getTitle() override { return ""; } 70 | 71 | void setTitle(std::string_view title) override {} 72 | 73 | void setCursor(EMouseCursor cursor) override {} 74 | 75 | void setWaitCursor(bool wait) override {} 76 | 77 | double getWindowRefreshRate() const override { return 60.0; } 78 | 79 | void setWindowFrameDefault() override {} 80 | 81 | void getWindowFrame(float& xOut, float& yOut, float& wOut, float& hOut) const override {} 82 | 83 | void getWindowFrame(int& xOut, int& yOut, int& wOut, int& hOut) const override {} 84 | 85 | void setWindowFrame(float x, float y, float w, float h) override {} 86 | 87 | void setWindowFrame(int x, int y, int w, int h) override {} 88 | 89 | float getVirtualPixelFactor() const override { return 0; } 90 | 91 | void setStyle(EWindowStyle /*style*/) override {} 92 | 93 | EWindowStyle getStyle() const override { return EWindowStyle::None; } 94 | 95 | bool isFullscreen() const override { return false; } 96 | 97 | void setFullscreen(bool fs) override {} 98 | 99 | void claimKeyboardFocus(const int coord[2]) override {} 100 | 101 | bool clipboardCopy(EClipboardType type, const uint8_t* data, size_t sz) override { return false; } 102 | 103 | std::unique_ptr clipboardPaste(EClipboardType type, size_t& sz) override { return std::unique_ptr(); } 104 | 105 | int waitForRetrace() override { return 1; } 106 | 107 | uintptr_t getPlatformHandle() const override { return 0; } 108 | 109 | ETouchType getTouchType() const override { return ETouchType::None; } 110 | 111 | IGraphicsCommandQueue* getCommandQueue() override { return m_gfxCtx.getCommandQueue(); } 112 | 113 | IGraphicsDataFactory* getDataFactory() override { return m_gfxCtx.getDataFactory(); } 114 | 115 | IGraphicsDataFactory* getMainContextDataFactory() override { return m_gfxCtx.getMainContextDataFactory(); } 116 | 117 | IGraphicsDataFactory* getLoadContextDataFactory() override { return m_gfxCtx.getLoadContextDataFactory(); } 118 | }; 119 | 120 | std::shared_ptr _WindowWaylandNew(std::string_view title) { return std::make_shared(title); } 121 | 122 | } // namespace boo 123 | -------------------------------------------------------------------------------- /lib/inputdev/DeviceFinder.cpp: -------------------------------------------------------------------------------- 1 | #include "boo/inputdev/DeviceFinder.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #if _WIN32 7 | #include 8 | #include 9 | #include 10 | #endif 11 | 12 | namespace boo { 13 | 14 | DeviceFinder* DeviceFinder::skDevFinder = nullptr; 15 | 16 | DeviceFinder::DeviceFinder(std::unordered_set types) { 17 | if (skDevFinder) { 18 | fmt::print(stderr, FMT_STRING("only one instance of CDeviceFinder may be constructed")); 19 | std::abort(); 20 | } 21 | skDevFinder = this; 22 | for (const uint64_t& typeHash : types) { 23 | const DeviceSignature* sigIter = BOO_DEVICE_SIGS; 24 | while (sigIter->m_name) { 25 | if (sigIter->m_typeHash == typeHash) 26 | m_types.push_back(sigIter); 27 | ++sigIter; 28 | } 29 | } 30 | } 31 | 32 | DeviceFinder::~DeviceFinder() { 33 | if (m_listener) 34 | m_listener->stopScanning(); 35 | skDevFinder = nullptr; 36 | } 37 | 38 | bool DeviceFinder::_insertToken(std::unique_ptr&& token) { 39 | if (!DeviceSignature::DeviceMatchToken(*token, m_types)) { 40 | return false; 41 | } 42 | 43 | m_tokensLock.lock(); 44 | const TInsertedDeviceToken insertedTok = m_tokens.emplace(token->getDevicePath(), std::move(token)); 45 | m_tokensLock.unlock(); 46 | deviceConnected(*insertedTok.first->second); 47 | return true; 48 | } 49 | 50 | void DeviceFinder::_removeToken(const std::string& path) { 51 | const auto preCheck = m_tokens.find(path); 52 | if (preCheck == m_tokens.end()) { 53 | return; 54 | } 55 | 56 | DeviceToken& tok = *preCheck->second; 57 | std::shared_ptr dev = tok.m_connectedDev; 58 | tok._deviceClose(); 59 | deviceDisconnected(tok, dev.get()); 60 | m_tokensLock.lock(); 61 | m_tokens.erase(preCheck); 62 | m_tokensLock.unlock(); 63 | } 64 | 65 | bool DeviceFinder::startScanning() { 66 | if (!m_listener) 67 | m_listener = IHIDListenerNew(*this); 68 | if (m_listener) 69 | return m_listener->startScanning(); 70 | return false; 71 | } 72 | 73 | bool DeviceFinder::stopScanning() { 74 | if (!m_listener) 75 | m_listener = IHIDListenerNew(*this); 76 | if (m_listener) 77 | return m_listener->stopScanning(); 78 | return false; 79 | } 80 | 81 | bool DeviceFinder::scanNow() { 82 | if (!m_listener) 83 | m_listener = IHIDListenerNew(*this); 84 | if (m_listener) 85 | return m_listener->scanNow(); 86 | return false; 87 | } 88 | 89 | #if _WIN32 && !WINDOWS_STORE 90 | /* Windows-specific WM_DEVICECHANGED handler */ 91 | LRESULT DeviceFinder::winDevChangedHandler(WPARAM wParam, LPARAM lParam) { 92 | PDEV_BROADCAST_HDR dbh = (PDEV_BROADCAST_HDR)lParam; 93 | PDEV_BROADCAST_DEVICEINTERFACE dbhi = (PDEV_BROADCAST_DEVICEINTERFACE)lParam; 94 | DeviceFinder* finder = instance(); 95 | if (!finder) 96 | return 0; 97 | 98 | if (wParam == DBT_DEVICEARRIVAL) { 99 | if (dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { 100 | DeviceType type = DeviceType::None; 101 | if (dbhi->dbcc_classguid == GUID_DEVINTERFACE_USB_DEVICE) 102 | type = DeviceType::USB; 103 | else if (dbhi->dbcc_classguid == GUID_DEVINTERFACE_HID) 104 | type = DeviceType::HID; 105 | 106 | if (type != DeviceType::None) { 107 | #ifdef UNICODE 108 | char devPath[1024]; 109 | wcstombs(devPath, dbhi->dbcc_name, 1024); 110 | finder->m_listener->_extDevConnect(devPath); 111 | #else 112 | finder->m_listener->_extDevConnect(dbhi->dbcc_name); 113 | #endif 114 | } 115 | } 116 | } else if (wParam == DBT_DEVICEREMOVECOMPLETE) { 117 | if (dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { 118 | DeviceType type = DeviceType::None; 119 | if (dbhi->dbcc_classguid == GUID_DEVINTERFACE_USB_DEVICE) 120 | type = DeviceType::USB; 121 | else if (dbhi->dbcc_classguid == GUID_DEVINTERFACE_HID) 122 | type = DeviceType::HID; 123 | 124 | if (type != DeviceType::None) { 125 | #ifdef UNICODE 126 | char devPath[1024]; 127 | wcstombs(devPath, dbhi->dbcc_name, 1024); 128 | finder->m_listener->_extDevDisconnect(devPath); 129 | #else 130 | finder->m_listener->_extDevDisconnect(dbhi->dbcc_name); 131 | #endif 132 | } 133 | } 134 | } 135 | 136 | return 0; 137 | } 138 | #endif 139 | 140 | } // namespace boo 141 | --------------------------------------------------------------------------------