diff --git a/.github/scripts/package-Windows.sh b/.github/scripts/package-Windows.sh index e4a89d3384..01d2e06e6a 100644 --- a/.github/scripts/package-Windows.sh +++ b/.github/scripts/package-Windows.sh @@ -4,9 +4,9 @@ if [[ $1 == "x64" ]]; then X64BitMode="x64" fi -VERSION=0.8.3 +VERSION=0.9.0 -rm -f ./plugdata.wxs +rm -f ./plugdata.wxs cat > ./plugdata.wxs <<-EOL @@ -25,7 +25,7 @@ cat > ./plugdata.wxs <<-EOL - @@ -52,9 +52,9 @@ cat > ./plugdata.wxs <<-EOL - - @@ -170,12 +170,12 @@ EOL if [[ $X64BitMode == "x64" ]]; then -"C:/Program Files (x86)/WiX Toolset v3.11/bin/candle" -arch x64 plugdata.wxs -"C:/Program Files (x86)/WiX Toolset v3.11/bin/light" plugdata.wixobj -out plugdata-Installer.msi -ext WixUIExtension +"C:/Program Files (x86)/WiX Toolset v3.14/bin/candle" -arch x64 plugdata.wxs +"C:/Program Files (x86)/WiX Toolset v3.14/bin/light" plugdata.wixobj -out plugdata-Installer.msi -ext WixUIExtension cp ".\plugdata-Installer.msi" ".\plugdata-Win64.msi" else -"C:/Program Files (x86)/WiX Toolset v3.11/bin/candle" plugdata.wxs -"C:/Program Files (x86)/WiX Toolset v3.11/bin/light" plugdata.wixobj -out plugdata-Installer.msi -ext WixUIExtension +"C:/Program Files (x86)/WiX Toolset v3.14/bin/candle" plugdata.wxs +"C:/Program Files (x86)/WiX Toolset v3.14/bin/light" plugdata.wixobj -out plugdata-Installer.msi -ext WixUIExtension cp ".\plugdata-Installer.msi" ".\plugdata-Win32.msi" fi diff --git a/.github/scripts/package-macOS.sh b/.github/scripts/package-macOS.sh index 2b95052ade..2ffad7b24a 100755 --- a/.github/scripts/package-macOS.sh +++ b/.github/scripts/package-macOS.sh @@ -40,7 +40,7 @@ build_flavor() mkdir -p $TMPDIR cp -a $flavorprod $TMPDIR - + pkgbuild --analyze --root $TMPDIR ${PKG_DIR}/${PRODUCT_NAME}_${flavor}.plist plutil -replace BundleIsRelocatable -bool NO ${PKG_DIR}/${PRODUCT_NAME}_${flavor}.plist plutil -replace BundleIsVersionChecked -bool NO ${PKG_DIR}/${PRODUCT_NAME}_${flavor}.plist @@ -155,14 +155,14 @@ rm -r $PKG_DIR if [ -z "$AC_USERNAME" ]; then echo "No user name, skipping sign/notarize" # pretend that we signed the package and bail out - mv ${PRODUCT_NAME}.pkg ${PRODUCT_NAME}-MacOS-Universal.pkg + mv ${PRODUCT_NAME}.pkg ${PRODUCT_NAME}-MacOS-$1.pkg exit 0 fi # Sign installer -productsign -s "Developer ID Installer: Timothy Schoen (7SV7JPRR2L)" ${PRODUCT_NAME}.pkg ${PRODUCT_NAME}-MacOS-Universal.pkg +productsign -s "Developer ID Installer: Timothy Schoen (7SV7JPRR2L)" ${PRODUCT_NAME}.pkg ${PRODUCT_NAME}-MacOS-$1.pkg # Notarize installer xcrun notarytool store-credentials "notary_login" --apple-id ${AC_USERNAME} --password ${AC_PASSWORD} --team-id "7SV7JPRR2L" -xcrun notarytool submit ./plugdata-MacOS-Universal.pkg --keychain-profile "notary_login" --wait -xcrun stapler staple "plugdata-MacOS-Universal.pkg" +xcrun notarytool submit ./plugdata-MacOS-$1.pkg --keychain-profile "notary_login" --wait +xcrun stapler staple "plugdata-MacOS-$1.pkg" diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 626c84153f..fbb1e9cc8e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -23,11 +23,11 @@ jobs: key: macos - name: Create Build Environment - run: cmake -E make_directory ${{github.workspace}}/build + run: cmake -E make_directory ${{github.workspace}}/build - name: Configure CMake working-directory: ${{github.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_OFELIA=1 + run: cmake $GITHUB_WORKSPACE -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Check for Code-Signing secrets id: secret-check @@ -42,7 +42,7 @@ jobs: - name: Import Code-Signing Certificates uses: figleafteam/import-codesign-certs@v2 if: ${{ steps.secret-check.outputs.available == 'true' }} - with: + with: p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} @@ -55,7 +55,7 @@ jobs: env: AC_USERNAME: ${{ secrets.AC_USERNAME }} AC_PASSWORD: ${{ secrets.AC_PASSWORD }} - run: ./.github/scripts/package-macOS.sh + run: ./.github/scripts/package-macOS.sh Universal - name: Upload to server env: @@ -78,6 +78,76 @@ jobs: draft: true files: plugdata-macOS-Universal + macos-legacy-build: + runs-on: macos-12 + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 + + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: macos + + - name: Create Build Environment + run: cmake -E make_directory ${{github.workspace}}/build + + - name: Configure CMake + working-directory: ${{github.workspace}}/build + run: cmake $GITHUB_WORKSPACE -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DNANOVG_METAL_IMPLEMENTATION=0 -DMACOS_LEGACY=1 + + - name: Check for Code-Signing secrets + id: secret-check + shell: bash + run: | + if [ "${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}" != '' ]; then + echo "available=true" >> $GITHUB_OUTPUT; + else + echo "available=false" >> $GITHUB_OUTPUT; + fi + + - name: Import Code-Signing Certificates + uses: figleafteam/import-codesign-certs@v2 + if: ${{ steps.secret-check.outputs.available == 'true' }} + with: + p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} + p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} + + - name: Build + working-directory: ${{github.workspace}}/build + run: cmake --build . --config $BUILD_TYPE + + - name: Creating Installer + working-directory: ${{github.workspace}} + env: + AC_USERNAME: ${{ secrets.AC_USERNAME }} + AC_PASSWORD: ${{ secrets.AC_PASSWORD }} + run: ./.github/scripts/package-macOS.sh Legacy + + - name: Upload to server + env: + FTP_USERNAME: ${{ secrets.FTP_USERNAME }} + FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} + GIT_HASH: ${{ github.sha }} + run: ./.github/scripts/upload-ftp.sh plugdata-macOS-Legacy.pkg + + - name: Archive Artifacts + uses: actions/upload-artifact@v3 + with: + name: plugdata-macOS-Legacy + path: plugdata-macOS-Legacy.pkg + + - name: Release Artifacts + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + prerelease: true + draft: true + files: plugdata-macOS-Legacy + windows-64-build: runs-on: windows-2022 steps: @@ -87,12 +157,12 @@ jobs: fetch-depth: 0 - name: Create Build Environment - run: cmake -E make_directory ${{github.workspace}}/build + run: cmake -E make_directory ${{github.workspace}}/build - name: Configure CMake shell: bash working-directory: ${{github.workspace}}/build - run: cmake $GITHUB_WORKSPACE -G "Visual Studio 17 2022" -A x64 -DENABLE_TESTING=0 -DBUILD_OFELIA=1 + run: cmake $GITHUB_WORKSPACE -G "Visual Studio 17 2022" -A x64 - name: Build shell: bash @@ -142,7 +212,7 @@ jobs: - name: Configure CMake shell: bash working-directory: ${{github.workspace}}/build - run: cmake $GITHUB_WORKSPACE -G "Visual Studio 17 2022" -A Win32 -DENABLE_TESTING=0 -DBUILD_OFELIA=1 + run: cmake $GITHUB_WORKSPACE -G "Visual Studio 17 2022" -A Win32 - name: Build shell: bash @@ -215,11 +285,11 @@ jobs: steps: - name: Install Dependencies (dnf) if: ${{ matrix.pacman == 'dnf' }} - run: dnf install -y git cmake alsa-lib-devel libXinerama-devel freetype-devel curl libcurl-devel wget bzip2 gcc-c++ libXi-devel libXcomposite-devel freeglut-devel libXrandr-devel libXcursor-devel xz ccache python python3-pip + run: dnf install -y git cmake alsa-lib-devel libXinerama-devel freetype-devel curl libcurl-devel wget bzip2 gcc-c++ libXi-devel libXcomposite-devel freeglut-devel libXrandr-devel libXcursor-devel xz ccache python python3-pip jack-audio-connection-kit-devel - name: Install Dependencies (apt) if: ${{ matrix.pacman == 'apt' }} - run: apt update && DEBIAN_FRONTEND=noninteractive TZ="Europe/Amsterdam" apt install -y cmake git wget bzip2 build-essential libasound2-dev libjack-jackd2-dev curl libcurl4-openssl-dev libfreetype6-dev libx11-dev libxi-dev libxcomposite-dev libxcursor-dev libxcursor-dev libxext-dev libxrandr-dev libxinerama-dev ccache python3 python3-pip + run: apt update && DEBIAN_FRONTEND=noninteractive TZ="Europe/Amsterdam" apt install -y cmake git wget bzip2 build-essential libasound2-dev libjack-jackd2-dev curl libcurl4-openssl-dev libfreetype6-dev libx11-dev libxi-dev libxcomposite-dev libxcursor-dev libxcursor-dev libxext-dev libxrandr-dev libxinerama-dev ccache python3 python3-pip freeglut3-dev - name: Install Dependencies (zypper) if: ${{ matrix.pacman == 'zypper' }} @@ -227,7 +297,7 @@ jobs: - name: Install Dependencies (pacman) if: ${{ matrix.pacman == 'pacman' }} - run: pacman -Sy && pacman -S --noconfirm cmake wget bzip2 git alsa-lib freetype2 libx11 libxcursor libxi libxext libxinerama libxrandr libxrender webkit2gtk cmake make gcc pkgconf python python-pip curl ccache && pacman --noconfirm -Syu + run: pacman -Sy && pacman -S --noconfirm cmake wget bzip2 git alsa-lib freetype2 libx11 libxcursor libxi libxext libxinerama libxrandr libxrender webkit2gtk cmake make gcc pkgconf python python-pip curl ccache freeglut mesa glfw-x11 glew jack2 openssl && pacman --noconfirm -Syu - uses: actions/checkout@v3 with: @@ -245,7 +315,7 @@ jobs: - name: Configure working-directory: ${{github.workspace}} - run: mkdir build && cd build && CXX=g++ cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DENABLE_TESTING=0 -DBUILD_OFELIA=1 .. -G "Unix Makefiles" + run: mkdir build && cd build && CXX=g++ cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. -G "Unix Makefiles" - name: Build working-directory: ${{github.workspace}}/build @@ -274,4 +344,4 @@ jobs: with: prerelease: true draft: true - files: plugdata-${{ matrix.name }} \ No newline at end of file + files: plugdata-${{ matrix.name }} diff --git a/.gitmodules b/.gitmodules index c2dbb506d7..eb589751e3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,9 @@ [submodule "JUCE"] path = Libraries/JUCE - url = https://github.com/juce-framework/JUCE.git + url = https://github.com/plugdata-team/JUCE.git [submodule "Libraries/pure-data"] path = Libraries/pure-data url = https://github.com/plugdata-team/plugdata-pd -[submodule "Libraries/Catch2"] - path = Libraries/Catch2 - url = https://github.com/catchorg/Catch2.git [submodule "Libraries/heavylib"] path = Libraries/heavylib url = https://github.com/Wasted-Audio/heavylib.git @@ -16,23 +13,12 @@ [submodule "Libraries/clap-juce-extensions"] path = Libraries/clap-juce-extensions url = https://github.com/free-audio/clap-juce-extensions.git -[submodule "Libraries/filesystem"] - path = Libraries/filesystem - url = https://github.com/boostorg/filesystem.git -[submodule "Libraries/cpath"] - path = Libraries/cpath - url = https://github.com/BraedonWooding/cpath -[submodule "Libraries/plugdata-ofelia"] - path = Libraries/plugdata-ofelia - url = https://github.com/plugdata-team/plugdata-ofelia [submodule "Libraries/pd-else"] path = Libraries/pd-else url = https://github.com/timothyschoen/pd-else.git [submodule "Libraries/juce-raw-keyboard-input-module"] path = Libraries/juce-raw-keyboard-input-module url = https://github.com/izzyreal/juce-raw-keyboard-input-module.git -[submodule "./JUCE"] - url = https://github.com/plugdata-team/JUCE.git [submodule "Libraries/readerwriterqueue"] path = Libraries/readerwriterqueue url = https://github.com/cameron314/readerwriterqueue.git @@ -42,3 +28,18 @@ [submodule "Libraries/melatonin_blur"] path = Libraries/melatonin_blur url = https://github.com/sudara/melatonin_blur.git +[submodule "Libraries/Gem"] + path = Libraries/Gem + url = https://github.com/plugdata-team/plugdata-gem.git +[submodule "Libraries/ghc_filesystem"] + path = Libraries/ghc_filesystem + url = https://github.com/gulrak/filesystem.git +[submodule "Libraries/nanovg"] + path = Libraries/nanovg + url = https://github.com/timothyschoen/nanovg.git +[submodule "Libraries/plf_stack"] + path = Libraries/plf_stack + url = https://github.com/mattreecebentley/plf_stack.git +[submodule "Libraries/pd-cyclone"] + path = Libraries/pd-cyclone + url = https://github.com/timothyschoen/pd-cyclone diff --git a/CMakeLists.txt b/CMakeLists.txt index 37532e92c2..6dcbe78913 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,13 +4,21 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -option(RUN_CLANG_TIDY "" OFF) option(ENABLE_TESTING "" OFF) option(ENABLE_SFIZZ "" ON) +option(ENABLE_GEM "" ON) option(ENABLE_ASAN "" OFF) +option(MACOS_LEGACY "" OFF) option(VERBOSE "" OFF) -set (CMAKE_CXX_STANDARD 20) +if(APPLE) +option(NANOVG_METAL_IMPLEMENTATION "" ON) +else() +option(NANOVG_METAL_IMPLEMENTATION "" OFF) +endif() + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_EXTENSIONS OFF) # Visiblity needs to be hidden for all plugin targets, otherwise loading both plugdata and plugdata-fx will cause problems. We later undo this for the standalone build, so that externals can load set(CMAKE_CXX_VISIBILITY_PRESET hidden) @@ -24,20 +32,18 @@ endfunction() if(APPLE) set(CMAKE_XCODE_BUILD_SYSTEM "12" CACHE STRING "" FORCE) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version") - if(RUN_CLANG_TIDY) - set(CMAKE_OSX_ARCHITECTURES "arm64;" CACHE STRING "" FORCE) + if(MACOS_LEGACY) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "Minimum OS X deployment version") + set(CMAKE_OSX_ARCHITECTURES "x86_64;" CACHE STRING "" FORCE) else() - set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") + set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) endif() -endif() -if(RUN_CLANG_TIDY) - set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) endif() if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build type: Release" FORCE) endif() @@ -47,7 +53,7 @@ set(HARDENED_RUNTIME_OPTIONS "com.apple.security.device.audio-input") set(JUCE_ENABLE_MODULE_SOURCE_GROUPS ON CACHE BOOL "" FORCE) set_property(GLOBAL PROPERTY USE_FOLDERS YES) -project(plugdata VERSION 0.8.3 LANGUAGES C CXX) +project(plugdata VERSION 0.9.0 LANGUAGES C CXX) if(("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") OR ("${CMAKE_SYSTEM_NAME}" MATCHES "iOS")) @@ -55,6 +61,13 @@ if(("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES set(ENABLE_SFIZZ OFF) endif() +if(BSD) +message(STATUS "Disabled sfizz") +message(STATUS "Disabled Gem") +set(ENABLE_GEM OFF) +set(ENABLE_SFIZZ OFF) +endif() + add_subdirectory(Libraries/ EXCLUDE_FROM_ALL) cmake_policy(SET CMP0091 NEW) @@ -79,19 +92,29 @@ else() endif() message(STATUS "Preparing documentation") -execute_process(COMMAND python3 parse_documentation.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Scripts) +execute_process(COMMAND python3 parse_documentation.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Scripts RESULT_VARIABLE PREPARE_DOCUMENTATION_RESULT) + +if(NOT PREPARE_DOCUMENTATION_RESULT EQUAL 0) + message(FATAL_ERROR "Preparing documentation failed with error code ${PREPARE_DOCUMENTATION_RESULT}") +endif() message(STATUS "Packaging resources") -execute_process(COMMAND python3 package_resources.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Scripts) +execute_process(COMMAND python3 package_resources.py ${ENABLE_GEM} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Scripts RESULT_VARIABLE PACKAGE_RESOURCES_RESULT) +if(NOT PACKAGE_RESOURCES_RESULT EQUAL 0) + message(FATAL_ERROR "Resource packaging failed with error code ${PACKAGE_RESOURCES_RESULT}") +endif() -set(PLUGDATA_VERSION "0.8.3") +set(PLUGDATA_VERSION "0.9.0") set(PLUGDATA_COMPANY_NAME "plugdata") set(PLUGDATA_COMPANY_COPYRIGHT "plugdata by Timothy Schoen") set(PLUGDATA_COMPANY_WEBSITE "github.com/plugdata-team/plugdata") if("${CMAKE_SYSTEM_NAME}" MATCHES "iOS") set(PLUGDATA_ICON_BIG "${CMAKE_CURRENT_SOURCE_DIR}/Resources/Icons/plugdata_logo_ios.png") +file(GLOB IOS_LAUNCHSCREEN "${CMAKE_CURRENT_SOURCE_DIR}/Resources/Icons/plugdata_launchscreen_ios.png") +set_source_files_properties(${IOS_LAUNCHSCREEN} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + elseif(APPLE) set(PLUGDATA_ICON_BIG "${CMAKE_CURRENT_SOURCE_DIR}/Resources/Icons/plugdata_logo_mac.png") else() @@ -111,6 +134,7 @@ file(GLOB plugdata_resources ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/InterSemiBold.ttf ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/InterThin.ttf ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/InterVariable.ttf + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/InterRegular.ttf ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/RobotoMono-Regular.ttf ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Icons/plugdata_large_logo.png ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Icons/plugdata_logo.png @@ -118,6 +142,7 @@ file(GLOB plugdata_resources ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Documentation.bin ) + file(GLOB StandaloneBinarySources ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Extra/GeneralUser_GS.sf3 ) @@ -125,10 +150,10 @@ file(GLOB StandaloneBinarySources juce_add_binary_data(PlugDataBinaryData SOURCES ${plugdata_resources}) set_target_properties(PlugDataBinaryData PROPERTIES POSITION_INDEPENDENT_CODE ON) + juce_add_binary_data(StandaloneBinaryData HEADER_NAME "StandaloneBinaryData.h" NAMESPACE StandaloneBinaryData SOURCES ${StandaloneBinarySources} ) set_target_properties(StandaloneBinaryData PROPERTIES POSITION_INDEPENDENT_CODE ON) - file(GLOB plugdata_global_sources ${CMAKE_CACHEFILE_DIR}/plugdata_artefacts/JuceLibraryCode/JuceHeader.h) @@ -153,6 +178,13 @@ file(GLOB plugdata_sources ${SOURCES_DIRECTORY}/Heavy/*.h ) + +# Set up testing +if(ENABLE_TESTING) + list(APPEND plugdata_sources ${CMAKE_CURRENT_SOURCE_DIR}/Tests/Tests.cpp) + +endif() + if(APPLE) list(APPEND plugdata_sources ${SOURCES_DIRECTORY}/Utility/FileSystemWatcher.mm ${SOURCES_DIRECTORY}/Utility/OSUtils.mm) else() @@ -186,55 +218,88 @@ set(JUCE_COMPILE_DEFINITIONS JUCE_REPORT_APP_USAGE=0 JUCE_LOG_ASSERTIONS=1 JUCE_STRICT_REFCOUNTEDPOINTER=1 - JUCE_WEB_BROWSER=0 + JUCE_WEB_BROWSER=0 JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1 JUCE_USE_COREIMAGE_LOADER=0 JUCE_SILENCE_XCODE_15_LINKER_WARNING=1 JUCE_USE_XRENDER=1 - JUCE_ALSA=1 JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS=1 - #JUCE_JACK=1 - #JUCE_JACK_CLIENT_NAME="plugdata" ) +if(LINUX) + list(APPEND JUCE_COMPILE_DEFINITIONS JUCE_ALSA=1 JUCE_JACK=1 JUCE_JACK_CLIENT_NAME="plugdata") +elseif(UNIX AND NOT APPLE) # BSD + list(APPEND JUCE_COMPILE_DEFINITIONS JUCE_JACK=1 JUCE_JACK_CLIENT_NAME="plugdata") +endif() + set(PLUGDATA_COMPILE_DEFINITIONS PLUGDATA=1 PLUGDATA_VERSION="${PLUGDATA_VERSION}" PLUGDATA_GIT_HASH="${GIT_HASH}" PD=1 + ENABLE_TESTING=${ENABLE_TESTING} ) if(ENABLE_SFIZZ) list(APPEND PLUGDATA_COMPILE_DEFINITIONS ENABLE_SFIZZ=1) endif() +if(ENABLE_GEM) + list(APPEND PLUGDATA_COMPILE_DEFINITIONS ENABLE_GEM=1) +endif() + add_library(juce STATIC) -target_compile_definitions(juce - PUBLIC - ${JUCE_COMPILE_DEFINITIONS} +target_compile_definitions(juce + PUBLIC + ${JUCE_COMPILE_DEFINITIONS} INTERFACE $ ) +if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "iOS") target_link_libraries(juce PRIVATE juce::juce_audio_utils juce::juce_audio_plugin_client juce::juce_dsp juce::juce_cryptography - PUBLIC - juce::juce_recommended_lto_flags - #juce::juce_recommended_warning_flags + juce::juce_opengl + melatonin_blur + ) +else() +target_link_libraries(juce + PRIVATE + juce::juce_audio_utils + juce::juce_audio_plugin_client + juce::juce_dsp + juce::juce_cryptography + melatonin_blur ) +endif() + +target_compile_options(juce PUBLIC $<$:${JUCE_LTO_FLAGS}>) + +if(NANOVG_METAL_IMPLEMENTATION) +add_compile_definitions(NANOVG_METAL_IMPLEMENTATION=1) +else() +add_compile_definitions(NANOVG_GL3_IMPLEMENTATION=1) +endif() set(libs juce PlugDataBinaryData + nanovg ) if(UNIX AND NOT APPLE) list(APPEND libs curl X11) endif() +# Fixes BSD compilation +if(BSD) +include_directories(/usr/local/include) +link_directories(/usr/local/lib) +endif() + list(APPEND PLUGDATA_COMPILE_DEFINITIONS JUCE_MODAL_LOOPS_PERMITTED=1) list(APPEND PLUGDATA_INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Libraries/ELSE/sfont~/") @@ -250,6 +315,7 @@ target_compile_definitions(plugdata_core PUBLIC ${PLUGDATA_COMPILE_DEFINITIONS}) target_include_directories(plugdata_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Tests ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/raw-keyboard-input-module ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/pure-data/src ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/pure-data/src ${CMAKE_CURRENT_SOURCE_DIR}/Source ${CMAKE_CURRENT_SOURCE_DIR}/Libraries) target_link_libraries(plugdata_core PUBLIC ${libs}) target_include_directories(plugdata_core PUBLIC "$") +include_directories(./Libraries/nanovg/src/) source_group("Source" FILES ${plugdata_global_sources}) @@ -446,10 +512,14 @@ set_target_properties(plugdata_standalone PROPERTIES RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/Resources/Icons/pd-file.icns") endif() -if(UNIX AND NOT APPLE) +if(LINUX) target_link_libraries(plugdata_standalone PRIVATE plugdata_core pd-src externals StandaloneBinaryData "-Wl,-export-dynamic") target_link_libraries(plugdata PRIVATE plugdata_core pd-src-multi externals-multi) target_link_libraries(plugdata_fx PRIVATE plugdata_core pd-src-multi externals-multi) +elseif(UNIX AND NOT APPLE) # BSD + target_link_libraries(plugdata_standalone PRIVATE plugdata_core pd-src externals lua fluidlite StandaloneBinaryData "-Wl,-export-dynamic") + target_link_libraries(plugdata PRIVATE plugdata_core pd-src-multi externals-multi lua fluidlite) + target_link_libraries(plugdata_fx PRIVATE plugdata_core pd-src-multi externals-multi lua fluidlite) elseif(APPLE) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15.0) set(MACOS_COMPAT_LINKER_FLAGS "-Wl,-ld_classic") @@ -489,66 +559,15 @@ set_target_properties(plugdata_midi PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGDA set_target_properties(plugdata_midi PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGDATA_PLUGINS_LOCATION}) endif() -if(RUN_CLANG_TIDY) - find_program( CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable" ) - if(NOT CLANG_TIDY_EXE) - message(STATUS "clang-tidy not found.") - else() - message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") - set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-checks=clang-diagnostic-*,clang-diagnostic-unused-value,clang-analyzer-*,bugprone-*,performance-*,readability-*,-readability-magic-numbers,-readability-braces-around-statements,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter --header-filter='.*'") - endif() - set_target_properties(plugdata_standalone PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}") -endif() - -# Set up testing framework -if(ENABLE_TESTING) - -enable_testing() if(APPLE) -file(GLOB_RECURSE TestFiles CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/Tests/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Tests/*.mm") -else() -file(GLOB_RECURSE TestFiles CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/Tests/*.cpp") -endif() -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/Tests PREFIX "" FILES ${TestFiles}) - -# Include Catch2 -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Catch2) -set(Catch2_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Catch2) - -add_executable(Tests ${TestFiles}) -set_target_properties(Tests PROPERTIES CXX_STANDARD 20) - -target_link_libraries(Tests PRIVATE Catch2::Catch2WithMain plugdata ${libs}) - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/Tests PREFIX "" FILES ${TestFiles}) -include(${Catch2_SOURCE_DIR}/extras/Catch.cmake) -catch_discover_tests(Tests) - -target_compile_definitions(Tests PUBLIC TESTING=1) - -target_include_directories(Tests PUBLIC PLUGDATA_INCLUDE_DIRECTORY) -target_include_directories(Tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Tests/) -target_include_directories(Tests PUBLIC "$") - -set_target_properties(Tests PROPERTIES PREFIX "") -set_target_properties(Tests PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden) -set_target_properties(Tests PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGDATA_PLUGINS_LOCATION}) -set_target_properties(Tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PLUGDATA_PLUGINS_LOCATION}) -set_property(TARGET Tests PROPERTY CXX_VISIBILITY_PRESET hidden) -set_property(TARGET Tests PROPERTY VISIBILITY_INLINES_HIDDEN ON) - +# 2x speedup for standalone debug builds in xcode +SET_TARGET_PROPERTIES(plugdata_standalone PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] "YES") endif() if(MSVC) set_target_properties(pthreadVC3 pthreadVSE3 pthreadVCE3 PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) endif() -set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS - WORLD_READ - WORLD_WRITE - WORLD_EXECUTE -) - if(APPLE) install(DIRECTORY ${PLUGDATA_PLUGINS_LOCATION}/VST3/plugdata.vst3 DESTINATION "/Library/Audio/Plug-ins/VST3") install(DIRECTORY ${PLUGDATA_PLUGINS_LOCATION}/VST3/plugdata-fx.vst3 DESTINATION "/Library/Audio/Plug-ins/VST3") diff --git a/Libraries/CMakeLists.txt b/Libraries/CMakeLists.txt index f346d353f3..6744b8aaee 100755 --- a/Libraries/CMakeLists.txt +++ b/Libraries/CMakeLists.txt @@ -17,6 +17,8 @@ cmake_policy(SET CMP0091 NEW) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") add_subdirectory(JUCE) +add_subdirectory(nanovg) + juce_add_module(melatonin_blur) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21") @@ -25,6 +27,8 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21") unset(MESSAGE_QUIET) endif() +set(PD_DIR "pure-data/") + # ------------------------------------------------------------------------------# set(CMAKE_MACOSX_RPATH ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -39,7 +43,8 @@ set(LIBPD_OUTPUT_DIRECTORY "./..") option(PD_UTILS "Compile libpd utilities" OFF) option(PD_EXTRA "Compile extras" ON) option(PD_LOCALE "Set the LC_NUMERIC number format to the default C locale" ON) - + + # ------------------------------------------------------------------------------# # SOURCES # ------------------------------------------------------------------------------# @@ -211,21 +216,21 @@ include_directories(pd-else/Code_source/Compiled/audio/sfz~/sfizz/library/src) source_group(ELSE FILES ${ELSE_SOURCES}) file(GLOB_RECURSE CYCLONE_SOURCES - ./cyclone/cyclone_objects/binaries/cyclone_lib.c - ./cyclone/cyclone_objects/binaries/audio/*.c - ./cyclone/cyclone_objects/binaries/control/*.c - ./cyclone/shared/common/*.c - ./cyclone/shared/control/*.c - ./cyclone/shared/signal/*.c + ./pd-cyclone/cyclone_objects/binaries/cyclone_lib.c + ./pd-cyclone/cyclone_objects/binaries/audio/*.c + ./pd-cyclone/cyclone_objects/binaries/control/*.c + ./pd-cyclone/shared/common/*.c + ./pd-cyclone/shared/control/*.c + ./pd-cyclone/shared/signal/*.c ) -include_directories(cyclone/) -include_directories(cyclone/shared/) -source_group(cyclone FILES ${CYCLONE_SOURCES}) +include_directories(pd-cyclone/) +include_directories(pd-cyclone/shared/) +source_group(pd-cyclone FILES ${CYCLONE_SOURCES}) # pdlua sources set(PDLUA_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pd-lua") -set(PDLUA_SOURCES ${PDLUA_PATH}/pdlua.c ${PDLUA_PATH}/pdlua_multi_instance.cpp) +set(PDLUA_SOURCES ${PDLUA_PATH}/pdlua.c) set(LUA_PATH "${PDLUA_PATH}/lua") set(LUA_INCLUDE_DIR ${LUA_PATH}) @@ -253,12 +258,18 @@ source_group(pdlua FILES ${PDLUA_SOURCES}) # ------------------------------------------------------------------------------# set(LIBPD_COMPILE_DEFINITIONS PD=1 USEAPI_DUMMY=1 PD_INTERNAL=1) +if(ENABLE_GEM) +add_subdirectory(Gem) +set(GEM_LIBS Gem ftgl glew_s freetype) +set(GEM_LIBS_MULTI Gem-multi ftgl glew_s freetype) +endif() if(ENABLE_SFIZZ) list(APPEND LIBPD_COMPILE_DEFINITIONS ENABLE_SFIZZ=1) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pd-else/Code_source/Compiled/audio/sfz~) endif() + # COMPILE DEFINITIONS OPTIONS # ------------------------------------------------------------------------------# if(PD_EXTRA) @@ -282,9 +293,10 @@ if(WIN32) list(APPEND LIBPD_COMPILE_DEFINITIONS HAVE_STRUCT_TIMESPEC=1 _CRT_SECURE_NO_WARNINGS=1 HAVE_ALLOCA=1 DONT_USE_ALLOCA=0) endif() elseif(UNIX) - list(APPEND LIBPD_COMPILE_DEFINITIONS HAVE_LIBDL=1 HAVE_UNISTD_H=1 HAVE_ALLOCA_H=1 HAVE_ALLOCA=1 DONT_USE_ALLOCA=0) - if(NOT APPLE) - list(APPEND LIBPD_COMPILE_DEFINITIONS HAVE_ENDIAN_H=1) + if(LINUX OR APPLE) + list(APPEND LIBPD_COMPILE_DEFINITIONS HAVE_LIBDL=1 HAVE_UNISTD_H=1 HAVE_ALLOCA_H=1 HAVE_ALLOCA=1 DONT_USE_ALLOCA=0) + else() # BSD + list(APPEND LIBPD_COMPILE_DEFINITIONS HAVE_LIBDL=1 HAVE_UNISTD_H=1 HAVE_ALLOCA=1 DONT_USE_ALLOCA=0 HAVE_ENDIAN_H=0) endif() endif() @@ -298,11 +310,11 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") # These are the warning flags I need to get pd to compile withoout warnings # Would be nice if these warnings were solved instead add_compile_options(-Wno-format -Wno-format-security -Wno-conversion -Wno-unused-variable -Wno-int-to-pointer-cast -Wno-parentheses -Wno-unused-value -Wno-unknown-pragmas) - + if(CMAKE_C_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-compare-distinct-pointer-types -Wno-implicit-int-conversion) endif() - + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-int-conversion -Wno-pointer-sign -Wno-pointer-to-int-cast -Wno-incompatible-pointer-types") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -fno-finite-math-only -ffast-math -funroll-loops -fomit-frame-pointer -O3") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0") @@ -333,7 +345,11 @@ list(APPEND SFONT_SOURCES ${FLUIDLITE_DIR}/src/fluid_sys.c ${FLUIDLITE_DIR}/src/fluid_tuning.c ${FLUIDLITE_DIR}/src/fluid_voice.c +) + +if(MSVC) +list(APPEND SFONT_SOURCES ${FLUIDLITE_DIR}/libvorbis-1.3.5/lib/vorbisenc.c ${FLUIDLITE_DIR}/libvorbis-1.3.5/lib/info.c ${FLUIDLITE_DIR}/libvorbis-1.3.5/lib/analysis.c @@ -360,6 +376,7 @@ list(APPEND SFONT_SOURCES ${FLUIDLITE_DIR}/libogg-1.3.2/src/bitwise.c ${FLUIDLITE_DIR}/libogg-1.3.2/src/framing.c ) +endif() list(APPEND SFONT_INCLUDES ${FLUIDLITE_DIR}/libvorbis-1.3.5/include @@ -378,13 +395,11 @@ list(APPEND ELSE_SOURCES ${SFONT_DIR}/sfont~.c ) -file(GLOB OFELIA_SOURCES ./plugdata-ofelia/Source/Objects/*.cpp ./plugdata-ofelia/Source/Objects/*.h ./plugdata-ofelia/Source/Shared/*.cpp ./plugdata-ofelia/Source/Shared/*.h) -source_group(ofelia FILES ${OFELIA_SOURCES}) # ------------------------------------------------------------------------------# # TARGETS # ------------------------------------------------------------------------------# -add_library(externals STATIC ${ELSE_SOURCES} ${CYCLONE_SOURCES} ${PDLUA_SOURCES} ${AUBIO_SOURCES} ${OFELIA_SOURCES}) -add_library(externals-multi STATIC ${ELSE_SOURCES} ${CYCLONE_SOURCES} ${PDLUA_SOURCES} ${AUBIO_SOURCES} ${OFELIA_SOURCES}) +add_library(externals STATIC ${ELSE_SOURCES} ${CYCLONE_SOURCES} ${PDLUA_SOURCES} ${AUBIO_SOURCES}) +add_library(externals-multi STATIC ${ELSE_SOURCES} ${CYCLONE_SOURCES} ${PDLUA_SOURCES} ${AUBIO_SOURCES}) # ag: pdlua needs PLUGDATA symbol at compile time for PlugData integration. target_compile_definitions(externals PRIVATE ${LIBPD_COMPILE_DEFINITIONS} PLUGDATA=1) @@ -395,6 +410,7 @@ target_compile_definitions(pd-src PRIVATE ${LIBPD_COMPILE_DEFINITIONS}) if(UNIX) target_compile_options(pd-src PRIVATE -fvisibility=default) + target_compile_options(externals PRIVATE -fvisibility=default) endif() add_library(pd-src-multi STATIC ${SOURCE_FILES}) @@ -404,6 +420,7 @@ if(MSVC) target_compile_definitions(pd-src-multi PRIVATE PTW32_STATIC_LIB=1 "EXTERN= ") endif() +set_target_properties(externals-multi PROPERTIES CXX_VISIBILITY_PRESET hidden) set_target_properties(pd-src-multi PROPERTIES CXX_VISIBILITY_PRESET hidden) set_target_properties(pd-src PROPERTIES POSITION_INDEPENDENT_CODE ON) @@ -429,22 +446,22 @@ if("${CMAKE_SYSTEM}" MATCHES "Linux") add_library(pd INTERFACE) add_library(pd-multi INTERFACE) find_library(MATH_LIB m) - target_link_libraries(externals ${externals_libs}) - target_link_libraries(externals-multi ${externals_libs}) + target_link_libraries(externals ${externals_libs} ${GEM_LIBS}) + target_link_libraries(externals-multi ${externals_libs} ${GEM_LIBS_MULTI}) elseif(MSVC) add_library(pd SHARED $ $) add_library(pd-multi STATIC $ $) - target_link_libraries(pd PUBLIC pthreadVC3 ws2_32 ${externals_libs}) - target_link_libraries(pd-multi PUBLIC pthreadVC3 ws2_32 ${externals_libs}) + target_link_libraries(pd PUBLIC pthreadVC3 ws2_32 ${externals_libs} ${GEM_LIBS}) + target_link_libraries(pd-multi PUBLIC pthreadVC3 ws2_32 ${externals_libs} ${GEM_LIBS_MULTI}) add_custom_command(TARGET pd POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/$/pd.dll" ${CMAKE_SOURCE_DIR}/Plugins/Standalone/pd.dll) elseif(APPLE) - target_link_libraries(externals ${externals_libs}) - target_link_libraries(externals-multi ${externals_libs}) + target_link_libraries(externals ${externals_libs} ${GEM_LIBS}) + target_link_libraries(externals-multi ${externals_libs} ${GEM_LIBS_MULTI}) endif() # PTHREAD diff --git a/Libraries/Catch2 b/Libraries/Catch2 deleted file mode 160000 index 8c952bd076..0000000000 --- a/Libraries/Catch2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8c952bd0762c2962c5ac1b2bf8af075b2b4c3500 diff --git a/Libraries/Gem b/Libraries/Gem new file mode 160000 index 0000000000..dacd06992e --- /dev/null +++ b/Libraries/Gem @@ -0,0 +1 @@ +Subproject commit dacd06992ec5e8533187322fdd61810ac922123b diff --git a/Libraries/JUCE b/Libraries/JUCE index 3fa91012aa..66d55784e5 160000 --- a/Libraries/JUCE +++ b/Libraries/JUCE @@ -1 +1 @@ -Subproject commit 3fa91012aa5c1c65933ba8fa90984c0c5df293e0 +Subproject commit 66d55784e50d7ea384a48184b08da0a381e8a2b7 diff --git a/Libraries/clap-juce-extensions b/Libraries/clap-juce-extensions index 5f369ad244..4491bc3022 160000 --- a/Libraries/clap-juce-extensions +++ b/Libraries/clap-juce-extensions @@ -1 +1 @@ -Subproject commit 5f369ad244e4b1ccd2eb943bd6dac993fb444262 +Subproject commit 4491bc30223cecf8ff495de943510863b71a7a81 diff --git a/Libraries/cpath/LICENSE b/Libraries/cpath/LICENSE deleted file mode 100644 index 0fd3795b6c..0000000000 --- a/Libraries/cpath/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 Braedon - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Libraries/cpath/README.md b/Libraries/cpath/README.md deleted file mode 100644 index 46ab6e6044..0000000000 --- a/Libraries/cpath/README.md +++ /dev/null @@ -1,128 +0,0 @@ -# CPath - -![](https://github.com/BraedonWooding/cpath/workflows/CI/badge.svg) - -> Made By Braedon Wooding - -> Fast (see benchmarks at the bottom), efficient (optimised towards reducing dynamic allocations), and simple - -A simple and nice looking cross platform C FileSystem. I'll put up some documentation and tests up soon. - -It worked out really nicely from my basic idea in my head. Check out the `example.c` file if you want some basic idea of how it works. - -## Why - -Because I wanted a filesystem for my IMGUI Widget library but I didn't want to only support C++17 so I needed a preferably early standardised C++ (or C) library. While there existed plenty of variants their APIs weren't particularly nice or they didn't try to reduce includes or various other issues. The key thing for me was wanting to just have a single while loop function to both check if there is a next one and then assign the next one rather than having to split it into potentially 3! Which some had (i.e. a hasNext, a getFile, and a moveNext). - -I also felt that the code was quite obfuscated for some and it felt like they overused the #ifdefs to try to get as much similar as possible rather than trying to just make it more readable at the cost of a small amount of local duplication. - -I chose to make this very young i.e. C89/C99 ish since I was already going quite far with making it work with all versions of C++. - -## What this aims to be and what it doesn't aim to be - -- A simple and straightforward lite filesystem. -- The ability to create abstract paths and canonicalise them into real ones -- Very lite cpp bindings for C++ pre 17 (does include operators however) -- Meant to be highly extensible by the user so everything is exposed -- NOT make any overarching architectural designs that could pollute the user's paradigm -- NOT a replacement for a more heavy duty library like `std::filesystem` -- NOT to dictate anything to do with opening/handling files -- NOT to dictate anything to do with stuff like watching files or creating files - -## Credits - -I would like to put a thanks out to a lot of other similar libraries for giving me some source to compare against to make sure I was using the APIs correctly and some ideas for how to structure my API. - -## Comparisons against other libraries - -> If you want performance comparisons check out the benchmarks, TLDR though is that CPath is often around 3x faster than other libraries and even faster than `find`. - -CPath offers a variety of features such as; - -- The ability to emplace directories and save the old directory to be able to restore it later on - - This allows you to traverse it without having to use recursion or a custom stack (via a linked list or similar) allowing infinite traversal (within limits of RAM) - - While TinyDir offers emplacing it won't store the old one and you can't restore it this makes recursing using it limited and requires some external stack or queue. - - Cute files offers no such feature -- The ability to cache files and refer to them by number and then custom sort them - - Cute files offers no such feature - - TinyDir offers the ability to cache them but not custom sort you also can't refresh the cache -- Fully C++ Bindings in a familiar style including operators for paths -- The ability to concatenate paths together and compare them in an easy way - - Paths seem to be fully exempt from the other libraries except as just a 'string' -- Really efficient 'open file' (that is get information about a file from a path) - - Only requires a single system call! - - TinyDir has a similar function but it requires opening the parent directory and finding it from the iterator, this is very prone to races and is significantly slower requiring a lot more syscalls - - Up to O(n) minimum system calls - - Cute files offers no such feature -- Extensive tests for all features - - Cute files has a lot of functions marked with 'not tested' making it potentially highly unstable - - TinyDir has few tests that test edge cases or performance but all around good coverage -- You can output file sizes using multiple different byte size representations - - intervals of 1024 IEC (KiB, GiB, ...), JEDEC (KB, GB, ...) - - and intervals of 1000 both in normal (kB, GB, ...) and upper/lower - - you can also change the word `bytes` and force it to be always a word or just `B` independent of above. - - Both tinydir and cute files offers no feature like this -- In my opinion it also looks much nicer (especially cpp bindings) you can use a single function in a while loop to iterate and its very nice -- There are some serious benchmarking work going on to make sure that we don't regress to a slower speed over time! - -CPath however has a few 'cons'; - -- It is much larger at around ~2.5k lines compared to TinyDir's 800 and Cute Files 500 - - Cute files is much more bare bones (not a bad thing!) and results in smaller binaries - - You can disable the CPP bindings in CPath if you want to reduce the footprint by about 600 lines - - Just `#define NO_CPP_BINDINGS` before include -- It requires some constant tables for it's suffix printing - - Only some small constant strings and I presume since the tables are pretty similar they'll be some optimisation or something. -- It doesn't load `stat` automatically this is mainly for optimisation purposes as it is often not needed unless you need time information or size. It'll load it automatically as needed if you use the functions to get time / size and you can load it yourself using `cpathGetFileInfo` (or `File::GetFileInfo` in cpp) if you wish. I wouldn't call this a con but it is something that could be an inconvenience - - Both tinydir and cute files always load stats every time you get a file in unix - - TinyDir also loads it in windows every time you get a file - - Cutefiles also loads it again every time it is used for time/size - -## Benchmarks - -> Model Name: MacBook Air - -> Model Identifier: MacBookAir7,2 - -> Processor Name: Intel Core i5 - -> Processor Speed: 1.6 GHz - -> Number of Processors: 1 - -> Total Number of Cores: 2 - -> L2 Cache (per Core): 256 KB - -> L3 Cache: 3 MB - -> Memory: 8 GB - -These were retrieved from the test file. I sorted them by time and did a small amount of formatting. I'll always provide a picture with each one for the purposes of comparison :). - -> Note: If you feel that I somehow wrote these scripts inefficiently please submit a PR with fixes and I'll run the benchmarks. Eventually we'll run these benchmarks on multiple machines (eventually) but for now it's easier to just not. - -### Recursive vs Stack through a large directory system - -> This test takes a while to run since creating the files can take a while and we are running a 100 tests to get a reasonable average. - -| Test | User | System | Wall | -| ------------------------ | ------ | ------ | ------ | -| CPath (Recursion in C) | 0.020s | 0.062s | 0.082s | -| CPath (Emplace in C) | 0.020s | 0.063s | 0.083s | -| CPath (Recursive in cpp) | 0.020s | 0.062s | 0.082s | -| CPath (Emplace in cpp) | 0.020s | 0.063s | 0.083s | -| find | 0.021s | 0.126s | 0.147s | -| Python (os.walk) | 0.156s | 0.081s | 0.237s | -| Cute Files | 0.041s | 0.243s | 0.284s | -| TinyDir | 0.050s | 0.244s | 0.294s | -| tree | 0.369s | 0.256s | 0.626s | - -Observations - -- This is done on `-O3` BUT has no difference (from what I can see) for `-O1` and `-O2` the only difference is `-O0` which is consistently around 5% slower. -- Yes this does show that CPath is faster than `find` which I'm quite proud of - - The user time is the same which is not that surprising since they both are 'well' written in C - - The system time is different indicating I do less syscalls -- Interestingly enough python beats both of the other libraries, I guess this comes to show that writing good code is all about optimising the bottle necks! Even though the user time is around 4-5x faster (still not amazing since mine runs about 8-10x faster) it is absolutely hammered by the system time being around 3x slower there. And since that is a bottle neck it results in the whole system running signifincantly slower. -- All methods are practically identical in performance for CPath. diff --git a/Libraries/cpath/cpath.h b/Libraries/cpath/cpath.h deleted file mode 100644 index d1b8398121..0000000000 --- a/Libraries/cpath/cpath.h +++ /dev/null @@ -1,2506 +0,0 @@ -/* -MIT License - -Copyright (c) 2019 Braedon Wooding - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef CPATH_H -#define CPATH_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - Note this library also works with C++ via a C++ provided binding - which is available for free just by including this on a C++ compiler - or with __cplusplus defined - - If you want: - - Unicode just add a #define CPATH_UNICODE or UNICODE or _UNICODE - - Custom Allocators just #define: - - CPATH_MALLOC and CPATH_FREE (make sure to define both) -*/ - -/* - Note on why this library offers no guarantees on reentrant systems - or no TOUTOC (and other race conditions): - - Often supporting this requires breaking a ton of compatability - and often the behaviour of each of the individual commands differs way - too much to make it consistent. Even when fully following it we can't - guarantee that you won't just misuse it and still cause the race conditions - - The majority (99%) of cases simply just don't care about it how often - are your files being written over... - - We have extra safety on things like opening directories and recursive - solutions to make sure that things like that don't happen. - - How do you want to handle it properly? You may want to just keep going - or you may want some way to unwind what you previously did, or just take - a snapshot of the system... It is too varied for us to offer a generalised - way. - - The majority of libraries don't offer it or they offer it to an extremely - limited number of commands with the others not having it, in my opinion - this is worse than just not offering it. Atleast we are consistent with - our guarantees - - File Systems are a mess and already are basically a gigantic global mess - trying to guarantee any sort of safety is not only a complexity mess but - also can give the wrong idea. - - You should be able to detect hard failures due to the change in a folder - and simply just re-call. Of course this could happen repeatedly but - come on... In reality it will occur once in a blue moon. - - Reloading files is easy it is just cpathLoadFiles -*/ - -/* - @TODO: - - Windows has lifted their max path so we could use the new functions - I don't think all functions have an alternative and it could be more messy - still look into it eventually. -*/ - -// custom allocators -#if !defined CPATH_MALLOC && !defined CPATH_FREE -#define CPATH_MALLOC(size) malloc(size) -#define CPATH_FREE(ptr) free(ptr) -#elif (defined CPATH_MALLOC && !defined CPATH_FREE) || \ - (defined CPATH_FREE && !defined CPATH_MALLOC) -#error "Can't define only free or only malloc have to define both or neither" -#endif - -// Support unicode -#if defined CPATH_UNICODE || (!defined UNICODE && defined _UNICODE) -#define UNICODE -#endif - -#if defined CPATH_UNICODE || (defined UNICODE && !defined _UNICODE) -#define _UNICODE -#endif - -#if !defined CPATH_UNICODE && (defined UNICODE || defined _UNICODE) -#define CPATH_UNICODE -#endif - -#ifdef _MSC_VER -#define _CPATH_FUNC_ static __inline -#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L -#define _CPATH_FUNC_ static __inline__ -#else -#define _CPATH_FUNC_ static inline -#endif - -/* == #includes == */ - -#if defined _MSC_VER || defined __MINGW32__ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include -#endif - -#ifdef _MSC_VER -#include -// Ignore all warnings to do with std functions not being 100% safe -// they are fine -#pragma warning(push) -#pragma warning (disable : 4996) -#else -#include -#include -#include -#include -#endif - -// NOTE: This has to appear before defined BSD -// since sys/param.h defines BSD given environment -#if defined __unix__ || (defined __APPLE__ && defined __MACH__) -#include -#endif - -#if defined __linux__ || defined BSD -#include -#endif - -#ifdef __MINGW32__ -#include -#endif - -#include -#include -#include -#include -#include -#include - -// Linux has a max of 255 (+1 for \0) I couldn't find a max on windows -// But since 260 > 256 it is a reasonable value that should be crossplatform -#define CPATH_MAX_FILENAME_LEN (256) - -/* Windows Unicode Support */ -#if defined _MSC_VER || defined __MINGW32__ -#define CPATH_STR(str) _TEXT(str) -#define cpath_str_length _tcslen -#define cpath_str_copy _tcscpy -#define cpath_strn_copy _tcsncpy -#define cpath_str_find_last_char _tcsrchr -#define cpath_str_compare _tcscmp -#define cpath_str_compare_safe _tcsncmp -#define cpath_fopen _tfopen -#define cpath_sprintf _stprintf -#define cpath_vsnprintf _vsntprintf -#else -#define CPATH_STR(str) str -#define cpath_str_length strlen -#define cpath_str_copy strcpy -#define cpath_strn_copy strncpy -#define cpath_str_find_last_char strrchr -#define cpath_str_compare strcmp -#define cpath_str_compare_safe strncmp -#define cpath_fopen fopen -#define cpath_sprintf sprintf -#define cpath_vsnprintf vsnprintf -#endif - -#if defined _MSC_VER || defined __MINGW32__ -#define CPATH_MAX_PATH_LEN MAX_PATH -#elif defined __linux__ || defined BSD - -// @TODO: Do we add one? for \0 -// I have found conflicting info -// we definitely don't for windows -#ifdef PATH_MAX -#define CPATH_MAX_PATH_LEN PATH_MAX -#endif - -#endif - -// Found this value online in a few other libraries -// so I'll just continue this tradition/standard despite not knowing why -// @A: This seems to be the max on Linux so I suppose its a reasonable value -#ifndef CPATH_MAX_PATH_LEN -#define CPATH_MAX_PATH_LEN (4096) -#endif - -// on windows we need extra space for the \* mask that is required -// yes this is very weird... Maybe we can just chuck it onto the max path? -// I don't think we can because it seems that it is independent of the max path -// i.e. if you can have a max path of 256 characters this includes the extra -// in this case we could just subtract it from the max path -// but then again we may not always want to apply the mask (and we don't) -// so that isn't a great solution either... -// @TODO: Figure this stuff out. -#ifdef _MSC_VER -#define CPATH_PATH_EXTRA_CHARS (2) -#else -#define CPATH_PATH_EXTRA_CHARS (0) -#endif - -/* - NOTE: This isn't the maximum number of drives (that would be 26) - This is the length of a drive prepath i.e. D:\ which is clearly 3 - - No such max exists on other systems to the best of my knowledge - - By defining it like (static_assert(0, msg), 1) we make sure that we don't - have a compiler syntax error in it's typical usage we prefer having - the error from having the static assert rather than the error for having - an incorrect token. - @TODO: Do we actually need this??? -*/ -#if defined _MSC_VER -#define FILE_IS(f, flag) !!(f.dwFileAttributes & FILE_ATTRIBUTE_##flag) -#define FILE_IS_NOT(f, flag) !(f.dwFileAttributes & FILE_ATTRIBUTE_##flag) -#endif - -#if defined _MSC_VER || defined __MINGW32__ -#define CPATH_MAX_DRIVE_LEN (3) -#elif __cpp_static_assert -#define CPATH_MAX_DRIVE_LEN \ - (static_assert(0, "You shouldn't use max drive length on non windows"), 1) -#elif __STDC_VERSION__ >= 201112L -#define CPATH_MAX_DRIVE_LEN \ - (_Static_assert(0, "You shouldn't use max drive length on non windows"), 1) -#else -#define CPATH_MAX_DRIVE_LEN \ - ("You shouldn't use max drive length on non windows", ) -#endif - -#if defined _WIN32 - #include - #define _cpath_getcwd _getcwd -#else - #include // for getcwd() - #define _cpath_getcwd getcwd -#endif - -#if !defined _MSC_VER -#if defined __MINGW32__ && defined _UNICODE -#define _cpath_opendir _wopendir -#define _cpath_readdir _wreaddir -#define _cpath_closedir _wclosedir -#else -#define _cpath_opendir opendir -#define _cpath_readdir readdir -#define _cpath_closedir closedir -#endif -#endif - -#if defined CPATH_FORCE_CONVERSION_SYSTEM -#if defined _MSC_VER || defined __MINGW32__ -#define CPATH_SEP CPATH_STR('\\') -#define CPATH_OTHER_SEP CPATH_STR('/') -#else -#define CPATH_SEP CPATH_STR('/') -#define CPATH_OTHER_SEP CPATH_STR('\\') -#endif -#else -#define CPATH_SEP CPATH_STR('/') -#define CPATH_OTHER_SEP CPATH_STR('\\') -#endif - -#if !defined CPATH_NO_CPP_BINDINGS && defined __cplusplus - namespace cpath { namespace internals { -#endif - -// @NOTE: gdb/lldb can't print our strings -// for some reason they don't understand the typedefs -// however they will understand a #define cause they'll -// just see it as a char symbol. -// @BUG: @TODO: Make it so it can be a typedef... -// Currently I just have decided to make it default to this -// Worse case we introduce a #define -#if defined _MSC_VER || defined __MINGW32__ -// todo -typedef int cpath_offset_t; -typedef int cpath_time_t; -typedef TCHAR cpath_char_t; -#else -typedef char cpath_char_t; -typedef off_t cpath_offset_t; -typedef time_t cpath_time_t; -#endif - -#if !defined _MSC_VER -#if defined __MINGW32__ && defined _UNICODE -typedef _WDIR cpath_dirdata_t; -typedef struct _wdirent cpath_dirent_t; -#else -typedef DIR cpath_dirdata_t; -typedef struct dirent cpath_dirent_t; -#endif -#endif - -typedef cpath_char_t *cpath_str; -typedef int(*cpath_err_handler)(); -typedef int(*cpath_cmp)(const void*, const void*); -typedef struct cpath_t { - cpath_char_t buf[CPATH_MAX_PATH_LEN]; - size_t len; -} cpath; - -typedef struct cpath_file_t { - int isDir; - int isReg; - int isSym; - -#if !defined _MSC_VER -#if defined __MINGW32__ - struct _stat stat; -#else - struct stat stat; -#endif -#endif - - int statLoaded; - - cpath path; - cpath_char_t name[CPATH_MAX_FILENAME_LEN]; - cpath_str extension; -} cpath_file; - -typedef struct cpath_dir_t { - cpath_file *files; - size_t size; - -#ifdef _MSC_VER - HANDLE handle; - WIN32_FIND_DATA findData; -#else - cpath_dirdata_t *dir; - cpath_dirent_t *dirent; -#endif - - // This is set whenever you do an emplace - // This allows you to revert an emplace - struct cpath_dir_t *parent; - - int hasNext; - - cpath path; -} cpath_dir; - -// This allows a forced type -typedef uint8_t CPathByteRep; -enum CPathByteRep_ { - BYTE_REP_JEDEC = 0, // KB = 1024, ... - BYTE_REP_DECIMAL = 1, // 1000 interval segments, B, kB, MB, GB, ... - BYTE_REP_IEC = 2, // KiB = 1024, ... - BYTE_REP_DECIMAL_UPPER = 3, // 1000 interval segments but B, KB, MB, GB, ... - BYTE_REP_DECIMAL_LOWER = 4, // 1000 interval segments but b, kb, mb, gb, ... - - // representations - BYTE_REP_LONG = 0b10000000, // Represent as words i.e. kibibytes - BYTE_REP_BYTE_WORD = 0b01000000, // Just B as Byte (only bytes) -}; - -typedef void(*cpath_traverse_it)( - cpath_file *file, cpath_dir *parent, int depth, - void *data -); - -/* == Declarations == */ - -/* == Path == */ - -/* - A clear path is always just '.' - - When constructing a path it will always ignore extra / or \ at the end - and multiple in a row. - - i.e. C://a\b\\c\ is just C:/a/b/c/ - - If you wish to force conversion to the system specific one - (/ on posix \ on windows) then just add - #define CPATH_FORCE_CONVERSION_SYSTEM - i.e. on Windows it will be C:\a\b\c on Posix it will be C:/a/b/c -*/ - -/* - Does a strcpy but converts all separators and ignores multiple in a row - Returns how many characters were copied. -*/ -_CPATH_FUNC_ -size_t cpathStrCpyConv(cpath_str dest, size_t len, const cpath_char_t *src); - -/* - Trim all trailing / or \ from a path -*/ -_CPATH_FUNC_ -void cpathTrim(cpath *path); - -/* - Construct a path from a utf8 string -*/ -_CPATH_FUNC_ -cpath cpathFromUtf8(const char *str); - -/* - Copy a path -*/ -_CPATH_FUNC_ -void cpathCopy(cpath *out, const cpath *in); - -/* - Construct a path from a system typed string. -*/ -_CPATH_FUNC_ -int cpathFromStr(cpath *out, const cpath_char_t *str); - -/* - Concatenate a path with a literal -*/ -#define CPATH_CONCAT_LIT(path, other) cpathConcatStr(path, CPATH_STR(other)) - -/* - Appends to a path with a literal, wont add a / -*/ -#define CPATH_APPEND_LIT(path, other) cpathAppendStr(path, CPATH_STR(other)) - -/* - Append to the cpath buffer. - NOTE: Won't add a / - There is no concat version since it would be too inefficient - and thus encourage bad habits. Just add a / everytime you call this -*/ -_CPATH_FUNC_ -void cpathAppendSprintf(cpath *out, const cpath_char_t *fmt, ...); - -/* - Appends to the path (not adding /) -*/ -_CPATH_FUNC_ -int cpathAppendStrn(cpath *out, const cpath_char_t *other, size_t len); - -/* - Appends to the path (not adding /) -*/ -_CPATH_FUNC_ -int cpathAppendStr(cpath *out, const cpath_char_t *other); - -/* - Appends to the path (not adding /) -*/ -_CPATH_FUNC_ -int cpathAppend(cpath *out, const cpath *other); - -/* - Concatenate a path (adds / for you) from a system typed string -*/ -_CPATH_FUNC_ -int cpathConcatStrn(cpath *out, const cpath_char_t *other, size_t len); - -/* - Concatenate a path (adds / for you) from a system typed string -*/ -_CPATH_FUNC_ -int cpathConcatStr(cpath *out, const cpath_char_t *other); - -/* - Concat a path with another. -*/ -_CPATH_FUNC_ -int cpathConcat(cpath *out, const cpath *other); - -/* - Does the path exist. -*/ -_CPATH_FUNC_ -int cpathExists(const cpath *path); - -/* - Attempts to canonicalise without system calls - Will fail in cases where it can't predict the path - i.e. C:/a/../b will be just b -*/ -_CPATH_FUNC_ -int cpathCanonicaliseNoSysCall(cpath *out, cpath *path); - -/* - Resolves the path. Involves system calls. -*/ -_CPATH_FUNC_ -int cpathCanonicalise(cpath *out, cpath *path); - -/* - Tries to canonicalise without any system calls - then resorts to the system call version if it fails -*/ -_CPATH_FUNC_ -int cpathCanonicaliseAvoidSysCall(cpath *out, cpath *path); - -/* - Clears a given path. -*/ -_CPATH_FUNC_ -void cpathClear(cpath *path); - -/* - Iterate through every component. Doesn't include the \ - i.e. \usr\local\bin\myfile.so will be '' 'usr' 'local' 'bin' 'myfile.so' - - If you wish to iterate from the beginning set index to 0. Else set index - to whatever index you wish to iterate from. It'll restore the previous - segments as it goes meaning on completion the path will be fully restored. - - NOTE: Modifies the path buffer so you shouldn't use the path for anything - Until this returns nullptr (indicating no more path segments) - OR you use cpathItRefRestore() note that on the last path segment - it obviously won't have to add an '\0' so it'll also work if you bail - out then. It is hard to detect that though. - - You can strdup it yourself or do a memcpy if you care about editing it -*/ -_CPATH_FUNC_ -const cpath_char_t *cpathItRef(cpath *path, int *index); - -/* - Restores the path to a usable state. - ONLY needs to be called if the path is wanted to be usable and you haven't - iterated through all the references. - If the index isn't valid it'll cycle through the path fixing it up. - This is just for the sake of it, it'll make things easier and less prone - to breaking. - - Do note that this will update index so that you can use it again with - it ref to get the resumed behaviour you would expect (effectively just a ++) -*/ -_CPATH_FUNC_ -void cpathItRefRestore(cpath *path, int *index); - -/* - Go up a directory effectively going back by one / - i.e. C:/D/E/F/g.c => C:/D/E/F and so on... - Returns true if it succeeded - Could possibly involve a canonicalise if the path is a symlink - i.e. ./ has to be resolved and so does ~/ -*/ -_CPATH_FUNC_ -int cpathUpDir(cpath *path); - -/* - Converts all separators to the given separator - Note: will only convert / and \ -*/ -_CPATH_FUNC_ -void cpathConvertSepCustom(cpath *path, cpath_char_t sep); - -/* - Converts all seperators to the default one. -*/ -_CPATH_FUNC_ -void cpathConvertSep(cpath *path) { cpathConvertSepCustom(path, CPATH_SEP); } - -/* == File System == */ - -/* - Get the current working directory allocating the space -*/ -_CPATH_FUNC_ -cpath_char_t *cpathGetCwdAlloc(); - -/* - Get the current working directory passing in a buffer -*/ -_CPATH_FUNC_ -cpath_char_t *cpathGetCwdBuf(cpath_char_t *buf, size_t size); - -/* - Write the cwd to a path buffer. -*/ -_CPATH_FUNC_ -void cpathWriteCwd(cpath *path); - -/* - Get the cwd as a path. -*/ -_CPATH_FUNC_ -cpath cpathGetCwd(); - -/* - Opens a directory placing information into the given directory buffer. -*/ -_CPATH_FUNC_ -int cpathOpenDir(cpath_dir *dir, const cpath *path); - -/* - Restarts the given directory iterator. -*/ -_CPATH_FUNC_ -int cpathRestartDir(cpath_dir *dir); - -/* - Clear directory data. - If closing parents then will recurse through all previous emplaces. -*/ -_CPATH_FUNC_ -void cpathCloseDir(cpath_dir *dir); - -/* - Move to the next file in the iterator. -*/ -_CPATH_FUNC_ -int cpathMoveNextFile(cpath_dir *dir); - -/* - Load stat. Sets statLoaded. -*/ -_CPATH_FUNC_ -int cpathGetFileInfo(cpath_file *file); - -/* - Load file flags such as isDir, isReg, isSym - Attempts to not use stat since that is slow -*/ -_CPATH_FUNC_ -int cpathLoadFlags(cpath_dir *dir, cpath_file *file, void *data); - -/* - Peeks the next file but doesn't move the iterator along. -*/ -_CPATH_FUNC_ -int cpathPeekNextFile(cpath_dir *dir, cpath_file *file); - -/* - Get the next file inside the directory, acts like an iterator. - i.e. while (cpathGetNextFile(...)) can use dir->hasNext to verify - that there are indeed a file but it is safe! - - File may be nullptr if you don't wish to actually get a copy -*/ -_CPATH_FUNC_ -int cpathGetNextFile(cpath_dir *dir, cpath_file *file); - -/* - Is the file . or .. -*/ -_CPATH_FUNC_ -int cpathFileIsSpecialHardLink(const cpath_file *file); - -/* - Preload all files in a directory. Will be called automatically in some - function calls such as cpathGetFile() -*/ -_CPATH_FUNC_ -int cpathLoadAllFiles(cpath_dir *dir); - -/* - More of a helper function, checks if we have space for n - and will preload any files if required. -*/ -_CPATH_FUNC_ -int cpathCheckGetN(cpath_dir *dir, size_t n); - -/* - Get the nth file inside the directory, this is independent of the iterator - above. - - Note calling this will require the reading of the entire directory. - if you want to prevent all these allocations then I recommend using - getNextFile(...) -*/ -_CPATH_FUNC_ -int cpathGetFile(cpath_dir *dir, cpath_file *file, size_t n); - -/* - Get a const reference to a file, this is more performant than GetFile - but you can't modify anything about the object. -*/ -_CPATH_FUNC_ -int cpathGetFileConst(cpath_dir *dir, const cpath_file **file, size_t n); - -/* - Opens the next sub directory into this - Saves the old directory into the parent if given saveDir -*/ -_CPATH_FUNC_ -int cpathOpenSubFileEmplace(cpath_dir *dir, const cpath_file *file, int saveDir); - -/* - Opens the n'th sub directory into this directory - Saves the old directory into the parent if given saveDir -*/ -_CPATH_FUNC_ -int cpathOpenSubDirEmplace(cpath_dir *dir, size_t n, int saveDir); - -/* - Opens the n'th sub directory into other given directory -*/ -_CPATH_FUNC_ -int cpathOpenSubDir(cpath_dir *out, cpath_dir *dir, size_t n); - -/* - Opens the next sub directory into other given directory -*/ -_CPATH_FUNC_ -int cpathOpenNextSubDir(cpath_dir *out, cpath_dir *dir); - -/* - Peeks the sub directory. -*/ -_CPATH_FUNC_ -int cpathOpenNextSubDir(cpath_dir *out, cpath_dir *dir); - -/* - Opens the next sub directory into this - Saves the old directory into the parent if given saveDir -*/ -_CPATH_FUNC_ -int cpathOpenNextSubDirEmplace(cpath_dir *dir, int saveDir); - -/* - Peeks the sub directory -*/ -_CPATH_FUNC_ -int cpathOpenCurrentSubDirEmplace(cpath_dir *dir, int saveDir); - -/* - Revert an emplace and go back to the parent. - Note: This can occur multiple times. - Returns true if it went back to the parent. - - This form is for a pointer variant where the storage - of the first directory is external. -*/ -_CPATH_FUNC_ -int cpathRevertEmplace(cpath_dir **dir); - -/* - Revert an emplace and go back to the parent. - Note: This can occur multiple times. - Returns true if it went back to the parent. - - This form is for a directory that is stored - internally to the function. -*/ -_CPATH_FUNC_ -int cpathRevertEmplaceCopy(cpath_dir *dir); - -/* - Opens the given path as a file. -*/ -_CPATH_FUNC_ -int cpathOpenFile(cpath_file *file, const cpath *path); - -/* - Converts a given file to a directory. - Note: Fails to convert if the file isn't a directory. -*/ -_CPATH_FUNC_ -int cpathFileToDir(cpath_dir *dir, const cpath_file *file); - -/* - Get the extension for a file. - Note: You can't access a file's extension BEFORE you call this - It will be nullptr prior. - Returns nullptr if no extension or if it is a directory. -*/ -_CPATH_FUNC_ -cpath_str cpathGetExtension(cpath_file *file); - -/* - Get the time of last access -*/ -_CPATH_FUNC_ -cpath_time_t cpathGetLastAccess(cpath_file *file); - -/* - Get the time of last modification -*/ -_CPATH_FUNC_ -cpath_time_t cpathGetLastModification(cpath_file *file); - -/* - Get the file size in bytes of this file. -*/ -_CPATH_FUNC_ -cpath_offset_t cpathGetFileSize(cpath_file *file); - -/* - Standard compare function for files -*/ -_CPATH_FUNC_ -void cpathSort(cpath_dir *dir, cpath_cmp cmp); - -/* - Get the file size in decimal form -*/ -_CPATH_FUNC_ -double cpathGetFileSizeDec(cpath_file *file, int interval); - -/* - Get the file size prefix -*/ -_CPATH_FUNC_ -const cpath_char_t *cpathGetFileSizeSuffix(cpath_file *file, CPathByteRep rep); - -/* - Create the given directory -*/ -_CPATH_FUNC_ -int cpathMkdir(const cpath *path); - -/* - Open a given file -*/ -_CPATH_FUNC_ -FILE *cpathOpen(const cpath *path, const cpath_char_t *mode); - -/* == Definitions == */ - -/* == Path == */ - -_CPATH_FUNC_ -size_t cpathStrCpyConv(cpath_str dest, size_t len, const cpath_char_t *src) { - int lastWasSep = 0; - cpath_str startDest = dest; - for (size_t i = 0; i < len + 1; i++) { - int isSep = src[i] == CPATH_OTHER_SEP || src[i] == CPATH_SEP; - - if (isSep && !lastWasSep) { - *dest++ = CPATH_SEP; - } else if (!isSep || !lastWasSep) { - *dest++ = src[i]; - } - lastWasSep = isSep; - } - return dest - startDest - 1; -} - -_CPATH_FUNC_ -void cpathTrim(cpath *path) { - /* trim all the terminating / and \ */ - /* We don't want to trim // into empty string - We will trim it to just / - */ - while (path->len > 1 && (path->buf[path->len - 1] == CPATH_SEP || - path->buf[path->len - 1] == CPATH_OTHER_SEP)) { - path->len--; - } - path->buf[path->len] = CPATH_STR('\0'); -} - -_CPATH_FUNC_ -cpath cpathFromUtf8(const char *str) { - cpath path; - if (str[0] == CPATH_STR('\0')) { - // empty string which is just '.' - path.len = 1; - path.buf[0] = CPATH_STR('.'); - path.buf[1] = CPATH_STR('\0'); - return path; - } - - path.len = 0; - path.buf[0] = CPATH_STR('\0'); - size_t len = cpath_str_length(str); - // NOTE: max path len includes the \0 where as str length doesn't! - if (len >= CPATH_MAX_PATH_LEN) { - errno = ENAMETOOLONG; - return path; - } -#if defined CPATH_UNICODE && defined _MSC_VER - mbstowcs_s(&path.len, path.buf, len + 1, str, CPATH_MAX_PATH_LEN); - cpathConvertSep(&path); -#else - path.len = cpathStrCpyConv(path.buf, len, str); -#endif - cpathTrim(&path); - return path; -} - -_CPATH_FUNC_ -void cpathCopy(cpath *out, const cpath *in) { - cpath_str_copy(out->buf, in->buf); - out->len = in->len; -} - -_CPATH_FUNC_ -int cpathFromStr(cpath *out, const cpath_char_t *str) { - size_t len = cpath_str_length(str); - if (len >= CPATH_MAX_PATH_LEN) return 0; - if (len == 0) { - out->len = 1; - out->buf[0] = CPATH_STR('.'); - out->buf[1] = CPATH_STR('\0'); - return 1; - } - - out->len = cpathStrCpyConv(out->buf, len, str); - cpathTrim(out); - return 1; -} - -_CPATH_FUNC_ -void cpathAppendSprintf(cpath *out, const cpath_char_t *fmt, ...) { - va_list list; - va_start(list, fmt); - out->len += cpath_vsnprintf(out->buf + out->len, - CPATH_MAX_PATH_LEN - out->len, fmt, list); - va_end(list); -} - -_CPATH_FUNC_ -int cpathAppendStrn(cpath *out, const cpath_char_t *other, size_t len) { - if (len + out->len >= CPATH_MAX_PATH_LEN) { - // path too long, >= cause max path includes CPATH_STR('\0') - errno = ENAMETOOLONG; - return 0; - } - - // This is more efficient than a strcat since it doesn't have to get - // the length again it also handles all the conversions well and doesn't - // have to retraverse the out->buf which we know is fine. - out->len += cpathStrCpyConv(out->buf + out->len, len, other); - cpathTrim(out); - return 1; -} - -_CPATH_FUNC_ -int cpathAppendStr(cpath *out, const cpath_char_t *other) { - return cpathAppendStrn(out, other, cpath_str_length(other)); -} - -_CPATH_FUNC_ -int cpathAppend(cpath *out, const cpath *other) { - return cpathAppendStrn(out, other->buf, other->len); -} - -_CPATH_FUNC_ -int cpathConcatStrn(cpath *out, const cpath_char_t *str, size_t len) { - if (len + out->len >= CPATH_MAX_PATH_LEN) { - // path too long, >= cause max path includes CPATH_STR('\0') - errno = ENAMETOOLONG; - return 0; - } - - if (str[0] != CPATH_SEP && out->buf[out->len - 1] != CPATH_SEP && - str[0] != CPATH_OTHER_SEP && out->buf[out->len - 1] != CPATH_OTHER_SEP) { - out->buf[out->len++] = CPATH_SEP; - out->buf[out->len] = CPATH_STR('\0'); - } - - // This is more efficient than a strcat since it doesn't have to get - // the length again it also handles all the conversions well and doesn't - // have to retraverse the out->buf which we know is fine. - out->len += cpathStrCpyConv(out->buf + out->len, len, str); - cpathTrim(out); - return 1; -} - -_CPATH_FUNC_ -int cpathConcatStr(cpath *out, const cpath_char_t *other) { - return cpathConcatStrn(out, other, cpath_str_length(other)); -} - -_CPATH_FUNC_ -int cpathConcat(cpath *out, const cpath *other) { - return cpathConcatStrn(out, other->buf, other->len); -} - -_CPATH_FUNC_ -int cpathExists(const cpath *path) { -#if defined _MSC_VER || defined __MINGW32__ - DWORD res = GetFileAttributes(path->buf); - return res != INVALID_FILE_ATTRIBUTES; -#else - /* - We can either try to use stat or just access, access is more efficient - when not checking permissions. - - struct stat tmp; - return stat(path->buf, &tmp) == 0; - */ - return access(path->buf, F_OK) != -1; -#endif -} - -_CPATH_FUNC_ -int cpathCanonicaliseNoSysCall(cpath *out, cpath *path) { - /* - NOTE: This should work even if out == path - It just has been written that way. - */ - if (path == nullptr) { - errno = EINVAL; - return 0; - } - - out->len = 0; - cpath_char_t *chr = &path->buf[0]; - - while (*chr != CPATH_STR('\0')) { - if (*chr == CPATH_STR('.')) { - if (chr[1] == CPATH_STR('.')) { - if (out->len == 0 || (out->len == 1 && - (out->buf[0] == CPATH_SEP || out->buf[0] == CPATH_OTHER_SEP))) { - // no directory to go back based on string alone - errno = ENOENT; - return 0; - } - // remove last directory ignoring the last / since that is part of .. - out->len--; - while (out->len > 0 && out->buf[out->len - 1] != CPATH_SEP && - out->buf[out->len - 1] != CPATH_OTHER_SEP) { - out->len--; - } - // skip twice - chr++; - chr++; - } else if (chr[1] == CPATH_SEP || chr[1] == CPATH_STR('\0') || - chr[1] == CPATH_OTHER_SEP) { - // skip - chr++; - } else { - out->buf[out->len++] = *chr; - } - } else { - out->buf[out->len++] = *chr; - } - chr++; - } - - out->buf[out->len] = CPATH_STR('\0'); - cpathTrim(out); - if (out->len == 0) { - out->buf[0] = CPATH_STR('.'); - out->buf[1] = CPATH_STR('\0'); - out->len = 1; - } - - return 1; -} - -_CPATH_FUNC_ -int cpathCanonicalise(cpath *out, cpath *path) { - cpath tmp; - if (out == path) { - // support non-restrict method - cpathCopy(&tmp, path); - path = &tmp; - } - -#if defined _MSC_VER - DWORD size = GetFullPathName(path->buf, CPATH_MAX_PATH_LEN, out->buf, nullptr); - if (size == 0) { - // figure out errno - return 0; - } else { - path->len = size; - return 1; - } -#else - char *res = realpath(path->buf, out->buf); - if (res != nullptr) { - out->len = cpath_str_length(out->buf); - } - return res != nullptr; -#endif -} - -_CPATH_FUNC_ -int cpathCanonicaliseAvoidSysCall(cpath *out, cpath *path) { - if (!cpathCanonicaliseNoSysCall(out, path)) { - return cpathCanonicalise(out, path); - } - return 1; -} - -_CPATH_FUNC_ -void cpathClear(cpath *path) { - path->buf[0] = CPATH_STR('.'); - path->buf[1] = CPATH_STR('\0'); - path->len = 1; -} - -_CPATH_FUNC_ -const cpath_char_t *cpathItRef(cpath *path, int *index) { - if (path == nullptr || index == nullptr || *index >= path->len || *index < 0) { - return nullptr; - } - - if (path->buf[*index] == CPATH_STR('\0')) { - path->buf[*index] = CPATH_SEP; - (*index)++; - } - int old_pos = *index; - - // find next '/' - while (*index < path->len && path->buf[*index] != CPATH_SEP && - path->buf[*index] != CPATH_OTHER_SEP) { - (*index)++; - } - - path->buf[*index] = '\0'; - - return &path->buf[old_pos]; -} - -_CPATH_FUNC_ -void cpathItRefRestore(cpath *path, int *index) { - if (path == nullptr) return; - - if (index == nullptr || *index < 0 || *index >= path->len || - path->buf[*index] != CPATH_STR('\0')) { - // we have to loop - for (int i = 0; i < path->len; i++) { - if (path->buf[i] == CPATH_STR('\0')) path->buf[i] = CPATH_SEP; - } - // set index to the length since we have no real way to determine - // where abouts it its (that is if it isn't nullptr) - if (index != nullptr) *index = path->len; - } else { - path->buf[*index] = CPATH_SEP; - (*index)++; - } -} - -_CPATH_FUNC_ -int cpathUpDir(cpath *path) { - if (path->len == 0) { - // shouldn't have a path with this length - errno = EINVAL; - return 0; - } - - // We have to find the last component and strip it - int oldLen = path->len; - while (path->len > 1 && path->buf[path->len - 1] != CPATH_SEP && - path->buf[path->len - 1] != CPATH_SEP) { - path->len--; - } - if (path->len == 1) { - // we failed to quickly go up a dir - // so we will have to restore len and try another method - // this is better than the avoid method because - // this will allow you to go up a directory if the path == PATH_MAX - path->len = oldLen; - if (!CPATH_CONCAT_LIT(path, "..")) { - return 0; - } - return cpathCanonicalise(path, path); - } - - // we have found a '/' so we just set it to '\0' - path->buf[path->len - 1] = '\0'; - path->len--; - return 1; -} - -_CPATH_FUNC_ -void cpathConvertSepCustom(cpath *path, cpath_char_t sep) { - int lastSep = 0; - cpath_str cur = path->buf; - for (int i = 0; i < path->len + 1; i++) { - int isSep = path->buf[i] == CPATH_SEP || path->buf[i] == CPATH_OTHER_SEP; - if (isSep && !lastSep) { - *cur++ = CPATH_SEP; - } else if (!isSep || !lastSep) { - *cur++ = path->buf[i]; - } - lastSep = isSep; - } -} - -/* == File System == */ - -/* - Get the current working directory allocating the space -*/ -_CPATH_FUNC_ -cpath_char_t *cpathGetCwdAlloc() { - cpath_char_t *buf; - buf = (cpath_char_t*)CPATH_MALLOC(sizeof(cpath_char_t) * CPATH_MAX_PATH_LEN); - return cpathGetCwdBuf(buf, CPATH_MAX_PATH_LEN); -} - -_CPATH_FUNC_ -cpath_char_t *cpathGetCwdBuf(cpath_char_t *buf, size_t size) { - return _cpath_getcwd(buf, size); -} - -_CPATH_FUNC_ -void cpathWriteCwd(cpath *path) { - cpathGetCwdBuf(path->buf, CPATH_MAX_PATH_LEN); - path->len = cpath_str_length(path->buf); - cpathTrim(path); -} - -_CPATH_FUNC_ -cpath cpathGetCwd() { - cpath path; - cpathWriteCwd(&path); - cpathTrim(&path); - return path; -} - -_CPATH_FUNC_ -int cpathOpenDir(cpath_dir *dir, const cpath *path) { - if (dir == nullptr || path == nullptr || path->len == 0) { - // empty strings are invalid arguments - errno = EINVAL; - return 0; - } - - if (path->len + CPATH_PATH_EXTRA_CHARS >= CPATH_MAX_PATH_LEN) { - errno = ENAMETOOLONG; - return 0; - } - - dir->files = nullptr; - -#if defined _MSC_VER - dir->handle = INVALID_HANDLE_VALUE; -#else - dir->dir = nullptr; -#endif - dir->path.buf[path->len] = CPATH_STR('\0'); - dir->parent = nullptr; - dir->files = nullptr; -#if defined _MSC_VER - dir->handle = INVALID_HANDLE_VALUE; -#else - dir->dir = nullptr; - dir->dirent = nullptr; -#endif - - cpathCopy(&dir->path, path); - return cpathRestartDir(dir); -} - -_CPATH_FUNC_ -int cpathRestartDir(cpath_dir *dir) { - // @TODO: I think there is a faster way if the handles exist - if (dir == nullptr) { - errno = EINVAL; - return 0; - } - - dir->hasNext = 1; - dir->size = -1; - if (dir->files != nullptr) CPATH_FREE(dir->files); - dir->files = nullptr; - -#if defined _MSC_VER - if (dir->handle != INVALID_HANDLE_VALUE) FindClose(dir->handle); - dir->handle = INVALID_HANDLE_VALUE; -#else - if (dir->dir != nullptr) _cpath_closedir(dir->dir); - dir->dir = nullptr; - dir->dirent = nullptr; -#endif - - // Ignore parent, just restart this dir - -#if defined _MSC_VER - cpath_char_t pathBuf[CPATH_MAX_PATH_LEN]; - cpath_str_copy(pathBuf, dir->path.buf); - strcat(pathBuf, CPATH_STR("\\*")); - -#if (defined WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) - dir->handle = FindFirstFileEx(pathBuf, FindExInfoStandard, &dir->findData, - FindExSearchNameMatch, nullptr, 0); -#else - dir->handle = FindFirstFile(pathBuf, &dir->findData); -#endif - - if (dir->handle == INVALID_HANDLE_VALUE) { - errno = ENOENT; - // free associate memory and exit - cpathCloseDir(dir); - return 0; - } - -#else - - dir->dir = _cpath_opendir(dir->path.buf); - if (dir->dir == nullptr) { - cpathCloseDir(dir); - return 0; - } - dir->dirent = _cpath_readdir(dir->dir); - // empty directory - if (dir->dirent == nullptr) dir->hasNext = 0; - -#endif - - return 1; -} - -_CPATH_FUNC_ -void cpathCloseDir(cpath_dir *dir) { - if (dir == nullptr) return; - - dir->hasNext = 1; - dir->size = -1; - if (dir->files != nullptr) CPATH_FREE(dir->files); - dir->files = nullptr; - -#if defined _MSC_VER - if (dir->handle != INVALID_HANDLE_VALUE) FindClose(dir->handle); - dir->handle = INVALID_HANDLE_VALUE; -#else - if (dir->dir != nullptr) _cpath_closedir(dir->dir); - dir->dir = nullptr; - dir->dirent = nullptr; -#endif - - cpathClear(&dir->path); - if (dir->parent != nullptr) { - cpathCloseDir(dir->parent); - CPATH_FREE(dir->parent); - dir->parent = nullptr; - } -} - -_CPATH_FUNC_ -int cpathMoveNextFile(cpath_dir *dir) { - if (dir == nullptr) { - errno = EINVAL; - return 0; - } - if (!dir->hasNext) { - return 0; - } - -#if defined _MSC_VER - if (FindNextFile(dir->handle, &dir->findData) == 0) { - dir->hasNext = 0; - if (GetLastError() != ERROR_SUCCESS && - GetLastError() != ERROR_NO_MORE_FILES) { - cpathCloseDir(dir); - errno = EIO; - return 0; - } - } -#else - dir->dirent = _cpath_readdir(dir->dir); - if (dir->dirent == nullptr) { - dir->hasNext = 0; - } -#endif - - return 1; -} - -_CPATH_FUNC_ -int cpathGetFileInfo(cpath_file *file) { - if (file->statLoaded) { - return 1; - } -#if !defined _MSC_VER -#if defined __MINGW32__ - if (_tstat(file->path.buf, &file->stat) == -1) { - return 0; - } -#elif defined _BSD_SOURCE || defined _DEFAULT_SOURCE \ - || (defined _XOPEN_SOURCE && _XOPEN_SOURCE >= 500) \ - || (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 200112L) - if (lstat(file->path.buf, &file->stat) == -1) { - return 0; - } -#else - if (stat(file->path.buf, &file->stat) == -1) { - return 0; - } -#endif -#endif - file->statLoaded = 1; - return 1; -} - -_CPATH_FUNC_ -int cpathLoadFlags(cpath_dir *dir, cpath_file *file, void *data) { -#if defined _MSC_VER - WIN32_FIND_DATA find = *((WIN32_FIND_DATA*) data); - file->isDir = FILE_IS(find, DIRECTORY); - if (FILE_IS(find, NORMAL)) { - file->isReg = 1; - } else if (FILE_IS_NOT(find, DEVICE) && FILE_IS_NOT(find, DIRECTORY) && - FILE_IS_NOT(find, ENCRYPTED) && FILE_IS_NOT(find, OFFLINE) && -#ifdef FILE_ATTRIBUTE_INTEGRITY_STREAM - FILE_IS_NOT(find, INTEGRITY_STREAM) && -#endif -#ifdef FILE_ATTRIBUTE_NO_SCRUB_DATA - FILE_IS_NOT(find, NO_SCRUB_DATA) && -#endif - FILE_IS_NOT(find, TEMPORARY)) { - file->isReg = 1; - } else { - file->isReg = 0; - } - file->isSym = FILE_IS(find, REPARSE_POINT); -#else - if (dir->dirent == nullptr || dir->dirent->d_type == DT_UNKNOWN) { - if (!cpathGetFileInfo(file)) { - return 0; - } - - file->isDir = S_ISDIR(file->stat.st_mode); - file->isReg = S_ISREG(file->stat.st_mode); - file->isSym = S_ISLNK(file->stat.st_mode); - } else { - file->isDir = dir->dirent->d_type == DT_DIR; - file->isReg = dir->dirent->d_type == DT_REG; - file->isSym = dir->dirent->d_type == DT_LNK; - file->statLoaded = 0; - } -#endif - return 1; -} - -_CPATH_FUNC_ -int cpathPeekNextFile(cpath_dir *dir, cpath_file *file) { - if (file == nullptr || dir == nullptr) { - errno = EINVAL; - return 0; - } - - file->statLoaded = 0; - // load current file into file - const cpath_char_t *filename; - size_t filenameLen; -#if defined _MSC_VER - if (dir->handle == INVALID_HANDLE_VALUE) { - return 0; - } - filename = dir->findData.cFileName; - filenameLen = cpath_str_length(filename); -#else - if (dir->dirent == nullptr) { - return 0; - } - filename = dir->dirent->d_name; - // TODO: On MACOS there is a d_namlen but not on linux - filenameLen = strlen(dir->dirent->d_name); -#endif - size_t totalLen = dir->path.len + filenameLen; - if (totalLen + 1 + CPATH_PATH_EXTRA_CHARS >= CPATH_MAX_PATH_LEN || - filenameLen >= CPATH_MAX_FILENAME_LEN) { - errno = ENAMETOOLONG; - return 0; - } - - cpath_str_copy(file->name, filename); - cpathCopy(&file->path, &dir->path); - if (!CPATH_CONCAT_LIT(&file->path, "/") || - !cpathConcatStr(&file->path, filename)) { - return 0; - } -#ifndef CPATH_NO_AUTOLOAD_EXT - cpathGetExtension(file); -#endif -#if defined _MSC_VER - if (!cpathLoadFlags(dir, file, (WIN32_FIND_DATA*)(&dir->findData))) return 0; -#else - if (!cpathLoadFlags(dir, file, nullptr)) return 0; -#endif -#ifdef CPATH_AUTOLOAD_STAT - if (!cpathGetFileInfo(file)) return 0; -#endif - return 1; -} - -_CPATH_FUNC_ -int cpathGetNextFile(cpath_dir *dir, cpath_file *file) { - if (file != nullptr) { - if (!cpathPeekNextFile(dir, file)) { - return 0; - } - } - - errno = 0; - // @TODO: Bug I think - // I think we want to remove the condition that dir->hasNext - // Sicne cpath checks that. - if (dir->hasNext && !cpathMoveNextFile(dir) && errno != 0) { - return 0; - } - - return 1; -} - -_CPATH_FUNC_ -int cpathFileIsSpecialHardLink(const cpath_file *file) { - return file->name[0] == CPATH_STR('.') && (file->name[1] == CPATH_STR('\0') || - (file->name[1] == CPATH_STR('.') && file->name[2] == CPATH_STR('\0'))); -} - -_CPATH_FUNC_ -int cpathLoadAllFiles(cpath_dir *dir) { - if (dir == nullptr) { - errno = EINVAL; - return 0; - } - - if (dir->files != nullptr) CPATH_FREE(dir->files); - - // @Ugly: - /* - The problem is that we could go through all files to get a count - This is kinda ugly but is linear and ensures we don't make allocations - The other method is to use a 'vector' however the copies are really - expensive since we have huge objects which is why I chose the count method - */ - size_t count = 0; - errno = 0; - while (cpathMoveNextFile(dir)) { - count++; - } - - // we can have 0 files - if (count == 0) { - dir->size = 0; - return 1; - } - - // loading failed for some reason or we failed to restart the dir iterator - if (errno != 0 || !cpathRestartDir(dir)) { - // we won't close the directory though! - // we'll just pretend we have no files! - dir->size = 0; - return 0; - } - - dir->size = count; - dir->files = (cpath_file*) CPATH_MALLOC(sizeof(cpath_file) * count); - if (dir->files == nullptr) { - // we won't close the directory just error out - dir->size = 0; - return 0; - } - - errno = 0; - int i = 0; - // also make sure that we don't overflow the array - // because size requirements changed i.e. race condition - // we could fix this by resizing but that's super expensive - // maybe this is time for a linked list or just to dynamically allocate - // all file nodes and waste the extra 8 bytes per (and cache locality) - while (i < dir->size && cpathGetNextFile(dir, &dir->files[i])) { - i++; - } - - if (i < dir->size) { - // we stopped early due to error I'm still not going to crazily error out - // because it may just be race condition and I'll be a bit lazy - // @TODO: check if it was just race or if a read failed - dir->size = i; - } - - return 1; -} - -_CPATH_FUNC_ -int cpathCheckGetN(cpath_dir *dir, size_t n) { - if (dir == nullptr) { - errno = EINVAL; - return 0; - } - - if (dir->size == -1) { - // we haven't loaded - cpathLoadAllFiles(dir); - } - - if (n >= dir->size) { - errno = ENOENT; - return 0; - } - return 1; -} - -_CPATH_FUNC_ -int cpathGetFile(cpath_dir *dir, cpath_file *file, size_t n) { - if (file == nullptr) { - errno = EINVAL; - return 0; - } - if (!cpathCheckGetN(dir, n)) return 0; - - memcpy(file, &dir->files[n], sizeof(cpath_file)); - return 1; -} - -_CPATH_FUNC_ -int cpathGetFileConst(cpath_dir *dir, const cpath_file **file, size_t n) { - if (dir == nullptr || file == nullptr) { - errno = EINVAL; - return 0; - } - - if (dir->size == -1) { - // we haven't loaded - cpathLoadAllFiles(dir); - } - - if (n >= dir->size) { - errno = ENOENT; - return 0; - } - - *file = &dir->files[n]; - return 1; -} - -_CPATH_FUNC_ -int cpathOpenSubFileEmplace(cpath_dir *dir, const cpath_file *file, - int saveDir) { - cpath_dir *saved = nullptr; - if (saveDir) { - // save the old one - saved = (cpath_dir*)CPATH_MALLOC(sizeof(cpath_dir)); - if (saved != nullptr) memcpy(saved, dir, sizeof(cpath_dir)); - } - - if (!cpathFileToDir(dir, file)) { - if (saved != nullptr) CPATH_FREE(saved); - return 0; - } - - dir->parent = saved; - - return 1; -} - -_CPATH_FUNC_ -int cpathOpenSubDirEmplace(cpath_dir *dir, size_t n, int saveDir) { - if (dir == nullptr) { - errno = EINVAL; - return 0; - } - if (!cpathCheckGetN(dir, n)) return 0; - - const cpath_file *file; - if (!cpathGetFileConst(dir, &file, n) || - !file->isDir || !cpathOpenSubFileEmplace(dir, file, saveDir)) { - if (!file->isDir) errno = EINVAL; - return 0; - } - - return 1; -} - -_CPATH_FUNC_ -int cpathOpenSubDir(cpath_dir *out, cpath_dir *dir, size_t n) { - if (dir == nullptr || out == nullptr) { - errno = EINVAL; - return 0; - } - if (!cpathCheckGetN(dir, n)) return 0; - - const cpath_file *file; - if (!cpathGetFileConst(dir, &file, n) || - !file->isDir || !cpathFileToDir(out, file)) { - if (!file->isDir) errno = EINVAL; - return 0; - } - return 1; -} - -_CPATH_FUNC_ -int cpathOpenNextSubDir(cpath_dir *out, cpath_dir *dir) { - if (dir == nullptr || out == nullptr) { - errno = EINVAL; - return 0; - } - - cpath_file file; - if (!cpathGetNextFile(dir, &file) || - !file.isDir || !cpathFileToDir(out, &file)) { - if (!file.isDir) errno = EINVAL; - return 0; - } - return 1; -} - -_CPATH_FUNC_ -int cpathOpenCurrentSubDir(cpath_dir *out, cpath_dir *dir) { - if (dir == nullptr || out == nullptr) { - errno = EINVAL; - return 0; - } - - cpath_file file; - if (!cpathPeekNextFile(dir, &file) || - !file.isDir || !cpathFileToDir(out, &file)) { - if (!file.isDir) errno = EINVAL; - return 0; - } - return 1; -} - -_CPATH_FUNC_ -int cpathOpenNextSubDirEmplace(cpath_dir *dir, int saveDir) { - if (dir == nullptr) { - errno = EINVAL; - return 0; - } - - cpath_file file; - if (!cpathGetNextFile(dir, &file) || - !file.isDir || !cpathOpenSubFileEmplace(dir, &file, saveDir)) { - if (!file.isDir) errno = EINVAL; - return 0; - } - return 1; -} - -_CPATH_FUNC_ -int cpathOpenCurrentSubDirEmplace(cpath_dir *dir, int saveDir) { - if (dir == nullptr) { - errno = EINVAL; - return 0; - } - - cpath_file file; - if (!cpathPeekNextFile(dir, &file) || - !file.isDir || !cpathOpenSubFileEmplace(dir, &file, saveDir)) { - if (!file.isDir) errno = EINVAL; - return 0; - } - return 1; -} - -_CPATH_FUNC_ -int cpathRevertEmplace(cpath_dir **dir) { - if (dir == nullptr || *dir == nullptr) return 0; - cpath_dir *tmp = (*dir)->parent; - (*dir)->parent = nullptr; - cpathCloseDir(*dir); - *dir = tmp; - return *dir != nullptr; -} - -_CPATH_FUNC_ -int cpathRevertEmplaceCopy(cpath_dir *dir) { - if (dir == nullptr) return 0; - cpath_dir *tmp = dir->parent; - dir->parent = nullptr; - cpathCloseDir(dir); - if (tmp != nullptr) { - memcpy(dir, tmp, sizeof(cpath_dir)); - } - return tmp != nullptr; -} - -_CPATH_FUNC_ -int cpathOpenFile(cpath_file *file, const cpath *path) { - // We want to efficiently open this file so unlike most libraries - // we won't use a directory search we will just find the given file - // or directly use stuff like dirname/basename! - cpath_dir dir; - - if (file == nullptr || path == nullptr || path->len == 0) { - errno = EINVAL; - return 0; - } - if (path->len >= CPATH_MAX_PATH_LEN) { - errno = ENAMETOOLONG; - return 0; - } - - void* data = nullptr; - - cpathCopy(&file->path, path); - -#if defined _MSC_VER - void *handle = nullptr; - WIN32_FIND_DATA findData; - -#if (defined WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) - handle = FindFirstFileEx(path->buf, FindExInfoStandard, &findData, - FindExSearchNameMatch, nullptr, 0); -#else - handle = FindFirstFile(path->buf, &findData); -#endif - - if (handle == INVALID_HANDLE_VALUE) { - errno = ENOENT; - return 0; - } - - data = &findData; - cpath_str_copy(file->name, findData.cFileName); -#else - // copy the name then strip to just basename - // this is very ewwwww, honestly we probably would be better - // to just do this ourselves since ugh - cpath_strn_copy(file->name, path->buf, path->len); - char *tmp = basename(file->name); - // some systems allocate it seems.. ugh - if (tmp != file->name) { - cpath_str_copy(file->name, tmp); - CPATH_FREE(tmp); - } - // @TODO: make sure tmp isn't too long -#endif - - file->statLoaded = 0; - int res = cpathLoadFlags(&dir, file, data); -#if defined _MSC_VER - FindClose((HANDLE)handle); -#else - dir.dirent = nullptr; -#endif - - return res; -} - -_CPATH_FUNC_ -int cpathFileToDir(cpath_dir *dir, const cpath_file *file) { - if (dir == nullptr || file == nullptr || !file->isDir) { - errno = EINVAL; - return 0; - } - return cpathOpenDir(dir, &file->path); -} - -_CPATH_FUNC_ -cpath_str cpathGetExtension(cpath_file *file) { - if (file->extension != nullptr) return file->extension; - - cpath_char_t *dot = cpath_str_find_last_char(file->name, CPATH_STR('.')); - if (dot != nullptr) { - // extension - file->extension = dot + 1; - } else { - // no extension so set to CPATH_STR('\0') - file->extension = &file->name[cpath_str_length(file->name)]; - } - return file->extension; -} - -_CPATH_FUNC_ -cpath_time_t cpathGetLastAccess(cpath_file *file) { - if (!file->statLoaded) cpathGetFileInfo(file); - -#if defined _MSC_VER || defined __MINGW32__ - // Idk todo -#else - return file->stat.st_atime; -#endif -} - -_CPATH_FUNC_ -cpath_time_t cpathGetLastModification(cpath_file *file) { - if (!file->statLoaded) cpathGetFileInfo(file); - -#if defined _MSC_VER || defined __MINGW32__ - // Idk todo -#else - return file->stat.st_mtime; -#endif -} - -_CPATH_FUNC_ -cpath_offset_t cpathGetFileSize(cpath_file *file) { - if (!file->statLoaded) cpathGetFileInfo(file); - -#if defined _MSC_VER || defined __MINGW32__ - // Idk todo -#else - return file->stat.st_size; -#endif -} - -_CPATH_FUNC_ -void cpathSort(cpath_dir *dir, cpath_cmp cmp) { - if (dir->files == nullptr) { - if (dir->size == -1) { - // bad, this means you try to sorted a directory before you preloaded - // in this case we'll just preload the files. This is just to be nice - cpathLoadAllFiles(dir); - } - - // this is fine just means no files in directory - if (dir->size == 0) { - return; - } - } - qsort(dir->files, dir->size, sizeof(struct cpath_dir_t), cmp); -} - -static const cpath_char_t *prefixTableDecimal[] = { - CPATH_STR("kB"), CPATH_STR("MB"), CPATH_STR("GB"), CPATH_STR("TB"), - CPATH_STR("PB"), CPATH_STR("EB"), CPATH_STR("ZB"), CPATH_STR("YB"), -}; -static const cpath_char_t *prefixTableDecimalUpper[] = { - CPATH_STR("KB"), CPATH_STR("MB"), CPATH_STR("GB"), CPATH_STR("TB"), - CPATH_STR("PB"), CPATH_STR("EB"), CPATH_STR("ZB"), CPATH_STR("YB"), -}; -static const cpath_char_t *prefixTableDecimalLower[] = { - CPATH_STR("kb"), CPATH_STR("mb"), CPATH_STR("gb"), CPATH_STR("tb"), - CPATH_STR("pb"), CPATH_STR("eb"), CPATH_STR("zb"), CPATH_STR("yb"), -}; -static const cpath_char_t *prefixTableIEC[] = { - CPATH_STR("KiB"), CPATH_STR("MiB"), CPATH_STR("GiB"), CPATH_STR("TiB"), - CPATH_STR("PiB"), CPATH_STR("EiB"), CPATH_STR("ZiB"), CPATH_STR("YiB"), -}; -// identical to decimal upper but kept separate for the sake of readability -static const cpath_char_t *prefixTableJEDEC[] = { - CPATH_STR("KB"), CPATH_STR("MB"), CPATH_STR("GB"), CPATH_STR("TB"), - CPATH_STR("PB"), CPATH_STR("EB"), CPATH_STR("ZB"), CPATH_STR("YB"), -}; - -_CPATH_FUNC_ -double cpathGetFileSizeDec(cpath_file *file, int intervalSize) { - double size = cpathGetFileSize(file); - int steps = 0; - while (size >= intervalSize / 2 && steps < 8) { - size /= intervalSize; - steps++; - } - return size; -} - -_CPATH_FUNC_ -const cpath_char_t *cpathGetFileSizeSuffix(cpath_file *file, CPathByteRep rep) { - cpath_offset_t size = cpathGetFileSize(file); - int word = (rep & BYTE_REP_LONG) == BYTE_REP_LONG; - int byte_word = (rep & BYTE_REP_BYTE_WORD) == BYTE_REP_BYTE_WORD; - // disable both them to make comparing easier - rep &= ~BYTE_REP_LONG; - rep &= ~BYTE_REP_BYTE_WORD; - int interval = rep == BYTE_REP_IEC || rep == BYTE_REP_JEDEC ? 1024 : 1000; - - if (size < interval / 2) { - // then we just have a byte case - if (word || byte_word) { - return rep != BYTE_REP_DECIMAL_LOWER ? CPATH_STR("Bytes") - : CPATH_STR("bytes"); - } else { - return rep != BYTE_REP_DECIMAL_LOWER ? CPATH_STR("B") - : CPATH_STR("b"); - } - } - - int steps = 0; - double size_flt = size; - while (size_flt >= interval / 2 && steps < 8) { - size_flt /= (double)interval; - steps++; - } - - switch (rep) { - case BYTE_REP_IEC: return prefixTableIEC[steps - 1]; - case BYTE_REP_JEDEC: return prefixTableJEDEC[steps - 1]; - case BYTE_REP_DECIMAL: return prefixTableDecimal[steps - 1]; - case BYTE_REP_DECIMAL_LOWER: return prefixTableDecimalLower[steps - 1]; - case BYTE_REP_DECIMAL_UPPER: return prefixTableDecimalUpper[steps - 1]; - default: return nullptr; - } -} - -_CPATH_FUNC_ -void cpath_traverse( - cpath_dir *dir, int depth, int visit_subdirs, cpath_err_handler err, - cpath_traverse_it it, void *data -) { - // currently implemented recursively - if (dir == nullptr) { - errno = EINVAL; - if (err != nullptr) err(); - return; - } - cpath_file file; - while (cpathGetNextFile(dir, &file)) { - if (it != nullptr) { - it(&file, dir, depth, data); - } - if (file.isDir && visit_subdirs && !cpathFileIsSpecialHardLink(&file)) { - cpath_dir tmp; - if (!cpathFileToDir(&tmp, &file)) { - if (err) err(); - continue; - } - cpath_traverse(&tmp, depth + 1, visit_subdirs, err, it, data); - cpathCloseDir(&tmp); - } - } -} - -_CPATH_FUNC_ -int cpathMkdir(const cpath *path) { -#if defined _MSC_VER || __MINGW32__ - return CreateDirectory(path->buf, nullptr); -#else - return mkdir(path->buf, 0700) == 0; -#endif -} - -_CPATH_FUNC_ -FILE *cpathOpen(const cpath *path, const cpath_char_t *mode) { - return cpath_fopen(path->buf, mode); -} - -#endif -#ifdef __cplusplus -} -#ifndef CPATH_NO_CPP_BINDINGS - } } - -// cpp bindings -namespace cpath { -// using is a C++11 extension, we want to remain pretty -// compatible to all versions -typedef internals::cpath_time_t Time; -typedef internals::cpath_offset_t Offset; -typedef internals::cpath_char_t RawChar; -typedef internals::cpath RawPath; -typedef internals::cpath_dir RawDir; -typedef internals::cpath_file RawFile; -typedef internals::CPathByteRep ByteRep; - -struct File; -struct Path; - -typedef void(*TraversalIt)( - struct File &file, struct Dir &parent, int depth, void *data -); - -typedef void(*ErrorHandler)(); - -/* - This has to be kept to date with the other representation - Kinda disgusting but seems to be the best way to ensure encapsulation -*/ -const ByteRep BYTE_REP_JEDEC = internals::BYTE_REP_JEDEC; -const ByteRep BYTE_REP_DECIMAL = internals::BYTE_REP_DECIMAL; -const ByteRep BYTE_REP_IEC = internals::BYTE_REP_IEC; -const ByteRep BYTE_REP_DECIMAL_UPPER = internals::BYTE_REP_DECIMAL_UPPER; -const ByteRep BYTE_REP_DECIMAL_LOWER = internals::BYTE_REP_DECIMAL_LOWER; -const ByteRep BYTE_REP_LONG = internals::BYTE_REP_LONG; -const ByteRep BYTE_REP_BYTE_WORD = internals::BYTE_REP_BYTE_WORD; - -#if !defined _MSC_VER -#if defined __MINGW32__ -typedef struct _stat RawStat; -#else -typedef struct stat RawStat; -#endif -#endif - -template -struct Opt { -private: -#if __cplusplus <= 199711L - struct Data { -#else - union Data { -#endif - T raw; - Err err; - - Data(T raw) : raw(raw) {} - Data(Err err) : err(err) {} -} data; - bool ok; - -public: - Opt(T raw) : data(raw), ok(true) {} - Opt(Err err) : data(err), ok(false) {} - Opt() : data(Err()), ok(false) {} - - bool IsOk() const { - return ok; - } - - operator bool() const { - return ok; - } - - Err GetErr() const { - return data.err; - } - - T GetRaw() const { - return data.raw; - } - - T *operator*() { - if (!ok) return nullptr; - return &data.raw; - } - - T *operator->() { - if (!ok) return nullptr; - return &data.raw; - } -}; - -struct Error { - enum Type { - UNKNOWN, - INVALID_ARGUMENTS, - NAME_TOO_LONG, - NO_SUCH_FILE, - IO_ERROR, - }; - - static Type FromErrno() { - switch (errno) { - case EINVAL: return INVALID_ARGUMENTS; - case ENAMETOOLONG: return NAME_TOO_LONG; - case ENOENT: return NO_SUCH_FILE; - case EIO: return IO_ERROR; - default: return UNKNOWN; - } - } - - static void WriteToErrno(Type type) { - switch (type) { - case INVALID_ARGUMENTS: errno = EINVAL; - case NAME_TOO_LONG: errno = ENAMETOOLONG; - case NO_SUCH_FILE: errno = ENOENT; - case IO_ERROR: errno = IO_ERROR; - default: errno = 0; - } - } -}; - -struct Path { -private: - RawPath path; - -public: - inline Path(const char *str) : path(internals::cpathFromUtf8(str)) { } - -#if CPATH_UNICODE - inline Path(RawChar *str) { - internals::cpathFromStr(&path, str); - } -#endif - - inline Path() { - path.len = 1; - path.buf[0] = CPATH_STR('.'); - path.buf[1] = CPATH_STR('\0'); - } - - inline Path(RawPath path) : path(path) {} - - static inline Path GetCwd() { - return Path(internals::cpathGetCwd()); - } - - inline bool Exists() const { - return internals::cpathExists(&path); - } - - inline const RawChar *GetBuffer() const { - return path.buf; - } - - inline const RawPath *GetRawPath() const { - return &path; - } - - inline unsigned long Size() const { - return path.len; - } - - inline friend bool operator==(const Path &p1, const Path &p2) { - if (p1.path.len != p2.path.len) return false; - return !cpath_str_compare_safe(p1.path.buf, p2.path.buf, p1.path.len); - } - - inline friend bool operator!=(const Path &p1, const Path &p2) { - return !(p1 == p2); - } - - inline Path &operator/=(const Path &other) { - internals::cpathConcat(&path, &other.path); - return *this; - } - - inline Path &operator/=(const RawChar *str) { - internals::cpathConcatStr(&path, str); - return *this; - } - -#if CPATH_UNICODE - inline Path &operator/=(const char *str) { - internals::cpathConcatStr(&path, str); - return *this; - } -#endif - - inline friend Path operator/(Path lhs, const Path &rhs) { - lhs /= rhs; - return lhs; - } - - inline friend Path operator/(Path lhs, const char *&rhs) { - lhs /= rhs; - return lhs; - } - -#if CPATH_UNICODE - inline friend Path operator/(Path lhs, const RawChar *&rhs) { - lhs /= rhs; - return lhs; - } -#endif -}; - -struct File { -private: - RawFile file; - bool hasArg; - -public: - inline bool LoadFileInfo() { - return internals::cpathGetFileInfo(&file); - } - - inline bool LoadFlags(struct Dir &dir, void *data); - - inline RawFile *GetRawFile() { - return &file; - } - - inline const RawFile *GetRawFileConst() const { - return &file; - } - - inline File(RawFile file) : file(file), hasArg(true) {} - inline File() : hasArg(false) {} - - inline static Opt OpenFile(const Path &path) { - RawFile file; - if (!internals::cpathOpenFile(&file, path.GetRawPath())) { - return Error::FromErrno(); - } else { - return File(file); - } - } - - inline Opt ToDir() const; - - inline bool IsSpecialHardLink() const { - if (!hasArg) { - errno = EINVAL; - return false; - } - return internals::cpathFileIsSpecialHardLink(&file); - } - - inline bool IsDir() const { - if (!hasArg) { - errno = EINVAL; - return false; - } - return file.isDir; - } - - inline bool IsReg() const { - if (!hasArg) { - errno = EINVAL; - return false; - } - return file.isReg; - } - - inline bool IsSym() const { - if (!hasArg) { - errno = EINVAL; - return false; - } - return file.isSym; - } - - inline const RawChar *Extension() { - if (internals::cpathGetExtension(&file)) { - return file.extension; - } else { - return nullptr; - } - } - - inline Time GetLastAccess() { - return internals::cpathGetLastAccess(&file); - } - - inline Time GetLastModification() { - return internals::cpathGetLastModification(&file); - } - - inline Time GetFileSize() { - return internals::cpathGetFileSize(&file); - } - - inline double GetFileSizeDec(int intervalSize) { - return internals::cpathGetFileSizeDec(&file, intervalSize); - } - - inline const RawChar *GetFileSizeSuffix(ByteRep rep) { - return internals::cpathGetFileSizeSuffix(&file, rep); - } - - inline Path GetPath() const { - return cpath::Path(file.path); - } - - inline const RawChar *Name() { - return file.name; - } - -#if !defined _MSC_VER -#if defined __MINGW32__ - inline RawStat Stat() { - if (!file.statLoaded) internals::cpathGetFileInfo(&file); - return file.stat; - } -#else - inline RawStat Stat() { - if (!file.statLoaded) internals::cpathGetFileInfo(&file); - return file.stat; - } -#endif -#endif -}; - -struct Dir { -private: - RawDir dir; - bool loadedFiles; - -public: - inline Dir(const Path &path) { - loadedFiles = false; - internals::cpathOpenDir(&dir, path.GetRawPath()); - } - inline Dir(RawDir dir) : dir(dir) { - loadedFiles = false; - } - inline Dir() { - loadedFiles = false; - internals::cpathOpenDir(&dir, Path().GetRawPath()); - } - - inline static Opt Open(const File &file) { - RawDir dir; - internals::cpathFileToDir(&dir, file.GetRawFileConst()); - return Dir(dir); - } - - inline void Traverse(TraversalIt it, ErrorHandler err, int visitSubDir, - int depth, void *data) { - while (Opt file = GetNextFile()) { - if (file && it) it(**file, *this, depth, data); - if (!file) { - Error::WriteToErrno(file.GetErr()); - if (err) err(); - continue; - } - - if (file->IsDir() && !file->IsSpecialHardLink()) { - Opt dir = file->ToDir(); - if (!dir) { - Error::WriteToErrno(dir.GetErr()); - if (err) err(); - continue; - } - dir->Traverse(it, err, visitSubDir, depth + 1, data); - dir->Close(); - } - } - } - - inline bool OpenEmplace(const Path &path) { - internals::cpathCloseDir(&dir); - loadedFiles = false; - return internals::cpathOpenDir(&dir, path.GetRawPath()); - } - - inline void Close() { - return internals::cpathCloseDir(&dir); - } - - inline void Sort(internals::cpath_cmp cmp) { - loadedFiles = true; // will load files as required - internals::cpathSort(&dir, cmp); - } - - inline bool MoveNext() { - return internals::cpathMoveNextFile(&dir); - } - - inline RawDir *GetRawDir() { - return &dir; - } - - inline Opt PeekNextFile() { - RawFile file; - if (!internals::cpathPeekNextFile(&dir, &file)) { - return Error::FromErrno(); - } else { - return File(file); - } - } - - inline Opt GetNextFile() { - RawFile file; - file.extension = nullptr; - if (!internals::cpathGetNextFile(&dir, &file)) { - return Error::FromErrno(); - } else { - return File(file); - } - } - - inline bool LoadFiles() { - loadedFiles = true; - return internals::cpathLoadAllFiles(&dir); - } - - inline unsigned long Size() { - if (!loadedFiles && !LoadFiles()) return 0; - return dir.size; - } - - inline Opt GetFile(unsigned long n) { - RawFile file; - if (!internals::cpathGetFile(&dir, &file, n)) { - return Error::FromErrno(); - } else { - return File(file); - } - } - - inline bool OpenSubFileEmplace(const File &file, bool saveDir) { - loadedFiles = false; - return internals::cpathOpenSubFileEmplace(&dir, file.GetRawFileConst(), saveDir); - } - - inline bool OpenSubDirEmplace(unsigned int n, bool saveDir) { - loadedFiles = false; - return internals::cpathOpenSubDirEmplace(&dir, n, saveDir); - } - - inline Opt OpenSubDir(unsigned int n) { - RawDir raw; - if (!internals::cpathOpenSubDir(&raw, &dir, n)) { - return Error::FromErrno(); - } else { - return Dir(raw); - } - } - - inline Dir OpenNextSubDir() { - RawDir raw; - internals::cpathOpenNextSubDir(&raw, &dir); - return Dir(raw); - } - - inline Dir OpenCurrentSubDir() { - RawDir raw; - internals::cpathOpenCurrentSubDir(&raw, &dir); - return Dir(raw); - } - - inline bool OpenNextSubDirEmplace(bool saveDir) { - loadedFiles = false; - return internals::cpathOpenNextSubDirEmplace(&dir, saveDir); - } - - inline bool OpenCurrentSubDirEmplace(bool saveDir) { - loadedFiles = false; - return internals::cpathOpenCurrentSubDirEmplace(&dir, saveDir); - } - - inline bool RevertEmplace() { - return internals::cpathRevertEmplaceCopy(&dir); - } -}; - -bool File::LoadFlags(struct Dir &dir, void *data) { - return internals::cpathLoadFlags(dir.GetRawDir(), &file, data); -} - -Opt File::ToDir() const { - return Dir::Open(*this); -} - -} - -#endif -#endif /* CPath */ - diff --git a/Libraries/cyclone/LICENSE.txt b/Libraries/cyclone/LICENSE.txt deleted file mode 100644 index c70c227b59..0000000000 --- a/Libraries/cyclone/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) <2003-2020>, -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/Libraries/cyclone/README.md b/Libraries/cyclone/README.md deleted file mode 100644 index 02f273f60e..0000000000 --- a/Libraries/cyclone/README.md +++ /dev/null @@ -1,233 +0,0 @@ - - -Cyclone: A set of Pure Data objects cloned from Max/MSP -------- - -> Cyclone expands Pure Data with objects cloned from cycling74's Max/MSP and provides some good level of compatibility between the two environments. - -------- - -Pure Data (or just "Pd") project is found at: https://sourceforge.net/p/pure-data/pure-data/ci/master/tree/ -or in its github mirror https://github.com/pure-data/pure-data. The official download page is here: http://msp.ucsd.edu/software.html - -Max is found at: https://cycling74.com/ - -------- - -Copyright © 2003-2021 - Krzysztof Czaja, Hans-Christoph Steiner, Fred Jan Kraan, Alexandre Porres, Derek Kwan, Matt Barber and others. - -This work is free. You can redistribute it and/or modify it under the terms of the BSD-3-Clause (aka Revised BSD License). See License.txt and for more details. - -------- - -Current Release: Cyclone 0.6-1 (this release needs at least Pd Vanilla 0.52-1) - -Released june 8th 2022 - -Find Cyclone's latest releases at: https://github.com/porres/pd-cyclone/releases or directly via Pd's external manager (Help => Find Externals). Please report bugs at https://github.com/porres/pd-cyclone/issues. - -------- -### About Cyclone: - -Cyclone 0.6-1 needs at least Pd Vanilla 0.52-1. - -Outdated versions of cyclone (0.1) are available in the long abandoned Pd-extended distribution (which no one should be using now in the 2020's) as well as in Pd-l2ork and Purr Data - both originally based on Pd-Extended but ported to nw.js (0.1 versions of cyclone here were not fully ported to nw.js at the time of this writing). - -The original author of Cyclone (Krzysztof Czaja) abandoned it in 2005 at version 0.1-alpha55, when Cyclone was compatible to MAX 4.0. Cyclone was then incorporated and available in Pd-extended, where it only a had a minor update under the maintenance of Hans-Christoph Steiner in 2013 (0.1-alpha56), right before Pd-extended (and Cyclone by consequence, were abandoned altogether (this version was also inherited by Pd-l2ork/Purr Data). Under a new maintenance phase by Fred Jan Kraan, 0.1-alpha57 and Cyclone 0.2 beta versions were released, still closely related to the previous '0.1-alpha' releases and mostly compliant to Max 4.0! - -Cyclone 0.3-0 was the major overhaul in Cyclone, where almost all of its objects got updated to the latest Max 7 version (Max 7.3.5). Many bugs were also fixed, the documentation was rewritten from scratch and new objects were included. Check the provided **CHANGELOG.txt** file for the details in all version changes. - -Currently, Cyclone still hasn't reached full compatibility to Max 7.3.5 . Some functionalities that depend on "transport" or "dictionaries" haven't been implemented and actually will never be. Porres, the main current maintainer of Cyclone has a new project called ELSE and some of the missing things in Cyclone can be found there (like an alternative to using 'transport'). ELSE also has many alternatives to objects in Cyclone. Therefore, Cyclone is not in much active development these days and the goal is to maintain the library, fix bugs, update to newer versions of MAX, but not include newer things. The only job that hasn't been updated yet is [mtr]. The [comment] object will most likely always miss 'bubble' stuff from Max 6+. Other minor incomatibility issues are described in the help files of corresponding objects. Cyclone may still incorporate functionalities from Max 8 (current release) in newer versions. Nonetheless, things like 'mc' compatiblity won't be possible or make it into Cyclone! - - - -------- - -### Installing Cyclone: - -You can compile Cyclone from the source provided in this repository for the current bleeding edge last state or download one of the more stable compiled releases from . A good alternative is simply to use Pd's own external download manager (a.k.a deken plugin): just click on the "find externals" option under the Help menu and search for "cyclone". - -When installing cyclone, make sure the Cyclone folder is included in a folder that Pd searches for, such as `~/Documents/Pd/externals` - which is what Pd suggests you to do (since version 0.48-0). - -Now you can install Cyclone by loading it in the startup: go to "Preferences => Startup", then click "New", type "cyclone" and hit OK. Next time you restart Pd, the Cyclone library binary will be loaded. - -This library binary loads the non alphanumeric operators objects (which are: `!-`, `!-~`, `!/`, `!/~`, `!=~`, `%~`, `+=~`, `<=~`, `<~`, `==~`, `>=~` and `>~`) but it also adds Cyclone's path to Pd's preferences, so you can load the other objects from Cyclone (which are separate binaries and abstractions). - -But note that in order to actually force a path search priority in your patch, you need to use [declare -path cyclone]. - -You can also use the [declare -lib cyclone] in a patch to load the library if you don't want to always have Cyclone loaded when Pd starts. Loading the Cyclone binary as an object ([cyclone]) also loads the library, see its help file for more details. - -------- - -### Building Cyclone for Pd Vanilla: - -Since "Cyclone 0.1-alpha57", the Cyclone package has relied on the new build system called "pd-lib-builder" by Katja Vetter (check the project in: ). - -* Compiling with pdlibbuilder - -PdLibBuilder tries to find the Pd source directory at several common locations, but when this fails, you have to specify the path yourself using the pdincludepath variable. Example: - -
make pdincludepath=~/pd-0.52-2/src/  (for Windows/MinGW add 'pdbinpath=~/pd-0.52-2/bin/)
- -* Make Install - -Use "objectsdir" to set a relative path for your build, something like: - -
make install objectsdir=../cyclone-build
-Then move it to your preferred install folder for Pd. - -------- - -#### Building with CMake - -It is now possible to build Cyclone for Pd Vanilla or libpd using CMake. CMake is a cross-platform, open-source build system. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice. -This allows native compilation via Windows (Microsoft Visual Studio), Linux (GCC) and macOS (XCode). - -* Dependencies: - - - CMake: You can download for your platform [here](https://cmake.org). - - Only on Windows: pthreads library - - Pure-data or libpd: sources and binaries. - -If you are using MinGW, you can use the pthreadGC-3.dll included in the `maintenance/windows_dll` directory in this repository. Alternatively, you can also download it or compile it yourself from the sources [here](https://www.sourceware.org/pthreads-win32/). This will typically result in pthreadGC2.(dll/lib). - -If you are using Visual Studio, you need to provide a `pthreads` library compiled for Visual Studio either by downloading it or compiling it yourself. See [here](https://www.sourceware.org/pthreads-win32/). Be careful to download / compile the right version for your setup. This would typically be `pthreadVC2.(dll/lib)`. - -* Configuring the build - -One way to configure CMake is to use the [CMake GUI](https://cmake.org/runningcmake/). The GUI will list the variables that can be provided to configure the build. The variables can also be specified in the command-line interface (See below for an example). - -In this step you can select if you want to build shared libraries with `BUILD_SHARED_LIBS` and if you want to build all Cyclone objects into one single library with `BUILD_SINGLE_LIBRARY` (more on this below). - -When using Microsoft Visual Studio (MSVC), you will be requested to provide a path to the `pthreads` library and its headers using variables `CMAKE_THREAD_LIBS_INIT` and `PTHREADS_INCLUDE_DIR`. - -You will be requested to provide a path to the pure-data sources and to the pure-data library. If building Cylone for libpd, these can also be satisfied by providing the path to the `pure-data` folder inside the libpd sources and providing the path to the libpd library. The variables are: `PD_INCLUDE_DIR` and `PD_LIBRARY`. - -On macOS, you can define different deployment target and architectures from your current system using the variables `CMAKE_OSX_DEPLOYMENT_TARGET` and `CMAKE_OSX_ARCHITECTURES`. - -You can specify additional compilation flags using the variable `CMAKE_C_FLAGS`. - -CMake can now generate Makefiles, a MSVC solution, or an XCode project. - -* Building - -After generation, depending on your platform you can navigate to the directory where CMake generated the build files and then: - -* On Linux: run `make` -* On Windows: open the MSVC solution and build it -* On macOS: open the XCode project and build it - -Of course you can also use CMake itself to build cyclone by running this on the command line: - -``` - cd - cmake --build . -``` - -* Building a single library - -Per default Cyclone will build most of its objects as a single binary file (`.so` / `.dll` / `.dylib` / `.pd_darwin`). The exception is the "cyclone" object/binary that loads the non alphanumeric operators objects (which are: `!-`, `!-~`, `!/`, `!/~`, `!=~`, `%~`, `+=~`, `<=~`, `<~`, `==~`, `>=~` and `>~`). - -If you want you can also build all of the Cyclone objects into one `cyclone.so/dll/dylib/pd_darwin` by activating the `BUILD_SINGLE_LIBRARY` option. - -Each one of the individual libraries contain a `_setup()` method that will be invoked by pure-data on [library load](https://github.com/pure-data/pure-data/blob/5526f7d08db7fe5d48884e1cb4b0f53fa79197ae/src/s_loader.c#L116). If you select the `BUILD_SINGLE_LIBRARY`, CMake will generate the appropriate code so that all `*_setup()` methods will be invoked in the main `cyclone_setup()`. - -* Command-line examples - -Here are a few examples of how to download, configure and build the latest Cyclone on the command line using CMake and pure-data or libpd. - -Linux: - -``` -git clone https://github.com/pure-data/pure-data - - -git clone https://github.com/porres/pd-cyclone -cd pd-cyclone -mkdir build && cd build -cmake .. -DPD_INCLUDE_DIR:PATH=pure-data/src -DPD_LIBRARY:PATH= -cmake --build . -``` -Windows / MSVC: - -``` -git clone https://github.com/pure-data/pure-data - - -#Clone the Cyclone repository from GitHub: -git clone https://github.com/porres/pd-cyclone -cd pd-cyclone -mkdir build && cd build -cmake .. -DCMAKE_THREAD_LIBS_INIT:PATH= -DPTHREADS_INCLUDE_DIR:PATH= -DPD_INCLUDE_DIR:PATH=pure-data/src -DPD_LIBRARY:PATH= -cmake --build . -``` - -Using libpd in Linux: - -``` -# Here we compile libpd ourselves, you can skip the building steps if you download the libpd binaries -git clone https://github.com/libpd/libpd -cd libpd -git submodule init -git submodule update -# libpd build steps: -mkdir build && cd build -cmake .. -cmake --build . -cd ../.. - -# Now clone the Cyclone repository -git clone https://github.com/porres/pd-cyclone -cd pd-cyclone -mkdir build && cd build -cmake .. -DPD_INCLUDE_DIR:PATH=../libpd/pure-data/src -DPD_LIBRARY:PATH=../libpd/libs/libpd.so -cmake --build . -``` -------- - -### A Brief History of Cyclone's Development: - -Excerpt from Cyclone's original Readme (by its original author Krzysztof Czaja): - -* "Cyclone is a library of Pure Data classes, bringing some level of compatibility between Max/MSP and Pd environments. Although being itself in the early stage of development, it is meant to eventually become part of a much larger project, aiming at unification and standardization of computer musician's tools. In its current form, cyclone is mainly for people using both Max and Pd, and thus wanting to develop cross-platform patches. (...)." The full original readme is provided in this repository at: - -Cyclone's original author Krzysztof Czaja worked on it as part of his miXed library from 2002 to 2005 and later abandoned it all together. In parallel, miXed had been incorporated into Pd Extended and eventually ended up under the maintenance of Hans-Christoph Steiner - the main developer and maintainer of Pd-Extended. When Pd Extended was abandoned after its last release (from Jan 2013), Cyclone and miXed were left unmaintained as a result. In Dec-2014, Fred Jan Kraan took over maintenance and development for cyclone (but not the rest of the miXed library) and released 0.1-alpha57 and Cyclone 0.2 beta versions, but decided to abandon development for it in Feb-2016. - -Since February 21st 2016, further development for Cyclone started on this repository by Alexandre Porres, Derek Kwan, Matt Barber and other collaborators. The first stable release was Cyclone 0.3-0 from february 2019! - -#### About Cyclone's Repositories and its Fork History: - -=> Original Repository (up to version 0.1-Alpha-56): -The original repository of MiXed as part of Pd Extended - containing Cyclone and more (such as 'toxy') - resides at and the migrated repository: . This repository embraces work from three different maintenance phases: - -- Czaja's era (until 2005 and up to 0.1-Alpha55): Czaja (the original author) worked on Cyclone from version 01-alpha-01 (2002) to 0.1-alpha-55 (2005). -- Hans era (until 2013 and 0.1-Alpha-56): Hans maintained Cyclone from 2005 to 2013. The 0.1-Alpha55 version of Cyclone is found in most of Pd-Extended versions up to Pd-Extended 0.42-5. The last release of Pd-Extended is 0.43-4 from Jan-2013 and it carries the 0.1-Alpha56 version of Cyclone, which can also be found as "cyclone-v0-0extended" when searching for externals in Pd Vanilla. -- Kraan era (up to 2015): The later work in this repository was not made available into a new release from this repository. - -=> Fred Jan Kraan's Repository (0.1-Alpha57 and 0.2-beta): - -Fred Jan Kraan forked the original repository to , but containing only the Cyclone library. This repository has a few releases - see https://github.com/electrickery/pd-miXedSon/releases - it starts with Cyclone version 0.1-alpha-57, from October 2015, which is basically the last developments made on the original repository in its last phase. Then it moves on to a new Cyclone 0.2 version which stopped at a beta stage in february 2016. - -=> This Repository (0.3-0 and onwards): - -In February 2016, Porres forked from https://github.com/electrickery/pd-miXedSon to this repository that resides at: https://github.com/porres/pd-cyclone. The fork happened while cyclone was at 0.2-beta stage. Since then, Alexandre Porres, Derek Kwan, Matt Barber and other collaborators have worked on further developments of cyclone. The first stable release from this repository was cyclone 0.3-0 from february 2019. In late 2021, after the release of version 0.6-0, this repository was detached from Kraan's (electrickery) here on GitHub, after being thousands of commits ahead and with a completely restructure of the code base. - -=> The 'nilwind' fork: - -The 'nilwind' library is a fork of Cyclone and it starts as a fork of the last stage was left at, meaning it is a is a development over cyclone 0.2-beta. The nilwind's repository is at https://github.com/electrickery/pd-nilwind. Its first release is 'nilwind 0.2.1', from November 2019. This fork of cyclone does not aim to pursue updates according to newer versions of Max and its main concern is to keep compatibility to old/legacy patches made in the Pd-Extended era (which carried cyclone 0.1). Nonetheless, versions of cyclone 0.3 onward are also compatible to Pd-Extended era, as the current development phase does not introduce breaking changes and has only offered stable releases since 0.3! - -------- - -### About This Repository's Goals: - -This repository resides at and is faithful to the original goal of Cyclone in creating an external Pd package with a collection of objects cloned and compatible to Max/MSP objects. Bugs and issues should be reported to . Releases from this repository are stable and offer many fixes and improves stability from earlier versions. - -Compatibility to newer versions of Max is a concern, but Max compatibility was always the main goal of cyclone and nothing really changed, since Max itself keeps backwards compatibilities. No incompatibilities should arise between cyclone 0.3-0 onwards with the legacy stage of the library (the cyclone 0.1 phase that was available in Pd Extended). Since this development stage of Cyclone is concerned to provide compatibility for patches made in the Pd-Extended era, if such issues arise, they should be treated as bugs and reported/fixed. - -### Collaborating to Cyclone: - -This repository/project is open to collaboration to anyone who wishes to work (keeping in mind the key and central goal of Max/MSP compatibility). Feel free to collaborate. - -### Acknowledgements: - -Thanks to previous maintainers, Lucas Cordiviola for working on compilation and cross compilation issues and generating binaries for many releases. Diego Barrios Romero worked on the possibility of compiling all of objects in cyclone as a single binary instead of separate binaries. diff --git a/Libraries/cyclone/cyclone_objects/abstractions/buffer~.pd b/Libraries/cyclone/cyclone_objects/abstractions/buffer~.pd deleted file mode 100644 index 4187e6d375..0000000000 --- a/Libraries/cyclone/cyclone_objects/abstractions/buffer~.pd +++ /dev/null @@ -1,1750 +0,0 @@ -#N canvas 526 173 814 272 10; -#X declare -path /Users/porres/Desktop/git/pd-cyclone/cyclone_objects/abstractions -; -#X obj 24 24 inlet; -#N canvas 396 59 533 410 rename 0; -#X obj 319 189 r \$0-name; -#X obj 59 76 symbol; -#X obj 59 50 inlet; -#X obj 162 186 cyclone/uzi 1 0; -#X obj 135 138 v ch_\$0; -#X obj 135 161 sel 1; -#X obj 212 130 s \$0-new-name; -#X obj 390 190 r \$0-new-name; -#X obj 59 132 s \$0-name; -#X obj 59 105 trigger symbol bang symbol; -#X obj 204 285 r \$0-name; -#X obj 147 251 r \$0-new-name; -#X obj 249 217 pack float symbol symbol; -#X msg 249 242 \; \$1-\$2 rename \$1-\$3; -#X obj 135 311 cyclone/join; -#X msg 147 283 set \$1; -#X msg 135 337 \; \$1 rename \$2; -#X connect 0 0 12 1; -#X connect 1 0 9 0; -#X connect 2 0 1 0; -#X connect 3 2 12 0; -#X connect 4 0 5 0; -#X connect 5 0 14 0; -#X connect 5 1 3 0; -#X connect 7 0 12 2; -#X connect 9 0 8 0; -#X connect 9 1 4 0; -#X connect 9 2 6 0; -#X connect 10 0 14 1; -#X connect 11 0 15 0; -#X connect 12 0 13 0; -#X connect 14 0 16 0; -#X connect 15 0 14 0; -#X restore 64 100 pd rename; -#N canvas 961 127 479 442 \$0-buffers 0; -#X coords 0 0 0 0 10 20 0; -#X restore 627 59 pd \$0-buffers; -#N canvas 386 286 457 330 clear 0; -#X obj 301 150 r \$0-name; -#X obj 202 177 pack float symbol; -#X msg 202 201 \; \$1-\$2 const 0; -#X obj 88 25 inlet; -#X obj 115 142 cyclone/uzi 1 0; -#X obj 88 94 v ch_\$0; -#X obj 88 58 t b f; -#X obj 88 117 sel 1; -#X obj 121 168 r \$0-name; -#X obj 88 218 pack s f; -#X obj 88 189 symbol; -#X msg 88 246 \; \$1 const 0; -#X connect 0 0 1 1; -#X connect 1 0 2 0; -#X connect 3 0 6 0; -#X connect 4 2 1 0; -#X connect 5 0 7 0; -#X connect 6 0 5 0; -#X connect 6 1 9 1; -#X connect 7 0 10 0; -#X connect 7 1 4 0; -#X connect 8 0 10 1; -#X connect 9 0 11 0; -#X connect 10 0 9 0; -#X restore 24 124 pd clear; -#N canvas 600 187 502 387 fill 0; -#X obj 35 24 inlet; -#X obj 62 192 cyclone/uzi 1 0; -#X obj 35 144 v ch_\$0; -#X obj 284 191 r \$0-name; -#X obj 149 217 pack float float symbol; -#X msg 149 241 \; \$1-\$3 const \$2; -#X obj 104 79 route bang; -#X msg 104 103 1; -#N canvas 143 25 666 661 sin 0; -#X obj 319 197 r \$0-name; -#X obj 274 221 pack f s; -#X obj 131 292 cyclone/uzi 1 0; -#X obj 304 391 tabwrite; -#X obj 463 254 list; -#X obj 385 177 list length; -#X obj 385 204 > 1; -#X obj 385 228 sel 0 1; -#X obj 463 277 /; -#X obj 385 152 trigger list list; -#X obj 424 256 list; -#X obj 62 46 inlet; -#X obj 204 220 r \$0-size; -#X obj 169 225 f; -#X obj 169 192 trigger bang float; -#X obj 131 263 trigger float float; -#X obj 62 80 trigger bang list; -#X obj 118 344 expr sin(($f1 / ($f2 / $f3)) * 2 * pi_\$0) \; $f1; -#X obj 107 160 cyclone/uzi 1 0; -#X obj 62 112 v ch_\$0; -#X obj 88 198 r \$0-name; -#X obj 55 222 symbol; -#X obj 62 135 select 1; -#X obj 55 249 t b s; -#X msg 68 276 set \$1; -#X msg 274 247 set \$1-\$2; -#X connect 0 0 1 1; -#X connect 1 0 25 0; -#X connect 2 2 17 0; -#X connect 4 0 8 0; -#X connect 5 0 6 0; -#X connect 6 0 7 0; -#X connect 7 0 10 0; -#X connect 7 1 4 0; -#X connect 8 0 17 2; -#X connect 9 0 5 0; -#X connect 9 1 4 1; -#X connect 9 1 10 1; -#X connect 10 0 17 2; -#X connect 11 0 16 0; -#X connect 12 0 13 1; -#X connect 13 0 15 0; -#X connect 14 0 13 0; -#X connect 14 1 1 0; -#X connect 15 0 2 0; -#X connect 15 1 17 1; -#X connect 16 0 19 0; -#X connect 16 1 9 0; -#X connect 17 0 3 0; -#X connect 17 1 3 1; -#X connect 18 2 14 0; -#X connect 19 0 22 0; -#X connect 20 0 21 1; -#X connect 21 0 23 0; -#X connect 22 0 21 0; -#X connect 22 1 18 0; -#X connect 23 0 13 0; -#X connect 23 1 24 0; -#X connect 24 0 3 0; -#X connect 25 0 3 0; -#X restore 122 135 pd sin; -#X obj 174 79 route bang; -#X msg 174 103 1; -#X obj 35 108 t b f; -#N canvas 143 25 740 581 cos 0; -#X obj 467 249 r \$0-name; -#X obj 422 273 pack f s; -#X obj 279 344 cyclone/uzi 1 0; -#X obj 461 443 tabwrite; -#X obj 230 221 cyclone/uzi 1 0; -#X obj 620 306 list; -#X obj 542 229 list length; -#X obj 542 256 > 1; -#X obj 542 280 sel 0 1; -#X obj 620 329 /; -#X obj 542 204 trigger list list; -#X obj 581 308 list; -#X obj 85 114 inlet; -#X obj 352 272 r \$0-size; -#X obj 317 277 f; -#X obj 317 244 trigger bang float; -#X obj 279 315 trigger float float; -#X obj 85 148 trigger bang list; -#X obj 275 396 expr cos(($f1 / ($f2 / $f3)) * 2 * pi_\$0) \; $f1; -#X obj 85 192 v ch_\$0; -#X obj 118 248 r \$0-name; -#X obj 85 272 symbol; -#X obj 85 215 select 1; -#X obj 85 299 t b s; -#X msg 98 326 set \$1; -#X msg 422 299 set \$1-\$2; -#X connect 0 0 1 1; -#X connect 1 0 25 0; -#X connect 2 2 18 0; -#X connect 4 2 15 0; -#X connect 5 0 9 0; -#X connect 6 0 7 0; -#X connect 7 0 8 0; -#X connect 8 0 11 0; -#X connect 8 1 5 0; -#X connect 9 0 18 2; -#X connect 10 0 6 0; -#X connect 10 1 5 1; -#X connect 10 1 11 1; -#X connect 11 0 18 2; -#X connect 12 0 17 0; -#X connect 13 0 14 1; -#X connect 14 0 16 0; -#X connect 15 0 14 0; -#X connect 15 1 1 0; -#X connect 16 0 2 0; -#X connect 16 1 18 1; -#X connect 17 0 19 0; -#X connect 17 1 10 0; -#X connect 18 0 3 0; -#X connect 18 1 3 1; -#X connect 19 0 22 0; -#X connect 20 0 21 1; -#X connect 21 0 23 0; -#X connect 22 0 21 0; -#X connect 22 1 4 0; -#X connect 23 0 14 0; -#X connect 23 1 24 0; -#X connect 24 0 3 0; -#X connect 25 0 3 0; -#X restore 189 135 pd cos; -#X obj 35 167 sel 1; -#X obj 68 218 r \$0-name; -#X obj 35 268 pack s f; -#X obj 35 239 symbol; -#X msg 35 296 \; \$1 const \$2; -#N canvas 0 22 276 214 pi 0; -#X obj 97 94 expr atan(1) * 4; -#X obj 97 66 loadbang; -#X obj 97 120 v pi_\$0; -#X connect 0 0 2 0; -#X connect 1 0 0 0; -#X restore 362 122 pd pi; -#X obj 35 51 route float sin cos sinc, f 47; -#N canvas 325 23 674 597 sinc 0; -#X obj 521 256 r \$0-name; -#X obj 476 295 pack f s; -#X obj 253 365 cyclone/uzi 1 0; -#X obj 253 524 tabwrite; -#X obj 264 200 cyclone/uzi 1 0; -#X obj 35 21 inlet; -#X obj 452 255 r \$0-size; -#X obj 397 287 f; -#X obj 119 196 v ch_\$0; -#X obj 152 259 r \$0-name; -#X obj 119 283 symbol; -#X obj 119 226 select 1; -#X obj 119 310 t b s; -#X msg 146 337 set \$1; -#X obj 484 502 v x_\$0; -#X obj 533 491 /; -#X msg 533 470 1; -#X obj 533 513 v r_\$0; -#X obj 533 448 t b f; -#X obj 253 459 expr if($f1 == 0 \, 1 \, sin(x_\$0) * r_\$0) \; $f1 -* 2*pi_\$0 * $f2; -#X obj 216 258 / 2; -#X obj 119 159 t b f; -#X obj 189 197 sel 0; -#X obj 216 228 abs; -#X obj 397 322 t f f; -#X obj 397 254 t b f; -#X obj 35 55 route bang; -#X obj 164 135 != 0; -#X obj 92 128 sel 0; -#X obj 164 159 v half_\$0; -#X obj 253 394 expr if(half_\$0 == 1 \, ($f1 / $f2) \, ($f1 - $f2/2) -/ ($f2/2)) \; $f1, f 34; -#X obj 164 57 list length; -#X obj 164 82 sel 1; -#X msg 164 107 0; -#X obj 92 79 t l l; -#X obj 92 103 unpack; -#X msg 476 321 set \$1-\$2; -#N canvas 154 73 345 332 fill_1 0; -#X obj 48 26 inlet; -#X obj 251 84 r \$0-name; -#X obj 206 123 pack f s; -#X obj 119 92 cyclone/uzi 1 0; -#X obj 48 63 v ch_\$0; -#X obj 48 150 symbol; -#X obj 48 93 select 1; -#X msg 206 149 symbol \$1-\$2; -#X obj 200 258 send, f 12; -#X msg 200 208 const 1; -#X obj 150 219 t b s; -#X obj 206 179 trigger b s; -#X connect 0 0 4 0; -#X connect 1 0 2 1; -#X connect 1 0 5 1; -#X connect 2 0 7 0; -#X connect 3 2 2 0; -#X connect 4 0 6 0; -#X connect 5 0 10 0; -#X connect 6 0 5 0; -#X connect 6 1 3 0; -#X connect 7 0 11 0; -#X connect 9 0 8 0; -#X connect 10 0 9 0; -#X connect 10 1 8 1; -#X connect 11 0 9 0; -#X connect 11 1 8 1; -#X restore 44 180 pd fill_1; -#X connect 0 0 1 1; -#X connect 1 0 36 0; -#X connect 2 2 30 0; -#X connect 4 2 25 0; -#X connect 5 0 26 0; -#X connect 6 0 7 1; -#X connect 7 0 24 0; -#X connect 8 0 11 0; -#X connect 9 0 10 1; -#X connect 10 0 12 0; -#X connect 11 0 10 0; -#X connect 11 1 4 0; -#X connect 12 0 7 0; -#X connect 12 1 13 0; -#X connect 13 0 3 0; -#X connect 15 0 17 0; -#X connect 16 0 15 0; -#X connect 18 0 16 0; -#X connect 18 1 15 1; -#X connect 19 0 3 0; -#X connect 19 1 14 0; -#X connect 19 1 18 0; -#X connect 20 0 19 1; -#X connect 21 0 8 0; -#X connect 21 1 22 0; -#X connect 22 1 23 0; -#X connect 23 0 20 0; -#X connect 24 0 2 0; -#X connect 24 1 30 1; -#X connect 25 0 7 0; -#X connect 25 1 1 0; -#X connect 26 1 34 0; -#X connect 27 0 29 0; -#X connect 28 0 37 0; -#X connect 28 1 21 0; -#X connect 30 0 19 0; -#X connect 30 1 3 1; -#X connect 31 0 32 0; -#X connect 32 0 33 0; -#X connect 33 0 27 0; -#X connect 34 0 35 0; -#X connect 34 1 31 0; -#X connect 35 0 28 0; -#X connect 35 1 27 0; -#X connect 36 0 3 0; -#X restore 244 136 pd sinc; -#X connect 0 0 19 0; -#X connect 1 2 4 0; -#X connect 2 0 13 0; -#X connect 3 0 4 2; -#X connect 4 0 5 0; -#X connect 6 0 7 0; -#X connect 6 1 8 0; -#X connect 7 0 8 0; -#X connect 9 0 10 0; -#X connect 9 1 12 0; -#X connect 10 0 12 0; -#X connect 11 0 2 0; -#X connect 11 1 4 1; -#X connect 11 1 15 1; -#X connect 13 0 16 0; -#X connect 13 1 1 0; -#X connect 14 0 16 1; -#X connect 15 0 17 0; -#X connect 16 0 15 0; -#X connect 19 0 11 0; -#X connect 19 1 6 0; -#X connect 19 2 9 0; -#X connect 19 3 20 0; -#X restore 228 124 pd fill; -#N canvas 0 22 450 300 vis 0; -#X msg 241 123 vis \$1; -#X msg 241 96 1; -#X msg 273 96 0; -#X obj 231 149 send pd-\$0-buffers; -#X obj 212 54 inlet; -#X obj 287 58 inlet; -#X connect 0 0 3 0; -#X connect 1 0 0 0; -#X connect 2 0 0 0; -#X connect 4 0 1 0; -#X connect 5 0 2 0; -#X restore 149 100 pd vis; -#N canvas 745 220 574 222 apply 0; -#X obj 35 24 inlet; -#N canvas 318 219 560 455 gain 0; -#X obj 409 175 r \$0-name; -#X obj 364 199 pack f s; -#X obj 197 231 cyclone/uzi 1 0; -#X obj 231 205 r \$0-size; -#X obj 197 204 f; -#X obj 172 133 cyclone/uzi 1 0; -#X obj 172 105 v ch_\$0; -#X obj 259 166 trigger bang float; -#X obj 172 78 trigger bang float; -#X obj 277 102 v gain_\$0; -#X obj 172 35 inlet; -#X obj 311 294 tabread; -#X obj 311 390 tabwrite; -#X obj 311 318 expr $f1 * gain_\$0; -#X obj 284 254 t f f; -#X obj 290 342 swap; -#X obj 105 135 sel 1; -#X msg 364 225 set \$1-\$2; -#X obj 142 168 r \$0-name; -#X obj 109 192 symbol; -#X obj 109 226 t b s; -#X msg 168 263 set \$1; -#X connect 0 0 1 1; -#X connect 1 0 17 0; -#X connect 2 2 14 0; -#X connect 3 0 4 1; -#X connect 4 0 2 0; -#X connect 5 2 7 0; -#X connect 6 0 16 0; -#X connect 7 0 4 0; -#X connect 7 1 1 0; -#X connect 8 0 6 0; -#X connect 8 1 9 0; -#X connect 10 0 8 0; -#X connect 11 0 13 0; -#X connect 13 0 15 1; -#X connect 14 0 15 0; -#X connect 14 1 11 0; -#X connect 15 0 12 0; -#X connect 15 1 12 1; -#X connect 16 0 19 0; -#X connect 16 1 5 0; -#X connect 17 0 11 0; -#X connect 17 0 12 0; -#X connect 18 0 19 1; -#X connect 19 0 20 0; -#X connect 20 0 4 0; -#X connect 20 1 21 0; -#X connect 21 0 11 0; -#X connect 21 0 12 0; -#X restore 35 117 pd gain; -#N canvas 601 88 532 489 offset 0; -#X obj 413 180 r \$0-name; -#X obj 368 204 pack f s; -#X obj 263 236 cyclone/uzi 1 0; -#X obj 297 210 r \$0-size; -#X obj 263 209 f; -#X obj 176 138 cyclone/uzi 1 0; -#X obj 176 110 v ch_\$0; -#X obj 263 171 trigger bang float; -#X obj 176 83 trigger bang float; -#X obj 176 40 inlet; -#X obj 315 319 tabread; -#X obj 312 407 tabwrite; -#X msg 368 230 \$1-\$2; -#X obj 368 273 cyclone/prepend set; -#X obj 288 279 t f f; -#X obj 288 375 swap; -#X obj 281 107 v offset_\$0; -#X obj 315 343 expr $f1 + offset_\$0; -#X obj 128 139 sel 1; -#X obj 148 168 r \$0-name; -#X obj 128 196 symbol; -#X obj 128 235 t b s; -#X connect 0 0 1 1; -#X connect 1 0 12 0; -#X connect 2 2 14 0; -#X connect 3 0 4 1; -#X connect 4 0 2 0; -#X connect 5 2 7 0; -#X connect 6 0 18 0; -#X connect 7 0 4 0; -#X connect 7 1 1 0; -#X connect 8 0 6 0; -#X connect 8 1 16 0; -#X connect 9 0 8 0; -#X connect 10 0 17 0; -#X connect 12 0 13 0; -#X connect 13 0 10 0; -#X connect 13 0 11 0; -#X connect 14 0 15 0; -#X connect 14 1 10 0; -#X connect 15 0 11 0; -#X connect 15 1 11 1; -#X connect 17 0 15 1; -#X connect 18 0 20 0; -#X connect 18 1 5 0; -#X connect 19 0 20 1; -#X connect 20 0 21 0; -#X connect 21 0 4 0; -#X connect 21 1 13 0; -#X restore 49 92 pd offset; -#N canvas 132 100 605 629 hanning 0; -#X obj 374 246 r \$0-name; -#X obj 329 270 pack f s; -#X obj 137 204 cyclone/uzi 1 0; -#X obj 110 138 v ch_\$0; -#X obj 224 237 trigger bang float; -#X obj 110 48 inlet; -#X obj 276 397 tabread; -#X obj 329 561 tabwrite; -#X msg 329 328 \$1-\$2; -#X obj 329 351 cyclone/prepend set; -#X obj 249 369 t f f; -#X obj 249 305 r \$0-size; -#X obj 110 169 sel 1; -#X obj 125 232 r \$0-name; -#X obj 92 256 symbol; -#X obj 92 358 t b s; -#X obj 110 72 route half; -#X obj 110 96 t b b; -#X obj 167 96 t b b; -#X msg 194 119 0; -#X msg 164 119 1; -#X obj 180 148 v half_\$0; -#X obj 162 333 cyclone/uzi 1 0; -#X obj 197 458 expr if (half_\$0 == 1 \, (($f1 * 0.5) / $f2) + 0.5 -\, $f1/$f2) \; $f1, f 30; -#X obj 162 511 expr $f2 * (cos(pi_\$0 + ($f1 * 2*pi_\$0)) * 0.5 + 0.5) -, f 61; -#X connect 0 0 1 1; -#X connect 1 0 8 0; -#X connect 2 2 4 0; -#X connect 3 0 12 0; -#X connect 4 0 22 0; -#X connect 4 1 1 0; -#X connect 5 0 16 0; -#X connect 6 0 24 1; -#X connect 8 0 9 0; -#X connect 9 0 6 0; -#X connect 9 0 7 0; -#X connect 10 0 23 0; -#X connect 10 1 6 0; -#X connect 11 0 22 1; -#X connect 11 0 23 1; -#X connect 12 0 14 0; -#X connect 12 1 2 0; -#X connect 13 0 14 1; -#X connect 14 0 15 0; -#X connect 15 0 22 0; -#X connect 15 1 9 0; -#X connect 16 0 17 0; -#X connect 16 1 18 0; -#X connect 17 0 3 0; -#X connect 17 1 20 0; -#X connect 18 0 3 0; -#X connect 18 1 19 0; -#X connect 19 0 21 0; -#X connect 20 0 21 0; -#X connect 22 2 10 0; -#X connect 23 0 24 0; -#X connect 23 1 7 1; -#X connect 24 0 7 0; -#X restore 141 135 pd hanning; -#N canvas 727 125 654 634 blackman 0; -#X obj 374 246 r \$0-name; -#X obj 329 270 pack f s; -#X obj 137 204 cyclone/uzi 1 0; -#X obj 110 138 v ch_\$0; -#X obj 224 237 trigger bang float; -#X obj 110 48 inlet; -#X obj 276 397 tabread; -#X obj 329 561 tabwrite; -#X msg 329 328 \$1-\$2; -#X obj 329 351 cyclone/prepend set; -#X obj 249 369 t f f; -#X obj 249 305 r \$0-size; -#X obj 110 169 sel 1; -#X obj 125 232 r \$0-name; -#X obj 92 256 symbol; -#X obj 92 358 t b s; -#X obj 110 72 route half; -#X obj 110 96 t b b; -#X obj 167 96 t b b; -#X msg 194 119 0; -#X msg 164 119 1; -#X obj 180 148 v half_\$0; -#X obj 162 333 cyclone/uzi 1 0; -#X obj 197 458 expr if (half_\$0 == 1 \, (($f1 * 0.5) / $f2) + 0.5 -\, $f1/$f2) \; $f1, f 30; -#X obj 197 509 expr $f2 * (0.42 - (cos($f1 * 2*pi_\$0) * 0.5)) + (cos($f1 -* 4*pi_\$0) * 0.08), f 47; -#X connect 0 0 1 1; -#X connect 1 0 8 0; -#X connect 2 2 4 0; -#X connect 3 0 12 0; -#X connect 4 0 22 0; -#X connect 4 1 1 0; -#X connect 5 0 16 0; -#X connect 6 0 24 1; -#X connect 8 0 9 0; -#X connect 9 0 6 0; -#X connect 9 0 7 0; -#X connect 10 0 23 0; -#X connect 10 1 6 0; -#X connect 11 0 22 1; -#X connect 11 0 23 1; -#X connect 12 0 14 0; -#X connect 12 1 2 0; -#X connect 13 0 14 1; -#X connect 14 0 15 0; -#X connect 15 0 22 0; -#X connect 15 1 9 0; -#X connect 16 0 17 0; -#X connect 16 1 18 0; -#X connect 17 0 3 0; -#X connect 17 1 20 0; -#X connect 18 0 3 0; -#X connect 18 1 19 0; -#X connect 19 0 21 0; -#X connect 20 0 21 0; -#X connect 22 2 10 0; -#X connect 23 0 24 0; -#X connect 23 1 7 1; -#X connect 24 0 7 0; -#X restore 218 89 pd blackman; -#N canvas 296 45 515 593 hamming 0; -#X obj 324 216 r \$0-name; -#X obj 279 240 pack f s; -#X obj 87 174 cyclone/uzi 1 0; -#X obj 60 108 v ch_\$0; -#X obj 174 207 trigger bang float; -#X obj 60 18 inlet; -#X obj 226 375 tabread; -#X obj 279 531 tabwrite; -#X msg 279 298 \$1-\$2; -#X obj 279 321 cyclone/prepend set; -#X obj 199 339 t f f; -#X obj 199 275 r \$0-size; -#X obj 60 139 sel 1; -#X obj 75 202 r \$0-name; -#X obj 42 226 symbol; -#X obj 42 328 t b s; -#X obj 60 42 route half; -#X obj 60 66 t b b; -#X obj 117 66 t b b; -#X msg 144 89 0; -#X msg 114 89 1; -#X obj 130 118 v half_\$0; -#X obj 112 303 cyclone/uzi 1 0; -#X obj 147 432 expr if (half_\$0 == 1 \, (($f1 * 0.5) / $f2) + 0.5 -\, $f1/$f2) \; $f1, f 30; -#X obj 147 482 expr $f2 * (cos(pi_\$0 + ($f1 * 2*pi_\$0)) * 0.46 + -0.54); -#X connect 0 0 1 1; -#X connect 1 0 8 0; -#X connect 2 2 4 0; -#X connect 3 0 12 0; -#X connect 4 0 22 0; -#X connect 4 1 1 0; -#X connect 5 0 16 0; -#X connect 6 0 24 1; -#X connect 8 0 9 0; -#X connect 9 0 6 0; -#X connect 9 0 7 0; -#X connect 10 0 23 0; -#X connect 10 1 6 0; -#X connect 11 0 22 1; -#X connect 11 0 23 1; -#X connect 12 0 14 0; -#X connect 12 1 2 0; -#X connect 13 0 14 1; -#X connect 14 0 15 0; -#X connect 15 0 22 0; -#X connect 15 1 9 0; -#X connect 16 0 17 0; -#X connect 16 1 18 0; -#X connect 17 0 3 0; -#X connect 17 1 20 0; -#X connect 18 0 3 0; -#X connect 18 1 19 0; -#X connect 19 0 21 0; -#X connect 20 0 21 0; -#X connect 22 2 10 0; -#X connect 23 0 24 0; -#X connect 23 1 7 1; -#X connect 24 0 7 0; -#X restore 194 112 pd hamming; -#N canvas 225 220 519 522 triangle 0; -#X obj 328 221 r \$0-name; -#X obj 283 245 pack f s; -#X obj 91 179 cyclone/uzi 1 0; -#X obj 178 212 trigger bang float; -#X obj 64 24 inlet; -#X obj 404 361 tabread; -#X obj 283 453 tabwrite; -#X msg 283 271 \$1-\$2; -#X obj 283 294 cyclone/prepend set; -#X obj 204 263 r \$0-size; -#X obj 191 324 t f f; -#X obj 64 152 sel 1; -#X obj 97 207 r \$0-name; -#X obj 64 233 symbol; -#X obj 64 262 t b s; -#X obj 117 297 cyclone/uzi 1 0; -#X obj 64 122 v ch_\$0; -#X obj 64 56 route half; -#X obj 64 80 t b b; -#X obj 121 80 t b b; -#X msg 148 103 0; -#X msg 118 103 1; -#X obj 134 132 v half_\$0; -#X obj 137 392 expr $f3 * if(half_\$0 == 1 \, 1 - ($f1 / $f2) \, 1 -- (abs($f1 - ($f2 * 0.5)) / ($f2 * 0.5))) \; $f1, f 45; -#X connect 0 0 1 1; -#X connect 1 0 7 0; -#X connect 2 2 3 0; -#X connect 3 0 15 0; -#X connect 3 1 1 0; -#X connect 4 0 17 0; -#X connect 5 0 23 2; -#X connect 7 0 8 0; -#X connect 8 0 5 0; -#X connect 8 0 6 0; -#X connect 9 0 15 1; -#X connect 9 0 23 1; -#X connect 10 0 23 0; -#X connect 10 1 5 0; -#X connect 11 0 13 0; -#X connect 11 1 2 0; -#X connect 12 0 13 1; -#X connect 13 0 14 0; -#X connect 14 0 15 0; -#X connect 14 1 8 0; -#X connect 15 2 10 0; -#X connect 16 0 11 0; -#X connect 17 0 18 0; -#X connect 17 1 19 0; -#X connect 18 0 16 0; -#X connect 18 1 21 0; -#X connect 19 0 16 0; -#X connect 19 1 20 0; -#X connect 20 0 22 0; -#X connect 21 0 22 0; -#X connect 23 0 6 0; -#X connect 23 1 6 1; -#X restore 300 123 pd triangle; -#N canvas 715 130 552 528 welch 0; -#X obj 328 221 r \$0-name; -#X obj 283 245 pack f s; -#X obj 91 179 cyclone/uzi 1 0; -#X obj 178 212 trigger bang float; -#X obj 64 24 inlet; -#X obj 434 361 tabread; -#X obj 283 453 tabwrite; -#X msg 283 271 \$1-\$2; -#X obj 283 294 cyclone/prepend set; -#X obj 204 263 r \$0-size; -#X obj 204 324 t f f; -#X obj 64 152 sel 1; -#X obj 97 207 r \$0-name; -#X obj 64 233 symbol; -#X obj 64 262 t b s; -#X obj 117 297 cyclone/uzi 1 0; -#X obj 64 122 v ch_\$0; -#X obj 64 56 route half; -#X obj 64 80 t b b; -#X obj 121 80 t b b; -#X msg 148 103 0; -#X msg 118 103 1; -#X obj 134 132 v half_\$0; -#X obj 137 392 expr $f3 * if(half_\$0 == 1 \, 1 - pow($f1 / $f2 \, -2) \, 1 - pow((($f1 - ($f2 * 0.5)) / ($f2 * 0.5)) \, 2)) \; $f1, f -50; -#X connect 0 0 1 1; -#X connect 1 0 7 0; -#X connect 2 2 3 0; -#X connect 3 0 15 0; -#X connect 3 1 1 0; -#X connect 4 0 17 0; -#X connect 5 0 23 2; -#X connect 7 0 8 0; -#X connect 8 0 5 0; -#X connect 8 0 6 0; -#X connect 9 0 15 1; -#X connect 9 0 23 1; -#X connect 10 0 23 0; -#X connect 10 1 5 0; -#X connect 11 0 13 0; -#X connect 11 1 2 0; -#X connect 12 0 13 1; -#X connect 13 0 14 0; -#X connect 14 0 15 0; -#X connect 14 1 8 0; -#X connect 15 2 10 0; -#X connect 16 0 11 0; -#X connect 17 0 18 0; -#X connect 17 1 19 0; -#X connect 18 0 16 0; -#X connect 18 1 21 0; -#X connect 19 0 16 0; -#X connect 19 1 20 0; -#X connect 20 0 22 0; -#X connect 21 0 22 0; -#X connect 23 0 6 0; -#X connect 23 1 6 1; -#X restore 345 93 pd welch; -#X obj 35 62 route gain offset hanning hamming blackman triangle welch -kaiser getdeltas, f 80; -#N canvas 457 204 459 446 getdeltas 0; -#X obj 146 333 expr $s2[$f1 + 1] - $s2[$f1] \; $f1; -#X obj 338 389 tabwrite; -#X msg 338 305 set \$1; -#X obj 338 219 pack f s; -#X obj 146 126 cyclone/uzi 1 0; -#X obj 59 86 v ch_\$0; -#X obj 233 159 trigger bang float; -#X obj 59 128 sel 1; -#X obj 92 161 r \$0-name; -#X obj 59 185 symbol; -#X obj 59 43 inlet; -#X msg 338 245 symbol \$1-\$2; -#X obj 166 304 r \$0-size; -#X obj 59 303 cyclone/uzi 0 0; -#X obj 59 212 t b s; -#X connect 0 0 1 0; -#X connect 0 1 1 1; -#X connect 2 0 1 0; -#X connect 3 0 11 0; -#X connect 4 2 6 0; -#X connect 5 0 7 0; -#X connect 6 0 13 0; -#X connect 6 1 3 0; -#X connect 7 0 9 0; -#X connect 7 1 4 0; -#X connect 8 0 9 1; -#X connect 8 0 3 1; -#X connect 9 0 14 0; -#X connect 10 0 5 0; -#X connect 11 0 0 1; -#X connect 11 0 2 0; -#X connect 12 0 13 1; -#X connect 13 2 0 0; -#X connect 14 0 13 0; -#X connect 14 1 2 0; -#X connect 14 1 0 1; -#X restore 459 96 pd getdeltas; -#N canvas 286 46 809 742 kaiser 0; -#X obj 380 359 r \$0-name; -#X obj 335 383 pack f s; -#X obj 143 317 cyclone/uzi 1 0; -#X obj 116 266 v ch_\$0; -#X obj 230 350 trigger bang float; -#X obj 59 24 inlet; -#X obj 282 490 tabread; -#X obj 335 677 tabwrite; -#X msg 335 421 \$1-\$2; -#X obj 335 444 cyclone/prepend set; -#X obj 255 462 t f f; -#X obj 255 398 r \$0-size; -#X obj 116 292 sel 1; -#X obj 131 345 r \$0-name; -#X obj 98 369 symbol; -#X obj 98 451 t b s; -#X obj 258 255 route half; -#X msg 315 283 0; -#X msg 258 283 1; -#X obj 258 316 v half_\$0; -#X obj 168 426 cyclone/uzi 1 0; -#X obj 590 97 loadbang; -#X obj 677 255 t f f; -#X obj 569 299 * 1; -#X obj 601 299 t f; -#X obj 569 327 swap 1; -#X obj 569 354 /; -#X obj 569 383 t f f; -#X obj 569 413 *; -#X obj 569 453 tabwrite inv_sq_fact_\$0; -#X msg 590 160 23; -#X obj 537 56 array define inv_sq_fact_\$0 24; -#X msg 525 299 1 0; -#X obj 590 189 cyclone/uzi 1 1; -#X obj 116 100 list split 1; -#X obj 116 210 t b f; -#N canvas 519 73 1081 738 kaiser_window 0; -#X obj 70 38 inlet; -#X obj 413 38 inlet; -#X obj 298 417 outlet; -#X text 69 17 modified n; -#X obj 313 38 inlet; -#X text 292 17 value from table; -#N canvas 239 73 486 549 besselI0 0; -#X msg 88 118 24; -#X msg 120 149 pause; -#X obj 172 126 *; -#X obj 172 148 * 0.25; -#X msg 231 146 1; -#X obj 188 238 f; -#X obj 261 238 *; -#X obj 172 321 *; -#X obj 169 207 t f b; -#X obj 43 238 tabread inv_sq_fact_\$0; -#X obj 172 355 +; -#X msg 356 271 0; -#X obj 230 355 t f; -#X obj 45 35 inlet; -#X obj 51 511 outlet; -#X obj 172 396 t f b f; -#X obj 192 448 f; -#X obj 224 475 ==; -#X obj 138 513 sel 1; -#X obj 88 181 cyclone/uzi 1 0; -#X obj 208 268 moses 1.7e+38; -#X msg 221 302 0; -#X obj 51 413 f; -#X obj 64 69 t b b f f, f 26; -#X connect 0 0 19 0; -#X connect 1 0 19 0; -#X connect 2 0 3 0; -#X connect 3 0 6 1; -#X connect 4 0 5 1; -#X connect 5 0 6 0; -#X connect 5 0 20 0; -#X connect 6 0 5 1; -#X connect 7 0 10 0; -#X connect 8 0 9 0; -#X connect 8 1 5 0; -#X connect 9 0 7 0; -#X connect 10 0 12 0; -#X connect 10 0 15 0; -#X connect 11 0 10 1; -#X connect 11 0 16 1; -#X connect 12 0 10 1; -#X connect 13 0 23 0; -#X connect 15 0 16 1; -#X connect 15 0 22 1; -#X connect 15 1 16 0; -#X connect 15 2 17 1; -#X connect 16 0 17 0; -#X connect 17 0 18 0; -#X connect 18 0 1 0; -#X connect 19 2 8 0; -#X connect 20 0 7 1; -#X connect 20 1 21 0; -#X connect 21 0 7 1; -#X connect 22 0 14 0; -#X connect 23 0 22 0; -#X connect 23 1 0 0; -#X connect 23 2 2 0; -#X connect 23 3 4 0; -#X connect 23 3 11 0; -#X connect 23 3 2 1; -#X restore 527 189 pd besselI0; -#X text 413 16 alpha * pi; -#X obj 133 289 /; -#X obj 298 373 *; -#N canvas 239 73 486 549 besselI0 0; -#X msg 88 118 24; -#X msg 120 149 pause; -#X obj 172 126 *; -#X obj 172 148 * 0.25; -#X msg 231 146 1; -#X obj 188 238 f; -#X obj 261 238 *; -#X obj 172 321 *; -#X obj 169 207 t f b; -#X obj 43 238 tabread inv_sq_fact_\$0; -#X obj 172 355 +; -#X msg 356 271 0; -#X obj 230 355 t f; -#X obj 45 35 inlet; -#X obj 51 511 outlet; -#X obj 172 396 t f b f; -#X obj 192 448 f; -#X obj 224 475 ==; -#X obj 138 513 sel 1; -#X obj 88 181 cyclone/uzi 1 0; -#X obj 208 268 moses 1.7e+38; -#X msg 221 302 0; -#X obj 51 413 f; -#X obj 64 69 t b b f f, f 26; -#X connect 0 0 19 0; -#X connect 1 0 19 0; -#X connect 2 0 3 0; -#X connect 3 0 6 1; -#X connect 4 0 5 1; -#X connect 5 0 6 0; -#X connect 5 0 20 0; -#X connect 6 0 5 1; -#X connect 7 0 10 0; -#X connect 8 0 9 0; -#X connect 8 1 5 0; -#X connect 9 0 7 0; -#X connect 10 0 12 0; -#X connect 10 0 15 0; -#X connect 11 0 10 1; -#X connect 11 0 16 1; -#X connect 12 0 10 1; -#X connect 13 0 23 0; -#X connect 15 0 16 1; -#X connect 15 0 22 1; -#X connect 15 1 16 0; -#X connect 15 2 17 1; -#X connect 16 0 17 0; -#X connect 17 0 18 0; -#X connect 18 0 1 0; -#X connect 19 2 8 0; -#X connect 20 0 7 1; -#X connect 20 1 21 0; -#X connect 21 0 7 1; -#X connect 22 0 14 0; -#X connect 23 0 22 0; -#X connect 23 1 0 0; -#X connect 23 2 2 0; -#X connect 23 3 4 0; -#X connect 23 3 11 0; -#X connect 23 3 2 1; -#X restore 70 163 pd besselI0; -#X obj 70 86 expr $f2 * sqrt(1 - $f1*$f1); -#X obj 662 191 expr exp($f1)/sqrt(2*$f1 * pi_\$0 ) * (1.0 + 1.0/(8.0*$f1) -* (1.0 + 9.0/(16.0*$f1) * (1.0 + 25.0/(24.0*$f1)))); -#X obj 163 163 expr exp($f1)/sqrt(2*$f1 * pi_\$0 ) * (1.0 + 1.0/(8.0*$f1) -* (1.0 + 9.0/(16.0*$f1) * (1.0 + 25.0/(24.0*$f1)))); -#X obj 559 122 moses 16; -#X obj 70 120 moses 16; -#X connect 0 0 11 0; -#X connect 1 0 11 1; -#X connect 1 0 14 0; -#X connect 4 0 9 1; -#X connect 6 0 8 1; -#X connect 8 0 9 0; -#X connect 9 0 2 0; -#X connect 10 0 8 0; -#X connect 11 0 15 0; -#X connect 12 0 8 1; -#X connect 13 0 8 0; -#X connect 14 0 6 0; -#X connect 14 1 12 0; -#X connect 15 0 10 0; -#X connect 15 1 13 0; -#X restore 203 641 pd kaiser_window; -#X obj 143 236 s \$0-kaiser_a; -#X obj 296 608 r \$0-kaiser_a; -#X obj 258 226 list trim; -#X obj 203 524 expr if (half_\$0 == 1 \, ($f1 / $f2 ) + 1 \, 2.0*$f1/$f2) -- 1 \; $f1, f 30; -#X obj 116 133 abs; -#X obj 341 155 sel 1; -#X obj 341 251 print apply-kaiser; -#X obj 264 188 t f f; -#X obj 341 191 f; -#X obj 341 131 > 88; -#X obj 116 176 min 88; -#X msg 341 216 alpha value \$1 clipped to 88; -#X obj 59 49 route bang; -#X msg 59 75 6; -#X connect 0 0 1 1; -#X connect 1 0 8 0; -#X connect 2 2 4 0; -#X connect 3 0 12 0; -#X connect 4 0 20 0; -#X connect 4 1 1 0; -#X connect 5 0 49 0; -#X connect 6 0 36 1; -#X connect 8 0 9 0; -#X connect 9 0 6 0; -#X connect 9 0 7 0; -#X connect 10 0 40 0; -#X connect 10 1 6 0; -#X connect 11 0 20 1; -#X connect 11 0 40 1; -#X connect 12 0 14 0; -#X connect 12 1 2 0; -#X connect 13 0 14 1; -#X connect 14 0 15 0; -#X connect 15 0 20 0; -#X connect 15 1 9 0; -#X connect 16 0 18 0; -#X connect 16 1 17 0; -#X connect 17 0 19 0; -#X connect 18 0 19 0; -#X connect 20 2 10 0; -#X connect 21 0 30 0; -#X connect 21 0 32 0; -#X connect 22 0 23 0; -#X connect 22 1 29 1; -#X connect 23 0 24 0; -#X connect 23 0 25 0; -#X connect 24 0 23 1; -#X connect 25 0 26 0; -#X connect 25 1 26 1; -#X connect 26 0 27 0; -#X connect 27 0 28 0; -#X connect 27 1 28 1; -#X connect 28 0 29 0; -#X connect 30 0 33 0; -#X connect 32 0 29 0; -#X connect 33 2 22 0; -#X connect 34 0 41 0; -#X connect 34 1 39 0; -#X connect 35 0 3 0; -#X connect 35 1 37 0; -#X connect 36 0 7 0; -#X connect 38 0 36 2; -#X connect 39 0 16 0; -#X connect 40 0 36 0; -#X connect 40 1 7 1; -#X connect 41 0 44 0; -#X connect 41 0 47 0; -#X connect 42 0 45 0; -#X connect 44 0 46 0; -#X connect 44 1 45 1; -#X connect 45 0 48 0; -#X connect 46 0 42 0; -#X connect 47 0 35 0; -#X connect 48 0 43 0; -#X connect 49 0 50 0; -#X connect 49 1 34 0; -#X connect 50 0 34 0; -#X restore 406 130 pd kaiser; -#X connect 0 0 8 0; -#X connect 8 0 1 0; -#X connect 8 1 2 0; -#X connect 8 2 3 0; -#X connect 8 3 5 0; -#X connect 8 4 4 0; -#X connect 8 5 6 0; -#X connect 8 6 7 0; -#X connect 8 7 10 0; -#X connect 8 8 9 0; -#X restore 269 100 pd apply; -#N canvas 445 200 495 313 norm 0; -#X obj 134 144 cyclone/uzi 1 0; -#X obj 107 96 v ch_\$0; -#X obj 356 148 r \$0-name; -#X obj 107 42 inlet; -#X obj 107 68 trigger bang float; -#X obj 221 174 pack float float symbol; -#X msg 221 198 \; \$1-\$3 normalize \$2; -#X obj 107 120 sel 1; -#X obj 140 178 r \$0-name; -#X obj 107 204 symbol; -#X obj 107 241 pack s f; -#X msg 108 269 \; \$1 normalize \$2; -#X connect 0 2 5 0; -#X connect 1 0 7 0; -#X connect 2 0 5 2; -#X connect 3 0 4 0; -#X connect 4 0 1 0; -#X connect 4 1 5 1; -#X connect 4 1 10 1; -#X connect 5 0 6 0; -#X connect 7 0 9 0; -#X connect 7 1 0 0; -#X connect 8 0 9 1; -#X connect 9 0 10 0; -#X connect 10 0 11 0; -#X restore 473 128 pd norm; -#N canvas 239 23 768 460 resize 0; -#X obj 431 165 s \$0-size; -#X obj 217 114 cyclone/mstosamps~; -#X obj 217 78 inlet; -#X obj 345 82 inlet; -#X obj 338 253 cyclone/uzi 1 0; -#X obj 307 205 v ch_\$0; -#X obj 598 237 r \$0-name; -#X obj 463 263 pack float float symbol; -#X obj 345 154 t b f; -#X obj 308 228 sel 1; -#X obj 345 279 r \$0-name; -#X obj 321 329 pack s f; -#X obj 296 300 symbol; -#X msg 463 287 \; \$1-\$3 resize \$2; -#X msg 321 357 \; \$1 resize \$2; -#X connect 1 1 8 0; -#X connect 2 0 1 0; -#X connect 3 0 8 0; -#X connect 4 2 7 0; -#X connect 5 0 9 0; -#X connect 6 0 7 2; -#X connect 7 0 13 0; -#X connect 8 0 5 0; -#X connect 8 1 7 1; -#X connect 8 1 11 1; -#X connect 8 1 0 0; -#X connect 9 0 12 0; -#X connect 9 1 4 0; -#X connect 10 0 12 1; -#X connect 11 0 14 0; -#X connect 12 0 11 0; -#X restore 347 100 pd resize; -#N canvas 245 23 711 512 crop 0; -#X obj 269 30 inlet; -#X obj 108 213 unpack; -#X obj 141 240 cyclone/mstosamps~; -#X obj 47 275 cyclone/mstosamps~; -#X obj 181 356 array get; -#X obj 246 315 r \$0-name; -#X obj 195 388 array set; -#X obj 214 423 array size; -#X obj 54 313 trigger float float; -#X obj 74 365 expr $f2 - $f1; -#X obj 373 178 cyclone/uzi 1 0; -#X obj 269 100 v ch_\$0; -#X obj 269 124 sel 1; -#X obj 323 218 list; -#X obj 510 218 pack float symbol; -#X obj 609 194 r \$0-name; -#X msg 510 242 symbol \$1-\$2; -#X obj 269 71 trigger bang list; -#X obj 380 271 cyclone/mstosamps~; -#X obj 323 306 cyclone/mstosamps~; -#X obj 420 387 array get; -#X obj 434 419 array set; -#X obj 453 454 array size; -#X obj 313 396 expr $f2 - $f1; -#X obj 269 159 list; -#X obj 323 244 unpack f f; -#X obj 313 344 trigger f f; -#X obj 262 478 s \$0-size; -#X connect 0 0 17 0; -#X connect 1 0 3 0; -#X connect 1 1 2 0; -#X connect 2 1 4 1; -#X connect 2 1 9 1; -#X connect 3 1 8 0; -#X connect 4 0 6 0; -#X connect 5 0 4 2; -#X connect 5 0 6 2; -#X connect 5 0 7 1; -#X connect 8 0 9 0; -#X connect 8 1 4 0; -#X connect 9 0 7 0; -#X connect 9 0 27 0; -#X connect 10 0 13 0; -#X connect 10 2 14 0; -#X connect 11 0 12 0; -#X connect 12 0 24 0; -#X connect 12 1 10 0; -#X connect 13 0 25 0; -#X connect 14 0 16 0; -#X connect 15 0 14 1; -#X connect 16 0 20 2; -#X connect 16 0 21 2; -#X connect 16 0 22 1; -#X connect 17 0 11 0; -#X connect 17 1 13 1; -#X connect 17 1 24 1; -#X connect 18 1 20 1; -#X connect 18 1 23 1; -#X connect 19 1 26 0; -#X connect 20 0 21 0; -#X connect 23 0 22 0; -#X connect 23 0 27 0; -#X connect 24 0 1 0; -#X connect 25 0 19 0; -#X connect 25 1 18 0; -#X connect 26 0 23 0; -#X connect 26 1 20 0; -#X restore 514 101 pd crop; -#N canvas 709 338 322 283 soundfiler 0; -#X obj 192 102 list prepend; -#X obj 192 129 list; -#X obj 65 104 list append; -#X obj 65 134 list trim; -#X obj 166 168 r \$0-resize; -#X obj 65 168 soundfiler; -#X msg 166 200 1; -#X obj 65 203 spigot; -#X obj 65 236 s \$0-size; -#X obj 192 43 inlet; -#X obj 65 42 inlet; -#X msg 192 74 \$1-\$2; -#X obj 128 43 inlet; -#X msg 128 71 \$2; -#X connect 0 0 1 0; -#X connect 1 0 0 1; -#X connect 1 0 2 1; -#X connect 2 0 3 0; -#X connect 3 0 5 0; -#X connect 4 0 6 0; -#X connect 5 0 7 0; -#X connect 6 0 7 1; -#X connect 7 0 8 0; -#X connect 9 0 11 0; -#X connect 10 0 2 0; -#X connect 11 0 0 0; -#X connect 12 0 13 0; -#X connect 13 0 2 1; -#X restore 581 142 pd soundfiler; -#N canvas 836 309 267 305 load-args 0; -#N canvas 148 313 507 387 channels 0; -#X obj 123 180 v ch_\$0; -#X obj 210 223 r \$0-name; -#X obj 239 251 r \$0-size; -#X obj 95 220 cyclone/uzi 1 0; -#X obj 182 293 pack f s f; -#X obj 182 336 outlet; -#X obj 68 184 sel 1; -#X obj 68 280 pack f s f; -#X obj 68 336 outlet; -#X obj 123 27 inlet; -#X obj 168 27 inlet; -#X obj 291 26 inlet; -#X obj 291 59 list append \$4; -#N canvas 798 200 642 513 attributes 0; -#X obj 317 415 s \$0-size; -#X obj 317 390 max 1; -#X obj 212 341 cyclone/mstosamps~; -#X obj 161 341 t b b; -#X msg 188 365 1; -#X obj 161 417 s \$0-resize; -#X obj 161 315 select -1; -#X msg 390 387 [buffer~]'s size not defined; -#X obj 276 269 s \$0-size; -#X obj 276 233 max 1; -#X obj 56 49 inlet; -#X obj 161 166 select @size @samps; -#X obj 161 134 list append \$4; -#X obj 276 205 list append \$5; -#X obj 161 233 list append \$5; -#X obj 56 136 list append \$3; -#X obj 56 104 trigger bang bang; -#X obj 56 462 outlet; -#X obj 390 416 print Warning; -#X obj 390 362 select 1; -#X obj 390 340 <= 0; -#X connect 1 0 0 0; -#X connect 2 1 1 0; -#X connect 2 1 20 0; -#X connect 3 0 5 0; -#X connect 3 1 4 0; -#X connect 4 0 0 0; -#X connect 6 0 3 0; -#X connect 6 1 2 0; -#X connect 7 0 18 0; -#X connect 9 0 8 0; -#X connect 10 0 16 0; -#X connect 11 0 14 0; -#X connect 11 1 13 0; -#X connect 12 0 11 0; -#X connect 13 0 9 0; -#X connect 14 0 6 0; -#X connect 15 0 17 0; -#X connect 16 0 15 0; -#X connect 16 1 12 0; -#X connect 19 0 7 0; -#X connect 20 0 19 0; -#X restore 168 68 pd attributes; -#X obj 123 119 max 1; -#X obj 123 146 min 64; -#X obj 291 115 == 0; -#X obj 291 185 v ch_\$0; -#X obj 291 88 trigger float float; -#X obj 291 139 select 1 0; -#X obj 374 173 float; -#X connect 1 0 4 1; -#X connect 1 0 7 1; -#X connect 2 0 4 2; -#X connect 2 0 7 2; -#X connect 3 2 4 0; -#X connect 4 0 5 0; -#X connect 6 0 7 0; -#X connect 6 1 3 0; -#X connect 7 0 8 0; -#X connect 9 0 14 0; -#X connect 10 0 13 0; -#X connect 11 0 12 0; -#X connect 12 0 18 0; -#X connect 13 0 14 0; -#X connect 14 0 15 0; -#X connect 15 0 0 0; -#X connect 15 0 6 0; -#X connect 16 0 19 0; -#X connect 17 0 14 0; -#X connect 18 0 16 0; -#X connect 18 1 20 1; -#X connect 19 0 17 0; -#X connect 19 1 20 0; -#X connect 20 0 14 0; -#X restore 72 196 pd channels; -#N canvas 454 149 739 500 2nd_arg 0; -#X obj 209 187 t b f; -#X obj 462 358 s \$0-size; -#X obj 462 333 max 1; -#X obj 357 284 cyclone/mstosamps~; -#X obj 306 284 t b b; -#X msg 333 308 1; -#X obj 306 360 s \$0-resize; -#X obj 306 258 select -1; -#X obj 39 66 list append \$2; -#X obj 39 98 select @size @samps; -#X obj 94 135 list append \$3; -#X obj 39 165 list append \$3; -#X obj 209 102 b; -#X obj 209 158 route float symbol; -#X obj 209 187 t b f; -#X obj 215 264 s \$0-file; -#X obj 209 129 list append \$2; -#X obj 121 285 s \$0-size; -#X obj 94 195 t b f; -#X obj 39 195 t b f; -#X obj 39 26 inlet; -#X obj 94 436 outlet; -#X obj 209 436 outlet; -#X obj 121 250 max 1; -#X obj 261 438 outlet; -#X obj 261 186 t s b s; -#X obj 436 187 soundfiler; -#X msg 493 211 \$3; -#X obj 436 122 t s b; -#X obj 493 239 v ch_\$0; -#X obj 501 158 v \$0-init-size; -#X msg 501 137 -1; -#X msg 436 156 read \$1; -#X msg 550 341 [buffer~]'s size not defined; -#X obj 550 370 print Warning; -#X obj 550 316 select 1; -#X obj 550 294 <= 0; -#X connect 0 0 22 0; -#X connect 0 1 7 0; -#X connect 2 0 1 0; -#X connect 3 1 2 0; -#X connect 3 1 36 0; -#X connect 4 0 6 0; -#X connect 4 1 5 0; -#X connect 5 0 1 0; -#X connect 7 0 4 0; -#X connect 7 1 3 0; -#X connect 8 0 9 0; -#X connect 9 0 11 0; -#X connect 9 1 10 0; -#X connect 9 2 12 0; -#X connect 10 0 18 0; -#X connect 11 0 19 0; -#X connect 12 0 16 0; -#X connect 13 0 0 0; -#X connect 13 1 25 0; -#X connect 16 0 13 0; -#X connect 18 0 21 0; -#X connect 18 1 23 0; -#X connect 19 0 21 0; -#X connect 19 1 7 0; -#X connect 20 0 8 0; -#X connect 23 0 17 0; -#X connect 25 0 15 0; -#X connect 25 1 24 0; -#X connect 25 2 28 0; -#X connect 26 1 27 0; -#X connect 27 0 29 0; -#X connect 28 0 32 0; -#X connect 28 1 31 0; -#X connect 31 0 30 0; -#X connect 32 0 26 0; -#X connect 33 0 34 0; -#X connect 35 0 33 0; -#X connect 36 0 35 0; -#X restore 75 109 pd 2nd_arg; -#N canvas 668 110 822 542 3rd_arg_(size) 0; -#X obj 363 291 t b f; -#X obj 546 432 s \$0-size; -#X obj 546 407 max 1; -#X obj 441 358 cyclone/mstosamps~; -#X obj 390 358 t b b; -#X msg 417 382 1; -#X obj 390 434 s \$0-resize; -#X obj 390 332 select -1; -#X obj 363 291 t b f; -#X obj 578 343 select 0; -#X msg 618 403 [buffer~]'s size not defined; -#X obj 269 347 s \$0-size; -#X obj 242 217 t b f; -#X obj 242 478 outlet; -#X obj 269 274 max 1; -#X obj 187 88 list append \$3; -#X obj 242 157 list append \$4; -#X obj 187 187 list append \$4; -#X obj 187 53 inlet; -#X obj 187 286 t b f; -#X obj 187 286 t b f; -#X obj 363 478 outlet; -#X obj 187 120 select @size @samps; -#X obj 363 146 route float; -#X obj 618 432 print Warning; -#X obj 363 205 sel 0; -#X obj 392 250 v \$0-init-size; -#X connect 0 0 21 0; -#X connect 0 1 7 0; -#X connect 2 0 1 0; -#X connect 3 1 9 0; -#X connect 3 1 2 0; -#X connect 4 0 6 0; -#X connect 4 1 5 0; -#X connect 5 0 1 0; -#X connect 7 0 4 0; -#X connect 7 1 3 0; -#X connect 9 0 10 0; -#X connect 9 0 2 0; -#X connect 9 1 2 0; -#X connect 10 0 24 0; -#X connect 12 0 13 0; -#X connect 12 1 14 0; -#X connect 14 0 11 0; -#X connect 15 0 22 0; -#X connect 16 0 12 0; -#X connect 17 0 19 0; -#X connect 18 0 15 0; -#X connect 19 0 13 0; -#X connect 19 1 7 0; -#X connect 22 0 17 0; -#X connect 22 1 16 0; -#X connect 22 2 23 0; -#X connect 23 0 25 0; -#X connect 25 0 26 0; -#X connect 25 1 0 0; -#X connect 26 0 0 0; -#X restore 132 137 pd 3rd_arg_(size); -#X obj 72 238 outlet; -#X obj 135 237 outlet; -#N canvas 469 182 463 361 buffer_arg 0; -#X obj 35 85 list append \$1; -#X obj 80 241 print Warning:; -#X msg 80 189 [buffer~] needs a buffer name as the 1st argument, f -25; -#X obj 253 303 outlet; -#X obj 352 224 symbol \$1; -#X obj 352 251 s \$0-name; -#X obj 253 190 trigger bang bang; -#X obj 35 114 route float; -#X obj 35 142 select 0; -#X obj 98 144 select @samps @size; -#X obj 35 53 inlet; -#X connect 0 0 7 0; -#X connect 2 0 1 0; -#X connect 4 0 5 0; -#X connect 6 0 3 0; -#X connect 6 1 4 0; -#X connect 7 0 8 0; -#X connect 7 1 9 0; -#X connect 8 1 2 0; -#X connect 9 0 2 0; -#X connect 9 1 2 0; -#X connect 9 2 6 0; -#X connect 10 0 0 0; -#X restore 75 69 pd buffer_arg; -#N canvas 577 23 425 361 init 0; -#X obj 40 28 loadbang; -#X obj 138 100 samplerate~; -#X obj 138 129 s \$0-sr; -#X obj 232 139 send pd-\$0-buffers; -#X msg 232 91 clear; -#X obj 40 307 outlet; -#X text 276 83 just in case the abstraction gets corrupted, f 17; -#X obj 104 198 pdcontrol; -#N canvas 241 23 474 169 \$0-declare 0; -#X obj 50 50 declare -path /Users/porres/Desktop/git/pd-cyclone/cyclone_objects/abstractions -; -#X restore 243 178 pd \$0-declare; -#X obj 104 251 send pd-\$0-declare; -#X msg 104 224 clear \, obj 50 50 declare -path \$1; -#X obj 40 59 trigger bang bang; -#X msg 104 169 dir 1; -#X connect 0 0 11 0; -#X connect 1 0 2 0; -#X connect 4 0 3 0; -#X connect 7 0 10 0; -#X connect 10 0 9 0; -#X connect 11 0 5 0; -#X connect 11 1 1 0; -#X connect 11 1 12 0; -#X connect 11 1 4 0; -#X connect 12 0 7 0; -#X restore 75 41 pd init; -#X connect 0 0 3 0; -#X connect 0 1 4 0; -#X connect 1 0 0 0; -#X connect 1 1 0 1; -#X connect 1 2 2 0; -#X connect 2 0 0 0; -#X connect 2 1 0 2; -#X connect 5 0 1 0; -#X connect 6 0 5 0; -#X restore 675 101 pd load-args; -#N canvas 429 157 876 624 read/write 0; -#X obj 115 206 symbol; -#X obj 40 115 route bang; -#X obj 12 433 list prepend read; -#X obj 40 146 openpanel; -#X obj 323 248 cyclone/fromsymbol @separator ., f 18; -#X obj 135 164 r \$0-file; -#X obj 236 204 list; -#X obj 262 337 t l l, f 6; -#X msg 295 371 \$2; -#X msg 262 372 \$1; -#X obj 236 158 cyclone/fromsymbol @separator ., f 18; -#X obj 191 88 route bang, f 12; -#X obj 236 288 list length; -#X obj 236 261 t l l; -#X obj 202 290 > 1; -#X obj 262 315 list; -#X obj 203 313 sel 0 1; -#X obj 225 344 list; -#X obj 191 111 savepanel; -#X obj 482 565 outlet; -#X obj 40 23 inlet; -#X obj 149 425 r \$0-resize; -#X msg 323 310 \$2; -#X obj 323 282 list; -#X obj 447 246 route wave aiff, f 9; -#X obj 546 235 route bang, f 12; -#X obj 467 426 savepanel; -#X obj 615 291 t s b; -#X obj 546 259 t b b; -#X obj 656 248 route bang; -#X obj 713 317 t s b; -#X obj 656 292 t b b; -#X msg 741 447 -wave; -#X msg 788 445 -aiff; -#X obj 669 449 r \$0-bytes; -#X obj 40 51 route read readagain write filetype writewave writeaiff -format sr, f 115; -#N canvas 520 43 450 300 bytes 0; -#X obj 115 40 inlet; -#X msg 175 152 2; -#X msg 206 151 3; -#X msg 240 151 4; -#X obj 101 103 sel 16 24; -#X obj 115 73 route float int16 int24 float32; -#X obj 206 185 s \$0-bytes; -#X connect 0 0 5 0; -#X connect 1 0 6 0; -#X connect 2 0 6 0; -#X connect 3 0 6 0; -#X connect 4 0 1 0; -#X connect 4 1 2 0; -#X connect 5 0 4 0; -#X connect 5 1 1 0; -#X connect 5 2 2 0; -#X connect 5 3 3 0; -#X restore 554 80 pd bytes; -#X obj 641 82 s \$0-sr; -#X obj 551 495 cyclone/pak write -rate 0 -bytes 2 -aiff; -#X obj 615 449 r \$0-sr; -#X obj 482 527 list prepend; -#X msg 149 451 read -resize -maxsize 1e+18; -#X obj 323 339 route wav aiff aif caf; -#X msg 831 445 -caf; -#X connect 0 0 2 0; -#X connect 0 0 4 0; -#X connect 1 0 3 0; -#X connect 1 1 0 0; -#X connect 2 0 19 0; -#X connect 3 0 0 0; -#X connect 4 0 23 0; -#X connect 5 0 0 0; -#X connect 6 0 13 0; -#X connect 7 0 9 0; -#X connect 7 1 8 0; -#X connect 8 0 42 0; -#X connect 9 0 40 0; -#X connect 10 0 6 0; -#X connect 11 0 18 0; -#X connect 11 1 10 0; -#X connect 12 0 14 0; -#X connect 13 0 12 0; -#X connect 13 1 15 1; -#X connect 13 1 17 1; -#X connect 14 0 16 0; -#X connect 15 0 7 0; -#X connect 16 0 17 0; -#X connect 16 1 15 0; -#X connect 17 0 9 0; -#X connect 18 0 10 0; -#X connect 20 0 35 0; -#X connect 21 0 41 0; -#X connect 22 0 42 0; -#X connect 23 0 22 0; -#X connect 24 0 32 0; -#X connect 24 1 33 0; -#X connect 25 0 28 0; -#X connect 25 1 27 0; -#X connect 26 0 40 0; -#X connect 27 0 40 0; -#X connect 27 1 32 0; -#X connect 28 0 26 0; -#X connect 28 1 32 0; -#X connect 29 0 31 0; -#X connect 29 1 30 0; -#X connect 30 0 40 0; -#X connect 30 1 33 0; -#X connect 31 0 26 0; -#X connect 31 1 33 0; -#X connect 32 0 38 5; -#X connect 33 0 38 5; -#X connect 34 0 38 4; -#X connect 35 0 1 0; -#X connect 35 1 0 0; -#X connect 35 2 11 0; -#X connect 35 3 24 0; -#X connect 35 4 25 0; -#X connect 35 5 29 0; -#X connect 35 6 36 0; -#X connect 35 7 37 0; -#X connect 38 0 40 1; -#X connect 39 0 38 2; -#X connect 40 0 19 0; -#X connect 41 0 2 1; -#X connect 42 0 32 0; -#X connect 42 1 33 0; -#X connect 42 2 33 0; -#X connect 42 3 43 0; -#X connect 43 0 38 5; -#X restore 581 101 pd read/write; -#N canvas 147 315 743 423 init-buffers 0; -#X obj 340 246 send pd-\$0-buffers; -#X msg 340 85 \$1; -#X obj 313 61 t l l; -#X obj 313 31 inlet; -#X obj 438 123 - 1; -#X obj 389 98 + 20; -#X obj 389 120 t f f; -#X obj 389 75 * 100; -#X obj 340 149 pack float float float \$0; -#X obj 235 215 list append \$0; -#X obj 340 107 t f f; -#X msg 340 178 obj 6 \$2 cnv 15 448 80 empty empty empty 3 10 2 14 --233017 -66577 0 \, obj 5 \$3 pd ch\$1_\$4; -#X msg 276 276 \; pd-ch\$1_\$4 array \$1-\$2 \$3 float 2 \, coords -0 1 \$3 -1 450 82 2 0 0 \, vis 0; -#X obj 152 33 inlet; -#X obj 74 268 list append \$0; -#X obj 153 74 t l l; -#X msg 115 329 \; pd-ch\$1_\$4 array \$2 \$3 float 2 \, coords 0 1 -\$3 -1 450 82 2 0 0 \, vis 0; -#X connect 1 0 10 0; -#X connect 2 0 9 0; -#X connect 2 1 1 0; -#X connect 3 0 2 0; -#X connect 4 0 8 2; -#X connect 5 0 6 0; -#X connect 6 0 8 1; -#X connect 6 1 4 0; -#X connect 7 0 5 0; -#X connect 8 0 11 0; -#X connect 9 0 12 0; -#X connect 10 0 8 0; -#X connect 10 1 7 0; -#X connect 11 0 0 0; -#X connect 12 0 0 0; -#X connect 13 0 15 0; -#X connect 14 0 16 0; -#X connect 15 0 14 0; -#X connect 15 1 1 0; -#X connect 16 0 0 0; -#X restore 675 142 pd init-buffers; -#X obj 24 69 route clear name set open wclose fill apply setsize size -sizeinsamps samps normalize crop, f 89; -#X text 319 185 porres \, barber \, 2017-2018 \; for cyclone; -#X connect 0 0 14 0; -#X connect 11 0 10 1; -#X connect 11 0 13 0; -#X connect 11 1 10 2; -#X connect 11 1 13 1; -#X connect 12 0 10 0; -#X connect 14 0 3 0; -#X connect 14 1 1 0; -#X connect 14 2 1 0; -#X connect 14 3 5 0; -#X connect 14 4 5 1; -#X connect 14 5 4 0; -#X connect 14 6 6 0; -#X connect 14 7 8 0; -#X connect 14 8 8 0; -#X connect 14 9 8 1; -#X connect 14 10 8 1; -#X connect 14 11 7 0; -#X connect 14 12 9 0; -#X connect 14 13 12 0; diff --git a/Libraries/cyclone/cyclone_objects/abstractions/number~.pd b/Libraries/cyclone/cyclone_objects/abstractions/number~.pd deleted file mode 100644 index f0e2f3df0b..0000000000 --- a/Libraries/cyclone/cyclone_objects/abstractions/number~.pd +++ /dev/null @@ -1,437 +0,0 @@ -#N canvas 591 145 727 453 10; -#X obj 243 296 line~; -#X obj 243 399 outlet~; -#X obj 539 17 inlet; -#X obj 315 267 f; -#X obj 243 158 spigot; -#X obj 315 363 s \$0-set-n; -#X obj 351 303 spigot; -#X obj 422 400 outlet; -#X obj 243 267 pack f \$2; -#X obj 539 76 max 0; -#X obj 539 99 change -1; -#X obj 243 234 change; -#X obj 276 126 t b f; -#X msg 384 267 1; -#X msg 350 329 set \$1; -#X msg 354 267 0; -#X obj 315 126 t b f b; -#X obj 276 78 r \$0-tgl; -#X obj 117 68 r \$0-set-n; -#X text 63 265 before saving; -#X obj 61 324 s \$0-receive-nbx; -#X obj 422 267 snapshot~; -#X obj 422 17 inlet~ fwd; -#X obj 276 100 moses 1; -#N canvas 279 504 824 226 route 0; -#X obj 71 34 inlet; -#X obj 148 109 unpack; -#X obj 225 145 s \$0-ramp; -#X msg 71 109 set \$1; -#X obj 148 178 s \$0-set-n; -#X obj 533 156 s \$0-tgl-set; -#X obj 302 172 s \$0-interval; -#X obj 302 143 max 1; -#X obj 379 133 s \$0-min; -#X obj 456 122 s \$0-max; -#N canvas 180 29 390 311 tohex 0; -#X obj 227 98 makefilename %02x; -#X obj 155 124 makefilename %02x; -#X obj 82 161 makefilename %02x; -#X msg 82 220 symbol #\$1\$2\$3; -#X obj 82 191 pack symbol symbol symbol; -#X obj 120 70 unpack f f f; -#X obj 120 26 inlet; -#X obj 82 258 outlet; -#X connect 0 0 4 2; -#X connect 1 0 4 1; -#X connect 2 0 4 0; -#X connect 3 0 7 0; -#X connect 4 0 3 0; -#X connect 5 0 2 0; -#X connect 5 1 1 0; -#X connect 5 2 0 0; -#X connect 6 0 5 0; -#X restore 610 102 pd tohex; -#N canvas 180 29 390 311 tohex 0; -#X obj 227 98 makefilename %02x; -#X obj 155 124 makefilename %02x; -#X obj 82 161 makefilename %02x; -#X msg 82 220 symbol #\$1\$2\$3; -#X obj 82 191 pack symbol symbol symbol; -#X obj 120 70 unpack f f f; -#X obj 120 26 inlet; -#X obj 82 258 outlet; -#X connect 0 0 4 2; -#X connect 1 0 4 1; -#X connect 2 0 4 0; -#X connect 3 0 7 0; -#X connect 4 0 3 0; -#X connect 5 0 2 0; -#X connect 5 1 1 0; -#X connect 5 2 0 0; -#X connect 6 0 5 0; -#X restore 687 102 pd tohex; -#X obj 610 126 s \$0-bg; -#X obj 687 126 s \$0-fg; -#X obj 71 72 route set list ft1 interval minimum maximum bang bgcolor textcolor, f 116; -#X connect 0 0 14 0; -#X connect 1 0 4 0; -#X connect 1 1 2 0; -#X connect 3 0 4 0; -#X connect 7 0 6 0; -#X connect 10 0 12 0; -#X connect 11 0 13 0; -#X connect 14 0 3 0; -#X connect 14 1 1 0; -#X connect 14 2 2 0; -#X connect 14 3 7 0; -#X connect 14 4 8 0; -#X connect 14 5 9 0; -#X connect 14 6 5 0; -#X connect 14 7 10 0; -#X connect 14 8 11 0; -#X restore 479 48 pd route; -#X obj 243 53 r \$0-set; -#X obj 551 46 r \$0-ramp; -#N canvas 729 154 471 454 init 0; -#X obj 102 89 savestate; -#X obj 121 161 list split 1; -#X obj 155 183 list split 1; -#X obj 189 205 list split 1; -#X obj 223 231 list split 2, f 27; -#X obj 121 373 s \$0-tgl-set; -#X obj 102 411 s \$0-start; -#X obj 102 138 t b l l; -#X obj 180 259 max 1; -#X obj 149 321 s \$0-ramp; -#X obj 276 86 r \$0-receive-nbx; -#X obj 257 62 r \$0-interval; -#X obj 238 42 r \$0-ramp; -#X obj 276 108 route range color; -#X obj 219 22 r \$0-tgl; -#X obj 219 132 cyclone/pak 0 0 100 0 0 #2a3434 #ffffff #b6fefd, f 23; -#X obj 180 283 s \$0-interval; -#X obj 153 112 list; -#N canvas 502 160 486 274 args 0; -#X obj 55 103 pdcontrol; -#X msg 55 77 args; -#X obj 55 51 loadbang; -#X obj 78 128 spigot 1; -#X msg 123 103 0; -#X obj 123 19 inlet; -#X obj 78 202 outlet; -#N canvas 439 47 991 525 list 0; -#N canvas 377 245 403 531 break 0; -#X obj 82 15 inlet; -#X obj 82 48 list; -#X obj 82 72 t b l, f 8; -#X obj 82 109 until; -#X obj 106 151 list; -#X obj 106 175 list split 1, f 22; -#X obj 106 207 route float symbol; -#X obj 105 323 list prepend; -#X obj 105 347 t l; -#X obj 235 409 list; -#X obj 235 433 list trim; -#X obj 235 477 outlet; -#X obj 158 232 t s s; -#X obj 256 266 list fromsymbol; -#X obj 256 295 list split 1; -#X obj 256 324 sel 64; -#X obj 256 353 t b b; -#X connect 0 0 1 0; -#X connect 1 0 2 0; -#X connect 2 0 3 0; -#X connect 2 1 4 1; -#X connect 3 0 4 0; -#X connect 4 0 5 0; -#X connect 5 0 6 0; -#X connect 5 1 4 1; -#X connect 5 2 3 1; -#X connect 5 2 7 1; -#X connect 5 2 9 0; -#X connect 6 0 7 0; -#X connect 6 1 12 0; -#X connect 7 0 8 0; -#X connect 8 0 9 1; -#X connect 8 0 7 1; -#X connect 9 0 10 0; -#X connect 10 0 11 0; -#X connect 12 0 7 0; -#X connect 12 1 13 0; -#X connect 13 0 14 0; -#X connect 14 0 15 0; -#X connect 15 0 16 0; -#X connect 15 0 7 1; -#X connect 16 0 9 1; -#X connect 16 1 9 0; -#X restore 129 103 pd break; -#X obj 233 328 != 0; -#X obj 224 262 unpack; -#N canvas 180 29 390 311 tohex 0; -#X obj 227 98 makefilename %02x; -#X obj 155 124 makefilename %02x; -#X obj 82 161 makefilename %02x; -#X msg 82 220 symbol #\$1\$2\$3; -#X obj 82 191 pack symbol symbol symbol; -#X obj 120 70 unpack f f f; -#X obj 120 26 inlet; -#X obj 82 258 outlet; -#X connect 0 0 4 2; -#X connect 1 0 4 1; -#X connect 2 0 4 0; -#X connect 3 0 7 0; -#X connect 4 0 3 0; -#X connect 5 0 2 0; -#X connect 5 1 1 0; -#X connect 5 2 0 0; -#X connect 6 0 5 0; -#X restore 437 260 pd tohex; -#N canvas 180 29 390 311 tohex 0; -#X obj 227 98 makefilename %02x; -#X obj 155 124 makefilename %02x; -#X obj 82 161 makefilename %02x; -#X msg 82 220 symbol #\$1\$2\$3; -#X obj 82 191 pack symbol symbol symbol; -#X obj 120 70 unpack f f f; -#X obj 120 26 inlet; -#X obj 82 258 outlet; -#X connect 0 0 4 2; -#X connect 1 0 4 1; -#X connect 2 0 4 0; -#X connect 3 0 7 0; -#X connect 4 0 3 0; -#X connect 5 0 2 0; -#X connect 5 1 1 0; -#X connect 5 2 0 0; -#X connect 6 0 5 0; -#X restore 497 260 pd tohex; -#X obj 129 124 route bang; -#X obj 186 148 route @monitormode @sigoutmode; -#X obj 186 183 == 0; -#X obj 273 223 route list float @ft1 @interval @minimum @maximum @bgcolor @textcolor, f 37; -#X obj 743 265 list append #2a3434 #ffffff #b6fefd; -#X obj 743 290 unpack s s s; -#X obj 573 264 expr -pow(1e+19 \, 1e+19) \; pow(1e+19 \, 1e+19); -#X obj 35 39 inlet; -#X obj 233 452 outlet; -#X obj 233 386 pack 0 0 100 float float symbol symbol symbol, f 71; -#X obj 35 67 trigger bang list bang, f 49; -#X connect 0 0 5 0; -#X connect 1 0 14 0; -#X connect 2 0 1 0; -#X connect 2 1 14 1; -#X connect 3 0 14 5; -#X connect 4 0 14 6; -#X connect 5 0 14 0; -#X connect 5 1 6 0; -#X connect 6 0 7 0; -#X connect 6 1 8 0; -#X connect 6 2 8 0; -#X connect 7 0 8 0; -#X connect 8 0 2 0; -#X connect 8 1 1 0; -#X connect 8 2 14 1; -#X connect 8 3 14 2; -#X connect 8 4 14 3; -#X connect 8 5 14 4; -#X connect 8 6 3 0; -#X connect 8 7 4 0; -#X connect 9 0 10 0; -#X connect 10 0 14 5; -#X connect 10 1 14 6; -#X connect 10 2 14 7; -#X connect 11 0 14 3; -#X connect 11 1 14 4; -#X connect 12 0 15 0; -#X connect 14 0 13 0; -#X connect 15 0 14 0; -#X connect 15 1 0 0; -#X connect 15 2 11 0; -#X connect 15 2 9 0; -#X restore 78 163 pd list; -#X obj 184 117 print warning; -#X msg 184 85 [cyclone/number~] has been deprecated; -#X connect 0 0 3 0; -#X connect 1 0 0 0; -#X connect 2 0 1 0; -#X connect 2 0 9 0; -#X connect 3 0 7 0; -#X connect 4 0 3 1; -#X connect 5 0 4 0; -#X connect 7 0 6 0; -#X connect 9 0 8 0; -#X restore 39 103 pd args; -#N canvas 568 163 264 361 color 0; -#X obj 51 37 inlet; -#X obj 51 74 list split 3; -#X msg 93 173 color \$1 \$2 \$3; -#X obj 93 278 s \$0-receive-nbx; -#X obj 123 197 s \$0-cnv-a; -#X obj 117 216 s \$0-cnv-b; -#X obj 112 235 s \$0-cnv-c; -#X obj 105 254 s \$0-cnv-d; -#X obj 93 152 cyclone/pak s s s; -#X obj 93 101 r \$0-bg; -#X obj 142 127 r \$0-fg; -#X connect 0 0 1 0; -#X connect 1 0 8 0; -#X connect 2 0 3 0; -#X connect 2 0 7 0; -#X connect 2 0 6 0; -#X connect 2 0 5 0; -#X connect 2 0 4 0; -#X connect 8 0 2 0; -#X connect 9 0 8 0; -#X connect 10 0 8 1; -#X restore 302 259 pd color; -#N canvas 308 72 722 562 range 0; -#X msg 320 397 range \$1 \$2; -#X obj 320 420 s \$0-receive-nbx; -#X obj 340 320 r \$0-min; -#X obj 463 293 r \$0-max; -#X obj 78 175 expr $f1 == $f2; -#X obj 463 324 t b f; -#X obj 320 374 pack float float; -#X obj 456 257 expr pow(1e+19 \, 1e+19); -#X obj 92 319 expr -pow(1e+19 \, 1e+19); -#X obj 78 236 t b b; -#X obj 79 23 inlet; -#X obj 79 144 spigot 1; -#X msg 124 124 0; -#X obj 78 205 sel 1; -#X obj 393 108 route float; -#X obj 358 80 list split 1; -#X obj 79 54 t l l, f 47; -#X obj 318 108 route float; -#X obj 455 130 b; -#X obj 365 163 b; -#X connect 0 0 1 0; -#X connect 2 0 6 0; -#X connect 3 0 5 0; -#X connect 4 0 13 0; -#X connect 5 0 6 0; -#X connect 5 1 6 1; -#X connect 6 0 0 0; -#X connect 7 0 6 1; -#X connect 8 0 6 0; -#X connect 9 0 8 0; -#X connect 9 1 7 0; -#X connect 10 0 16 0; -#X connect 11 0 4 0; -#X connect 12 0 11 1; -#X connect 13 0 9 0; -#X connect 14 0 6 1; -#X connect 14 1 18 0; -#X connect 15 0 17 0; -#X connect 15 1 14 0; -#X connect 16 0 11 0; -#X connect 16 1 15 0; -#X connect 17 0 6 0; -#X connect 17 1 19 0; -#X connect 18 0 12 0; -#X connect 18 0 7 0; -#X connect 19 0 8 0; -#X connect 19 0 12 0; -#X restore 223 259 pd range; -#X obj 121 350 expr $f1 != 0; -#X connect 0 0 7 0; -#X connect 0 1 17 0; -#X connect 1 0 21 0; -#X connect 1 1 2 0; -#X connect 2 0 9 0; -#X connect 2 1 3 0; -#X connect 3 0 8 0; -#X connect 3 1 4 0; -#X connect 4 0 20 0; -#X connect 4 1 19 0; -#X connect 7 0 6 0; -#X connect 7 0 18 0; -#X connect 7 1 1 0; -#X connect 7 2 15 0; -#X connect 8 0 16 0; -#X connect 10 0 13 0; -#X connect 11 0 15 2; -#X connect 12 0 15 1; -#X connect 13 0 15 3; -#X connect 13 1 15 5; -#X connect 14 0 15 0; -#X connect 15 0 17 1; -#X connect 17 0 0 0; -#X connect 18 0 7 0; -#X connect 21 0 5 0; -#X restore 95 182 pd init; -#N canvas 752 210 423 223 gui-set 0; -#X obj 66 165 s \$0-cnv-c; -#X obj 66 85 sel 0 1; -#X msg 66 124 label ~; -#X msg 127 125 label; -#X obj 211 23 r \$0-tgl; -#X obj 211 48 sel 0 1; -#X obj 293 131 s \$0-cnv-a; -#X obj 186 144 s \$0-cnv-b; -#X msg 186 84 label; -#X msg 293 85 label |; -#X msg 230 85 label v; -#X connect 1 0 2 0; -#X connect 1 1 3 0; -#X connect 2 0 0 0; -#X connect 3 0 0 0; -#X connect 4 0 5 0; -#X connect 4 0 1 0; -#X connect 5 0 8 0; -#X connect 5 1 9 0; -#X connect 5 1 10 0; -#X connect 8 0 7 0; -#X connect 8 0 6 0; -#X connect 9 0 6 0; -#X connect 10 0 7 0; -#X restore 95 210 pd gui-set; -#X obj 460 220 r \$0-interval; -#X obj 433 244 metro; -#X obj 433 197 r \$0-start; -#X text 451 323 Part of Cyclone; -#X text 451 341 https://github.com/porres/pd-cyclone; -#X text 451 303 porres \, 2017-2020:; -#X msg 61 294 range 0 0; -#X obj 117 100 nbx 8 17 0 0 0 0 \$0-send-nbx \$0-receive-nbx empty 0 0 0 12 #2a3434 #ffffff #b6fefd 0 256; -#X obj 100 100 tgl 17 0 \$0-tgl \$0-tgl-set empty 17 7 0 10 #dcdcdc #000000 #c4fcfc 0 1; -#X obj 101 101 cnv 15 15 15 empty \$0-cnv-c ~ 2 6 0 19 #2a3434 #b6fefd 0; -#X obj 101 101 cnv 2 2 2 empty \$0-cnv-a empty 4 7 0 12 #2a3434 #b6fefd 0; -#X obj 101 101 cnv 2 2 2 empty \$0-cnv-b empty 4 8 0 12 #2a3434 #b6fefd 0; -#X obj 207 101 cnv 3 3 3 empty \$0-cnv-d empty 20 12 0 14 #2a3434 #b6fefd 0; -#X connect 0 0 1 0; -#X connect 2 0 9 0; -#X connect 3 0 5 0; -#X connect 4 0 3 1; -#X connect 4 0 11 0; -#X connect 6 0 14 0; -#X connect 8 0 0 0; -#X connect 9 0 10 0; -#X connect 10 0 8 1; -#X connect 11 0 8 0; -#X connect 12 0 13 0; -#X connect 12 1 4 1; -#X connect 13 0 6 1; -#X connect 14 0 5 0; -#X connect 15 0 6 1; -#X connect 16 0 3 0; -#X connect 16 1 4 1; -#X connect 16 2 15 0; -#X connect 17 0 23 0; -#X connect 18 0 36 0; -#X connect 21 0 6 0; -#X connect 21 0 7 0; -#X connect 22 0 21 0; -#X connect 22 1 24 0; -#X connect 23 0 12 0; -#X connect 23 1 16 0; -#X connect 25 0 4 0; -#X connect 26 0 9 0; -#X connect 29 0 30 1; -#X connect 30 0 21 0; -#X connect 31 0 30 0; -#X connect 35 0 20 0; -#X connect 36 0 4 0; -#X coords 0 -1 1 1 111 17 2 100 100; diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/acos.c b/Libraries/cyclone/cyclone_objects/binaries/audio/acos.c deleted file mode 100644 index 0920bc4065..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/acos.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - -// magic needed for manual isnan and isinf checks, which don't work -// reliably with -ffast-math compiler option -//#include "magicbit.h" - -typedef struct _acos { - t_object x_obj; - t_inlet *acos; - t_outlet *x_outlet; -} t_acos; - -void *acos_new(void); -static t_int * acos_perform(t_int *w); -static void acos_dsp(t_acos *x, t_signal **sp); - -static t_class *acos_class; - -static t_int *acos_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - {// CHECKED now there's protection against nan/inf - float f = *in++; - f = acosf(f); - *out++ = (PD_BADFLOAT(f)) ? 0 : f; - } - return (w + 4); -} - -static void acos_dsp(t_acos *x, t_signal **sp) -{ - dsp_add(acos_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -void *acos_new(void) -{ - t_acos *x = (t_acos *)pd_new(acos_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void acos_tilde_setup(void) -{ - acos_class = class_new(gensym("acos~"), (t_newmethod)acos_new, 0, - sizeof(t_acos), CLASS_DEFAULT, 0); - class_addmethod(acos_class, nullfn, gensym("signal"), 0); - class_addmethod(acos_class, (t_method) acos_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/acosh.c b/Libraries/cyclone/cyclone_objects/binaries/audio/acosh.c deleted file mode 100644 index ad1a8eefaf..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/acosh.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - -// magic needed for manual isnan and isinf checks, which don't work -// reliably with -ffast-math compiler option -//#include "magicbit.h" - -typedef struct _acosh { - t_object x_obj; - t_inlet *acosh; - t_outlet *x_outlet; -} t_acosh; - -void *acosh_new(void); -static t_int * acosh_perform(t_int *w); -static void acosh_dsp(t_acosh *x, t_signal **sp); - -static t_class *acosh_class; - -static t_int *acosh_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - {// CHECKED now there's protection against nan/inf - float f = *in++; - f = acoshf(f); - *out++ = (PD_BADFLOAT(f)) ? 0 : f; - } - return (w + 4); -} - -static void acosh_dsp(t_acosh *x, t_signal **sp) -{ - dsp_add(acosh_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -void *acosh_new(void) -{ - t_acosh *x = (t_acosh *)pd_new(acosh_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void acosh_tilde_setup(void) -{ - acosh_class = class_new(gensym("acosh~"), (t_newmethod)acosh_new, 0, - sizeof(t_acosh), CLASS_DEFAULT, 0); - class_addmethod(acosh_class, nullfn, gensym("signal"), 0); - class_addmethod(acosh_class, (t_method) acosh_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/allpass.c b/Libraries/cyclone/cyclone_objects/binaries/audio/allpass.c deleted file mode 100644 index 8b4ac681af..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/allpass.c +++ /dev/null @@ -1,319 +0,0 @@ -//almost complete rewrite since the previous version of Cyclone didn't implement it correctly (used only one delay buffer) -//- Derek Kwan 2016 - -#include -#include -#include "m_pd.h" -#include - -#define ALLPASS_STACK 48000 //stack buf size, 1 sec at 48k for good measure -#define ALLPASS_DELAY 10.0 //maximum delay -#define ALLPASS_MIND 1 //minimum delay -#define ALLPASS_MAXD 4294967294 //max delay = 2**32 - 2 - -#define ALLPASS_MINMS 0. //min delay in ms - -#define ALLPASS_DEFGAIN 0. //default gain - -static t_class *allpass_class; - -typedef struct _allpass -{ - t_object x_obj; - t_inlet *x_dellet; - t_inlet *x_alet; - t_outlet *x_outlet; - int x_sr; - //pointers to the delay bufs - double * x_ybuf; - double x_ffstack[ALLPASS_STACK]; - double * x_xbuf; - double x_fbstack[ALLPASS_STACK]; - int x_alloc; //if we are using allocated bufs - unsigned int x_sz; //actual size of each delay buffer - - t_float x_maxdel; //maximum delay in ms - unsigned int x_wh; //writehead -} t_allpass; - -static void allpass_clear(t_allpass *x){ - unsigned int i; - for(i=0; ix_sz; i++){ - x->x_xbuf[i] = 0.; - x->x_ybuf[i] = 0.; - }; - x->x_wh = 0; -} - -static void allpass_sz(t_allpass *x){ - //helper function to deal with allocation issues if needed - //ie if wanted size x->x_maxdel is bigger than stack, allocate - - //convert ms to samps - unsigned int newsz = (unsigned int)ceil((double)x->x_maxdel*0.001*(double)x->x_sr); - newsz++; //add a sample for good measure since say bufsize is 2048 and - //you want a delay of 2048 samples,.. problem! - - int alloc = x->x_alloc; - unsigned int cursz = x->x_sz; //current size - - if(newsz < 0){ - newsz = 0; - } - else if(newsz > ALLPASS_MAXD){ - newsz = ALLPASS_MAXD; - }; - if(!alloc && newsz > ALLPASS_STACK){ - x->x_xbuf = (double *)malloc(sizeof(double)*newsz); - x->x_ybuf = (double *)malloc(sizeof(double)*newsz); - x->x_alloc = 1; - x->x_sz = newsz; - } - else if(alloc && newsz > cursz){ - x->x_xbuf = (double *)realloc(x->x_xbuf, sizeof(double)*newsz); - x->x_ybuf = (double *)realloc(x->x_ybuf, sizeof(double)*newsz); - x->x_sz = newsz; - } - else if(alloc && newsz < ALLPASS_STACK){ - free(x->x_xbuf); - free(x->x_ybuf); - x->x_sz = ALLPASS_STACK; - x->x_xbuf = x->x_ffstack; - x->x_ybuf = x->x_fbstack; - x->x_alloc = 0; - }; - allpass_clear(x); -} - - - - -static double allpass_getlin(double tab[], unsigned int sz, double idx){ - //copying from my own library, linear interpolated reader - DK - double output; - unsigned int tabphase1 = (unsigned int)idx; - unsigned int tabphase2 = tabphase1 + 1; - double frac = idx - (double)tabphase1; - if(tabphase1 >= sz - 1){ - tabphase1 = sz - 1; //checking to see if index falls within bounds - output = tab[tabphase1]; - } - else if(tabphase1 < 0){ - tabphase1 = 0; - output = tab[tabphase1]; - } - else{ - double yb = tab[tabphase2]; //linear interp - double ya = tab[tabphase1]; - output = ya+((yb-ya)*frac); - - }; - return output; -} - -static double allpass_readmsdelay(t_allpass *x, double arr[], t_float ms){ - //helper func, basically take desired ms delay, convert to samp, read from arr[] - - //eventual reading head - double rh = (double)ms*((double)x->x_sr*0.001); //converting ms to samples - //bounds checking for minimum delay in samples - if(rh < ALLPASS_MIND){ - rh = ALLPASS_MIND; - }; - rh = (double)x->x_wh+((double)x->x_sz-rh); //essentially subracting from writehead to find proper position in buffer - //wrapping into length of delay buffer - while(rh >= x->x_sz){ - rh -= (double)x->x_sz; - }; - //now to read from the buffer! - double output = allpass_getlin(arr, x->x_sz, rh); - return output; - -} - - - -static t_int *allpass_perform(t_int *w) -{ - t_allpass *x = (t_allpass *)(w[1]); - int n = (int)(w[2]); - t_float *xin = (t_float *)(w[3]); - t_float *din = (t_float *)(w[4]); - t_float *ain = (t_float *)(w[5]); - t_float *out = (t_float *)(w[6]); - - int i; - for(i=0; ix_wh; - double input = (double)xin[i]; - //first off, write input to delay buf - x->x_xbuf[wh] = input; - //get delayed values of x and y - t_float delms = din[i]; - //first bounds checking - if(delms < 0){ - delms = 0; - } - else if(delms > x->x_maxdel){ - delms = x->x_maxdel; - }; - //now get those delayed vals - double delx = allpass_readmsdelay(x, x->x_xbuf, delms); - double dely = allpass_readmsdelay(x, x->x_ybuf, delms); - //figure out your current y term: y[n] = -a*x[n] + x[n-d] + a*y[n-d] - double output = (double)ain[i]*-1.*input + delx + (double)ain[i]*dely; - //stick this guy in the ybuffer and output - x->x_ybuf[wh] = output; - out[i] = output; - - //increment writehead - x->x_wh = (wh + 1) % x->x_sz; - }; - - return (w + 7); -} - -static void allpass_dsp(t_allpass *x, t_signal **sp) -{ - int sr = sp[0]->s_sr; - if(sr != x->x_sr){ - //if new sample rate isn't old sample rate, need to realloc - x->x_sr = sr; - allpass_sz(x); - }; - dsp_add(allpass_perform, 6, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, - sp[3]->s_vec); -} - -static void allpass_list(t_allpass *x, t_symbol *s, int argc, t_atom * argv){ - - - int argnum = 0; //current argument - while(argc){ - if(argv -> a_type == A_FLOAT){ - t_float curf = atom_getfloatarg(0, argc, argv); - switch(argnum){ - case 0: - //maxdel - x->x_maxdel = curf > 0 ? curf : ALLPASS_DELAY; - allpass_sz(x); - break; - case 1: - //initdel - if(curf < ALLPASS_MINMS){ - curf = ALLPASS_MINMS; - } - else if(curf > x->x_maxdel){ - curf = x->x_maxdel; - }; - pd_float((t_pd *)x->x_dellet, curf); - break; - case 2: - //gain - pd_float((t_pd *)x->x_alet, curf); - break; - default: - break; - }; - argnum++; - }; - argc--; - argv++; - }; - - - -} - - -static void *allpass_new(t_symbol *s, int argc, t_atom * argv){ - t_allpass *x = (t_allpass *)pd_new(allpass_class); - - //defaults - t_float maxdel = ALLPASS_DELAY; - t_float initdel = ALLPASS_MINMS; - t_float gain = ALLPASS_DEFGAIN; - x->x_sr = sys_getsr(); - - x->x_alloc = 0; - x->x_sz = ALLPASS_STACK; - //clear out stack bufs, set pointer to stack - x->x_ybuf = x->x_fbstack; - x->x_xbuf = x->x_ffstack; - allpass_clear(x); - - int argnum = 0; //current argument - while(argc){ - if(argv -> a_type == A_FLOAT){ - t_float curf = atom_getfloatarg(0, argc, argv); - switch(argnum){ - case 0: - maxdel = curf; - break; - case 1: - initdel = curf; - break; - case 2: - gain = curf; - break; - default: - break; - }; - argnum++; - }; - argc--; - argv++; - }; - - - x->x_maxdel = maxdel > 0 ? maxdel : ALLPASS_DELAY; - //ship off to the helper method to deal with allocation if necessary - allpass_sz(x); - //boundschecking - //this is 1/44.1 (1/(sr*0.001) rounded up, good enough? - - if(initdel < ALLPASS_MINMS){ - initdel = ALLPASS_MINMS; - } - else if(initdel > x->x_maxdel){ - initdel = x->x_maxdel; - }; - - - //inlets outlets - x->x_dellet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_dellet, initdel); - x->x_alet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_alet, gain); - x->x_outlet = outlet_new((t_object *)x, &s_signal); - return (x); -} - - - - - -static void * allpass_free(t_allpass *x){ - if(x->x_alloc){ - free(x->x_xbuf); - free(x->x_ybuf); - }; - inlet_free(x->x_dellet); - inlet_free(x->x_alet); - outlet_free(x->x_outlet); - return (void *)x; -} - -CYCLONE_OBJ_API void allpass_tilde_setup(void) -{ - allpass_class = class_new(gensym("allpass~"), - (t_newmethod)allpass_new, - (t_method)allpass_free, - sizeof(t_allpass), 0, - A_GIMME, 0); - class_addmethod(allpass_class, nullfn, gensym("signal"), 0); - class_addmethod(allpass_class, (t_method)allpass_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(allpass_class, (t_method)allpass_clear, gensym("clear"), 0); - class_addlist(allpass_class, (t_method)allpass_list); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/asin.c b/Libraries/cyclone/cyclone_objects/binaries/audio/asin.c deleted file mode 100644 index eed25e0000..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/asin.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - -// magic needed for manual isnan and isinf checks, which don't work -// reliably with -ffast-math compiler option -//#include "magicbit.h" - -typedef struct _asin { - t_object x_obj; - t_inlet *asin; - t_outlet *x_outlet; -} t_asin; - -void *asin_new(void); -static t_int * asin_perform(t_int *w); -static void asin_dsp(t_asin *x, t_signal **sp); - -static t_class *asin_class; - -static t_int *asin_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - {// CHECKED now there's protection against nan/inf - float f = *in++; - f = asinf(f); - *out++ = (PD_BADFLOAT(f)) ? 0 : f; - } - return (w + 4); -} - -static void asin_dsp(t_asin *x, t_signal **sp) -{ - dsp_add(asin_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -void *asin_new(void) -{ - t_asin *x = (t_asin *)pd_new(asin_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void asin_tilde_setup(void) -{ - asin_class = class_new(gensym("asin~"), (t_newmethod)asin_new, 0, - sizeof(t_asin), CLASS_DEFAULT, 0); - class_addmethod(asin_class, nullfn, gensym("signal"), 0); - class_addmethod(asin_class, (t_method) asin_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/asinh.c b/Libraries/cyclone/cyclone_objects/binaries/audio/asinh.c deleted file mode 100644 index 637173fa9c..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/asinh.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - - -typedef struct _asinh { - t_object x_obj; - t_inlet *asinh; - t_outlet *x_outlet; -} t_asinh; - -void *asinh_new(void); -static t_int * asinh_perform(t_int *w); -static void asinh_dsp(t_asinh *x, t_signal **sp); - -static t_class *asinh_class; - -static t_int *asinh_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - { - float f = *in++; - *out++ = asinhf(f); /* CHECKED no protection against NaNs */ - } - return (w + 4); -} - -static void asinh_dsp(t_asinh *x, t_signal **sp) -{ - dsp_add(asinh_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -void *asinh_new(void) -{ - t_asinh *x = (t_asinh *)pd_new(asinh_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void asinh_tilde_setup(void) -{ - asinh_class = class_new(gensym("asinh~"), (t_newmethod)asinh_new, 0, - sizeof(t_asinh), CLASS_DEFAULT, 0); - class_addmethod(asinh_class, nullfn, gensym("signal"), 0); - class_addmethod(asinh_class, (t_method) asinh_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/atan.c b/Libraries/cyclone/cyclone_objects/binaries/audio/atan.c deleted file mode 100644 index 66ac8ef523..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/atan.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - - -typedef struct _atan { - t_object x_obj; - t_inlet *atan; - t_outlet *x_outlet; -} t_atan; - -void *atan_new(void); -static t_int * atan_perform(t_int *w); -static void atan_dsp(t_atan *x, t_signal **sp); - -static t_class *atan_class; - -static t_int *atan_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - { - float f = *in++; - *out++ = atanf(f); // CHECKED no protection against NaNs - } - return (w + 4); -} - -static void atan_dsp(t_atan *x, t_signal **sp) -{ - dsp_add(atan_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -void *atan_new(void) -{ - t_atan *x = (t_atan *)pd_new(atan_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void atan_tilde_setup(void) -{ - atan_class = class_new(gensym("atan~"), (t_newmethod)atan_new, 0, - sizeof(t_atan), CLASS_DEFAULT, 0); - class_addmethod(atan_class, nullfn, gensym("signal"), 0); - class_addmethod(atan_class, (t_method) atan_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/atan2.c b/Libraries/cyclone/cyclone_objects/binaries/audio/atan2.c deleted file mode 100644 index 8e9924bbc4..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/atan2.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - - -typedef struct _atan2 { - t_object x_obj; - t_float x_input; //dummy var - t_inlet *x_inlet_y; // main 1st inlet - t_inlet *x_inlet_x; // 2nd inlet - t_outlet *x_outlet; -} t_atan2; - -static t_class *atan2_class; - -static t_int *atan2_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - float f1 = *in1++; - float f2 = *in2++; - *out++ = atan2f(f1, f2); - } - return (w + 5); -} - -static void atan2_dsp(t_atan2 *x, t_signal **sp) -{ - dsp_add(atan2_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -static void *atan2_new(t_floatarg f) // arg = x (not documented in max) -{ - t_atan2 *x = (t_atan2 *)pd_new(atan2_class); - x->x_inlet_x = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet_x, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void atan2_tilde_setup(void) -{ - atan2_class = class_new(gensym("atan2~"), (t_newmethod)atan2_new, 0, - sizeof(t_atan2), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(atan2_class, (t_method)atan2_dsp, gensym("dsp"), A_CANT, 0); - CLASS_MAINSIGNALIN(atan2_class, t_atan2, x_input); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/atanh.c b/Libraries/cyclone/cyclone_objects/binaries/audio/atanh.c deleted file mode 100644 index 931cd83db3..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/atanh.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - -// magic needed for manual isnan and isinf checks, which don't work -// reliably with -ffast-math compiler option -//#include "magicbit.h" - -typedef struct _atanh { - t_object x_obj; - t_inlet *atanh; - t_outlet *x_outlet; -} t_atanh; - -void *atanh_new(void); -static t_int * atanh_perform(t_int *w); -static void atanh_dsp(t_atanh *x, t_signal **sp); - -static t_class *atanh_class; - -static t_int *atanh_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - {// CHECKED now there's protection against nan/inf - float f = *in++; - f = atanhf(f); - *out++ = (PD_BADFLOAT(f)) ? 0 : f; - } - return (w + 4); -} - -static void atanh_dsp(t_atanh *x, t_signal **sp) -{ - dsp_add(atanh_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -void *atanh_new(void) -{ - t_atanh *x = (t_atanh *)pd_new(atanh_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void atanh_tilde_setup(void) -{ - atanh_class = class_new(gensym("atanh~"), (t_newmethod)atanh_new, 0, - sizeof(t_atanh), CLASS_DEFAULT, 0); - class_addmethod(atanh_class, nullfn, gensym("signal"), 0); - class_addmethod(atanh_class, (t_method) atanh_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/atodb.c b/Libraries/cyclone/cyclone_objects/binaries/audio/atodb.c deleted file mode 100644 index 46b7ef9f8f..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/atodb.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (c) 2016 Marco Matteo Markidis - mm.markidis@gmail.com - - For information on usage and redistribution, and for a DISCLAIMER OF ALL - WARRANTIES, see the file, "LICENSE.txt," in this distribution. - - Made while listening: - Evan Parker Electro-Acoustic Ensemble -- Hasselt - */ - -#include "m_pd.h" -#include -#include - -static t_class *atodb_class; - -typedef struct _atodb{ - t_object x_obj; - t_inlet *x_inlet; - t_outlet *x_outlet; -}t_atodb; - -static t_int * atodb_perform(t_int *w){ - t_atodb *x = (t_atodb *)(w[1]); - int n = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while(n--){ - t_float output = (20*log10(*in++)); - if(output < -999) - output = -999; - *out++ = output; - } - return(w+5); -} - -static void atodb_dsp(t_atodb *x, t_signal **sp){ - dsp_add(atodb_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void *atodb_new(void){ - t_atodb *x = (t_atodb *)pd_new(atodb_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (void *)x; -} - -CYCLONE_OBJ_API void atodb_tilde_setup(void) { - atodb_class = class_new(gensym("atodb~"), - (t_newmethod) atodb_new, 0, sizeof (t_atodb), CLASS_DEFAULT, 0); - class_addmethod(atodb_class, nullfn, gensym("signal"), 0); - class_addmethod(atodb_class, (t_method) atodb_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/average.c b/Libraries/cyclone/cyclone_objects/binaries/audio/average.c deleted file mode 100644 index a6ae41f7cf..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/average.c +++ /dev/null @@ -1,314 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* CHECKME no reset after changing of a window size? */ -/* CHECKME overlap */ - -/* Derek Kwan 2016 - OVERALL: old average~ was a chunked avg, this is now a moving avg - ======================== - rewrite average_absolutesum, average_rmssum, average_bipolarsum for addition, subtraction - rewrite perform, a lot of things in the struct to move from a chunked average to moving average - to parsing of input signal outside of average_ methods and inside perform method - getting rid of x_clock - write average_zerobuf, average_reset - changing float outlet to signal outlet - changed new method to accept list rather that defsym and deffloat - NOTE: I've written the bufrd so that it only uses [0, npoints) which makes overwriting the sample that drops - off the moving average easier, but this won't work if you want to resize the buffer and not clear it - also, averages are over npoints always, even if there are less than npoints accumulated so far */ - -#include -#include -#include "m_pd.h" -#include - -#define AVERAGE_STACK 44100 //stack value -#define AVERAGE_MAXBUF 882000 //max buffer size -#define AVERAGE_DEFNPOINTS 100 /* CHECKME */ -#define AVERAGE_DEFMODE AVERAGE_BIPOLAR -enum { AVERAGE_BIPOLAR, AVERAGE_ABSOLUTE, AVERAGE_RMS }; - -typedef struct _average -{ - t_object x_obj; - t_inlet *x_inlet1; - int x_mode; - double (*x_sumfn)(double, double, int); - unsigned int x_count; //number of samples seen so far, will no go beyond x_npoints + 1 - unsigned int x_npoints; //number of samples for moving average - double x_accum; //sum - double x_calib; //accumulator calibrator - double *x_buf; //buffer pointer - double x_stack[AVERAGE_STACK]; //buffer - int x_alloc; //if x_buf is allocated or stack - unsigned int x_sz; //allocated size for x_buf - unsigned int x_bufrd; //readhead for buffer - unsigned int x_max; //max size of buffer as specified by argt -} t_average; - -static t_class *average_class; - -static void average_zerobuf(t_average *x){ - - unsigned int i; - for(i=0; i < x->x_sz; i++){ - x->x_buf[i] = 0.; - }; -} - -static void average_reset(t_average * x){ - //clear buffer and reset everything to 0 - x->x_count = 0; - x->x_accum = 0; - x->x_bufrd = 0; - average_zerobuf(x); -}; - -static void average_sz(t_average *x, unsigned int newsz){ - //helper function to deal with allocation issues if needed - int alloc = x->x_alloc; - unsigned int cursz = x->x_sz; //current size - //requested size - if(newsz < 0){ - newsz = 0; - } - else if(newsz > AVERAGE_MAXBUF){ - newsz = AVERAGE_MAXBUF; - }; - if(!alloc && newsz > AVERAGE_STACK){ - x->x_buf = (double *)malloc(sizeof(double)*newsz); - x->x_alloc = 1; - x->x_sz = newsz; - } - else if(alloc && newsz > cursz){ - x->x_buf = (double *)realloc(x->x_buf, sizeof(double)*newsz); - x->x_sz = newsz; - } - else if(alloc && newsz < AVERAGE_STACK){ - free(x->x_buf); - x->x_sz = AVERAGE_STACK; - x->x_buf = x->x_stack; - x->x_alloc = 0; - }; - average_reset(x); -} - - -static double average_bipolarsum(double input, double accum, int add) -{ - if(add){ - accum += input; - } - else{ - accum -= input; - }; - return (accum); -} - -static double average_absolutesum(double input, double accum, int add) -{ - if(add){ - accum += (input >= 0 ? input : -input); - } - else{ - accum -= (input >= 0 ? input : -input); - }; - return (accum); -} - -static double average_rmssum(double input, double accum, int add) -{ - if(add){ - accum += (input * input); - } - else{ - accum -= (input * input); - }; - return (accum); -} - -static void average_setmode(t_average *x, int mode) -{ - if (mode == AVERAGE_BIPOLAR) - x->x_sumfn = average_bipolarsum; - else if (mode == AVERAGE_ABSOLUTE) - x->x_sumfn = average_absolutesum; - else if (mode == AVERAGE_RMS) - x->x_sumfn = average_rmssum; - x->x_mode = mode; - average_reset(x); -} - -static void average_float(t_average *x, t_float f) -{ - unsigned int i = (unsigned int)f; /* CHECKME noninteger */ - if (i > 0) /* CHECKME */ - { - //clip at max - if(i >= x->x_max){ - i = x->x_max; - }; - x->x_npoints = i; - average_reset(x); - } -} - -static void average_bipolar(t_average *x) -{ - average_setmode(x, AVERAGE_BIPOLAR); -} - -static void average_absolute(t_average *x) -{ - average_setmode(x, AVERAGE_ABSOLUTE); -} - -static void average_rms(t_average *x) -{ - average_setmode(x, AVERAGE_RMS); -} - -static t_int *average_perform(t_int *w) -{ - t_average *x = (t_average *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - double (*sumfn)(double, double, int) = x->x_sumfn; - int i; - unsigned int npoints = x->x_npoints; - for(i=0; i 1) - { - unsigned int bufrd = x->x_bufrd; - //add input to accumulator - x->x_accum = (*sumfn)(input, x->x_accum, 1); - x->x_calib = (*sumfn)(input, x->x_calib, 1); - unsigned int count = x->x_count; - if(count < npoints){ - //update count - count++; - x->x_count = count; - } - else{ - //start subtracting from the accumulator the sample that drops off the moving sum - - /*say npoints = 2, then when bufrd = 1, 0 and 1 are the accum, then when bufrd = 2, 1 and 2 should be the accum - so you subtract 0 from accum and add 2 and 0 = bufrd - npoints - if we are only using npoints of the x_buf, then bufrd will be the value we want to subtract - */ - - //subtract current value in bufrd's location from accum - x->x_accum = (*sumfn)(x->x_buf[bufrd], x->x_accum, 0); - - }; - - //overwrite/store current input value into buf - x->x_buf[bufrd] = input; - - - //calculate result - result = x->x_accum/(double)npoints; - if (x->x_mode == AVERAGE_RMS) - result = sqrt(result); - - //incrementation step - bufrd++; - if(bufrd >= npoints){ - bufrd = 0; - x->x_accum = x->x_calib; - x->x_calib = 0.0; - }; - x->x_bufrd = bufrd; - - } - else{ - //npoints = 1, just pass through (or absolute) - if(x->x_mode == AVERAGE_ABSOLUTE || x->x_mode == AVERAGE_RMS){ - result = fabs(input); - } - else{ - result = input; - }; - }; - out[i] = result; - }; - - return (w + 5); -} - -static void average_dsp(t_average *x, t_signal **sp) -{ - dsp_add(average_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void average_free(t_average *x) -{ - if(x->x_alloc){ - free(x->x_buf); - }; -} - -static void *average_new(t_symbol *s, int argc, t_atom * argv) -{ - t_average *x = (t_average *)pd_new(average_class); - int mode; - t_symbol * modename = &s_; - unsigned int maxbuf = AVERAGE_DEFNPOINTS; //default for max buf size - //default to stack for now... - x->x_buf = x->x_stack; - x->x_alloc = 0; - x->x_sz = AVERAGE_STACK; - - while(argc){ - if(argv -> a_type == A_FLOAT){ - t_float curfloat = atom_getfloatarg(0, argc, argv); - maxbuf = (unsigned int)curfloat; - } - else if(argv -> a_type == A_SYMBOL){ - modename = atom_getsymbolarg(0, argc, argv); - }; - argc--; - argv++; - - }; - /* CHECKED it looks like memory is allocated for the entire window, - in tune with the refman's note about ``maximum averaging interval'' -- - needed for dynamic control over window size, or what? LATER rethink */ - x->x_npoints = (maxbuf > 0 ? maxbuf : 1); - x->x_max = x->x_npoints; //designated max of average buffer - if (modename == gensym("bipolar")) - mode = AVERAGE_BIPOLAR; - else if (modename == gensym("absolute")) - mode = AVERAGE_ABSOLUTE; - else if (modename == gensym("rms")) - mode = AVERAGE_RMS; - else - { - mode = AVERAGE_DEFMODE; - /* CHECKME a warning if (s && s != &s_) */ - } - average_setmode(x, mode); - - //now allocate x_buf if necessary - average_sz(x, x->x_npoints); - /* CHECKME if not x->x_phase = 0 */ - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void average_tilde_setup(void) -{ - average_class = class_new(gensym("average~"), (t_newmethod)average_new, - (t_method)average_free, sizeof(t_average), 0, A_GIMME, 0); - class_addmethod(average_class, (t_method) average_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(average_class, nullfn, gensym("signal"), 0); - class_addmethod(average_class, (t_method)average_bipolar, gensym("bipolar"), 0); - class_addmethod(average_class, (t_method)average_absolute, gensym("absolute"), 0); - class_addmethod(average_class, (t_method)average_rms, gensym("rms"), 0); - class_addfloat(average_class, (t_method)average_float); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/avg.c b/Libraries/cyclone/cyclone_objects/binaries/audio/avg.c deleted file mode 100644 index 50ef2c4e8f..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/avg.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -typedef struct _avg -{ - t_object x_obj; - t_inlet *avg; - float x_count; - float x_accum; -} t_avg; - -static t_class *avg_class; - -static void avg_bang(t_avg *x) -{ - outlet_float(((t_object *)x)->ob_outlet, - (x->x_count ? x->x_accum / x->x_count : 0)); - x->x_count = 0; - x->x_accum = 0; -} - -static t_int *avg_perform(t_int *w) -{ - t_avg *x = (t_avg *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - float accum = 0; - x->x_count += nblock; /* LATER consider blockcount++ */ - while (nblock--) - { - float f = *in++; - accum += (f >= 0 ? f : -f); - } - x->x_accum += accum; - return (w + 4); -} - -static void avg_dsp(t_avg *x, t_signal **sp) -{ - dsp_add(avg_perform, 3, x, sp[0]->s_n, sp[0]->s_vec); -} - -static void *avg_new(void) -{ - t_avg *x = (t_avg *)pd_new(avg_class); - outlet_new((t_object *)x, &s_float); - x->x_count = 0; - x->x_accum = 0; - return (x); -} - -CYCLONE_OBJ_API void avg_tilde_setup(void) -{ - avg_class = class_new(gensym("avg~"), - (t_newmethod)avg_new, 0, - sizeof(t_avg), 0, 0); - class_addmethod(avg_class, nullfn, gensym("signal"), 0); - class_addmethod(avg_class, (t_method) avg_dsp, gensym("dsp"), A_CANT, 0); - class_addbang(avg_class, avg_bang); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/bitand.c b/Libraries/cyclone/cyclone_objects/binaries/audio/bitand.c deleted file mode 100644 index 31e6dc367f..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/bitand.c +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -//#include -#include "m_pd.h" -#include -#include "common/magicbit.h" - -// EXTERN t_float *obj_findsignalscalar(t_object *x, int m); - - -typedef struct _bitand -{ - t_object x_obj; - t_inlet *x_rightinlet; - t_glist *x_glist; - int32_t x_mask; - int x_mode; - int x_convert1; - t_float *x_signalscalar; - -} t_bitand; - -static t_class *bitand_class; - -static void bitand_intmask(t_bitand *x, t_floatarg f) -{ - x->x_mask = (int32_t)f; - pd_float(x->x_rightinlet, (t_float)x->x_mask); -} - -static t_int *bitand_perform(t_int *w) -{ - t_bitand *x = (t_bitand *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_i32_fl left, right, result; - switch (x->x_mode) - { - case 0: while (nblock--) // treat inputs as float - { - left.if_float = *in1++; - right.if_float = *in2++; - result.if_int32 = left.if_int32 & right.if_int32; - *out++ = result.if_float; - } - break; - case 1: while (nblock--) // convert inputs to int - { - int32_t i = ((int32_t)*in1++) & ((int32_t)*in2++); - *out++ = (t_float)i; - } - break; - case 2: while (nblock--) // right input as int - { - left.if_float = *in1++; - result.if_int32 = left.if_int32 & ((int32_t)*in2++); - *out++ = result.if_float; - } - break; - case 3: while (nblock--) // left input as int - { - right.if_float = *in2++; - int32_t i = ((int32_t)*in1++) & right.if_int32; - *out++ = (t_float)i; - } - break; - } - return (w + 6); -} - -static t_int *bitand_perform_noin2(t_int *w) -{ // LATER think about performance - t_bitand *x = (t_bitand *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - t_i32_fl left, result; - int32_t mask = x->x_mask; - t_float inmask = *x->x_signalscalar; - if (mask != (int32_t)inmask) - { - bitand_intmask(x, inmask); - } - if (x->x_convert1) - while (nblock--) - { int32_t i = ((int32_t)*in++) & mask; - *out++ = (t_float)i; - } - else while (nblock--) - { - left.if_float = *in++; - result.if_int32 = left.if_int32 & mask; - *out++ = result.if_float; - } - return (w + 5); -} - -static void bitand_dsp(t_bitand *x, t_signal **sp) -{ - if (magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal)) - dsp_add(bitand_perform, 5, x, // use mask from 2nd input signal - sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); - else // use mask set by 'bits' message or argument - dsp_add(bitand_perform_noin2, 4, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec); -} - -static void bitand_bits(t_bitand *x, t_symbol *s, int ac, t_atom *av) -{ - t_float f; - magic_setnan(&f); - x->x_mask = bitwise_getbitmask(ac, av); - pd_float(x->x_rightinlet, f); -} - -static void bitand_mode(t_bitand *x, t_floatarg f) -{ - int i = (int)f; - x->x_mode = i < 0 ? 0 : i > 3 ? 3 : i; - x->x_convert1 = (x->x_mode == 1 || x->x_mode == 3); -} - -static void *bitand_new(t_floatarg f1, t_floatarg f2) -{ - t_bitand *x = (t_bitand *)pd_new(bitand_class); - x->x_glist = canvas_getcurrent(); - x->x_rightinlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - outlet_new((t_object *)x, &s_signal); - x->x_signalscalar = obj_findsignalscalar(x, 1); - bitand_intmask(x, f1); - bitand_mode(x, f2); - return (x); -} - -CYCLONE_OBJ_API void bitand_tilde_setup(void) -{ - bitand_class = class_new(gensym("bitand~"), (t_newmethod)bitand_new, 0, - sizeof(t_bitand), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(bitand_class, nullfn, gensym("signal"), 0); - class_addmethod(bitand_class, (t_method) bitand_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(bitand_class, (t_method)bitand_bits, gensym("bits"), A_GIMME, 0); - class_addmethod(bitand_class, (t_method)bitand_mode, gensym("mode"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/bitnot.c b/Libraries/cyclone/cyclone_objects/binaries/audio/bitnot.c deleted file mode 100644 index 09f1e07e60..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/bitnot.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include -#include "common/magicbit.h" - -//~ union i32_fl { - //~ int32_t if_int32; - //~ t_float if_float; -//~ }; - -typedef struct _bitnot { - t_object x_obj; - t_outlet *x_outlet; - int x_convert1; -} t_bitnot; - -static t_class *bitnot_class; - -void *bitnot_new(t_floatarg f); -static t_int * bitnot_perform(t_int *w); -static void bitnot_dsp(t_bitnot *x, t_signal **sp); -static void bitnot_mode(t_bitnot *x, t_floatarg f); -static void bitnot_float(t_bitnot *x, t_float f); - - -static t_int * bitnot_perform(t_int *w) -{ // LATER think about performance - t_bitnot *x = (t_bitnot *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - t_i32_fl result; - if (x->x_convert1) while (nblock--) - { - int32_t i = ~((int32_t)*in++); - *out++ = (t_float)i; - } - else while (nblock--) - { - result.if_float = *in++; - result.if_int32 = ~result.if_int32; - *out++ = result.if_float; - } - return (w + 5); -} - -static void bitnot_dsp(t_bitnot *x, t_signal **sp) -{ - dsp_add(bitnot_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void bitnot_mode(t_bitnot *x, t_floatarg f) -{ - int i = (int)f; - x->x_convert1 = (i > 0); -} - -static void bitnot_float(t_bitnot *x, t_float f) -{ - int i = (int)f; - x->x_convert1 = (i > 0); -} - - -void *bitnot_new(t_floatarg f) -{ - t_bitnot *x = (t_bitnot *)pd_new(bitnot_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - bitnot_mode(x, f); - return (x); -} - -CYCLONE_OBJ_API void bitnot_tilde_setup(void) { - bitnot_class = class_new(gensym("bitnot~"), (t_newmethod) bitnot_new, 0, - sizeof (t_bitnot), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(bitnot_class, nullfn, gensym("signal"), 0); - class_addmethod(bitnot_class, (t_method) bitnot_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(bitnot_class, (t_method)bitnot_mode, gensym("mode"), A_FLOAT, 0); - class_addfloat(bitnot_class, (t_method)bitnot_float); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/bitor.c b/Libraries/cyclone/cyclone_objects/binaries/audio/bitor.c deleted file mode 100644 index 4758736e9b..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/bitor.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -//#include -#include "m_pd.h" -#include -#include "common/magicbit.h" - -//EXTERN t_float *obj_findsignalscalar(t_object *x, int m); - -//~ union i32_fl { - //~ int32_t if_int32; - //~ t_float if_float; -//~ }; - -typedef struct _bitor -{ - t_object x_obj; - t_inlet *x_rightinlet; - t_glist *x_glist; - int32_t x_mask; - int x_mode; - int x_convert1; - t_float *x_signalscalar; - -} t_bitor; - -static t_class *bitor_class; - -static void bitor_intmask(t_bitor *x, t_floatarg f) -{ - x->x_mask = (int32_t)f; - pd_float(x->x_rightinlet, (t_float)x->x_mask); -} - -static t_int *bitor_perform(t_int *w) -{ - t_bitor *x = (t_bitor *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_i32_fl left, right, result; - switch (x->x_mode) - { - case 0: while (nblock--) // treat inputs as float - { - left.if_float = *in1++; - right.if_float = *in2++; - result.if_int32 = left.if_int32 | right.if_int32; - *out++ = result.if_float; - } - break; - case 1: while (nblock--) // convert inputs to int - { - int32_t i = ((int32_t)*in1++) | ((int32_t)*in2++); - *out++ = (t_float)i; - } - break; - case 2: while (nblock--) // right input as int - { - left.if_float = *in1++; - result.if_int32 = left.if_int32 | ((int32_t)*in2++); - *out++ = result.if_float; - } - break; - case 3: while (nblock--) // left input as int - { - right.if_float = *in2++; - int32_t i = ((int32_t)*in1++) | right.if_int32; - *out++ = (t_float)i; - } - break; - } - return (w + 6); -} - -static t_int *bitor_perform_noin2(t_int *w) -{ // LATER think about performance - t_bitor *x = (t_bitor *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - t_i32_fl left, result; - int32_t mask = x->x_mask; - t_float inmask = *x->x_signalscalar; - if (mask != (int32_t)inmask) - { - bitor_intmask(x, inmask); - } - if (x->x_convert1) - while (nblock--) - { int32_t i = ((int32_t)*in++) | mask; - *out++ = (t_float)i; - } - else while (nblock--) - { - left.if_float = *in++; - result.if_int32 = left.if_int32 | mask; - *out++ = result.if_float; - } - return (w + 5); -} - -static void bitor_dsp(t_bitor *x, t_signal **sp) -{ - if (magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal)) - dsp_add(bitor_perform, 5, x, // use mask from 2nd input sig - sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); - else // use mask set by 'bits' message or argument - dsp_add(bitor_perform_noin2, 4, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec); -} - -static void bitor_bits(t_bitor *x, t_symbol *s, int ac, t_atom *av) -{ - t_float f; - magic_setnan(&f); - x->x_mask = bitwise_getbitmask(ac, av); - pd_float(x->x_rightinlet, f); -} - -static void bitor_mode(t_bitor *x, t_floatarg f) -{ - int i = (int)f; - x->x_mode = i < 0 ? 0 : i > 3 ? 3 : i; - x->x_convert1 = (x->x_mode == 1 || x->x_mode == 3); -} - -static void *bitor_new(t_floatarg f1, t_floatarg f2) -{ - t_bitor *x = (t_bitor *)pd_new(bitor_class); - x->x_glist = canvas_getcurrent(); - x->x_rightinlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - outlet_new((t_object *)x, &s_signal); - x->x_signalscalar = obj_findsignalscalar(x, 1); - bitor_intmask(x, f1); - bitor_mode(x, f2); - return (x); -} - -CYCLONE_OBJ_API void bitor_tilde_setup(void) -{ - bitor_class = class_new(gensym("bitor~"), (t_newmethod)bitor_new, 0, - sizeof(t_bitor), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(bitor_class, nullfn, gensym("signal"), 0); - class_addmethod(bitor_class, (t_method) bitor_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(bitor_class, (t_method)bitor_bits, gensym("bits"), A_GIMME, 0); - class_addmethod(bitor_class, (t_method)bitor_mode, gensym("mode"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/bitsafe.c b/Libraries/cyclone/cyclone_objects/binaries/audio/bitsafe.c deleted file mode 100644 index 68ac364f56..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/bitsafe.c +++ /dev/null @@ -1,51 +0,0 @@ -// Barber and Porres 2016 - -#include "m_pd.h" -#include -#include "common/magicbit.h" // for magic_isnan(), magic_isinf() and BITWISE_ISDENORM - -typedef struct _bitsafe { - t_object x_obj; - t_inlet *bitsafe; - t_outlet *x_outlet; -} t_bitsafe; - -void *bitsafe_new(void); -static t_int * bitsafe_perform(t_int *w); -static void bitsafe_dsp(t_bitsafe *x, t_signal **sp); - -static t_class *bitsafe_class; - -static t_int *bitsafe_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - { - float f = *in++; - if(magic_isnan(f) || magic_isinf(f) || BITWISE_ISDENORM(f)) f = 0; - *out++ = f; - } - return (w + 4); -} - -static void bitsafe_dsp(t_bitsafe *x, t_signal **sp) -{ - dsp_add(bitsafe_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -void *bitsafe_new(void) -{ - t_bitsafe *x = (t_bitsafe *)pd_new(bitsafe_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void bitsafe_tilde_setup(void) -{ - bitsafe_class = class_new(gensym("bitsafe~"), (t_newmethod)bitsafe_new, 0, - sizeof(t_bitsafe), CLASS_DEFAULT, 0); - class_addmethod(bitsafe_class, nullfn, gensym("signal"), 0); - class_addmethod(bitsafe_class, (t_method) bitsafe_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/bitshift.c b/Libraries/cyclone/cyclone_objects/binaries/audio/bitshift.c deleted file mode 100644 index 58e6c57e3f..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/bitshift.c +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include -#include "common/magicbit.h" - -static t_class *bitshift_class; - -//~ union i32_fl { - //~ int32_t if_int32; - //~ t_float if_float; -//~ }; - -typedef struct _bitshift { - t_object x_obj; - t_outlet *x_outlet; - t_int x_convert1; - t_float x_lshift; - t_float x_rshift; -} t_bitshift; - -void *bitshift_new(t_floatarg f1, t_floatarg f2); -static t_int * bitshift_perform(t_int *w); -static void bitshift_dsp(t_bitshift *x, t_signal **sp); -static void bitshift_mode(t_bitshift *x, t_floatarg f); -static void bitshift_float(t_bitshift *x, t_float f); - -static t_int * bitshift_perform(t_int *w) -{ // LATER think about performance - t_bitshift *x = (t_bitshift *)(w[1]); - t_int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - t_i32_fl result; - if (x->x_lshift) - { - unsigned int shift = (int)x->x_lshift; - if (x->x_convert1) while (nblock--) - { - int32_t i = ((int32_t)*in++ << shift); - *out++ = (t_float)i; - } - else while (nblock--) - { - result.if_float = *in++; - result.if_int32 = result.if_int32 << shift; - *out++ = result.if_float; - } - } - else if (x->x_rshift) - { - unsigned int shift = (int)x->x_rshift; - if (x->x_convert1) while (nblock--) - { - int32_t i = ((int32_t)*in++ >> shift); - *out++ = (t_float)i; - } - else while (nblock--) - { - result.if_float = *in++; - result.if_int32 = result.if_int32 >> shift; - *out++ = result.if_float; - } - } - else - while (nblock--) *out++ = *in++; - return (w + 5); -} - -static void bitshift_dsp(t_bitshift *x, t_signal **sp) -{ - dsp_add(bitshift_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void bitshift_mode(t_bitshift *x, t_floatarg f) -{ - int i = (int)f; - x->x_convert1 = (i > 0); -} - -static void bitshift_float(t_bitshift *x, t_float f) -{ - int i = (int)f; - x->x_convert1 = (i > 0); -} - -static void bitshift_shift(t_bitshift *x, t_floatarg f) - { - x->x_lshift = x->x_rshift = 0; - if (f > 0) x->x_lshift = f; - else x->x_rshift = -f; - } - -void *bitshift_new(t_floatarg f1, t_floatarg f2) -{ - t_bitshift *x = (t_bitshift *)pd_new(bitshift_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - bitshift_shift(x, f1); - bitshift_mode(x, f2); - return (x); -} - -CYCLONE_OBJ_API void bitshift_tilde_setup(void) { bitshift_class = class_new(gensym("bitshift~"), - (t_newmethod) bitshift_new, 0, sizeof (t_bitshift), CLASS_DEFAULT, - A_DEFFLOAT, A_DEFFLOAT, 0); - class_addfloat(bitshift_class, (t_method)bitshift_float); - class_addmethod(bitshift_class, nullfn, gensym("signal"), 0); - class_addmethod(bitshift_class, (t_method) bitshift_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(bitshift_class, (t_method)bitshift_mode, gensym("mode"), A_FLOAT, 0); - class_addmethod(bitshift_class, (t_method)bitshift_shift, gensym("shift"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/bitxor.c b/Libraries/cyclone/cyclone_objects/binaries/audio/bitxor.c deleted file mode 100644 index 33fb579477..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/bitxor.c +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -//adding argument parsing and errstate - Derek Kwan 2016 - -#include -//#include -#include "m_pd.h" -#include -#include "common/magicbit.h" - -#define PDCYBXORMASK 0 //default for bitmask -#define PDCYBXORMODE 0 //default for mode - - -//EXTERN t_float *obj_findsignalscalar(t_object *x, int m); - -//~ union i32_fl { - //~ int32_t if_int32; - //~ t_float if_float; -//~ }; - -typedef struct _bitxor -{ - t_object x_obj; - t_inlet *x_rightinlet; - t_glist *x_glist; - int32_t x_mask; - int x_mode; - int x_convert1; - t_float *x_signalscalar; - -} t_bitxor; - -static t_class *bitxor_class; - -static void bitxor_intmask(t_bitxor *x, t_floatarg f) -{ - x->x_mask = (int32_t)f; - pd_float(x->x_rightinlet, (t_float)x->x_mask); -} - -static t_int *bitxor_perform(t_int *w) -{ - t_bitxor *x = (t_bitxor *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_i32_fl left, right, result; - switch (x->x_mode) - { - case 0: while (nblock--) // treat inputs as float - { - left.if_float = *in1++; - right.if_float = *in2++; - result.if_int32 = left.if_int32 ^ right.if_int32; - *out++ = result.if_float; - } - break; - case 1: while (nblock--) // convert inputs to int - { - int32_t i = ((int32_t)*in1++) ^ ((int32_t)*in2++); - *out++ = (t_float)i; - } - break; - case 2: while (nblock--) // right input as int - { - left.if_float = *in1++; - result.if_int32 = left.if_int32 ^ ((int32_t)*in2++); - *out++ = result.if_float; - } - break; - case 3: while (nblock--) // left input as int - { - right.if_float = *in2++; - int32_t i = ((int32_t)*in1++) ^ right.if_int32; - *out++ = (t_float)i; - } - break; - } - return (w + 6); -} - -static t_int *bitxor_perform_noin2(t_int *w) -{ // LATER think about performance - t_bitxor *x = (t_bitxor *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - t_i32_fl left, result; - int32_t mask = x->x_mask; - t_float inmask = *x->x_signalscalar; - if (mask != (int32_t)inmask) - { - bitxor_intmask(x, inmask); - } - if (x->x_convert1) - while (nblock--) - { int32_t i = ((int32_t)*in++) ^ mask; - *out++ = (t_float)i; - } - else while (nblock--) - { - left.if_float = *in++; - result.if_int32 = left.if_int32 ^ mask; - *out++ = result.if_float; - } - return (w + 5); -} - -static void bitxor_dsp(t_bitxor *x, t_signal **sp) -{ - if (magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal)) - dsp_add(bitxor_perform, 5, x, // use mask from 2nd input sig - sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); - else // use mask set by 'bits' message or argument - dsp_add(bitxor_perform_noin2, 4, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec); -} - -static void bitxor_bits(t_bitxor *x, t_symbol *s, int ac, t_atom *av) -{ - t_float f; - magic_setnan(&f); - x->x_mask = bitwise_getbitmask(ac, av); - pd_float(x->x_rightinlet, f); -} - -static void bitxor_mode(t_bitxor *x, t_floatarg f) -{ - int i = (int)f; - x->x_mode = i < 0 ? 0 : i > 3 ? 3 : i; - x->x_convert1 = (x->x_mode == 1 || x->x_mode == 3); -} - -static void *bitxor_new(t_symbol *s, int argc, t_atom * argv) -{ - t_bitxor *x = (t_bitxor *)pd_new(bitxor_class); - x->x_glist = canvas_getcurrent(); - x->x_rightinlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - outlet_new((t_object *)x, &s_signal); - x->x_signalscalar = obj_findsignalscalar(x, 1); - - //defaults - t_float bitmask = PDCYBXORMASK; - t_float opmode = PDCYBXORMODE; - int curarg = 0; //current argument - //argument parsing - while(argc > 0){ - if(argv->a_type == A_FLOAT){ - t_float curfloat = atom_getfloatarg(0, argc, argv); - switch(curarg){ - case 0: - bitmask = curfloat; - break; - case 1: - opmode = curfloat; - break; - default: - break; - }; - //increment - curarg++; - argc--; - argv++; - } - else if(argv->a_type == A_SYMBOL){ - if(argc >= 2){ - t_symbol * cursym = atom_getsymbolarg(0, argc, argv); - t_float curfloat = atom_getfloatarg(1, argc, argv); - if(strcmp(cursym->s_name, "@mode") == 0){ - opmode = curfloat; - //increment - curarg+=2; - argc-=2; - argv+=2; - } - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - }; - bitxor_intmask(x, bitmask); - bitxor_mode(x, opmode); - return (x); - errstate: - pd_error(x, "bitxor~: improper args"); - return NULL; - -} - -CYCLONE_OBJ_API void bitxor_tilde_setup(void) -{ - bitxor_class = class_new(gensym("bitxor~"), (t_newmethod)bitxor_new, 0, - sizeof(t_bitxor), 0, A_GIMME, 0); - class_addmethod(bitxor_class, nullfn, gensym("signal"), 0); - class_addmethod(bitxor_class, (t_method) bitxor_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(bitxor_class, (t_method)bitxor_bits, gensym("bits"), A_GIMME, 0); - class_addmethod(bitxor_class, (t_method)bitxor_mode, gensym("mode"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/buffir.c b/Libraries/cyclone/cyclone_objects/binaries/audio/buffir.c deleted file mode 100644 index c40a37e4cb..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/buffir.c +++ /dev/null @@ -1,184 +0,0 @@ -/* Copyright (c) 2003-2005 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include -#include "signal/cybuf.h" - -#define BUFFIR_DEFSIZE 0 -#define BUFFIR_MAXSIZE 4096 - -typedef struct _buffir -{ - t_object x_obj; - t_cybuf *x_cybuf; - t_inlet *x_offlet; - t_inlet *x_sizlet; - t_float *x_lohead; - t_float *x_hihead; - t_float *x_histlo; - t_float *x_histhi; - t_float x_histbuf[2 * BUFFIR_MAXSIZE]; - int x_checked; -} t_buffir; - -static t_class *buffir_class; - -static void buffir_setrange(t_buffir *x, t_floatarg f1, t_floatarg f2) -{ - int off = (int)f1; - int siz = (int)f2; - if (off < 0) - off = 0; - if (siz <= 0) - siz = BUFFIR_DEFSIZE; - if (siz > BUFFIR_MAXSIZE) - siz = BUFFIR_MAXSIZE; - pd_float((t_pd *)x->x_offlet, off); - pd_float((t_pd *)x->x_sizlet, siz); -} - -static void buffir_clear(t_buffir *x) -{ - memset(x->x_histlo, 0, 2 * BUFFIR_MAXSIZE * sizeof(*x->x_histlo)); - x->x_lohead = x->x_histlo; - x->x_hihead = x->x_histhi = x->x_histlo + BUFFIR_MAXSIZE; -} - -static void buffir_set(t_buffir *x, t_symbol *s, t_floatarg f1, t_floatarg f2) -{ - cybuf_setarray(x->x_cybuf, s); - buffir_setrange(x, f1, f2); -} - - -static void buffir_float(t_buffir *x, t_float f) -{ - pd_error(x, "buffir~: no method for 'float'"); -} - -static t_int *buffir_perform(t_int *w) -{ - t_buffir *x = (t_buffir *)(w[1]); - int nblock = (int)(w[2]); - t_float *xin = (t_float *)(w[3]); - t_float *out = (t_float *)(w[6]); - t_float *lohead = x->x_lohead; - t_float *hihead = x->x_hihead; - t_cybuf *c = x->x_cybuf; - if (c->c_playable) - { - - t_float *oin = (t_float *)(w[4]); - t_float *sin = (t_float *)(w[5]); - int bufnpts = c->c_npts; - t_word *vec = c->c_vectors[0]; /* playable implies nonzero (mono) */ - while (nblock--) - { - - /* CHECKME every sample or once per block. - If once per block, then LATER think about performance. */ - /* CHECKME rounding */ - int off = (int)*oin++; - int npoints = (int)*sin++; - if (off < 0) - off = 0; - if (npoints > BUFFIR_MAXSIZE) - npoints = BUFFIR_MAXSIZE; - if (npoints > bufnpts - off) - npoints = bufnpts - off; - if (npoints > 0) - { - if (!(x->x_checked)) - { - x->x_checked = 1; - } - t_word *coefp = vec; - t_float *hp = hihead; - t_float sum = 0.; - *lohead++ = *hihead++ = *xin++; - while (npoints--) - sum += coefp[off++].w_float * *hp--; - //sum += coefp->w_float * *hp--; - *out++ = sum; - } - else - { - *lohead++ = *hihead++ = *xin++; - *out++ = 0.; - } - if (lohead >= x->x_histhi) - { - lohead = x->x_histlo; - hihead = x->x_histhi; - } - } - } - else while (nblock--) - { - *lohead++ = *hihead++ = *xin++; - *out++ = 0.; - if (lohead >= x->x_histhi) - { - lohead = x->x_histlo; - hihead = x->x_histhi; - } - } - x->x_lohead = lohead; - x->x_hihead = hihead; - return (w + 7); -} - -static void buffir_dsp(t_buffir *x, t_signal **sp) -{ - x->x_checked = 0; - cybuf_checkdsp(x->x_cybuf); - dsp_add(buffir_perform, 6, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); -} - -static void buffir_free(t_buffir *x) -{ - inlet_free(x->x_offlet); - inlet_free(x->x_sizlet); - cybuf_free(x->x_cybuf); -} - -static void *buffir_new(t_symbol *s, t_floatarg f1, t_floatarg f2) -{ - /* CHECKME always the first channel used. */ - /* three auxiliary signals: main, offset and size inputs */ - t_buffir *x = (t_buffir *)pd_new(buffir_class); - x->x_cybuf = cybuf_init((t_class *)x, s, 1, 0); - if (x->x_cybuf) - { - - - x->x_offlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - pd_float((t_pd *)x->x_offlet, f1); - x->x_sizlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - pd_float((t_pd *)x->x_sizlet, f2); - - outlet_new(&x->x_obj, gensym("signal")); - x->x_histlo = x->x_histbuf; - x->x_histhi = x->x_histbuf+BUFFIR_MAXSIZE; - x->x_checked = 0; - buffir_clear(x); - buffir_setrange(x, f1, f2); - } - return (x); -} - -CYCLONE_OBJ_API void buffir_tilde_setup(void) -{ - buffir_class = class_new(gensym("buffir~"), (t_newmethod)buffir_new, (t_method)buffir_free, - sizeof(t_buffir), CLASS_DEFAULT, A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, 0); - class_domainsignalin(buffir_class, -1); - class_addfloat(buffir_class, buffir_float); - class_addmethod(buffir_class, (t_method)buffir_dsp, gensym("dsp"), A_CANT, 0); - //class_addmethod(c, (t_method)arsic_enable, gensym("enable"), 0); - class_addmethod(buffir_class, (t_method)buffir_clear, gensym("clear"), 0); - class_addmethod(buffir_class, (t_method)buffir_set, gensym("set"), A_SYMBOL, - A_DEFFLOAT, A_DEFFLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/capture.c b/Libraries/cyclone/cyclone_objects/binaries/audio/capture.c deleted file mode 100644 index 7310175352..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/capture.c +++ /dev/null @@ -1,400 +0,0 @@ -/* Copyright (c) 2002-2005 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* CHECKME list of indices */ - -#include -#include "m_pd.h" -#include -#include "g_canvas.h" -#include "common/file.h" -#include -#include - -//string and errno for fail: in capture_dowrite, copying over functionality from loud.c -#define CAPTURE_DEFSIZE 4096 -#define CAPTURE_DEFPRECISION 4 -#define CAPTURE_MAXPRECISION 99 /* format array protection */ -#define CAPTURE_MAXINDICES 4096 /* FIXME */ - -typedef struct _capture{ - t_object x_obj; - t_inlet *x_inlet; - t_glist *x_glist; - char x_mode; /* 'f' for first or 0 for last */ - int x_precision; - char x_format[8]; - char *x_indices; - int x_szindices; /* size of x_indices array */ - int x_nindices; /* number of reported indices */ - int x_nblock; - float *x_buffer; - int x_bufsize; - int x_count; - int x_head; - t_file *x_filehandle; -} t_capture; - -static t_class *capture_class; - -static int capture_formatfloat(t_capture *x, float f, char *buf, int col, int maxcol){ - char *bp = buf; - int cnt = 0; - if (col > 0) - *bp++ = ' ', cnt++; - if (x->x_precision) - cnt += sprintf(bp, x->x_format, f); - else - cnt += sprintf(bp, "%d", (int)f); - if (col + cnt > maxcol) - buf[0] = '\n', col = cnt - 1; /* assuming col > 0 */ - else - col += cnt; - return (col); -} - -static int capture_writefloat(t_capture *x, float f, char *buf, int col, FILE *fp) -{ - /* CHECKME linebreaks */ - col = capture_formatfloat(x, f, buf, col, 80); - return(fputs(buf, fp) < 0 ? -1 : col); -} - -static void capture_dowrite(t_capture *x, t_symbol *fn) -{ - FILE *fp = 0; - int count = x->x_count; - char buf[MAXPDSTRING]; - canvas_makefilename(glist_getcanvas(x->x_glist), - fn->s_name, buf, MAXPDSTRING); - if ((fp = sys_fopen(buf, "w"))) /* LATER ask if overwriting, CHECKME */ - { - int col = 0; - if (x->x_mode == 'f' || count < x->x_bufsize) - { - float *bp = x->x_buffer; - while (count--) - if ((col = capture_writefloat(x, *bp++, buf, col, fp)) < 0) - goto fail; - } - else - { - float *bp = x->x_buffer + x->x_head; - count = x->x_bufsize - x->x_head; - while (count--) - if ((col = capture_writefloat(x, *bp++, buf, col, fp)) < 0) - goto fail; - bp = x->x_buffer; - count = x->x_head; - while (count--) - if ((col = capture_writefloat(x, *bp++, buf, col, fp)) < 0) - goto fail; - } - if (col) fputc('\n', fp); - fclose(fp); - return; - } -fail: - if (fp) - fclose(fp); - pd_error(x, "capture~: %s", strerror(errno)); -} - -static void capture_writehook(t_pd *z, t_symbol *fn, int ac, t_atom *av) -{ - ac = 0; - av = NULL; - capture_dowrite((t_capture *)z, fn); -} - -static void capture_write(t_capture *x, t_symbol *s) -{ - if (s && s != &s_) - capture_dowrite(x, s); - else - panel_save(x->x_filehandle, 0, 0); -} - -static int capture_appendfloat(t_capture *x, float f, char *buf, int col, int linebreak){ - /* CHECKME 80 columns */ - col = capture_formatfloat(x, f, buf, col, 80); - editor_append(x->x_filehandle, buf); - if(linebreak){ - if(col){ - editor_append(x->x_filehandle, "\n\n"); - col = 0; - } - else - editor_append(x->x_filehandle, "\n"); - } - return(col); -} - -static void capture_open(t_capture *x){ // CHECKED blank line between blocks - int count = x->x_count; - char buf[MAXPDSTRING]; - int nindices = (x->x_nindices > 0 ? x->x_nindices : x->x_nblock); - editor_open(x->x_filehandle, "Signal Capture", ""); /* CHECKED */ - if(x->x_mode == 'f' || count < x->x_bufsize){ - float *bp = x->x_buffer; - int col = 0, i; - for(i = 1; i <= count; i++) - col = capture_appendfloat(x, *bp++, buf, col, ((i % nindices) == 0)); - } - else{ - float *bp = x->x_buffer + x->x_head; - int col = 0, i = x->x_bufsize; - count = x->x_bufsize - x->x_head; - while (count--) - col = capture_appendfloat(x, *bp++, buf, col, ((--i % nindices) == 0)); - bp = x->x_buffer; - count = x->x_head; - while(count--) - col = capture_appendfloat(x, *bp++, buf, col, ((count % nindices) == 0)); - } - sys_vgui(" if {[winfo exists .%lx]} {\n", (unsigned long)x->x_filehandle); - sys_vgui(" wm deiconify .%lx\n", (unsigned long)x->x_filehandle); - sys_vgui(" raise .%lx\n", (unsigned long)x->x_filehandle); - sys_vgui(" focus .%lx.text\n", (unsigned long)x->x_filehandle); - sys_gui(" }\n"); -} - -static void capture_clear(t_capture *x){ - x->x_count = 0; - x->x_head = 0; - sys_vgui(" if {[winfo exists .%lx]} {\n", (unsigned long)x->x_filehandle); - sys_vgui(" .%lx.text delete 1.0 end\n", (unsigned long)x->x_filehandle); - sys_gui(" }\n"); -} - -/* CHECKED without asking and storing the changes */ -static void capture_wclose(t_capture *x) -{ - editor_close(x->x_filehandle, 0); -} - -static void capture_click(t_capture *x, t_floatarg xpos, t_floatarg ypos, - t_floatarg shift, t_floatarg ctrl, t_floatarg alt) -{ - alt = ctrl = shift = ypos = xpos = 0; - capture_open(x); -} - -static t_int *capture_perform_first(t_int *w){ - t_capture *x = (t_capture *)(w[1]); - int count = x->x_count; - int bufsize = x->x_bufsize; - if(count < bufsize){ - t_float *in = (t_float *)(w[2]); - int nblock = (int)(w[3]); - float *bp = x->x_buffer + count; - char *ndxp = x->x_indices; - if(nblock > x->x_szindices) - nblock = x->x_szindices; - while(nblock--){ - if(*ndxp++){ - *bp++ = *in++; - if(++count == bufsize) - break; - } - else - in++; - } - x->x_count = count; - } - return(w+4); -} - -static t_int *capture_perform_allfirst(t_int *w){ - t_capture *x = (t_capture *)(w[1]); - int count = x->x_count; - int bufsize = x->x_bufsize; - if(count < bufsize){ - t_float *in = (t_float *)(w[2]); - int nblock = (int)(w[3]); - float *bp = x->x_buffer + count; - while (nblock--){ - *bp++ = *in++; - if(++count == bufsize) - break; - } - x->x_count = count; - } - return(w+4); -} - -static t_int *capture_perform_last(t_int *w){ - t_capture *x = (t_capture *)(w[1]); - t_float *in = (t_float *)(w[2]); - int nblock = (int)(w[3]); - float *buffer = x->x_buffer; - int bufsize = x->x_bufsize; - int count = x->x_count; - int head = x->x_head; - char *ndxp = x->x_indices; - if (nblock > x->x_szindices) - nblock = x->x_szindices; - while (nblock--){ - if(*ndxp++){ - buffer[head++] = *in++; - if(head >= bufsize) - head = 0; - if(count < bufsize) - count++; - } - else - in++; - } - x->x_count = count; - x->x_head = head; - return(w+4); -} - -static t_int *capture_perform_alllast(t_int *w){ - t_capture *x = (t_capture *)(w[1]); - t_float *in = (t_float *)(w[2]); - int nblock = (int)(w[3]); - float *buffer = x->x_buffer; - int bufsize = x->x_bufsize; - int count = x->x_count; - int head = x->x_head; - while (nblock--){ - buffer[head++] = *in++; - if(head >= bufsize) - head = 0; - if(count < bufsize) - count++; - } - x->x_count = count; - x->x_head = head; - return(w+4); -} - -static void capture_dsp(t_capture *x, t_signal **sp){ - x->x_nblock = sp[0]->s_n; - if(x->x_indices) - dsp_add((x->x_mode == 'f' ? - capture_perform_first : capture_perform_last), - 3, x, sp[0]->s_vec, sp[0]->s_n); - else - dsp_add((x->x_mode == 'f' ? - capture_perform_allfirst : capture_perform_alllast), - 3, x, sp[0]->s_vec, sp[0]->s_n); -} - -static void capture_free(t_capture *x) -{ - file_free(x->x_filehandle); - if (x->x_indices) - freebytes(x->x_indices, x->x_szindices * sizeof(*x->x_indices)); - if (x->x_buffer) - freebytes(x->x_buffer, x->x_bufsize * sizeof(*x->x_buffer)); -} - -static void *capture_new(t_symbol *s, int ac, t_atom *av) -{ - s = NULL; - t_capture *x = 0; - char mode = 0; - int precision = -1; - float *buffer; - int bufsize = 0; - char *indices = 0; - int szindices = 0, nindices = -1; - if (ac && av->a_type == A_SYMBOL) - { - t_symbol *cursym = av->a_w.w_symbol; - if (cursym && *cursym->s_name == 'f') /* CHECKME */ - mode = 'f'; - ac--; av++; - } - if (ac && av->a_type == A_FLOAT) - { - bufsize = (int)av->a_w.w_float; /* CHECKME */ - ac--; av++; - if (ac && av->a_type == A_FLOAT) - { - int i; - t_atom *ap; - precision = (int)av->a_w.w_float; /* CHECKME */ - ac--; av++; - for (i = 0, ap = av; i < ac; i++, ap++) - { - if (ap->a_type == A_FLOAT) - { - int ndx = (int)ap->a_w.w_float; - /* CHECKME noninteger, negative */ - ndx++; - if (ndx >= CAPTURE_MAXINDICES) - { - /* CHECKME complaint */ - szindices = CAPTURE_MAXINDICES; - break; - } - else if (ndx > szindices) - szindices = ndx; - } - else break; /* CHECKME */ - } - if (szindices && (indices = getbytes(szindices * sizeof(*indices)))) - { - nindices = 0; - while (i--) - { - int ndx = (int)av++->a_w.w_float; - /* CHECKME noninteger */ - if (ndx >= 0 && ndx < szindices) - indices[ndx] = 1, nindices++; - } - } - } - } - if (bufsize <= 0) /* CHECKME */ - bufsize = CAPTURE_DEFSIZE; - if ((buffer = getbytes(bufsize * sizeof(*buffer)))) - { - x = (t_capture *)pd_new(capture_class); - x->x_glist = canvas_getcurrent(); - x->x_mode = mode; - if (precision < 0) /* CHECKME */ - precision = CAPTURE_DEFPRECISION; - else if (precision > CAPTURE_MAXPRECISION) /* CHECKME */ - precision = CAPTURE_MAXPRECISION; - if ((x->x_precision = precision)) - sprintf(x->x_format, "%%.%df", precision); - x->x_indices = indices; - x->x_szindices = szindices; - x->x_nindices = nindices; - x->x_nblock = 64; /* redundant */ - x->x_buffer = buffer; - x->x_bufsize = bufsize; - x->x_filehandle = file_new((t_pd *)x, 0, 0, capture_writehook, 0); - capture_clear(x); - } - else if (indices) - freebytes(indices, szindices * sizeof(*indices)); - return (x); -} - -CYCLONE_OBJ_API void capture_tilde_setup(void) -{ - capture_class = class_new(gensym("capture~"), - (t_newmethod)capture_new, - (t_method)capture_free, - sizeof(t_capture), CLASS_DEFAULT, A_GIMME, 0); - class_addmethod(capture_class, nullfn, gensym("signal"), 0); - class_addmethod(capture_class, (t_method) capture_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(capture_class, (t_method)capture_clear, - gensym("clear"), 0); - class_addmethod(capture_class, (t_method)capture_write, - gensym("write"), A_DEFSYM, 0); - class_addmethod(capture_class, (t_method)capture_open, - gensym("open"), 0); - class_addmethod(capture_class, (t_method)capture_wclose, - gensym("wclose"), 0); - class_addmethod(capture_class, (t_method)capture_click, - gensym("click"), - A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); - file_setup(capture_class, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/cartopol.c b/Libraries/cyclone/cyclone_objects/binaries/audio/cartopol.c deleted file mode 100644 index 6947c8d126..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/cartopol.c +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include -#include "common/magicbit.h" - -typedef struct _cartopol -{ - t_object x_obj; - t_inlet *cartopol; - t_outlet *x_out2; - - t_glist *x_glist; - t_float *x_signalscalar; - t_int x_hasfeeders; -} t_cartopol; - -static t_class *cartopol_class; - -//EXTERN t_float *obj_findsignalscalar(t_object *x, int m); - -static t_int *cartopol_perform(t_int *w) -{ - t_cartopol *x = (t_cartopol *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out1 = (t_float *)(w[5]); - t_float *out2 = (t_float *)(w[6]); - - // MAGIC: poll float for error - if (!magic_isnan(*x->x_signalscalar)) - { - magic_setnan(x->x_signalscalar); - pd_error(x, "cartopol~: doesn't understand 'float'"); - } - - while (nblock--) - { - float re, im, amp, ph; - // MAGIC - if (x->x_hasfeeders) - { - re = *in1++; - im = *in2++; - amp = hypotf(re, im); - ph = atan2f(im, re); - } - else amp = ph = 0.0; - *out1++ = amp; - *out2++ = ph; - } - return (w + 7); -} - -static t_int *cartopol_perform_nophase(t_int *w) -{ - t_cartopol *x = (t_cartopol *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out1 = (t_float *)(w[5]); - - // MAGIC: poll float for error - if (!magic_isnan(*x->x_signalscalar)) - { - magic_setnan(x->x_signalscalar); - pd_error(x, "cartopol~: doesn't understand 'float'"); // i think it's this one... - } - - while (nblock--) - { - float re, im, amp; - - // MAGIC - if (x->x_hasfeeders) - { - re = *in1++; - im = *in2++; - amp = hypotf(re, im); - } - else amp = 0.0; - - *out1++ = amp; - } - return (w + 6); -} - -static void cartopol_dsp(t_cartopol *x, t_signal **sp) -{ - // MAGIC - x->x_hasfeeders = magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal); - if (magic_outlet_connections(x->x_out2)) - dsp_add(cartopol_perform, 6, x, sp[0]->s_n, sp[0]->s_vec, - sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); - else - dsp_add(cartopol_perform_nophase, 5, x, sp[0]->s_n, sp[0]->s_vec, - sp[1]->s_vec, sp[2]->s_vec); -} - -static void *cartopol_new(void) -{ - t_cartopol *x = (t_cartopol *)pd_new(cartopol_class); - inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - outlet_new((t_object *)x, &s_signal); - x->x_glist = canvas_getcurrent(); - x->x_signalscalar = obj_findsignalscalar((t_object *)x, 1); - magic_setnan(x->x_signalscalar); - x->x_out2 = outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void cartopol_tilde_setup(void) -{ - cartopol_class = class_new(gensym("cartopol~"), (t_newmethod)cartopol_new, 0, - sizeof(t_cartopol), 0, 0); - class_addmethod(cartopol_class, nullfn, gensym("signal"), 0); - class_addmethod(cartopol_class, (t_method) cartopol_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/change.c b/Libraries/cyclone/cyclone_objects/binaries/audio/change.c deleted file mode 100644 index 5dc5129bf5..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/change.c +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -typedef struct _change -{ - t_object x_obj; - t_float x_last; - t_outlet *x_outlet; -} t_change; - -static t_class *change_class; - -static void *change_new(void); -static t_int * change_perform(t_int *w); -static void change_dsp(t_change *x, t_signal **sp); -static void change_float(t_change *x, t_float f); - -static t_int *change_perform(t_int *w) -{ - t_change *x = (t_change *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - t_float last = x->x_last; - while (nblock--) - { - t_float f = *in++; - *out++ = (f > last ? 1. : (f < last ? -1. : 0.)); - last = f; - } - x->x_last = last; - return (w + 5); -} - -static void change_dsp(t_change *x, t_signal **sp) -{ - dsp_add(change_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void change_float(t_change *x, t_float f) -{ - x->x_last = f; -} - - -static void *change_new(void) -{ - t_change *x = (t_change *)pd_new(change_class); - x->x_outlet = outlet_new((t_object *)x, &s_signal); - x->x_last = 0; - return (x); -} - -CYCLONE_OBJ_API void change_tilde_setup(void) -{ - change_class = class_new(gensym("change~"), (t_newmethod)change_new, 0, - sizeof(t_change), CLASS_DEFAULT, 0); - class_addmethod(change_class, nullfn, gensym("signal"), 0); - class_addmethod(change_class, (t_method) change_dsp, gensym("dsp"), A_CANT, 0); - class_addfloat(change_class, (t_method)change_float); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/click.c b/Libraries/cyclone/cyclone_objects/binaries/audio/click.c deleted file mode 100644 index 231df53c53..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/click.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -#define CLICK_MAX_SIZE 256 - -typedef struct _click -{ - t_object x_obj; - int x_nsamples; // as used - int x_bufsize; // as allocated - t_float *x_buffer; - t_float x_bufini[CLICK_MAX_SIZE]; - int x_nleft; - t_float *x_head; -} t_click; - -static t_class *click_class; - -static void click_bang(t_click *x) -{ - x->x_nleft = x->x_nsamples; - x->x_head = x->x_buffer; -} - -static void click_set(t_click *x, t_symbol *s, int ac, t_atom *av) -{ - int i, nsamples = 0; - t_atom *ap; - t_float *bp; - for (i = 0, ap = av; i < ac; i++, ap++) - { - if (ap->a_type == A_FLOAT) nsamples++; - /* CHECKED no restrictions (refman's error about 0.0-1.0 range) - CHECKED nonnumeric atoms silently ignored */ - } - if (nsamples > CLICK_MAX_SIZE) - nsamples = CLICK_MAX_SIZE; - if (nsamples) - { - x->x_nsamples = nsamples; - bp = x->x_buffer; - while (nsamples--) *bp++ = av++->a_w.w_float; - } - else x->x_nsamples = 0; // CHECKED, needs to 'set 1' explicitly - x->x_nleft = 0; - x->x_head = x->x_buffer; -} - -static t_int *click_perform(t_int *w) -{ - t_click *x = (t_click *)(w[1]); - int nblock = (int)(w[2]); - t_float *out = (t_float *)(w[3]); - if (x->x_nleft) - { - int nleft = x->x_nleft; - t_float *head = x->x_head; - if (nleft >= nblock) - { - x->x_nleft -= nblock; - while (nblock--) *out++ = *head++; - x->x_head = head; - } - else - { - nblock -= nleft; - while (nleft--) *out++ = *head++; - while (nblock--) *out++ = 0.; - x->x_nleft = 0; - x->x_head = x->x_buffer; - } - } - else while (nblock--) *out++ = 0.; - return (w + 4); -} - -static void click_dsp(t_click *x, t_signal **sp) -{ - dsp_add(click_perform, 3, x, sp[0]->s_n, sp[0]->s_vec); -} - -static void click_free(t_click *x) -{ - if (x->x_buffer != x->x_bufini) - freebytes(x->x_buffer, x->x_bufsize * sizeof(*x->x_buffer)); -} - -static void *click_new(t_symbol *s, int ac, t_atom *av) -{ - t_click *x = (t_click *)pd_new(click_class); - x->x_nsamples = 1; // CHECKED - x->x_bufsize = CLICK_MAX_SIZE; - x->x_buffer = x->x_bufini; - x->x_buffer[0] = 1.; // CHECKED - x->x_nleft = 0; - x->x_head = x->x_buffer; - outlet_new((t_object *)x, &s_signal); - if (ac) click_set(x, 0, ac, av); - return (x); -} - -CYCLONE_OBJ_API void click_tilde_setup(void) -{ - click_class = class_new(gensym("click~"), - (t_newmethod)click_new, - (t_method)click_free, - sizeof(t_click), 0, A_GIMME, 0); - class_domainsignalin(click_class, -1); - class_addbang(click_class, click_bang); - class_addmethod(click_class, (t_method)click_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(click_class, (t_method)click_set, gensym("set"), A_GIMME, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/clip.c b/Libraries/cyclone/cyclone_objects/binaries/audio/clip.c deleted file mode 100644 index 56fd459353..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/clip.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -#define CLIP_DEFLO 0. -#define CLIP_DEFHI 0. - -typedef struct _clip { - t_object x_obj; - t_inlet *x_lolet; - t_inlet *x_hilet; -} t_clip; - -static t_class *clip_class; - -static t_int *clip_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *in3 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - while (nblock--) - { - float f = *in1++; - float lo = *in2++; - float hi = *in3++; - if (f < lo) - *out++ = lo; - else if (f > hi) - *out++ = hi; - else - *out++ = f; - } - return (w + 6); -} - -static void clip_dsp(t_clip *x, t_signal **sp) -{ - dsp_add(clip_perform, 5, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); -} - - -static void *clip_new(t_symbol *s, int argc, t_atom *argv) -{ - t_clip *x = (t_clip *)pd_new(clip_class); - - t_float cliplo, cliphi; - cliplo = CLIP_DEFLO; - cliphi = CLIP_DEFHI; - - int argnum = 0; - while(argc > 0){ - if(argv -> a_type == A_FLOAT){ - t_float argval = atom_getfloatarg(0,argc,argv); - switch(argnum){ - case 0: - cliplo = argval; - break; - case 1: - cliphi = argval; - break; - default: - break; - }; - - argc--; - argv++; - argnum++; - } - else{ - goto errstate; - }; - }; - x->x_lolet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_lolet, cliplo); - x->x_hilet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_hilet, cliphi); - - outlet_new((t_object *)x, &s_signal); - return (x); -errstate: - pd_error(x, "clip~: improper args"); - return NULL; -} - -CYCLONE_OBJ_API void clip_tilde_setup(void) -{ - clip_class = class_new(gensym("cyclone/clip~"), - (t_newmethod)clip_new, 0, sizeof(t_clip), CLASS_DEFAULT, A_GIMME, 0); - class_addmethod(clip_class, nullfn, gensym("signal"), 0); - class_addmethod(clip_class, (t_method) clip_dsp, gensym("dsp"), A_CANT, 0); - class_sethelpsymbol(clip_class, gensym("clip~")); - pd_error(clip_class, "[cyclone/clip~] is deprecated, consider using vanilla's [clip~] instead"); - -} - -CYCLONE_OBJ_API void Clip_tilde_setup(void) -{ - clip_class = class_new(gensym("Clip~"), - (t_newmethod)clip_new, 0, sizeof(t_clip), CLASS_DEFAULT, A_GIMME, 0); - class_addmethod(clip_class, nullfn, gensym("signal"), 0); - class_addmethod(clip_class, (t_method) clip_dsp, gensym("dsp"), A_CANT, 0); - class_sethelpsymbol(clip_class, gensym("clip~")); - pd_error(clip_class, "Cyclone: please use [cyclone/clip~] instead of [Clip~] to suppress this error"); - pd_error(clip_class, "[cyclone/clip~] is deprecated, consider using vanilla's [clip~] instead"); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/comb.c b/Libraries/cyclone/cyclone_objects/binaries/audio/comb.c deleted file mode 100644 index 6fc6b59672..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/comb.c +++ /dev/null @@ -1,347 +0,0 @@ -//almost complete rewrite since the previous version of Cyclone didn't implement it correctly (used only one delay buffer) -//- Derek Kwan 2016 - -#include -#include -#include "m_pd.h" -#include - -#define COMB_STACK 48000 //stack buf size, 1 sec at 48k for good measure -#define COMB_DELAY 10.0 //maximum delay -#define COMB_MIND 1 //minimum delay -#define COMB_MAXD 4294967294 //max delay = 2**32 - 2 - -#define COMB_MINMS 0. //min delay in ms - -#define COMB_DEFGAIN 0. //default gain -#define COMB_DEFFF 0. //default ff gain -#define COMB_DEFFB 0. //default fb gain - -static t_class *comb_class; - -typedef struct _comb -{ - t_object x_obj; - t_inlet *x_dellet; - t_inlet *x_alet; - t_inlet *x_blet; - t_inlet *x_clet; - t_outlet *x_outlet; - int x_sr; - //pointers to the delay bufs - double * x_ybuf; - double x_ffstack[COMB_STACK]; - double * x_xbuf; - double x_fbstack[COMB_STACK]; - int x_alloc; //if we are using allocated bufs - unsigned int x_sz; //actual size of each delay buffer - - t_float x_maxdel; //maximum delay in ms - unsigned int x_wh; //writehead -} t_comb; - -static void comb_clear(t_comb *x){ - unsigned int i; - for(i=0; ix_sz; i++){ - x->x_xbuf[i] = 0.; - x->x_ybuf[i] = 0.; - }; - x->x_wh = 0; -} - -static void comb_sz(t_comb *x){ - //helper function to deal with allocation issues if needed - //ie if wanted size x->x_maxdel is bigger than stack, allocate - - //convert ms to samps - unsigned int newsz = (unsigned int)ceil((double)x->x_maxdel*0.001*(double)x->x_sr); - newsz++; //add a sample for good measure since say bufsize is 2048 and - //you want a delay of 2048 samples,.. problem! - - int alloc = x->x_alloc; - unsigned int cursz = x->x_sz; //current size - - if(newsz < 0){ - newsz = 0; - } - else if(newsz > COMB_MAXD){ - newsz = COMB_MAXD; - }; - if(!alloc && newsz > COMB_STACK){ - x->x_xbuf = (double *)malloc(sizeof(double)*newsz); - x->x_ybuf = (double *)malloc(sizeof(double)*newsz); - x->x_alloc = 1; - x->x_sz = newsz; - } - else if(alloc && newsz > cursz){ - x->x_xbuf = (double *)realloc(x->x_xbuf, sizeof(double)*newsz); - x->x_ybuf = (double *)realloc(x->x_ybuf, sizeof(double)*newsz); - x->x_sz = newsz; - } - else if(alloc && newsz < COMB_STACK){ - free(x->x_xbuf); - free(x->x_ybuf); - x->x_sz = COMB_STACK; - x->x_xbuf = x->x_ffstack; - x->x_ybuf = x->x_fbstack; - x->x_alloc = 0; - }; - comb_clear(x); -} - - - - -static double comb_getlin(double tab[], unsigned int sz, double idx){ - //copying from my own library, linear interpolated reader - DK - double output; - unsigned int tabphase1 = (unsigned int)idx; - unsigned int tabphase2 = tabphase1 + 1; - double frac = idx - (double)tabphase1; - if(tabphase1 >= sz - 1){ - tabphase1 = sz - 1; //checking to see if index falls within bounds - output = tab[tabphase1]; - } - else if(tabphase1 < 0){ - tabphase1 = 0; - output = tab[tabphase1]; - } - else{ - double yb = tab[tabphase2]; //linear interp - double ya = tab[tabphase1]; - output = ya+((yb-ya)*frac); - - }; - return output; -} - -static double comb_readmsdelay(t_comb *x, double arr[], t_float ms){ - //helper func, basically take desired ms delay, convert to samp, read from arr[] - - //eventual reading head - double rh = (double)ms*((double)x->x_sr*0.001); //converting ms to samples - //bounds checking for minimum delay in samples - if(rh < COMB_MIND){ - rh = COMB_MIND; - }; - rh = (double)x->x_wh+((double)x->x_sz-rh); //essentially subracting from writehead to find proper position in buffer - //wrapping into length of delay buffer - while(rh >= x->x_sz){ - rh -= (double)x->x_sz; - }; - //now to read from the buffer! - double output = comb_getlin(arr, x->x_sz, rh); - return output; - -} - - - -static t_int *comb_perform(t_int *w) -{ - t_comb *x = (t_comb *)(w[1]); - int n = (int)(w[2]); - t_float *xin = (t_float *)(w[3]); - t_float *din = (t_float *)(w[4]); - t_float *ain = (t_float *)(w[5]); - t_float *bin = (t_float *)(w[6]); - t_float *cin = (t_float *)(w[7]); - t_float *out = (t_float *)(w[8]); - - int i; - for(i=0; ix_wh; - double input = (double)xin[i]; - //first off, write input to delay buf - x->x_xbuf[wh] = input; - //get delayed values of x and y - t_float delms = din[i]; - //first bounds checking - if(delms < 0){ - delms = 0; - } - else if(delms > x->x_maxdel){ - delms = x->x_maxdel; - }; - //now get those delayed vals - double delx = comb_readmsdelay(x, x->x_xbuf, delms); - double dely = comb_readmsdelay(x, x->x_ybuf, delms); - //figure out your current y term: y[n] = a*x[n] + b*x[n-d] + c*y[n-d] - double output = (double)ain[i]*input + (double)bin[i]*delx + (double)cin[i]*dely; - //stick this guy in the ybuffer and output - x->x_ybuf[wh] = output; - out[i] = output; - - //increment writehead - x->x_wh = (wh + 1) % x->x_sz; - }; - - return (w + 9); -} - -static void comb_dsp(t_comb *x, t_signal **sp) -{ - int sr = sp[0]->s_sr; - if(sr != x->x_sr){ - //if new sample rate isn't old sample rate, need to realloc - x->x_sr = sr; - comb_sz(x); - }; - dsp_add(comb_perform, 8, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, - sp[3]->s_vec, sp[4]->s_vec, sp[5]->s_vec); -} - -static void comb_list(t_comb *x, t_symbol *s, int argc, t_atom * argv){ - - - int argnum = 0; //current argument - while(argc){ - if(argv -> a_type == A_FLOAT){ - t_float curf = atom_getfloatarg(0, argc, argv); - switch(argnum){ - case 0: - //maxdel - x->x_maxdel = curf > 0 ? curf : COMB_DELAY; - comb_sz(x); - break; - case 1: - //initdel - if(curf < COMB_MINMS){ - curf = COMB_MINMS; - } - else if(curf > x->x_maxdel){ - curf = x->x_maxdel; - }; - pd_float((t_pd *)x->x_dellet, curf); - break; - case 2: - //gain - pd_float((t_pd *)x->x_alet, curf); - break; - case 3: - //ffcoeff - pd_float((t_pd *)x->x_blet, curf); - break; - case 4: - //fbcoeff - pd_float((t_pd *)x->x_clet, curf); - break; - default: - break; - }; - argnum++; - }; - argc--; - argv++; - }; - - - -} - - -static void *comb_new(t_symbol *s, int argc, t_atom * argv){ - t_comb *x = (t_comb *)pd_new(comb_class); - - //defaults - t_float maxdel = COMB_DELAY; - t_float initdel = COMB_MINMS; - t_float gain = COMB_DEFGAIN; - t_float ffcoeff = COMB_DEFFF; - t_float fbcoeff = COMB_DEFFB; - x->x_sr = sys_getsr(); - - x->x_alloc = 0; - x->x_sz = COMB_STACK; - //clear out stack bufs, set pointer to stack - x->x_ybuf = x->x_fbstack; - x->x_xbuf = x->x_ffstack; - comb_clear(x); - - int argnum = 0; //current argument - while(argc){ - if(argv -> a_type == A_FLOAT){ - t_float curf = atom_getfloatarg(0, argc, argv); - switch(argnum){ - case 0: - maxdel = curf; - break; - case 1: - initdel = curf; - break; - case 2: - gain = curf; - break; - case 3: - ffcoeff = curf; - break; - case 4: - fbcoeff = curf; - break; - default: - break; - }; - argnum++; - }; - argc--; - argv++; - }; - - - x->x_maxdel = maxdel > 0 ? maxdel : COMB_DELAY; - //ship off to the helper method to deal with allocation if necessary - comb_sz(x); - //boundschecking - //this is 1/44.1 (1/(sr*0.001) rounded up, good enough? - - if(initdel < COMB_MINMS){ - initdel = COMB_MINMS; - } - else if(initdel > x->x_maxdel){ - initdel = x->x_maxdel; - }; - - - //inlets outlets - x->x_dellet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_dellet, initdel); - x->x_alet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_alet, gain); - x->x_blet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_blet, ffcoeff); - x->x_clet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_clet, fbcoeff); - x->x_outlet = outlet_new((t_object *)x, &s_signal); - return (x); -} - - - - - -static void * comb_free(t_comb *x){ - if(x->x_alloc){ - free(x->x_xbuf); - free(x->x_ybuf); - }; - inlet_free(x->x_dellet); - inlet_free(x->x_alet); - inlet_free(x->x_blet); - inlet_free(x->x_clet); - outlet_free(x->x_outlet); - return (void *)x; -} - -CYCLONE_OBJ_API void comb_tilde_setup(void) -{ - comb_class = class_new(gensym("comb~"), - (t_newmethod)comb_new, - (t_method)comb_free, - sizeof(t_comb), 0, - A_GIMME, 0); - class_addmethod(comb_class, nullfn, gensym("signal"), 0); - class_addmethod(comb_class, (t_method)comb_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(comb_class, (t_method)comb_clear, gensym("clear"), 0); - class_addlist(comb_class, (t_method)comb_list); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/cosh.c b/Libraries/cyclone/cyclone_objects/binaries/audio/cosh.c deleted file mode 100644 index 394444d626..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/cosh.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - -typedef struct _cosh { - t_object x_obj; - t_inlet *cosh; - t_outlet *x_outlet; -} t_cosh; - -void *cosh_new(void); -static t_int * cosh_perform(t_int *w); -static void cosh_dsp(t_cosh *x, t_signal **sp); - -static t_class *cosh_class; - -static t_int *cosh_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - { - float f = *in++; - *out++ = coshf(f); /* CHECKED no protection against NaNs */ - } - return (w + 4); -} - -static void cosh_dsp(t_cosh *x, t_signal **sp) -{ - dsp_add(cosh_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -void *cosh_new(void) -{ - t_cosh *x = (t_cosh *)pd_new(cosh_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void cosh_tilde_setup(void) -{ - cosh_class = class_new(gensym("cosh~"), (t_newmethod)cosh_new, 0, - sizeof(t_cosh), CLASS_DEFAULT, 0); - class_addmethod(cosh_class, nullfn, gensym("signal"), 0); - class_addmethod(cosh_class, (t_method) cosh_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/cosx.c b/Libraries/cyclone/cyclone_objects/binaries/audio/cosx.c deleted file mode 100644 index 21d8f0e882..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/cosx.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - -typedef struct _cosx { - t_object x_obj; - t_inlet *cosx; - t_outlet *x_outlet; -} t_cosx; - -void *cosx_new(void); -static t_int * cosx_perform(t_int *w); -static void cosx_dsp(t_cosx *x, t_signal **sp); - -static t_class *cosx_class; - -static t_int *cosx_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - { - float f = *in++; - *out++ = cosf(f); /* CHECKED no protection against NaNs */ - } - return (w + 4); -} - -static void cosx_dsp(t_cosx *x, t_signal **sp) -{ - dsp_add(cosx_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -void *cosx_new(void) -{ - t_cosx *x = (t_cosx *)pd_new(cosx_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void cosx_tilde_setup(void) -{ - cosx_class = class_new(gensym("cosx~"), (t_newmethod)cosx_new, 0, - sizeof(t_cosx), CLASS_DEFAULT, 0); - class_addmethod(cosx_class, nullfn, gensym("signal"), 0); - class_addmethod(cosx_class, (t_method) cosx_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/count.c b/Libraries/cyclone/cyclone_objects/binaries/audio/count.c deleted file mode 100644 index 1fac6f0da6..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/count.c +++ /dev/null @@ -1,249 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -//updating argument parsing on object creation and adding autoreset attribute - Derek Kwan 2016 -#include -#include "m_pd.h" -#include - -#define COUNTMAXINT 0x7fffffff - -#define PDCYCMINV 0. -#define PDCYCMAXV 0. -#define PDCYCONFL 0 -#define PDCYCAUTO 0 - -typedef struct _count -{ - t_object x_obj; - t_float x_lastin; - int x_min; - int x_max; - int x_limit; - int x_on; - int x_sig; - int x_autoreset; - int x_count; /* MAYBE use 64 bits (if 13.5 hours is not enough...) */ -} t_count; - -static t_class *count_class; - -static void count_bang(t_count *x) -{ - x->x_count = x->x_min; - x->x_on = 1; -} - -static void count_min(t_count *x, t_floatarg f) -{ - x->x_min = (int)f; -} - -static void count_max(t_count *x, t_floatarg f) -{ - x->x_max = (int)f; - /* MAYBE use 64 bits */ - x->x_limit = (x->x_max == 0 ? COUNTMAXINT - : x->x_max - 1); /* CHECKED */ -} - -static void count_autoreset(t_count *x, t_floatarg f) -{ - x->x_autoreset = (f != 0); -} - -static void count_float(t_count *x, t_floatarg f) -{ - x->x_count = x->x_min = (int)f; - x->x_on = 1; -} - -static void count_list(t_count *x, t_symbol *s, int ac, t_atom *av) -{ - int i; - if (ac > 4) ac = 4; - for (i = 0; i < ac; i++) - if (av[i].a_type != A_FLOAT) break; - switch (i) - { - case 4: - count_autoreset(x, av[3].a_w.w_float); - case 3: - x->x_on = (av[2].a_w.w_float != 0); - case 2: - count_max(x, av[1].a_w.w_float); - case 1: - count_min(x, av[0].a_w.w_float); - default: - x->x_count = x->x_min; - } -} - -/* changes minimum (and optional the maximum) without changing current value */ -static void count_set(t_count *x, t_symbol *s, int ac, t_atom *av) -{ - if (ac > 0) - { - if (av[0].a_type == A_FLOAT) { - x->x_min = (int)av[0].a_w.w_float; - { - x->x_max = (int)0; - x->x_limit = (x->x_max == 0 ? COUNTMAXINT : x->x_max - 1); - } - } - } - if (ac > 1) - { - if (av[1].a_type == A_FLOAT) - { - x->x_max = (int)av[1].a_w.w_float; - x->x_limit = (x->x_max == 0 ? COUNTMAXINT - : x->x_max - 1); - } - } -} - -static void count_stop(t_count *x) -{ - if (x->x_sig) { - x->x_count = x->x_min; -// x->x_on = 1; - } - else { - x->x_count = x->x_min; - x->x_on = 0; - } -} - -static t_int *count_perform(t_int *w) -{ - t_count *x = (t_count *)(w[1]); - int nblock = (int)(w[2]); - t_float *input = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - t_float lastin = x->x_lastin; - int count = x->x_count; - int limit = x->x_limit; - while (nblock--) - { - float in = *input++; -// Updating to Max 5 functionality of signal input -// (sample accurate) triggering - if (in != 0 && lastin == 0) // turn it on - { - count = x->x_min; - x->x_on = 1; - x->x_sig = 1; - } - else if (in == 0 && lastin != 0) // turn it off - { - count = x->x_min; - x->x_on = 0; - x->x_sig = 0; - } - lastin = in; // audio triggering is working! - if (x->x_on) - { - { - if (count > limit) count = x->x_min; - *out++ = (t_float)count++; - } - } - else *out++ = count; - } - x->x_lastin = lastin; - x->x_count = count; - return (w + 5); -} - -static void count_dsp(t_count *x, t_signal **sp) -{ - if (x->x_autoreset) count_bang(x); - dsp_add(count_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void *count_new(t_symbol *s, int argc, t_atom *argv) -{ - t_count *x = (t_count *)pd_new(count_class); - x->x_lastin = 0; - t_float minval, maxval, onflag, autoflag; - minval = PDCYCMINV; - maxval = PDCYCMAXV; - onflag = PDCYCONFL; - autoflag = PDCYCAUTO; - int argnum = 0; - while(argc > 0){ - if(argv -> a_type == A_FLOAT){ - t_float argval = atom_getfloatarg(0, argc, argv); - switch(argnum){ - case 0: - minval = argval; - break; - case 1: - maxval = argval; - break; - case 2: - onflag = argval; - break; - case 3: - autoflag = argval; - break; - default: - break; - }; - argnum++; - argc--; - argv++; - } - else if(argv -> a_type == A_SYMBOL){ - t_symbol * curarg = atom_getsymbolarg(0, argc, argv); - if(strcmp(curarg->s_name, "@autoreset") == 0){ - if(argc >= 2){ - t_float argval = atom_getfloatarg(1, argc, argv); - autoflag = argval; - argc-=2; - argv+=2; - } - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - - }; - count_min(x, minval); - count_max(x, maxval); - x->x_on = (onflag != 0); - count_autoreset(x, autoflag); - x->x_count = x->x_min; - inlet_new(&x->x_obj, &x->x_obj.ob_pd,&s_float, gensym("ft1")); - outlet_new(&x->x_obj, &s_signal); - return (x); - - errstate: - pd_error(x, "count~: improper args"); - return NULL; -} - -CYCLONE_OBJ_API void count_tilde_setup(void) -{ - count_class = class_new(gensym("count~"), (t_newmethod)count_new, - 0, sizeof(t_count), 0, A_GIMME, 0); - class_domainsignalin(count_class, -1); - class_addfloat(count_class, (t_method)count_float); - class_addlist(count_class, (t_method)count_list); - class_addmethod(count_class, (t_method)count_dsp, gensym("dsp"), A_CANT, 0); - class_addbang(count_class, (t_method)count_bang); - class_addmethod(count_class, (t_method)count_max, gensym("ft1"), A_FLOAT, 0); - class_addmethod(count_class, (t_method)count_autoreset, gensym("autoreset"), A_FLOAT, 0); - class_addmethod(count_class, (t_method)count_min, gensym("min"), A_FLOAT, 0); - class_addmethod(count_class, (t_method)count_set, gensym("set"), A_GIMME, 0); - class_addmethod(count_class, (t_method)count_stop, gensym("stop"), 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/cross.c b/Libraries/cyclone/cyclone_objects/binaries/audio/cross.c deleted file mode 100644 index db20df8d12..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/cross.c +++ /dev/null @@ -1,160 +0,0 @@ -// Porres 2016 - -#define _USE_MATH_DEFINES - -#include "m_pd.h" -#include -#include - -#define PI M_PI -#define PHI ((PI/2) * (2./3)) -#define TWO_COS_PHI (2 * cosf(PHI)) -#define TWO_SIN_PHI (2 * sinf(PHI)) - -typedef struct _cross { - t_object x_obj; - t_inlet *x_inlet_freq; - t_outlet *x_out1; - t_outlet *x_out2; - t_float x_nyq; - t_float x_last_f; - t_float x_lo1_x1; - t_float x_lo1_y1; - t_float x_lo2_x1; - t_float x_lo2_x2; - t_float x_lo2_y1; - t_float x_lo2_y2; - t_float x_hi1_x1; - t_float x_hi1_y1; - t_float x_hi2_x1; - t_float x_hi2_x2; - t_float x_hi2_y1; - t_float x_hi2_y2; - } t_cross; - -static t_class *cross_class; - -void cross_clear(t_cross *x) -{ - x->x_lo1_x1 = x->x_lo2_x1 = x->x_lo2_x2 = - x->x_lo1_y1 = x->x_lo2_y1 = x->x_lo2_y2 = 0.; -} - -static t_int *cross_perform(t_int *w) -{ - t_cross *x = (t_cross *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out1 = (t_float *)(w[5]); - t_float *out2 = (t_float *)(w[6]); - t_float lo1_x1 = x->x_lo1_x1; // 1st order zero LOWPASS - t_float lo1_y1 = x->x_lo1_y1; // 1st order pole LOWPASS - t_float lo2_x1 = x->x_lo2_x1; // 2nd order zero1 LOWPASS - t_float lo2_x2 = x->x_lo2_x2; // 2nd order zero2 LOWPASS - t_float lo2_y1 = x->x_lo2_y1; // 2nd order pole1 LOWPASS - t_float lo2_y2 = x->x_lo2_y2; // 2nd order pole2 LOWPASS - t_float hi1_x1 = x->x_hi1_x1; // 1st order zero HIGHPASS - t_float hi1_y1 = x->x_hi1_y1; // 1st order pole HIGHPASS - t_float hi2_x1 = x->x_hi2_x1; // 2nd order zero1 HIGHPASS - t_float hi2_x2 = x->x_hi2_x2; // 2nd order zero2 HIGHPASS - t_float hi2_y1 = x->x_hi2_y1; // 2nd order pole1 HIGHPASS - t_float hi2_y2 = x->x_hi2_y2; // 2nd order pole2 HIGHPASS - t_float nyq = x->x_nyq; - t_float last_f = x->x_last_f; - while (nblock--) - { - float lo2_yn, lo1_yn, lo2_xn, hi2_yn, hi1_yn, hi2_xn, lo1_xn, hi1_xn, f = *in2++; - lo1_xn = hi1_xn = *in1++; - if (f < 1) f = last_f; - if (f > nyq) f = nyq; - float r = tanf((f/nyq) * (PI/2)); - last_f = f; - // poles: - float c1 = (1 - r*r) / (1 + r*r + 2*r); - float re = (1 - r*r) / (1 + r*r + r*TWO_COS_PHI); - float im = r*TWO_SIN_PHI / (1 + r*r + r*TWO_COS_PHI); - float c2 = 2*re; - float c3 = -pow(hypotf(re, im), 2); - - // start of lowpass: - float lg1 = fabsf(1 - c1) * 0.5; // gain - lo2_xn = lo1_yn = lg1*lo1_xn + lg1*lo1_x1 + c1*lo1_y1; // 1sr order section - lo1_x1 = lo1_xn; - lo1_y1 = lo1_yn; - float lg2 = (pow(re-1, 2) + pow(im, 2)) * 0.25; // gain - lo2_yn = lg2*lo2_xn + 2*lg2*lo2_x1 + lg2*lo2_x2 + c2*lo2_y1 + c3*lo2_y2; // 2nd order section - lo2_x2 = lo2_x1; - lo2_x1 = lo2_xn; - lo2_y2 = lo2_y1; - lo2_y1 = lo2_yn; - *out1++ = lo2_yn; // LOWPASS OUTPUT - - // start of highpass: - float hg1 = (c1 + 1) * 0.5; // gain - hi2_xn = hi1_yn = hg1*lo1_xn + hg1*lo1_x1 + c1*lo1_y1; // 1sr order section - hi1_x1 = hi1_xn; - hi1_y1 = hi1_yn; - float hg2 = (pow(re+1, 2) + pow(im, 2)) * 0.25; // gain - hi2_yn = hg2*hi2_xn - 2*hg2*hi2_x1 + hg2*hi2_x2 + c2*hi2_y1 + c3*hi2_y2; // 2nd order section - hi2_x2 = hi2_x1; - hi2_x1 = hi2_xn; - hi2_y2 = hi2_y1; - hi2_y1 = hi2_yn; - *out2++ = hi2_yn; // HIGHPASS OUTPUT - } - x->x_lo1_x1 = lo1_x1; - x->x_lo1_y1 = lo1_y1; - x->x_lo2_x1 = lo2_x1; - x->x_lo2_x2 = lo2_x2; - x->x_lo2_y1 = lo2_y1; - x->x_lo2_y2 = lo2_y2; - x->x_hi1_x1 = hi1_x1; - x->x_hi1_y1 = hi1_y1; - x->x_hi2_x1 = hi2_x1; - x->x_hi2_x2 = hi2_x2; - x->x_hi2_y1 = hi2_y1; - x->x_hi2_y2 = hi2_y2; - x->x_last_f = last_f; - return (w + 7); -} - - -static void cross_dsp(t_cross *x, t_signal **sp) -{ - x->x_nyq = sp[0]->s_sr / 2; - dsp_add(cross_perform, 6, x, sp[0]->s_n, sp[0]->s_vec, - sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); -} - -static void *cross_new(t_floatarg f) -{ - t_cross *x = (t_cross *)pd_new(cross_class); - x->x_inlet_freq = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet_freq, f); - x->x_out1 = outlet_new((t_object *)x, &s_signal); - x->x_out2 = outlet_new((t_object *)x, &s_signal); - x->x_lo1_x1 = 0; - x->x_lo1_y1 = 0; - x->x_lo2_x1 = 0; - x->x_lo2_x2 = 0; - x->x_lo2_y1 = 0; - x->x_lo2_y2 = 0; - x->x_hi1_x1 = 0; - x->x_hi1_y1 = 0; - x->x_hi2_x1 = 0; - x->x_hi2_x2 = 0; - x->x_hi2_y1 = 0; - x->x_hi2_y2 = 0; - x->x_last_f = 1000; - return (x); -} - -CYCLONE_OBJ_API void cross_tilde_setup(void) -{ - cross_class = class_new(gensym("cross~"), (t_newmethod)cross_new, 0, - sizeof(t_cross), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(cross_class, (t_method)cross_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(cross_class, nullfn, gensym("signal"), 0); - class_addmethod(cross_class, (t_method) cross_clear, gensym("clear"), 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/curve.c b/Libraries/cyclone/cyclone_objects/binaries/audio/curve.c deleted file mode 100644 index 461dfd5100..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/curve.c +++ /dev/null @@ -1,483 +0,0 @@ -/* Copyright (c) 2004 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - -/* CHECKED apparently c74's formula has not been carefully tuned (yet?). - It has 5% deviation from the straight line for ccinput = 0 at half-domain, - range 1, and generates nans for ccinput > .995 (cf comment in clc.h). */ - - -// updated 2016 by Derek Kwan to change arg specification to A_GIMME -// and add defaults for initial value and curve param. -// also adding factor message that calls curve_factor (new method) - - -//NOTE FOR CURVE_COEFS TRANSPLANTED FROM CLC.C - - -/* Problem: find a function f : p -> q (where p is user's curve control - parameter, q is log factor) such that the curves will bend in - a semi-linear way over the p's range of 0..1. The curve function is - then g(x, p) = (exp(f(p) * x) - 1) / (exp(f(p)) - 1), where x is - curve's domain. If, for example, the points g(0.5, p) are to make - a semi-linear pattern, then the solution is a function f that minimizes - the integral of the error function e(p) = sqr(((1-p)/2)-g(.5, p)) - over 0..1. Until someone does this analytically, we are left with - a lame formula, which has been tweaked and tested in gnuplot: - f(p) = h(p) / (1 - h(p)), where h(p) = (((p + 1e-20) * 1.2) ** .41) * .91. - The file curve.gp, in the sickle's source directory, may come handy, - in case there is anyone, who fancy tweaking it even further - (only in very old versions now, pre 0.3) - - To implement this, start from these equations: - nhops = npoints - 1 - bb * mm ^ nhops = bb + 1 - (bb ^ 2) * (mm ^ nhops) = ((exp(ff/2) - 1) / (exp(ff) - 1)) ^ 2 - - and calculate: - hh = pow(((p + c1) * c2), c3) * c4 - ff = hh / (1 - hh) - eff = exp(ff) - 1 - gh = (exp(ff * .5) - 1) / eff - bb = gh * (gh / (1 - (gh + gh))) - mm = ((exp(ff * (1/nhops)) - 1) / (eff * bb)) + 1 - - The loop is: - for (vv = bb, i = 0; i <= nhops; vv *= mm, i++) - result = (vv - bb) * (y1 - y0) + y0 - where y0, y1 are start and destination values - - This formula generates curves with < .000004% deviation from the straight - line for p = 0 at half-domain, range 1. There are no nans for -1 <= p <= 1. -*/ - - -//definitions for curve-coefs -#define CURVE_C1 1e-20 -#define CURVE_C2 1.2 -#define CURVE_C3 0.41 -#define CURVE_C4 0.91 - -#define PDCYCURVEINITVAL 0. -#define PDCYCURVEPARAM 0. -#define CURVE_MAXSIZE 42 - -typedef struct _curveseg -{ - float s_target; - float s_delta; - int s_nhops; - float s_ccinput; - double s_bb; - double s_mm; -} t_curveseg; - -typedef struct _curve -{ - t_object x_obj; - float x_value; - float x_ccinput; - float x_target; - float x_delta; - int x_deltaset; - double x_vv; - double x_bb; - double x_mm; - float x_y0; - float x_dy; - float x_ksr; - int x_nleft; - int x_retarget; - int x_size; /* as allocated */ - int x_nsegs; /* as used */ - int x_pause; - t_curveseg *x_curseg; - t_curveseg *x_segs; - t_curveseg x_segini[CURVE_MAXSIZE]; - t_clock *x_clock; - t_outlet *x_bangout; -} t_curve; - -static t_class *curve_class; -static double curve_coef; - - -static void curve_coefs(int nhops, double crv, double *bbp, double *mmp) -{ - if (nhops > 0) - { - double hh, ff, eff, gh; - if (crv < 0) - { - if (crv < -1.) - crv = -1.; - hh = pow(((CURVE_C1 - crv) * CURVE_C2), CURVE_C3) - * CURVE_C4; - ff = hh / (1. - hh); - eff = exp(ff) - 1.; - gh = (exp(ff * .5) - 1.) / eff; - *bbp = gh * (gh / (1. - (gh + gh))); - *mmp = 1. / (((exp(ff * (1. / (double)nhops)) - 1.) / - (eff * *bbp)) + 1.); - *bbp += 1.; - } - else - { - if (crv > 1.) - crv = 1.; - hh = pow(((crv + CURVE_C1) * CURVE_C2), CURVE_C3) - * CURVE_C4; - ff = hh / (1. - hh); - eff = exp(ff) - 1.; - gh = (exp(ff * .5) - 1.) / eff; - *bbp = gh * (gh / (1. - (gh + gh))); - *mmp = ((exp(ff * (1. / (double)nhops)) - 1.) / - (eff * *bbp)) + 1.; - } - } - else if (crv < 0) - *bbp = 2., *mmp = 1.; - else - *bbp = *mmp = 1.; -} - - -static void curve_cc(t_curve *x, t_curveseg *segp, float f) -{ - int nhops = segp->s_delta * x->x_ksr + 0.5; /* LATER rethink */ - segp->s_ccinput = f; - segp->s_nhops = (nhops > 0 ? nhops : 0); - curve_coefs(segp->s_nhops, (double)f, &segp->s_bb, &segp->s_mm); -} - - -static void curve_tick(t_curve *x) -{ - outlet_bang(x->x_bangout); -} - -static t_int *curve_perform(t_int *w) -{ - t_curve *x = (t_curve *)(w[1]); - t_float *out = (t_float *)(w[2]); - int nblock = (int)(w[3]); - int nxfer = x->x_nleft; - float curval = x->x_value; - double vv = x->x_vv; - double bb = x->x_bb; - double mm = x->x_mm; - float dy = x->x_dy; - float y0 = x->x_y0; - if (x->x_pause) - { - while (nblock--) *out++ = curval; - return (w + 4); - } - if (PD_BIGORSMALL(curval)) /* LATER rethink */ - curval = x->x_value = 0; -retarget: - if (x->x_retarget) - { - float target = x->x_curseg->s_target; - float delta = x->x_curseg->s_delta; - int nhops = x->x_curseg->s_nhops; - bb = x->x_curseg->s_bb; - mm = x->x_curseg->s_mm; - if (x->x_curseg->s_ccinput < 0) - dy = x->x_value - target; - else - dy = target - x->x_value; - x->x_nsegs--; - x->x_curseg++; - while (nhops <= 0) - { - curval = x->x_value = target; - if (x->x_nsegs) - { - target = x->x_curseg->s_target; - delta = x->x_curseg->s_delta; - nhops = x->x_curseg->s_nhops; - bb = x->x_curseg->s_bb; - mm = x->x_curseg->s_mm; - if (x->x_curseg->s_ccinput < 0) - dy = x->x_value - target; - else - dy = target - x->x_value; - x->x_nsegs--; - x->x_curseg++; - } - else - { - while (nblock--) *out++ = curval; - x->x_nleft = 0; - clock_delay(x->x_clock, 0); - x->x_retarget = 0; - return (w + 4); - } - } - nxfer = x->x_nleft = nhops; - x->x_vv = vv = bb; - x->x_bb = bb; - x->x_mm = mm; - x->x_dy = dy; - x->x_y0 = y0 = x->x_value; - x->x_target = target; - x->x_retarget = 0; - } - if (nxfer >= nblock) - { - int silly = ((x->x_nleft -= nblock) == 0); /* LATER rethink */ - while (nblock--) - { - *out++ = curval = (vv - bb) * dy + y0; - vv *= mm; - } - if (silly) - { - if (x->x_nsegs) x->x_retarget = 1; - else - { - clock_delay(x->x_clock, 0); - } - x->x_value = x->x_target; - } - else - { - x->x_value = curval; - x->x_vv = vv; - } - } - else if (nxfer > 0) - { - nblock -= nxfer; - do - *out++ = (vv - bb) * dy + y0, vv *= mm; - while (--nxfer); - curval = x->x_value = x->x_target; - if (x->x_nsegs) - { - x->x_retarget = 1; - goto retarget; - } - else - { - while (nblock--) *out++ = curval; - x->x_nleft = 0; - clock_delay(x->x_clock, 0); - } - } - else while (nblock--) *out++ = curval; - return (w + 4); -} - -static void curve_float(t_curve *x, t_float f) -{ - if (x->x_deltaset) - { - x->x_deltaset = 0; - x->x_target = f; - x->x_nsegs = 1; - x->x_curseg = x->x_segs; - x->x_curseg->s_target = f; - x->x_curseg->s_delta = x->x_delta; - curve_cc(x, x->x_curseg, x->x_ccinput); - x->x_retarget = 1; - } - else - { - x->x_value = x->x_target = f; - x->x_nsegs = 0; - x->x_curseg = 0; - x->x_nleft = 0; - x->x_retarget = 0; - } - x->x_pause = 0; -} - -/* CHECKED delta is not persistent, but ccinput is */ -static void curve_ft1(t_curve *x, t_floatarg f) -{ - x->x_delta = f; - x->x_deltaset = (f > 0); -} - -static void curve_list(t_curve *x, t_symbol *s, int ac, t_atom *av) -{ - int natoms, nsegs, odd; - t_atom *ap; - t_curveseg *segp; - for (natoms = 0, ap = av; natoms < ac; natoms++, ap++) - { - if (ap->a_type != A_FLOAT) - { - pd_error(x, "curve~: list needs to only contain floats"); - return; /* CHECKED */ - } - } - if (!natoms) - return; /* CHECKED */ - odd = natoms % 3; - nsegs = natoms / 3; - if (odd) nsegs++; - //clip at maxsize - if(nsegs > CURVE_MAXSIZE) - { - nsegs = CURVE_MAXSIZE; - odd = 0; - }; - x->x_nsegs = nsegs; - segp = x->x_segs; - if (odd) nsegs--; - while (nsegs--) - { - segp->s_target = av++->a_w.w_float; - segp->s_delta = av++->a_w.w_float; - curve_cc(x, segp, av++->a_w.w_float); - segp++; - } - if (odd) - { - segp->s_target = av->a_w.w_float; - if (odd > 1) - segp->s_delta = av[1].a_w.w_float; - else - segp->s_delta = 0; - curve_cc(x, segp, x->x_ccinput); - } - x->x_deltaset = 0; - x->x_target = x->x_segs->s_target; - x->x_curseg = x->x_segs; - x->x_retarget = 1; - x->x_pause = 0; -} - -static void curve_dsp(t_curve *x, t_signal **sp) -{ - float ksr = sp[0]->s_sr * 0.001; - if (ksr != x->x_ksr) - { - int nsegs = x->x_nsegs; - t_curveseg *segp = x->x_segs; - x->x_ksr = ksr; - while (nsegs--) - { - curve_cc(x, segp, segp->s_ccinput); - segp++; - } - } - dsp_add(curve_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); -} - -static void curve_factor(t_curve *x, t_float f){ - if(f < -1.){ - x->x_ccinput = -1.; - } - else if(f > 1.){ - x->x_ccinput = 1.; - } - else{ - x->x_ccinput = f; - }; - -}; - - -static void curve_stop(t_curve *x) -{ - x->x_nsegs = 0; - x->x_nleft = 0; -} - -static void curve_pause(t_curve *x) -{ - x->x_pause = 1; -} - -static void curve_resume(t_curve *x) -{ - x->x_pause = 0; -} - -static void curve_free(t_curve *x) -{ - if (x->x_segs != x->x_segini) - freebytes(x->x_segs, x->x_size * sizeof(*x->x_segs)); - if (x->x_clock) clock_free(x->x_clock); -} - -static void *curve_new(t_symbol *s, int argc, t_atom *argv) -{ - t_curve *x = (t_curve *)pd_new(curve_class); - t_float initval = PDCYCURVEINITVAL; - t_float param = PDCYCURVEPARAM; - int argnum = 0; - while(argc > 0){ - if(argv -> a_type == A_FLOAT){ - t_float argval = atom_getfloatarg(0, argc, argv); - switch(argnum){ - case 0: initval = argval; - break; - case 1: param = argval; - break; - default: - break; - }; - argnum++; - argc--; - argv++; - - } - else{ - goto errstate; - }; - - }; - - x->x_value = x->x_target = initval; - curve_factor(x, param); - x->x_deltaset = 0; - x->x_ksr = sys_getsr() * 0.001; - x->x_nleft = 0; - x->x_retarget = 0; - x->x_pause = 0; - x->x_size = CURVE_MAXSIZE; - x->x_nsegs = 0; - x->x_segs = x->x_segini; - x->x_curseg = 0; - inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); - inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("factor")); - outlet_new((t_object *)x, &s_signal); - x->x_bangout = outlet_new((t_object *)x, &s_bang); - x->x_clock = clock_new(x, (t_method)curve_tick); - return (x); - errstate: - pd_error(x, "curve~: improper args"); - return NULL; -} - -CYCLONE_OBJ_API void curve_tilde_setup(void) -{ - curve_class = class_new(gensym("curve~"), - (t_newmethod)curve_new, - (t_method)curve_free, - sizeof(t_curve), 0, - A_GIMME, 0); - class_domainsignalin(curve_class, -1); - class_addmethod(curve_class, (t_method)curve_dsp, gensym("dsp"), A_CANT, 0); - class_addfloat(curve_class, curve_float); - class_addlist(curve_class, curve_list); - class_addmethod(curve_class, (t_method)curve_ft1, - gensym("ft1"), A_FLOAT, 0); - class_addmethod(curve_class, (t_method)curve_factor, - gensym("factor"), A_FLOAT, 0); - class_addmethod(curve_class, (t_method)curve_stop, - gensym("stop"), 0); - class_addmethod(curve_class, (t_method)curve_pause, - gensym("pause"), 0); - class_addmethod(curve_class, (t_method)curve_resume, - gensym("resume"), 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/cycle.c b/Libraries/cyclone/cyclone_objects/binaries/audio/cycle.c deleted file mode 100644 index 36f8571e0e..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/cycle.c +++ /dev/null @@ -1,560 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#define _USE_MATH_DEFINES -#include -#include -#include "m_pd.h" -#include -//#include "cybuf.h" - -#define CYCYCLE_FREQ 0 -#define CYCYCLE_OFFSET 0 -#define CYCYCLE_TABSIZE 512 -#define COS_TABSIZE 16384 -#define CYCYCLE_MAX 1728000000 -typedef struct _cycle -{ - t_object x_obj; - - t_float x_freq; - double x_phase; - double x_conv; - int x_offset; //offset into window - int x_cycle_tabsize; //how far to loop - int x_user_tabsize; //user tabsize - int x_use_all; - double *x_costable; - t_float *x_usertable; - t_float x_usertable_ini[CYCYCLE_TABSIZE + 1]; - // t_cybuf *x_cybuf; - int x_nameset; //if nameset, use usertable else use costable - t_symbol * x_name; //name of buffer - int x_warn; //flag to not warn about user table on init - - t_inlet *x_phaselet; - t_outlet *x_outlet; -} t_cycle; - -static t_class *cycle_class; - - -//making the cosine table -static double *cycle_makecostab(t_cycle *x){ - /*it looks like the original sickle was rounding up from the specified table length so COS_TABSIZE - originally wasn't even reflective of the actual table size... - I've tried stepsize being twopi/(COS_TABSIZE) and also twopi/(COS_TABSIZE+1),.. in the former - case the last index would be cos(twopi) while in the latter it would be cos(twopi-1/(COS_TABSIZE+1))... - both seem to get no clicks,.. but if I make the wavetable exactly COS_TABSIZE indices,.. clicks.... - so it has to be the way the tablesize is used in the perform methods... - DXK - - Matt's comments: yes, it was rounding up in case some other object using the makecostable function - asked for something that wasn't a power of 2. - - The function from sic made a table of COS_TABSIZE+1, and made sure that the waveform was symmetric. - In order to do this, the first quarter of the wave table was generated, then the 0 in the next index, - which needs to be exactly 0 (and cos(x) doesn't guarantee that even with a precise 2.f*M_PI). Then - the first quarter is copied in reverse order with a phase reversal, and then the first half is - copied exactly, in reverse order. This ensures that the guard point is the same as the 0th point, which - is exactly 1.0. The stepsize has to be twopi/(COS_TABSIZE) to get this to work, since you want a full - cycle through the first COS_TABSIZE, and then the beginning of a new cycle at the guard point. - - One last thing - since this table is exactly the same for each instance of [cycle~], it can be moved - out and accessed in one place by all instances, as in [osc~], rather than having each instance own its - own table. This saves memory (not that it is breaking the bank), but more importantly load time. So when - we call this function it either makes the table and returns a pointer, or if it's already been made it - just returns the pointer. - */ - - static double *costable; // stays allocated as long as pd is running - - if (costable) - { - return costable; - } - double twopi = 2.0 * M_PI; - int ndx, sz = COS_TABSIZE; - int cnt = sz + 1; - costable = getbytes(cnt * sizeof(*costable)); - double *tp = costable; - int i; - double phase = 0, phsinc = twopi / sz; - if (costable) - { - i = sz/4; - while (i--) - { - *tp++ = cos(phase); - phase += phsinc; - } - *tp++ = 0; - i = sz/4; - while (i--) - { - *tp++ = -costable[i]; - } - i = sz/2; - while (i--) - { - *tp++ = costable[i]; - } - } - else - { - pd_error(x, "could not make cosine table"); - } - return costable; -} - - -static t_word *cycle_fetcharray(t_cycle * x, int * tabsz, int indsp){ - //modifying old vefl_get a bit - DXK - t_symbol * name = x->x_name; - char buf[MAXPDSTRING]; - t_symbol * chname; - int warn = x->x_warn; - if (name && name != &s_){ - t_garray *ap = (t_garray *)pd_findbyclass(name, garray_class); - if(!ap) - { - sprintf(buf, "0-%s", x->x_name->s_name); - chname = gensym(buf); - ap = (t_garray *)pd_findbyclass(chname, garray_class); - - }; - if (ap){ - int tabsize; - t_word *vec; - if (garray_getfloatwords(ap, &tabsize, &vec)){ - if (indsp) - { - garray_usedindsp(ap); - } - if (tabsz) - { - *tabsz = tabsize; - } - return (vec); - } - else - { /* always complain */ - if(warn) pd_error(x, "[cycle~]: bad template of array '%s'", name->s_name); - } - } - else if (x) - { - if(warn) pd_error(x, "[cycle~]: no such array '%s'", name->s_name); - } - } - return (0); - -} - -static void cycle_gettable(t_cycle *x) -{ - - //original allocated for array size + 1, was that for a guard point? not including for now... - //but can uncomment wantsz++ and the x->x_usertable[wantsz] = 0 lines if you want to include it - int i; - - t_word *table = 0; - int wantsz; - int warn = x->x_warn; - if (x->x_name) table = cycle_fetcharray(x, &wantsz, 1); - //wantsz++; - /* CHECKED buffer is copied */ - if (table != NULL) - { - - int cursz = x->x_user_tabsize; - int heaped = x->x_usertable != x->x_usertable_ini; - - - if(heaped && wantsz <= CYCYCLE_TABSIZE){ - //if x_value is pointing to a heap and incoming list can fit into CYCYCLE_TABSIZE - //deallocate x_value and point it to stack, update status - freebytes(x->x_usertable, (cursz) * sizeof(t_float)); - x->x_usertable = x->x_usertable_ini; - x->x_user_tabsize = CYCYCLE_TABSIZE; - } - else if(heaped && wantsz > CYCYCLE_TABSIZE && wantsz > cursz){ - //if already heaped, incoming list can't fit into CYCYCLE_TABSIZE and can't fit into allocated t_atom - //reallocate to accommodate larger list, update status - - - //bounds checking for maxsize - if(wantsz > CYCYCLE_MAX) - wantsz = CYCYCLE_MAX; - - x->x_usertable = (t_float *)resizebytes(x->x_usertable, cursz * sizeof(t_float), wantsz * sizeof(t_float)); - x->x_user_tabsize = wantsz; - } - else if(!heaped && wantsz > CYCYCLE_TABSIZE){ - //if not heaped and incoming list can't fit into CYCYCLE_TABSIZE - //allocate and update status - - - //bounds checking for maxsize - if(wantsz > CYCYCLE_MAX) - wantsz = CYCYCLE_MAX; - x->x_usertable = (t_float *)getbytes(wantsz * sizeof(t_float)); - x->x_user_tabsize = wantsz; - - }; - x->x_nameset = 1; - //now to copy contents of array into allocated array - for(i=0; i < wantsz; i++) - x->x_usertable[i] = table[i].w_float; - //x->x_usertable[wantsz] = 0; - if(x->x_use_all) x->x_cycle_tabsize = x->x_user_tabsize; - } - else - { - if (x->x_name) - { - x->x_nameset = 0; - if(warn) pd_error(x, "[cycle~]: using cosine table"); - } - //x->x_name = 0; - x->x_cycle_tabsize = COS_TABSIZE; - } -} - - - - -static void cycle_phase_reset(t_cycle *x){ - x->x_phase = 0.; -} - -static void cycle_set(t_cycle *x, t_symbol *s, t_floatarg f) -{ - x->x_use_all = 0; - x->x_offset = 0; - x->x_cycle_tabsize = CYCYCLE_TABSIZE; - if (s && s != &s_) - { - //cybuf_setarray(x->x_cybuf, s); - x->x_name = s; - x->x_offset = f < 0 ? 0 : (int)f; - cycle_gettable(x); - //x->x_nameset = 1; - - } - else{ - if(x->x_nameset > 0){ - //only reset if switching from named buffer - cycle_phase_reset(x); - }; - x->x_nameset = 0; - pd_error(x, "[cycle~]: using cosine table"); - }; - -} - -static void cycle_setall(t_cycle *x, t_symbol *s) -{ - x->x_use_all = 1; - x->x_offset = 0; - if (s && s != &s_){ - //cybuf_setarray(x->x_cybuf, s); - //x->x_nameset = 1; - x->x_name = s; - cycle_gettable(x); - } - else{ - if(x->x_nameset > 0){ - //only reset if switching from named buffer - cycle_phase_reset(x); - }; - x->x_nameset = 0; - pd_error(x, "[cycle~]: using cosine table"); - }; - -} - -static void cycle_buffer_offset(t_cycle *x, t_floatarg f) -{ - x->x_offset = f < 0 ? 0 : (int) f; -} - - -static void cycle_set_buffersize(t_cycle *x, t_floatarg f) -{ - if (f==0.) - { - x->x_use_all = 0; - x->x_cycle_tabsize = CYCYCLE_TABSIZE; - } - else if (f == -1.) - { - x->x_use_all = 1; - x->x_cycle_tabsize = x->x_user_tabsize; - } - else if (f == (1 << ilog2(f)) && f <= 65536. && f >= 16) - { - x->x_use_all = 0; - x->x_cycle_tabsize = f; - } - else - { - pd_error(x, "[cycle~]: buffer_sizeinsamps must be a power of two from 16 to 65536"); - return; - } -} - -static void cycle_buffer_sizeinsamps(t_cycle *x, t_floatarg f) -{ - - cycle_set_buffersize(x, f); -} - -static void cycle_frequency(t_cycle *x, t_floatarg f) -{ - x->x_freq = f; -} - -static void cycle_phase(t_cycle *x, t_floatarg f) -{ - f = f < 0 ? 0 : (f > 1 ? 1 : f); - pd_float((t_pd *)x->x_phaselet, f); -} - -static t_int *cycle_perform(t_int *w){ - t_cycle *x = (t_cycle *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_float *tab = x->x_usertable; - double *costab = x->x_costable; - double dphase = x->x_phase; - double conv = x->x_conv; - double wrapphase, tabphase, frac; - t_float f1, f2, freq, phaseoff, output; - double df1, df2; - int i, index; - int cycle_tabsize = x->x_cycle_tabsize; - int offset = x->x_offset; - int npts = x->x_user_tabsize; - int usetable = x->x_nameset > 0; - for (i=0; i< nblock; i++){ - freq = in1[i]; - phaseoff = in2[i]; - - wrapphase = dphase + phaseoff; - - while(wrapphase >= 1) - wrapphase -= 1.; - while(wrapphase < 0) - wrapphase += 1.; - if(usetable) - tabphase = wrapphase * cycle_tabsize; - else - tabphase = wrapphase * COS_TABSIZE; - index = (int)tabphase; - frac = tabphase - index; - if(usetable){ - f1 = (offset + index) >= npts ? 0. : tab[offset + index]; - index++; - f2 = (offset + index) >= npts ? 0. : tab[offset + index]; - output = (t_float)(f1 + frac * (f2 - f1)); - } - else{ - df1 = costab[index++]; - df2 = costab[index]; - output = (t_float) (df1 + frac * (df2 - df1)); - }; - out[i] = output; - - // incrementation step - dphase += ((double)freq * conv); - while(dphase >= 1) - dphase -= 1.; - while(dphase < 0) - dphase += 1.; - }; - x->x_phase = dphase; - return(w+6); -} - -static void cycle_dsp(t_cycle *x, t_signal **sp){ - cycle_gettable(x); - x->x_conv = 1.0 / sp[0]->s_sr; - cycle_phase_reset(x); - dsp_add(cycle_perform, 5, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -static void *cycle_new(t_symbol *s, int argc, t_atom *argv) -{ - t_cycle *x = (t_cycle *)pd_new(cycle_class); - - t_symbol * name = NULL; - t_float phaseoff, freq, offset, bufsz; - - phaseoff = 0; - freq = CYCYCLE_FREQ; - offset = CYCYCLE_OFFSET; - bufsz = CYCYCLE_TABSIZE; - int argnum = 0; - int pastargs = 0; //flag if attributes are specified, then don't accept array name anymore - int bufferattrib = 0; //flag if @buffer attribute is set; needs to default to whole buffer - int buffersizeattrib = 0; // flag if @buffer_sizeinsamps attribute is set - while(argc > 0){ - if(argv -> a_type == A_FLOAT){ - if(!pastargs){ - t_float argval = atom_getfloatarg(0, argc, argv); - switch(argnum){ - case 0: - freq = argval; - break; - case 1: - offset = argval; - break; - default: - break; - }; - argnum++; - }; - argc--; - argv++; - } - - else if(argv -> a_type == A_SYMBOL){ - t_symbol * curarg = atom_getsymbolarg(0, argc, argv); - if(strcmp(curarg->s_name, "@buffer")==0){ - if(argc >= 2){ - if((argv+1) -> a_type == A_SYMBOL){ - name = atom_getsymbolarg(1, argc, argv); - argc-=2; - argv+=2; - pastargs = 1; - bufferattrib = 1; - } - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - } - else if(strcmp(curarg->s_name, "@buffer_offset")==0){ - if(argc >= 2){ - offset = atom_getfloatarg(1, argc, argv); - argc-=2; - argv+=2; - pastargs = 1; - } - else{ - goto errstate; - }; - } - else if(strcmp(curarg->s_name, "@buffer_sizeinsamps")==0){ - if(argc >= 2){ - bufsz = atom_getfloatarg(1, argc, argv); - argc-=2; - argv+=2; - pastargs = 1; - if(bufsz > 0) buffersizeattrib = 1; - } - else{ - goto errstate; - }; - } - else if(strcmp(curarg->s_name, "@phase")==0){ - if(argc >= 2){ - phaseoff = atom_getfloatarg(1, argc, argv); - argc-=2; - argv+=2; - pastargs = 1; - } - else{ - goto errstate; - }; - } - else if(strcmp(curarg->s_name, "@frequency")==0){ - if(argc >= 2){ - freq = atom_getfloatarg(1, argc, argv); - argc-=2; - argv+=2; - pastargs = 1; - } - else{ - goto errstate; - }; - } - else if(!pastargs){ - //specifying buffer name through argt - name = curarg; - argc--; - argv++; - } - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - }; - - x->x_costable = cycle_makecostab(x); - x->x_phaselet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - cycle_phase(x, phaseoff); - - x->x_outlet = outlet_new(&x->x_obj, gensym("signal")); - if(offset < 0) offset = 0; - x->x_offset = offset; - x->x_nameset = name ? 1 : 0; - //x->x_cybuf = cybuf_init((t_class *)x, name, 1, 0); - x->x_usertable = x->x_usertable_ini; - x->x_user_tabsize = CYCYCLE_TABSIZE; - x->x_warn = 0; - if(x->x_nameset == 1) - cycle_set(x, name, offset); - x->x_warn = 1; - x->x_freq = freq; - x->x_phase = 0; - x->x_conv = 0.; - cycle_set_buffersize(x, bufsz); - if(bufferattrib && !buffersizeattrib) x->x_use_all = 1; - return (x); - errstate: - pd_error(x, "[cycle~]: improper args"); - return NULL; -} - -static void *cycle_free(t_cycle *x) -{ - //cybuf_free(x->x_cybuf); - if (x->x_usertable != x->x_usertable_ini) - freebytes(x->x_usertable, (x->x_user_tabsize + 1) * sizeof(*x->x_usertable)); - //free(x->x_costable); - outlet_free(x->x_outlet); - inlet_free(x->x_phaselet); - return (void *)x; -} - -CYCLONE_OBJ_API void cycle_tilde_setup(void) -{ - cycle_class = class_new(gensym("cycle~"), (t_newmethod)cycle_new, (t_method)cycle_free, - sizeof(t_cycle), 0, A_GIMME, 0); - CLASS_MAINSIGNALIN(cycle_class, t_cycle, x_freq); - class_addmethod(cycle_class, (t_method)cycle_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(cycle_class, (t_method)cycle_set,gensym("set"), - A_DEFSYMBOL, A_DEFFLOAT, 0); - class_addmethod(cycle_class, (t_method)cycle_setall, gensym("buffer"), - A_DEFSYMBOL, 0); - class_addmethod(cycle_class, (t_method)cycle_buffer_offset,gensym("buffer_offset"), - A_DEFFLOAT, 0); - class_addmethod(cycle_class, (t_method)cycle_buffer_sizeinsamps,gensym("buffer_sizeinsamps"), - A_DEFFLOAT, 0); - class_addmethod(cycle_class, (t_method)cycle_setall,gensym("setall"), - A_DEFSYMBOL, 0); - class_addmethod(cycle_class, (t_method)cycle_frequency, gensym("frequency"), A_DEFFLOAT, 0); - class_addmethod(cycle_class, (t_method)cycle_phase, gensym("phase"), A_DEFFLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/dbtoa.c b/Libraries/cyclone/cyclone_objects/binaries/audio/dbtoa.c deleted file mode 100644 index 1d18094eb0..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/dbtoa.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (c) 2016 Marco Matteo Markidis - mm.markidis@gmail.com - - For information on usage and redistribution, and for a DISCLAIMER OF ALL - WARRANTIES, see the file, "LICENSE.txt," in this distribution. - - Made while listening: - Evan Parker Electro-Acoustic Ensemble -- Hasselt -*/ -#include "m_pd.h" -#include -#include - -static t_class *dbtoa_class; - -typedef struct _dbtoa { - t_object x_obj; - t_inlet *x_inlet; - t_outlet *x_outlet; -} t_dbtoa; - -static t_int * dbtoa_perform(t_int *w) -{ - t_dbtoa *x = (t_dbtoa *)(w[1]); - int n = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - - while(n--) - *out++ = pow(10.,*in++/20); - return (w + 5); -} - - -static void dbtoa_dsp(t_dbtoa *x, t_signal **sp) -{ - dsp_add(dbtoa_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void *dbtoa_new(void) -{ - t_dbtoa *x = (t_dbtoa *)pd_new(dbtoa_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - return (void *)x; -} - -CYCLONE_OBJ_API void dbtoa_tilde_setup(void) { - dbtoa_class = class_new(gensym("dbtoa~"), - (t_newmethod) dbtoa_new, - 0, - sizeof (t_dbtoa), - CLASS_DEFAULT, - 0); - class_addmethod(dbtoa_class, nullfn, gensym("signal"), 0); - class_addmethod(dbtoa_class, (t_method) dbtoa_dsp, gensym("dsp"), A_CANT, 0); -} - diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/degrade.c b/Libraries/cyclone/cyclone_objects/binaries/audio/degrade.c deleted file mode 100644 index d86d32aa29..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/degrade.c +++ /dev/null @@ -1,101 +0,0 @@ -// Porres 2016 - -#include "m_pd.h" -#include -#include - -#define SR_DEF 1.f -#define BIT_DEF 24.f - -static t_class *degrade_class; - - -typedef struct _degrade -{ - t_object x_obj; - t_float x_phase; - t_float x_lastout; - t_float sr_val; - t_float bit_val; - t_inlet *x_ratio_inlet; - t_inlet *x_bitdepth_inlet; - t_outlet *x_outlet; -} t_degrade; - - -static t_int *degrade_perform(t_int *w) -{ - t_degrade *x = (t_degrade *)(w[1]); - int nblock = (t_int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *in3 = (t_float *)(w[5]); - t_float *out = (t_float *)(w[6]); - t_float phase = x->x_phase; - t_float lastout = x->x_lastout; - while (nblock--) - { - float input = *in1++; - float bit = *in3++; - float steps = pow(2, (bit > 24. ? 24. : bit < 1. ? 1. : bit)) / 2; - if (input > 0) input = ((int)(input * steps)) / steps; - else input = (((int)(input * steps)) / steps) - (1 / steps); - float phase_step = *in2++; - if (phase_step > 1.) phase_step = 1.; - if (phase_step < 0.) phase_step = 0.; - if (phase >= 1.) lastout = input; - *out++ = lastout; - phase = fmod(phase, 1.) + phase_step; - } - x->x_phase = phase; - x->x_lastout = lastout; - return (w + 7); -} - - -static void degrade_dsp(t_degrade *x, t_signal **sp) -{ - dsp_add(degrade_perform, 6, x, sp[0]->s_n, sp[0]->s_vec, - sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); -} - -static void *degrade_free(t_degrade *x){ - inlet_free(x->x_ratio_inlet); - inlet_free(x->x_bitdepth_inlet); - outlet_free(x->x_outlet); - return (void *)x; -} - -static void *degrade_new(t_symbol *s, int argc, t_atom *argv){ //two optional args: sr, bits - t_degrade *x = (t_degrade *)pd_new(degrade_class); - x->sr_val = SR_DEF; - x->bit_val = BIT_DEF; - switch(argc){ - default: - case 2: - x->bit_val = atom_getfloat(argv+1); - (x->bit_val > 24. ? 24. : (x->bit_val < 1. ? 1. : x->bit_val)); - case 1: - x->sr_val = atom_getfloat(argv); - (x->sr_val > 1. ? 1. : (x->sr_val < 0. ? 0. : x->sr_val)); - break; - case 0: - break; - } - x->x_ratio_inlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - x->x_bitdepth_inlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - pd_float( (t_pd *) x->x_ratio_inlet, x->sr_val); - pd_float( (t_pd *) x->x_bitdepth_inlet, x->bit_val); - x->x_outlet = outlet_new(&x->x_obj, gensym("signal")); - x->x_lastout = 0; - x->x_phase = 0; - return (x); -} - -CYCLONE_OBJ_API void degrade_tilde_setup(void) -{ - degrade_class = class_new(gensym("degrade~"), (t_newmethod)degrade_new, (t_method)degrade_free, - sizeof(t_degrade), CLASS_DEFAULT, A_GIMME, 0); - class_addmethod(degrade_class, nullfn, gensym("signal"), 0); - class_addmethod(degrade_class, (t_method)degrade_dsp, gensym("dsp"), A_CANT, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/delay.c b/Libraries/cyclone/cyclone_objects/binaries/audio/delay.c deleted file mode 100644 index 9cf0fa7e16..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/delay.c +++ /dev/null @@ -1,332 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include -#include "common/magicbit.h" -#include - -#define DELAY_DEFMAXSIZE 512 // default buffer size -#define DELAY_GUARD 4 // guard points for 4-point interpolation -#define DELAY_EXTRA 1 // one sample extra delay for 4-point interpolation - - -typedef struct _delay -{ - t_object x_obj; - t_glist *x_glist; - t_inlet *x_inlet; - t_float *x_buf; - t_float *x_bufend; - t_float *x_whead; - int x_sr; //sample rate - int x_maxsize; // buffer size in samples - int x_maxsofar; // largest maxsize so far - int x_delsize; // current delay in samples - int x_prevdelsize; // previous delay in samples - t_float x_ramplength; // length of ramp in ms - double x_rampinc; // samplewise ramp increment - double x_rampvals[2]; // current ramp scalar values [0] current [1] previous - int x_remain; // number of samples remaining in ramp - int x_hasfeeders; // true if right inlet has signal input - t_float x_bufini[DELAY_DEFMAXSIZE + 2*DELAY_GUARD - 1]; // default stack buffer -} t_delay; - -static t_class *delay_class; - - - -static void delay_clear(t_delay *x) -{ -// int i; -// for (i = 0; i < x->x_maxsize; i++) { -// x->x_buf[i] = 0; - memset(x->x_buf, 0, (x->x_maxsize + 2*DELAY_GUARD - 1) * sizeof(*x->x_buf)); - -} - -static void delay_bounds(t_delay *x) -{ - if (x->x_hasfeeders) - { - x->x_whead = x->x_buf + DELAY_GUARD - 1; - x->x_bufend = x->x_buf + x->x_maxsize + 2*DELAY_GUARD - 1; - } - else - { - x->x_whead = x->x_buf; - x->x_bufend = x->x_buf + x->x_maxsize; - } -} - -static void delay_maxsize(t_delay *x, t_float f) -{ -// int maxsize = x->x_maxsize = (f > 1 ? (int)f : 1); -// t_float *buf = (t_float *)getbytes(maxsize * sizeof(*buf)); -// if (x->x_delsize > x->x_maxsize) -// x->x_delsize = x->x_maxsize; -// x->x_buf = x->x_whead = buf; -// x->x_bufend = buf + maxsize - 1; -int maxsize = (f < 1 ? 1 : (int)f); -if (maxsize > x->x_maxsofar) -{ - x->x_maxsofar = maxsize; - if (x->x_buf == x->x_bufini) - { - if (!(x->x_buf = (t_float *)getbytes((maxsize + 2*DELAY_GUARD - 1) * sizeof(*x->x_buf)))) - { - x->x_buf = x->x_bufini; - x->x_maxsize = DELAY_DEFMAXSIZE; - pd_error(x, "unable to resize buffer; using size %d", DELAY_DEFMAXSIZE); - } - } - else if (x->x_buf) - { - if (!(x->x_buf = (t_float *)resizebytes(x->x_buf, - (x->x_maxsize + 2*DELAY_GUARD - 1) * sizeof(*x->x_buf), - (maxsize + 2*DELAY_GUARD - 1) * sizeof(*x->x_buf)))) - { - x->x_buf = x->x_bufini; - x->x_maxsize = DELAY_DEFMAXSIZE; - pd_error(x, "unable to resize buffer; using size %d", DELAY_DEFMAXSIZE); - } - } -} -x->x_maxsize = maxsize; -if (x->x_delsize > maxsize) - x->x_delsize = maxsize; -x->x_remain = 0; -delay_clear(x); -delay_bounds(x); -} - - -static void delay_delay(t_delay *x, t_floatarg f) -{ - x->x_prevdelsize = x->x_delsize; - x->x_delsize = (f > 0 ? (int)f : 0); - if (x->x_delsize > x->x_maxsize) - x->x_delsize = x->x_maxsize; - x->x_remain = (int)(x->x_ramplength * x->x_sr * 0.001); - x->x_rampinc = (double)(1.0)/(double)(x->x_remain); - x->x_rampvals[0] = 0.0; /*current*/ - x->x_rampvals[1] = 1.0; /*previous*/ -} - -static void delay_ramp(t_delay *x, t_floatarg f) -{ - x->x_ramplength = (f < 0. ? 0. : f); -} - -static t_int *delay_perform(t_int *w) -{ - t_delay *x = (t_delay *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_float *buf = x->x_buf; - t_float *ep = x->x_bufend; - t_float *wp = x->x_whead; - int maxsize = x->x_maxsize; - - if (*in2 != x->x_delsize && !x->x_remain) - { - delay_delay(x, *in2); - } - - int nleft = x->x_remain; - if (nleft) - { - double incr = x->x_rampinc; - double currramp = x->x_rampvals[0]; - double prevramp = x->x_rampvals[1]; - t_float *prevrp = wp - x->x_prevdelsize; - t_float *currrp = wp - x->x_delsize; - if (prevrp < buf) prevrp += maxsize + 1; - if (currrp < buf) currrp += maxsize + 1; - - if (nleft > nblock) - { - nleft -= nblock; - while (nblock--) - { - t_sample f = *in1++; - if (PD_BIGORSMALL(f)) - f = 0.; - currramp += incr; - prevramp -= incr;*wp = f; - *out++ = (t_float)(*prevrp * prevramp + *currrp * currramp); - if (prevrp++ == ep) prevrp = buf; - if (currrp++ == ep) currrp = buf; - if (wp++ == ep) wp = buf; - } - } - else - { - while (nleft) - { - nleft--; - nblock--; - t_sample f = *in1++; - if (PD_BIGORSMALL(f)) - f = 0.; - currramp += incr; - prevramp -= incr; - *wp = f; - *out++ = (t_float)(*prevrp * prevramp + *currrp * currramp); - if (prevrp++ == ep) prevrp = buf; - if (currrp++ == ep) currrp = buf; - if (wp++ == ep) wp = buf; - } - while (nblock--) - { - t_sample f = *in1++; - if (PD_BIGORSMALL(f)) - f = 0.; - *wp = f; - *out++ = *currrp; - if (currrp++ == ep) currrp = buf; - if (wp++ == ep) wp = buf; - } - } /* end else */ - x->x_rampvals[0] = currramp; - x->x_rampvals[1] = prevramp; - x->x_remain = nleft; - } - else if (x->x_delsize) - { - t_float *rp = wp - x->x_delsize; - if (rp < buf) rp += maxsize + 1; - while (nblock--) - { - t_sample f = *in1++; - if (PD_BIGORSMALL(f)) - f = 0.; - *out++ = *rp; - *wp = f; - if (rp++ == ep) rp = buf; - if (wp++ == ep) wp = buf; - } - } - else while (nblock--) - { - t_sample f = *in1++; - if (PD_BIGORSMALL(f)) - f = 0.; - *out++ = *wp = f; - if (wp++ == ep) wp = buf; - } - x->x_whead = wp; - return (w + 6); -} - -static t_int *delay_performsig(t_int *w) -{ - t_delay *x = (t_delay *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_float *buf = x->x_buf; - t_float *bp = x->x_buf + DELAY_GUARD - 1; - t_float *ep = x->x_bufend; - t_float *wp = x->x_whead; - int maxsize = x->x_maxsize; - t_float *rp; - - while (nblock--) - { - t_sample f, del, frac, a, b, c, d, cminusb; - int idel; - f = *in1++; - if (PD_BIGORSMALL(f)) - f = 0.; - *wp = f; - del = *in2++; - del = (del > 0. ? del : 0.); - del = (del < maxsize ? del : maxsize); - idel = (int)del; - frac = del - (t_sample)idel; - rp = wp - idel; - if (rp < bp) - rp += (maxsize + DELAY_GUARD); - d = rp[-3]; - c = rp[-2]; - b = rp[-1]; - a = rp[0]; - cminusb = c-b; - *out++ = b + frac * ( - cminusb - 0.1666667f * (1.-frac) * ( - (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b) - ) - ); - if (++wp == ep) - { - buf[0] = wp[-3]; - buf[1] = wp[-2]; - buf[2] = wp[-1]; - wp = bp; - } - } - x->x_whead = wp; - return (w + 6); -} - -static void delay_dsp(t_delay *x, t_signal **sp) -{ - //memset(x->x_buf, 0, x->x_maxsize * sizeof(*x->x_buf)); /* CHECKED */ - x->x_hasfeeders = magic_inlet_connection(&x->x_obj, x->x_glist, 1, &s_signal); - x->x_sr = sp[0]->s_sr; - x->x_remain = 0; - delay_clear(x); - delay_bounds(x); - if (x->x_hasfeeders) - { - dsp_add(delay_performsig, 5, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); - } - else - { - dsp_add(delay_perform, 5, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); - } -} - -static void *delay_new(t_floatarg f1, t_floatarg f2) -{ - t_delay *x; - //t_float *buf = (t_float *)getbytes(maxsize * sizeof(*buf)); - //if (!buf) - //return (0); - x = (t_delay *)pd_new(delay_class); - int maxsize = (f1 > 0 ? (int)f1 : DELAY_DEFMAXSIZE); - x->x_maxsize = x->x_maxsofar = DELAY_DEFMAXSIZE; - x->x_buf = x->x_whead = x->x_bufini; - delay_maxsize(x, maxsize); - x->x_delsize = (f2 > 0 ? (int)f2 : 0); - if (x->x_delsize > maxsize) - x->x_delsize = maxsize; - x->x_glist = canvas_getcurrent(); - pd_float((t_pd *)inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal), x->x_delsize); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -static void delay_free(t_delay *x) -{ - if (x->x_buf != x->x_bufini) freebytes(x->x_buf, x->x_maxsofar * sizeof(*x->x_buf)); -} - -CYCLONE_OBJ_API void delay_tilde_setup(void) -{ - delay_class = class_new(gensym("delay~"), - (t_newmethod)delay_new, (t_method)delay_free, - sizeof(t_delay), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(delay_class, nullfn, gensym("signal"), 0); - class_addmethod(delay_class, (t_method)delay_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(delay_class, (t_method)delay_clear, - gensym("clear"), 0); - class_addmethod(delay_class, (t_method)delay_ramp, - gensym("ramp"), A_FLOAT, 0); - class_addmethod(delay_class, (t_method)delay_maxsize, gensym("maxsize"), A_DEFFLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/delta.c b/Libraries/cyclone/cyclone_objects/binaries/audio/delta.c deleted file mode 100644 index 3584e39f50..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/delta.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -typedef struct _delta -{ - t_object x_obj; - t_inlet *delta; - t_outlet *x_outlet; - t_float x_last; -} t_delta; - -static t_class *delta_class; - -static t_int *delta_perform(t_int *w) -{ - t_delta *x = (t_delta *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - t_float last = x->x_last; - while (nblock--) - { - t_float f = *in++; - *out++ = f - last; - last = f; - } - x->x_last = last; - return (w + 5); -} - -static void delta_dsp(t_delta *x, t_signal **sp) -{ - dsp_add(delta_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void *delta_new(void) -{ - t_delta *x = (t_delta *)pd_new(delta_class); - x->x_outlet = outlet_new(&x->x_obj, &s_signal); - x->x_last = 0; - return (x); -} - -CYCLONE_OBJ_API void delta_tilde_setup(void) -{ - delta_class = class_new(gensym("delta~"), - (t_newmethod)delta_new, 0, - sizeof(t_delta), CLASS_DEFAULT, 0); - class_addmethod(delta_class, nullfn, gensym("signal"), 0); - class_addmethod(delta_class, (t_method) delta_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/deltaclip.c b/Libraries/cyclone/cyclone_objects/binaries/audio/deltaclip.c deleted file mode 100644 index e23c9334d7..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/deltaclip.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ -// updated 2016 by Derek Kwan and 2021 by porres - -#include "m_pd.h" -#include - -typedef struct _deltaclip{ - t_object x_obj; - t_float x_last; - t_inlet *x_lolet; - t_inlet *x_hilet; -}t_deltaclip; - -static t_class *deltaclip_class; - -static t_int *deltaclip_perform(t_int *w){ - t_deltaclip *x = (t_deltaclip *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *in3 = (t_float *)(w[5]); - t_float *out = (t_float *)(w[6]); - t_float last = x->x_last; - while(nblock--){ - float f = *in1++; - float delta = f - last; - float lo = *in2++; - if(lo > 0) - lo = 0; - float hi = *in3++; - if(hi < 0) - hi = 0; - if(delta < lo) - f = last + lo; - else if (delta > hi) - f = last + hi; - *out++ = last = f; - } - x->x_last = last; - return(w+7); -} - -static void deltaclip_dsp(t_deltaclip *x, t_signal **sp){ - dsp_add(deltaclip_perform, 6, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); -} - -static void deltaclip_reset(t_deltaclip *x){ - x->x_last = 0; -} - -static void *deltaclip_free(t_deltaclip *x){ - inlet_free(x->x_lolet); - inlet_free(x->x_hilet); - return(void *)x; -} - -static void *deltaclip_new(t_symbol *s, int argc, t_atom *argv){ - t_deltaclip *x = (t_deltaclip *)pd_new(deltaclip_class); - t_float cliplo = 0, cliphi = 0; - int argnum = 0; - while(argc > 0){ - if(argv -> a_type == A_FLOAT){ - t_float argval = atom_getfloatarg(0,argc,argv); - switch(argnum){ - case 0: - cliplo = argval; - break; - case 1: - cliphi = argval; - break; - default: - break; - }; - argc--; - argv++; - argnum++; - } - else{ - goto errstate; - }; - }; - x->x_lolet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_lolet, cliplo); - x->x_hilet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_hilet, cliphi); - outlet_new((t_object *)x, &s_signal); - x->x_last = 0; - return(x); - errstate: - pd_error(x, "deltaclip~: improper args"); - return(NULL); -} - -CYCLONE_OBJ_API void deltaclip_tilde_setup(void){ - deltaclip_class = class_new(gensym("deltaclip~"), (t_newmethod)deltaclip_new, - (t_method)deltaclip_free, sizeof(t_deltaclip), 0, A_GIMME, 0); - class_addmethod(deltaclip_class, nullfn, gensym("signal"), 0); - class_addmethod(deltaclip_class, (t_method)deltaclip_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(deltaclip_class, (t_method)deltaclip_reset, gensym("reset"), 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/downsamp.c b/Libraries/cyclone/cyclone_objects/binaries/audio/downsamp.c deleted file mode 100644 index 2d034231cc..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/downsamp.c +++ /dev/null @@ -1,76 +0,0 @@ -// Porres 2016 - -#include -#include "m_pd.h" -#include - -static t_class *downsamp_class; - -typedef struct _downsamp -{ - t_object x_obj; - t_float x_phase; - t_float x_lastout; - t_inlet *x_inlet; -} t_downsamp; - -static t_int *downsamp_perform(t_int *w) -{ - t_downsamp *x = (t_downsamp *)(w[1]); - int nblock = (t_int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_float phase = x->x_phase; - t_float lastout = x->x_lastout; -while (nblock--) -{ - float input = *in1++; - float phase_step; - float samples = *in2++; - phase_step = 1. / (samples > 1. ? samples : 1.); - if (phase >= 1.) - lastout = input; - *out++ = lastout; - phase = fmod(phase, 1.) + phase_step; -} -x->x_phase = phase; -x->x_lastout = lastout; -return (w + 6); -} - -static void downsamp_dsp(t_downsamp *x, t_signal **sp) -{ - dsp_add(downsamp_perform, 5, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -static void *downsamp_free(t_downsamp *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -static void *downsamp_new(t_floatarg f) -{ - t_downsamp *x = (t_downsamp *)pd_new(downsamp_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, (f > 1. ? f : 1.)); - outlet_new((t_object *)x, &s_signal); - x->x_lastout = 0; - x->x_phase = 0; - return (x); -} - -CYCLONE_OBJ_API void downsamp_tilde_setup(void) -{ - downsamp_class = class_new(gensym("downsamp~"), - (t_newmethod)downsamp_new, - (t_method)downsamp_free, - sizeof(t_downsamp), - CLASS_DEFAULT, - A_DEFFLOAT, - 0); - class_addmethod(downsamp_class, nullfn, gensym("signal"), 0); - class_addmethod(downsamp_class, (t_method)downsamp_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/edge.c b/Libraries/cyclone/cyclone_objects/binaries/audio/edge.c deleted file mode 100644 index fce239f596..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/edge.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -typedef struct _edge -{ - t_object x_obj; - t_inlet *edge; - t_outlet *x_outlet; - t_float x_last; - int x_zeroleft; - int x_zerohit; - t_outlet *x_out2; - t_clock *x_clock; -} t_edge; - -static t_class *edge_class; - -static void edge_tick(t_edge *x) -{ /* CHECKED both may fire simultaneously */ - if (x->x_zeroleft) - { - outlet_bang(((t_object *)x)->ob_outlet); - x->x_zeroleft = 0; - } - if (x->x_zerohit) - { - outlet_bang(x->x_out2); - x->x_zerohit = 0; - } -} - -static t_int *edge_perform(t_int *w) -{ - t_edge *x = (t_edge *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float last = x->x_last; - while (nblock--) - { - float f = *in++; - if (last == 0.) - { - if (f != 0.) - { - x->x_zeroleft = 1; - if (x->x_zerohit) - { - clock_delay(x->x_clock, 0); - x->x_last = in[nblock - 1]; - return (w + 4); - } - } - } - else - { - if (f == 0.) - { - x->x_zerohit = 1; - if (x->x_zeroleft) - { - clock_delay(x->x_clock, 0); - x->x_last = in[nblock - 1]; - return (w + 4); - } - } - } - last = f; - } - if (x->x_zeroleft || x->x_zerohit) clock_delay(x->x_clock, 0); - x->x_last = last; - return (w + 4); -} - -static void edge_dsp(t_edge *x, t_signal **sp) -{ - dsp_add(edge_perform, 3, x, sp[0]->s_n, sp[0]->s_vec); -} - -static void edge_free(t_edge *x) -{ - if (x->x_clock) clock_free(x->x_clock); -} - -static void *edge_new(void) -{ - t_edge *x = (t_edge *)pd_new(edge_class); - x->x_last = 0.; /* CHECKED fires at startup */ - x->x_zeroleft = x->x_zerohit = 0; - x->x_outlet = outlet_new((t_object *)x, &s_bang); - x->x_out2 = outlet_new((t_object *)x, &s_bang); - x->x_clock = clock_new(x, (t_method)edge_tick); - return (x); -} - -CYCLONE_OBJ_API void edge_tilde_setup(void) -{ - edge_class = class_new(gensym("edge~"), - (t_newmethod)edge_new, - (t_method)edge_free, - sizeof(t_edge), CLASS_DEFAULT, 0); - class_addmethod(edge_class, nullfn, gensym("signal"), 0); - class_addmethod(edge_class, (t_method) edge_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/equals.c b/Libraries/cyclone/cyclone_objects/binaries/audio/equals.c deleted file mode 100644 index 11b6d7e26e..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/equals.c +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2016 Porres. - -#include "m_pd.h" -#include - -static t_class *equals_class; - -typedef struct _equals -{ - t_object x_obj; - t_inlet *x_inlet; -} t_equals; - -static t_int *equals_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f1 == f2); - } - return (w + 5); -} - -static void equals_dsp(t_equals *x, t_signal **sp) -{ - dsp_add(equals_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -// FREE -static void *equals_free(t_equals *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -static void *equals_new(t_floatarg f) -{ - t_equals *x = (t_equals *)pd_new(equals_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void equals_tilde_setup(void) -{ - equals_class = class_new(gensym("equals~"), - (t_newmethod)equals_new, - (t_method)equals_free, - sizeof(t_equals), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(equals_class, nullfn, gensym("signal"), 0); - class_addmethod(equals_class, (t_method)equals_dsp, gensym("dsp"), A_CANT, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/frameaccum.c b/Libraries/cyclone/cyclone_objects/binaries/audio/frameaccum.c deleted file mode 100644 index ff1076acd7..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/frameaccum.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#define _USE_MATH_DEFINES -#include -#include "m_pd.h" -#include -#include "common/grow.h" - -#define FRAMEACCUM_INISIZE 512 -#define TWO_PI (M_PI * 2.) - -typedef struct _frameaccum{ - t_object x_obj; - t_inlet *frameaccum; - int x_size; - int x_wrapFlag; - t_float *x_frame; - t_float x_frameini[FRAMEACCUM_INISIZE]; -}t_frameaccum; - -static t_class *frameaccum_class; - -static t_int *frameaccum_perform(t_int *w){ - int nblock = (int)(w[1]); - t_frameaccum *x = (t_frameaccum *)(w[2]); - t_float *frame = x->x_frame; - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - if(x->x_wrapFlag){ - while (nblock--){ - *frame += *in++; - double dnorm = *frame + M_PI; - if (dnorm < 0) - *frame = M_PI - fmod(-dnorm, TWO_PI); - else - *frame = fmod(dnorm, TWO_PI) - M_PI; - *out++ = *frame++; - } - } - else{ - while(nblock--) - *out++ = (*frame++ += *in++); - } - return(w+5); -} - -static void frameaccum_dsp(t_frameaccum *x, t_signal **sp){ - int nblock = sp[0]->s_n; - if(nblock > x->x_size){ - x->x_frame = grow_nodata(&nblock, &x->x_size, x->x_frame, - FRAMEACCUM_INISIZE, x->x_frameini, sizeof(*x->x_frame)); - } - memset(x->x_frame, 0, nblock * sizeof(*x->x_frame)); /* CHECKED */ - dsp_add(frameaccum_perform, 4, nblock, x, sp[0]->s_vec, sp[1]->s_vec); -} - -static void frameaccum_free(t_frameaccum *x) -{ - if (x->x_frame != x->x_frameini) - freebytes(x->x_frame, x->x_size * sizeof(*x->x_frame)); -} - -static void *frameaccum_new(t_floatarg f) -{ - t_frameaccum *x = (t_frameaccum *)pd_new(frameaccum_class); - x->x_wrapFlag = f != 0; - int size; - x->x_size = FRAMEACCUM_INISIZE; - x->x_frame = x->x_frameini; - if ((size = sys_getblksize()) > FRAMEACCUM_INISIZE) - x->x_frame = grow_nodata(&size, &x->x_size, x->x_frame, - FRAMEACCUM_INISIZE, x->x_frameini, sizeof(*x->x_frame)); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void frameaccum_tilde_setup(void) -{ - frameaccum_class = class_new(gensym("frameaccum~"), - (t_newmethod)frameaccum_new, - (t_method)frameaccum_free, - sizeof(t_frameaccum), 0, A_DEFFLOAT, 0); - class_addmethod(frameaccum_class, nullfn, gensym("signal"), 0); - class_addmethod(frameaccum_class, (t_method) frameaccum_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/framedelta.c b/Libraries/cyclone/cyclone_objects/binaries/audio/framedelta.c deleted file mode 100644 index bb8d5fa27c..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/framedelta.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include -#include "common/grow.h" - -#define FRAMEDELTA_INISIZE 512 - -typedef struct _framedelta -{ - t_object x_obj; - t_inlet *framedelta; - int x_size; - t_float *x_frame; - t_float x_frameini[FRAMEDELTA_INISIZE]; -} t_framedelta; - -static t_class *framedelta_class; - -static t_int *framedelta_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *frame = (t_float *)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - float f = *in++; - *out++ = f - *frame; /* CHECKME */ - *frame++ = f; - } - return (w + 5); -} - -static void framedelta_dsp(t_framedelta *x, t_signal **sp) -{ - int nblock = sp[0]->s_n; - if (nblock > x->x_size) - x->x_frame = grow_nodata(&nblock, &x->x_size, x->x_frame, - FRAMEDELTA_INISIZE, x->x_frameini, - sizeof(*x->x_frame)); - memset(x->x_frame, 0, nblock * sizeof(*x->x_frame)); /* CHECKME */ - dsp_add(framedelta_perform, 4, nblock, x->x_frame, - sp[0]->s_vec, sp[1]->s_vec); -} - -static void framedelta_free(t_framedelta *x) -{ - if (x->x_frame != x->x_frameini) - freebytes(x->x_frame, x->x_size * sizeof(*x->x_frame)); -} - -static void *framedelta_new(t_symbol *s, int ac, t_atom *av) -{ - t_framedelta *x = (t_framedelta *)pd_new(framedelta_class); - int size; - x->x_size = FRAMEDELTA_INISIZE; - x->x_frame = x->x_frameini; - if ((size = sys_getblksize()) > FRAMEDELTA_INISIZE) - x->x_frame = grow_nodata(&size, &x->x_size, x->x_frame, - FRAMEDELTA_INISIZE, x->x_frameini, - sizeof(*x->x_frame)); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void framedelta_tilde_setup(void) -{ - framedelta_class = class_new(gensym("framedelta~"), - (t_newmethod)framedelta_new, - (t_method)framedelta_free, - sizeof(t_framedelta), 0, 0); - class_addmethod(framedelta_class, nullfn, gensym("signal"), 0); - class_addmethod(framedelta_class, (t_method) framedelta_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/gate.c b/Libraries/cyclone/cyclone_objects/binaries/audio/gate.c deleted file mode 100644 index bf74fa2c21..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/gate.c +++ /dev/null @@ -1,144 +0,0 @@ -// based on selector~ - -#include "m_pd.h" -#include -#include "common/magicbit.h" -//#include - - -#define GATEOUTPUT 1 //default number of outputs -#define MAXOUTPUT 500 //maximum number of outputs -#define GATESTATE 0 //default state (0 = closed) - -typedef struct _gate -{ - t_object x_obj; - t_float *x_mainsig; // the main signal input - int x_sig_outs; // outlets ???excluding gate idx (1 indexed)??? - t_float x_state; // 0 = closed, nonzero = index of outlet to output (1 indexed) - t_float *x_ivec; // input vector - t_float **x_ovecs; // output vectors - t_glist *x_glist; - t_float *x_signalscalar; - int x_hasfeeders; -} t_gate; - -static t_class *gate_class; - -//EXTERN t_float *obj_findsignalscalar(t_object *x, int m); - -static t_int *gate_perform(t_int *w) -{ - t_gate *x = (t_gate *)(w[1]); - int nblock = (int)(w[2]); - t_float *state = x->x_mainsig; - t_float *ivec = x->x_ivec; // input vector - t_float **ovecs = x->x_ovecs; // output vectors - int i, j; - int sig_outs = x->x_sig_outs; - if (!magic_isnan(*x->x_signalscalar)) - { - //x->x_badfloat = scalar; - magic_setnan(x->x_signalscalar); - pd_error(x, "gate~: doesn't understand 'float'"); - } - for(i = 0; i < nblock; i++) - { - t_float f; - int curst = (int)state[i]; - if (curst > sig_outs){ - curst = sig_outs; - } - - for(j = 0; j < sig_outs; j++) // 'for' counter - { /*remember that the signals are counted clockwise - so the outlets are labeled BACKWARDS from intuition - */ - int realidx = sig_outs-j-1; - if(curst == realidx+1 && x->x_hasfeeders) // if index == count - { - ovecs[realidx][i] = ivec[i]; // gate_out == indexed output - } - else{ - ovecs[realidx][i] = 0.0; - }; - }; - }; - return (w + 3); -} - -static void gate_dsp(t_gate *x, t_signal **sp) -{ - int i, nblock = sp[0]->s_n; - t_signal **sigp = sp; - x->x_mainsig = (*sigp++)->s_vec; // gate idx - x->x_ivec = (*sigp++)->s_vec; // now for the signal inlet - for (i = 0; i < x->x_sig_outs; i++){ //now for the sig_outs - *(x->x_ovecs+i) = (*sigp++)->s_vec; - }; - x->x_hasfeeders = magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal); - magic_setnan(x->x_signalscalar); - dsp_add(gate_perform, 2, x, nblock); -} - -static void *gate_new(t_symbol *s, int argc, t_atom *argv) -{ - t_gate *x = (t_gate *)pd_new(gate_class); - t_float sig_outs = (t_float) GATEOUTPUT; // outlets - t_float state = (t_float) GATESTATE; // initially closed - int i; - int argnum = 0; - while(argc > 0){ - if(argv -> a_type == A_FLOAT){ - t_float argval = atom_getfloatarg(0, argc, argv); - switch(argnum){ - case 0: - sig_outs = argval; - break; - case 1: - state = argval; - break; - default: - break; - }; - argc--; - argv++; - argnum++; - }; - }; - - //bounds checking - if(sig_outs < (t_float)GATEOUTPUT){ - sig_outs = GATEOUTPUT; - } - else if(sig_outs > (t_float)MAXOUTPUT){ - sig_outs = MAXOUTPUT; - }; - if(state < 0){ - state = 0; - } - else if(state > sig_outs){ - state = sig_outs; - }; - - x->x_sig_outs = (int)sig_outs; - x->x_state = state; - x->x_ovecs = getbytes(sig_outs * sizeof(*x->x_ovecs)); - - inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - for (i = 0; i < sig_outs; i++) - { - outlet_new(&x->x_obj, gensym("signal")); - }; - x->x_glist = canvas_getcurrent(); - x->x_signalscalar = obj_findsignalscalar((t_object *)x, 1); - return (x); -} - -CYCLONE_OBJ_API void gate_tilde_setup(void) -{ - gate_class = class_new(gensym("gate~"), (t_newmethod)gate_new, 0, - sizeof(t_gate), CLASS_DEFAULT, A_GIMME, 0); - class_addmethod(gate_class, (t_method)gate_dsp, gensym("dsp"), A_CANT, 0); - CLASS_MAINSIGNALIN(gate_class, t_gate, x_state); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/greaterthan.c b/Libraries/cyclone/cyclone_objects/binaries/audio/greaterthan.c deleted file mode 100644 index de75b75884..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/greaterthan.c +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2016 Porres. - -#include "m_pd.h" -#include - -// --------------------------------------------------- -// Class definition -// --------------------------------------------------- -static t_class *greaterthan_class; - -// --------------------------------------------------- -// Data structure definition -// --------------------------------------------------- -typedef struct _greaterthan -{ - t_object x_obj; - t_inlet *x_inlet; -} t_greaterthan; - -// --------------------------------------------------- -// Perform -// --------------------------------------------------- -static t_int *greaterthan_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f1 > f2); - } - return (w + 5); -} - -// --------------------------------------------------- -// DSP Function -// --------------------------------------------------- -static void greaterthan_dsp(t_greaterthan *x, t_signal **sp) -{ - dsp_add(greaterthan_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -// FREE -static void *greaterthan_free(t_greaterthan *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -// --------------------------------------------------- -// Functions signature -// --------------------------------------------------- -static void *greaterthan_new(t_floatarg f) -{ - t_greaterthan *x = (t_greaterthan *)pd_new(greaterthan_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -// --------------------------------------------------- -// Setup -// --------------------------------------------------- -CYCLONE_OBJ_API void greaterthan_tilde_setup(void) -{ - greaterthan_class = class_new(gensym("greaterthan~"), - (t_newmethod)greaterthan_new, - (t_method)greaterthan_free, - sizeof(t_greaterthan), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(greaterthan_class, nullfn, gensym("signal"), 0); - class_addmethod(greaterthan_class, (t_method)greaterthan_dsp, gensym("dsp"), A_CANT, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/greaterthaneq.c b/Libraries/cyclone/cyclone_objects/binaries/audio/greaterthaneq.c deleted file mode 100644 index 1632f6e90d..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/greaterthaneq.c +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2016 Porres. - -#include "m_pd.h" -#include - -// --------------------------------------------------- -// Class definition -// --------------------------------------------------- -static t_class *greaterthaneq_class; - -// --------------------------------------------------- -// Data structure definition -// --------------------------------------------------- -typedef struct _greaterthaneq -{ - t_object x_obj; - t_inlet *x_inlet; -} t_greaterthaneq; - -// --------------------------------------------------- -// Perform -// --------------------------------------------------- -static t_int *greaterthaneq_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f1 >= f2); - } - return (w + 5); -} - -// --------------------------------------------------- -// DSP Function -// --------------------------------------------------- -static void greaterthaneq_dsp(t_greaterthaneq *x, t_signal **sp) -{ - dsp_add(greaterthaneq_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -// FREE -static void *greaterthaneq_free(t_greaterthaneq *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -// --------------------------------------------------- -// Functions signature -// --------------------------------------------------- -static void *greaterthaneq_new(t_floatarg f) -{ - t_greaterthaneq *x = (t_greaterthaneq *)pd_new(greaterthaneq_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -// --------------------------------------------------- -// Setup -// --------------------------------------------------- -CYCLONE_OBJ_API void greaterthaneq_tilde_setup(void) -{ - greaterthaneq_class = class_new(gensym("greaterthaneq~"), - (t_newmethod)greaterthaneq_new, - (t_method)greaterthaneq_free, - sizeof(t_greaterthaneq), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(greaterthaneq_class, nullfn, gensym("signal"), 0); - class_addmethod(greaterthaneq_class, (t_method)greaterthaneq_dsp, gensym("dsp"), A_CANT, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/index.c b/Libraries/cyclone/cyclone_objects/binaries/audio/index.c deleted file mode 100644 index 5ab27e4cfc..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/index.c +++ /dev/null @@ -1,116 +0,0 @@ -//Derek Kwan 2016 - de-arsiced,.. cybuffed - -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* LATER: 'click' method */ - -#include -#include "m_pd.h" -#include -#include "signal/cybuf.h" - -#define INDEX_MAXCHANNELS 64 - -typedef struct _index -{ - t_object x_obj; - t_cybuf *x_cybuf; - int x_channum; //requested channel number (1-indexed) - t_inlet *x_phaselet; - t_outlet *x_outlet; -} t_index; - -static t_class *index_class; - -static void index_set(t_index *x, t_symbol *s){ - cybuf_setarray(x->x_cybuf, s); -} - -static t_int *index_perform(t_int *w) -{ - t_index *x = (t_index *)(w[1]); - int nblock = (int)(w[2]); - t_float *out = (t_float *)(w[4]); - - t_cybuf *c = x->x_cybuf; - if (c->c_playable) - { - t_float *xin = (t_float *)(w[3]); - int index, maxindex = c->c_npts - 1; - t_word *vp = c->c_vectors[0]; - if (vp) /* handle array swapping on the fly via ft1 */ - { - while (nblock--) - { - index = (int)(*xin++ + 0.5); - if (index < 0) - index = 0; - else if (index > maxindex) - index = maxindex; - *out++ = vp[index].w_float; - } - } - else while (nblock--) *out++ = 0; - } - else while (nblock--) *out++ = 0; - return (w + 5); -} - -static void index_float(t_index *x, t_float f) -{ - pd_error(x, "index~: no method for 'float'"); -} - -static void index_ft1(t_index *x, t_floatarg f) -{ - int ch = (f < 1) ? 1 : (f > CYBUF_MAXCHANS) ? CYBUF_MAXCHANS : (int) f; - x->x_channum = ch; - cybuf_getchannel(x->x_cybuf, ch, 1); -} - -static void index_dsp(t_index *x, t_signal **sp) -{ - cybuf_checkdsp(x->x_cybuf); - dsp_add(index_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void index_free(t_index *x) -{ - inlet_free(x->x_phaselet); - outlet_free(x->x_outlet); - cybuf_free(x->x_cybuf); -} - -static void *index_new(t_symbol *s, t_floatarg f) -{ - //like peek~, changing so it doesn't default to 0 but 1 for the new cybuf - //single channel mode, not sure how much of a diff it makes... - DK - int ch = (f < 1) ? 1 : (f > CYBUF_MAXCHANS) ? CYBUF_MAXCHANS : (int) f; - /* two signals: index input, value output */ - t_index *x = (t_index *)pd_new(index_class); - x->x_cybuf = cybuf_init((t_class *)x, s, 1, ch); - if (x->x_cybuf){ - x->x_channum = ch; - x->x_phaselet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); - x->x_outlet = outlet_new(&x->x_obj, gensym("signal")); - }; - return (x); -} - -CYCLONE_OBJ_API void index_tilde_setup(void) -{ - index_class = class_new(gensym("index~"), - (t_newmethod)index_new, - (t_method)index_free, - sizeof(t_index), 0, - A_DEFSYM, A_DEFFLOAT, 0); - class_addmethod(index_class, (t_method)index_dsp, gensym("dsp"), A_CANT, 0); - class_domainsignalin(index_class, -1); - class_addfloat(index_class, (t_method)index_float); - class_addmethod(index_class, (t_method)index_set, - gensym("set"), A_SYMBOL, 0); - class_addmethod(index_class, (t_method)index_ft1, - gensym("ft1"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/kink.c b/Libraries/cyclone/cyclone_objects/binaries/audio/kink.c deleted file mode 100644 index a6d684ae6b..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/kink.c +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* CHECKED negative float in 2nd inlet: "illegal slope value %f", - but no complaints for signal input -- this is impossible in Pd. - The only thing we could do (and a bit stupid one) would be to - clock this exception out from the perf routine. - - UPDATE 02/17 - used the "magic trick" to fix this -- MB */ - -#include "m_pd.h" -#include -#include "common/magicbit.h" - -static t_class *kink_class; - -typedef struct _kink { - t_object x_obj; - t_float x_slope; - t_glist *x_glist; - t_float *x_signalscalar; - int x_hasfeeders; -} t_kink; - - -static t_int *kink_perform(t_int *w) -{ - t_kink *x = (t_kink *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_float *scalar = x->x_signalscalar; - if (*scalar < 0.0) - { - pd_error(x, "kink~: illegal float value %.2f", *scalar); - *scalar = x->x_slope; - } - x->x_slope = *scalar; - while (nblock--) - { - t_float slope; - t_float iph = *in1++; - if (x->x_hasfeeders) - { - slope = *in2++; - if (slope < 0) slope = 0; - } - else - slope = x->x_slope; - if (slope) - { - t_float breakpoint = 0.5/slope; - if (iph <= breakpoint) - *out++ = iph * slope; - else - *out++ = 0.5/(1.0-breakpoint)*(iph-breakpoint) + 0.5; - } - else - *out++ = 0; - - } - return (w + 6); -} - -static void kink_dsp(t_kink *x, t_signal **sp) -{ - x->x_hasfeeders = magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal); - dsp_add(kink_perform, 5, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - - -static void *kink_new(t_floatarg f) -{ - t_kink *x = (t_kink *)pd_new(kink_class); - if (f < 0.0) - { - pd_error(x, "kink~: illegal float value %.2f", f); - f = 1.0; - } - f = (f == 0.0 ? 1.0 : f); - x->x_slope = f; - pd_float((t_pd *)inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal), f); - outlet_new((t_object *)x, &s_signal); - x->x_glist = canvas_getcurrent(); - x->x_signalscalar = obj_findsignalscalar((t_object *)x, 1); - return (x); -} - -CYCLONE_OBJ_API void kink_tilde_setup(void) -{ - kink_class = class_new(gensym("kink~"), - (t_newmethod)kink_new, 0, - sizeof(t_kink), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(kink_class, nullfn, gensym("signal"), 0); - class_addmethod(kink_class, (t_method)kink_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/lessthan.c b/Libraries/cyclone/cyclone_objects/binaries/audio/lessthan.c deleted file mode 100644 index 5395b95b54..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/lessthan.c +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2016 Porres. - -#include "m_pd.h" -#include - -// --------------------------------------------------- -// Class definition -// --------------------------------------------------- -static t_class *lessthan_class; - -// --------------------------------------------------- -// Data structure definition -// --------------------------------------------------- -typedef struct _lessthan -{ - t_object x_obj; - t_inlet *x_inlet; -} t_lessthan; - -// --------------------------------------------------- -// Perform -// --------------------------------------------------- -static t_int *lessthan_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f1 < f2); - } - return (w + 5); -} - -// --------------------------------------------------- -// DSP Function -// --------------------------------------------------- -static void lessthan_dsp(t_lessthan *x, t_signal **sp) -{ - dsp_add(lessthan_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -// FREE -static void *lessthan_free(t_lessthan *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -// --------------------------------------------------- -// Functions signature -// --------------------------------------------------- -static void *lessthan_new(t_floatarg f) -{ - t_lessthan *x = (t_lessthan *)pd_new(lessthan_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -// --------------------------------------------------- -// Setup -// --------------------------------------------------- -CYCLONE_OBJ_API void lessthan_tilde_setup(void) -{ - lessthan_class = class_new(gensym("lessthan~"), - (t_newmethod)lessthan_new, - (t_method)lessthan_free, - sizeof(t_lessthan), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(lessthan_class, nullfn, gensym("signal"), 0); - class_addmethod(lessthan_class, (t_method)lessthan_dsp, gensym("dsp"), A_CANT, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/lessthaneq.c b/Libraries/cyclone/cyclone_objects/binaries/audio/lessthaneq.c deleted file mode 100644 index 9f45214d4d..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/lessthaneq.c +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2016 Porres. - -#include "m_pd.h" -#include - -// --------------------------------------------------- -// Class definition -// --------------------------------------------------- -static t_class *lessthaneq_class; - -// --------------------------------------------------- -// Data structure definition -// --------------------------------------------------- -typedef struct _lessthaneq -{ - t_object x_obj; - t_inlet *x_inlet; -} t_lessthaneq; - -// --------------------------------------------------- -// Perform -// --------------------------------------------------- -static t_int *lessthaneq_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f1 <= f2); - } - return (w + 5); -} - -// --------------------------------------------------- -// DSP Function -// --------------------------------------------------- -static void lessthaneq_dsp(t_lessthaneq *x, t_signal **sp) -{ - dsp_add(lessthaneq_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -// FREE -static void *lessthaneq_free(t_lessthaneq *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -// --------------------------------------------------- -// Functions signature -// --------------------------------------------------- -static void *lessthaneq_new(t_floatarg f) -{ - t_lessthaneq *x = (t_lessthaneq *)pd_new(lessthaneq_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -// --------------------------------------------------- -// Setup -// --------------------------------------------------- -CYCLONE_OBJ_API void lessthaneq_tilde_setup(void) -{ - lessthaneq_class = class_new(gensym("lessthaneq~"), - (t_newmethod)lessthaneq_new, - (t_method)lessthaneq_free, - sizeof(t_lessthaneq), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(lessthaneq_class, nullfn, gensym("signal"), 0); - class_addmethod(lessthaneq_class, (t_method)lessthaneq_dsp, gensym("dsp"), A_CANT, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/line.c b/Libraries/cyclone/cyclone_objects/binaries/audio/line.c deleted file mode 100644 index cee9205253..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/line.c +++ /dev/null @@ -1,289 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -// Added code for the stop, pause and resume messages, fjkraan, 2014-12-02 (alpha57) - -#include "m_pd.h" -#include - -#define LINE_MAX_SIZE 128 - -typedef struct _lineseg -{ - float s_target; - float s_delta; -} t_lineseg; - -typedef struct _line -{ - t_object x_obj; - float x_value; - float x_target; - float x_delta; - int x_deltaset; - float x_inc; - float x_biginc; - float x_ksr; - int x_nleft; - int x_retarget; - int x_size; /* as allocated */ - int x_nsegs; /* as used */ - int x_pause; - t_lineseg *x_curseg; - t_lineseg *x_segs; - t_lineseg x_segini[LINE_MAX_SIZE]; - t_clock *x_clock; - t_outlet *x_bangout; -} t_line; - -static t_class *line_class; - -static void line_tick(t_line *x) -{ - outlet_bang(x->x_bangout); -} - -static t_int *line_perform(t_int *w) -{ - t_line *x = (t_line *)(w[1]); - t_float *out = (t_float *)(w[2]); - int nblock = (int)(w[3]); - int nxfer = x->x_nleft; - float curval = x->x_value; - float inc = x->x_inc; - float biginc = x->x_biginc; - - if (x->x_pause) - { - while (nblock--) *out++ = curval; - return (w + 4); - } - if (PD_BIGORSMALL(curval)) /* LATER rethink */ - curval = x->x_value = 0; -retarget: - if (x->x_retarget) - { - float target = x->x_curseg->s_target; - float delta = x->x_curseg->s_delta; - int npoints = delta * x->x_ksr + 0.5; /* LATER rethink */ - x->x_nsegs--; - x->x_curseg++; - while (npoints <= 0) - { - curval = x->x_value = target; - if (x->x_nsegs) - { - target = x->x_curseg->s_target; - delta = x->x_curseg->s_delta; - npoints = delta * x->x_ksr + 0.5; /* LATER rethink */ - x->x_nsegs--; - x->x_curseg++; - } - else - { - while (nblock--) *out++ = curval; - x->x_nleft = 0; - clock_delay(x->x_clock, 0); - x->x_retarget = 0; - return (w + 4); - } - } - nxfer = x->x_nleft = npoints; - inc = x->x_inc = (target - x->x_value) / (float)npoints; - x->x_biginc = (int)(w[3]) * inc; - biginc = nblock * inc; - x->x_target = target; - x->x_retarget = 0; - } - if (nxfer >= nblock) - { - if ((x->x_nleft -= nblock) == 0) - { - if (x->x_nsegs) x->x_retarget = 1; - else - { - clock_delay(x->x_clock, 0); - } - x->x_value = x->x_target; - } - else x->x_value += biginc; - while (nblock--) - *out++ = curval, curval += inc; - } - else if (nxfer > 0) - { - nblock -= nxfer; - do - *out++ = curval, curval += inc; - while (--nxfer); - curval = x->x_value = x->x_target; - if (x->x_nsegs) - { - x->x_retarget = 1; - goto retarget; - } - else - { - while (nblock--) *out++ = curval; - x->x_nleft = 0; - clock_delay(x->x_clock, 0); - } - } - else while (nblock--) *out++ = curval; - return (w + 4); -} - -static void line_float(t_line *x, t_float f) -{ - if (x->x_deltaset) - { - x->x_deltaset = 0; - x->x_target = f; - x->x_nsegs = 1; - x->x_curseg = x->x_segs; - x->x_curseg->s_target = f; - x->x_curseg->s_delta = x->x_delta; - x->x_retarget = 1; - } - else - { - x->x_value = x->x_target = f; - x->x_nsegs = 0; - x->x_curseg = 0; - x->x_nleft = 0; - x->x_retarget = 0; - } - x->x_pause = 0; -} - -static void line_ft1(t_line *x, t_floatarg f) -{ - x->x_delta = f; - x->x_deltaset = (f > 0); -} - -static void line_list(t_line *x, t_symbol *s, int ac, t_atom *av) -{ - int natoms, nsegs, odd; - t_atom *ap; - t_lineseg *segp; - for (natoms = 0, ap = av; natoms < ac; natoms++, ap++) - { - if (ap->a_type != A_FLOAT) - { - pd_error(x, "line~: list needs to only contain floats"); - return; - } - } - if (!natoms) - return; /* CHECKED */ - odd = natoms % 2; - nsegs = natoms / 2; - if (odd) nsegs++; - - //clip at maxsize - if(nsegs > LINE_MAX_SIZE) - { - nsegs = LINE_MAX_SIZE; - odd = 0; - }; - x->x_nsegs = nsegs; - segp = x->x_segs; - if (odd) nsegs--; - while (nsegs--) - { - segp->s_target = av++->a_w.w_float; - segp->s_delta = av++->a_w.w_float; - segp++; - } - if (odd) - { - segp->s_target = av->a_w.w_float; - segp->s_delta = 0; - } - x->x_deltaset = 0; - x->x_target = x->x_segs->s_target; - x->x_curseg = x->x_segs; - x->x_retarget = 1; - x->x_pause = 0; -} - -static void line_dsp(t_line *x, t_signal **sp) -{ - dsp_add(line_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); - x->x_ksr = sp[0]->s_sr * 0.001; -} - -static void line_free(t_line *x) -{ - if (x->x_segs != x->x_segini) - freebytes(x->x_segs, x->x_size * sizeof(*x->x_segs)); - if (x->x_clock) clock_free(x->x_clock); -} - -static void line_stop(t_line *x) -{ - x->x_nsegs = 0; - x->x_nleft = 0; -} - -static void line_pause(t_line *x) -{ - x->x_pause = 1; -} - -static void line_resume(t_line *x) -{ - x->x_pause = 0; -} - -static void *line_new(t_floatarg f) -{ - t_line *x = (t_line *)pd_new(line_class); - x->x_value = x->x_target = f; - x->x_deltaset = 0; - x->x_nleft = 0; - x->x_retarget = 0; - x->x_size = LINE_MAX_SIZE; - x->x_nsegs = 0; - x->x_pause = 0; - x->x_segs = x->x_segini; - x->x_curseg = 0; - inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); - outlet_new((t_object *)x, &s_signal); - x->x_bangout = outlet_new((t_object *)x, &s_bang); - x->x_clock = clock_new(x, (t_method)line_tick); - return (x); -} - -CYCLONE_OBJ_API void line_tilde_setup(void) -{ - line_class = class_new(gensym("cyclone/line~"), // avoid name clash with vanilla - (t_newmethod)line_new, (t_method)line_free, sizeof(t_line), 0, A_DEFFLOAT, 0); - class_domainsignalin(line_class, -1); // bug? - class_addmethod(line_class, (t_method)line_dsp, gensym("dsp"), A_CANT, 0); - class_addfloat(line_class, line_float); - class_addlist(line_class, line_list); - class_addmethod(line_class, (t_method)line_ft1, gensym("ft1"), A_FLOAT, 0); - class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0); - class_addmethod(line_class, (t_method)line_pause, gensym("pause"), 0); - class_addmethod(line_class, (t_method)line_resume, gensym("resume"), 0); - class_sethelpsymbol(line_class, gensym("line~")); -} - -CYCLONE_OBJ_API void Line_tilde_setup(void) -{ - line_class = class_new(gensym("Line~"), // avoid name clash with vanilla - (t_newmethod)line_new, (t_method)line_free, sizeof(t_line), 0, A_DEFFLOAT, 0); - class_domainsignalin(line_class, -1); // bug? - class_addmethod(line_class, (t_method)line_dsp, gensym("dsp"), A_CANT, 0); - class_addfloat(line_class, line_float); - class_addlist(line_class, line_list); - class_addmethod(line_class, (t_method)line_ft1, gensym("ft1"), A_FLOAT, 0); - class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0); - class_addmethod(line_class, (t_method)line_pause, gensym("pause"), 0); - class_addmethod(line_class, (t_method)line_resume, gensym("resume"), 0); - class_sethelpsymbol(line_class, gensym("line~")); - pd_error(line_class, "Cyclone: please use [cyclone/line~] instead of [Line~] to suppress this error"); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/lookup.c b/Libraries/cyclone/cyclone_objects/binaries/audio/lookup.c deleted file mode 100644 index d245150646..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/lookup.c +++ /dev/null @@ -1,212 +0,0 @@ -//old code scrapped, brand new code by Derek Kwan - 2016 - -#include "m_pd.h" -#include -#include -#include "signal/cybuf.h" - -#define CYLKUPENDPT 512 - -static t_class *lookup_class; - -typedef struct _lookup -{ - t_object x_obj; - t_cybuf *x_cybuf; - - t_inlet *x_startlet; //inlet for stpt - t_inlet *x_endlet; //inlet for endpoint - t_outlet *x_out; //outlet -} t_lookup; - -static double lookup_getlin(t_word * arr, int sz, double idx){ - - double output; - int tabphase1 = (int)idx; - int tabphase2 = tabphase1 + 1; - double frac = idx - (double)tabphase1; - if(tabphase1 >= (sz - 1)){ - tabphase1 = sz - 1; //checking to see if index falls within bounds - output = arr[tabphase1].w_float; - } - else if(tabphase1 < 0){ - tabphase1 = 0; - output = arr[tabphase1].w_float; - } - else{ - //linear interp - double yb = arr[tabphase2].w_float; //read the buffer! - double ya = arr[tabphase1].w_float; //read the buffer! - output = ya+((yb-ya)*frac); - - }; - return output; -} - - -static void lookup_set(t_lookup *x, t_symbol *s) -{ - cybuf_setarray(x->x_cybuf, s); -} - -static void *lookup_new(t_symbol *s, int argc, t_atom *argv){ - t_lookup *x = (t_lookup *)pd_new(lookup_class); - - t_symbol * name = NULL; - int floatarg = 0;//argument counter for floatargs (don't include symbol arg) - //setting defaults for start and end points - t_float stpt = 0; - t_float endpt = CYLKUPENDPT; - - while(argc){ - if(argv -> a_type == A_SYMBOL){ - if(floatarg == 0){ - //we haven't hit any floatargs, go ahead and set name - name = atom_getsymbolarg(0, argc, argv); - }; - } - else{ - //else we're dealing with a float - switch(floatarg){ - case 0: - stpt = atom_getfloatarg(0, argc, argv); - break; - case 1: - endpt = atom_getfloatarg(0, argc, argv); - break; - default: - break; - }; - floatarg++; //increment the floatarg we're looking at - }; - argc--; - argv++; - }; - - x->x_cybuf = cybuf_init((t_class *) x, name, 1, 0); - //boundschecking - if(stpt < 0){ - stpt = 0; - } - else{ - stpt = (t_float)floor(stpt); //basically typecasting to int without actual typecasting - }; - if(endpt < 0){ - endpt = 0; - } - else{ - endpt = (t_float)floor(endpt); - }; - - x->x_startlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - x->x_endlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - pd_float((t_pd *)x->x_startlet, stpt); - pd_float( (t_pd *)x->x_endlet, endpt); - x->x_out = outlet_new(&x->x_obj, gensym("signal")); - - return (x); -} - -static t_int *lookup_perform(t_int *w) -{ - t_lookup *x = (t_lookup *)(w[1]); - t_cybuf *c = x->x_cybuf; - t_float *phase = (t_float *)(w[2]); - t_float *stpt = (t_float *)(w[3]); - t_float *endpt = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - int n = (int)(w[6]); - int npts = c->c_npts; - int maxidx = npts -1; - t_word *buf = (t_word *)c->c_vectors[0]; - - int i; - for(i=0;i curendpt){ - int temp; - temp = curstpt; - curstpt = curendpt; - curendpt = temp; - curdir *= -1.f; - }; - - - //bounds checking - if(curendpt > npts){ - curendpt = npts; - }; - if(curstpt < 0){ - curstpt = 0; - } - else if(curstpt > maxidx){ - curstpt = maxidx; - }; - //current size calculation, remember that maxidxes are alays size -1 - cursz = curendpt - curstpt; - if(cursz < 1){ - cursz = 1; - }; - - if(curphs >= -1 && curphs <= 1 && buf){ - //if phase if b/w -1 and 1, map and read, else 0 - //mapping curphs to the realidx where -1 maps to stpt and 1 maps to stpt + cursz - 1 - //resulting in mappings to endpt indices (if stpt = 0, and endpt = 9, 8 is the maxidx to map to) - //if curdir is -1, need to flip relation - - //calc the real mapped idx in the buffer - double realidx = (double)curstpt + (((curphs*curdir)+1.) * 0.5 * ((double)cursz-1.)); - - //bounds checking - if(realidx > maxidx){ - realidx = (double)maxidx; - }; - if(c->c_playable && npts){ - curout = lookup_getlin(buf, npts, realidx); //read the buffer! - } - else{ - curout = 0.; - }; - }; - - out[i] = curout; - }; - - return (w+7); -} - -static void lookup_dsp(t_lookup *x, t_signal **sp) -{ - cybuf_checkdsp(x->x_cybuf); - dsp_add(lookup_perform, 6, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n); -} - -static void *lookup_free(t_lookup *x) -{ - inlet_free(x->x_startlet); - inlet_free(x->x_endlet); - outlet_free(x->x_out); - return (void *)x; -} - -CYCLONE_OBJ_API void lookup_tilde_setup(void) -{ - lookup_class = class_new(gensym("lookup~"), - (t_newmethod)lookup_new, - (t_method)lookup_free, - sizeof(t_lookup), CLASS_DEFAULT, - A_GIMME, 0); - class_addmethod(lookup_class, nullfn, gensym("signal"), 0); - class_addmethod(lookup_class, (t_method)lookup_dsp, - gensym("dsp"), A_CANT, 0); - class_addmethod(lookup_class, (t_method)lookup_set, - gensym("set"), A_SYMBOL, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/lores.c b/Libraries/cyclone/cyclone_objects/binaries/audio/lores.c deleted file mode 100644 index a43332ecca..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/lores.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) 2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* The general two-pole loresator (csound's lp2). For a nice analysis - see section 9.1.3 of ``Introduction to Digital Filters'' by Smith. */ - -/* CHECKME if creation args (or defaults) restored after signal disconnection */ - -#define _USE_MATH_DEFINES -#include -#include "m_pd.h" -#include - -/* CHECKME negative loresance */ -/* CHECKME max loresance, esp. at low freqs (watch out, gain not normalized) */ -#define LORES_MAXloresANCE (1. - 1e-20) -#define LORES_MINOMEGA .0001 /* CHECKME */ -#define LORES_MAXOMEGA M_PI /* CHECKME */ -#define TWO_PI (M_PI * 2.) - -typedef struct _lores -{ - t_object x_obj; - t_inlet *x_freq_inlet; - t_inlet *x_q_inlet; - float x_srcoef; - float x_ynm1; - float x_ynm2; -} t_lores; - -static t_class *lores_class; - -static void lores_clear(t_lores *x) -{ - x->x_ynm1 = x->x_ynm2 = 0.; -} - -/* LATER make ready for optional audio-rate modulation - (separate scalar case routines, use sic_makecostable(), etc.) */ -static t_int *lores_perform(t_int *w) -{ - t_lores *x = (t_lores *)(w[1]); - int nblock = (int)(w[2]); - t_float *xin = (t_float *)(w[3]); - t_float fin0 = *(t_float *)(w[4]); - t_float rin0 = *(t_float *)(w[5]); - t_float *out = (t_float *)(w[6]); - float ynm1 = x->x_ynm1; - float ynm2 = x->x_ynm2; - /* CHECKME sampled once per block */ - float omega = fin0 * x->x_srcoef; - float radius, c1, c2, b0; - if (omega < LORES_MINOMEGA) - omega = LORES_MINOMEGA; - else if (omega > LORES_MAXOMEGA) - omega = LORES_MAXOMEGA; - if (rin0 > LORES_MAXloresANCE) - rin0 = LORES_MAXloresANCE; - /* radius = pow(base, rin0 - 1), which maps rin0 of 0..1 to radius - of 1/base..1, where base=exp(.125), and 1/base=.882496902585 */ - radius = expf(rin0 * .125) * .882496902585; - c1 = 2. * radius * cos(omega); - c2 = radius * radius; - b0 = 1. - c1 + c2; - while (nblock--) - { - float yn; - *out++ = yn = b0 * *xin++ + c1 * ynm1 - c2 * ynm2; - ynm2 = ynm1; - ynm1 = yn; - } - /* LATER rethink */ - x->x_ynm1 = (PD_BIGORSMALL(ynm1) ? 0. : ynm1); - x->x_ynm2 = (PD_BIGORSMALL(ynm2) ? 0. : ynm2); - return (w + 7); -} - -static void lores_dsp(t_lores *x, t_signal **sp) -{ - x->x_srcoef = TWO_PI / sp[0]->s_sr; - lores_clear(x); - dsp_add(lores_perform, 6, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); -} - -static void *lores_new(t_floatarg f1, t_floatarg f2) -{ - t_lores *x = (t_lores *)pd_new(lores_class); - x->x_srcoef = TWO_PI / sys_getsr(); - x->x_freq_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_freq_inlet, f1); - x->x_q_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_q_inlet, f2); - outlet_new((t_object *)x, &s_signal); - lores_clear(x); - return (x); -} - -CYCLONE_OBJ_API void lores_tilde_setup(void) -{ - lores_class = class_new(gensym("lores~"), - (t_newmethod)lores_new, 0, - sizeof(t_lores), 0, - A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(lores_class, nullfn, gensym("signal"), 0); - class_addmethod(lores_class, (t_method)lores_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(lores_class, (t_method)lores_clear, gensym("clear"), 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/matrix.c b/Libraries/cyclone/cyclone_objects/binaries/audio/matrix.c deleted file mode 100644 index aeb56a2dd5..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/matrix.c +++ /dev/null @@ -1,588 +0,0 @@ -/* Copyright (c) 2005 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* -updated to add @ramp attribute, slightly updated argument parsing. -left a lot of legacy code (the way all methods do things remains intact) -but managed to remove all external dependencies. commented out the loud_debug stuff -(which got turned on when MATRIX_DEBUG was defined). -matrix_float is there because the first inlet shouldn't accept floats -(and not do the usu convert float to signal business) -for some reason this code segfaults if class_domainsignalin(matrix_class, -1) -isn't there (don't ask me why) -changed matrix_free to return void * instead of nothing -(for consistency's sake) -- Derek Kwan 2016 - -- porres made minor revisions to the code in 2021 (removed unnecessary -dependencies, changed indentation -*/ - -#include "m_pd.h" -#include -#include "common/magicbit.h" - -#define MATRIX_DEFGAIN 0. // CHECKED -#define MATRIX_DEFRAMP 10. // CHECKED -#define MATRIX_GAINEPSILON 1e-20f -#define MATRIX_MINRAMP 001 // LATER rethink -#define MATRIX_MININLETS 1 -#define MATRIX_MAXINLETS 250 -#define MATRIX_MINOUTLETS 1 -#define MATRIX_MAXOUTLETS 499 - -typedef struct _matrix{ - t_object x_obj; - int x_numinlets; - int x_numoutlets; - int x_nblock; - int x_maxblock; - t_float **x_ivecs; - t_float **x_ovecs; - t_float **x_osums; - int x_ncells; - int *x_cells; - t_outlet *x_dumpout; - /* The following fields are specific to nonbinary mode, i.e. we keep them - unallocated in binary mode. This is CHECKED to be incompatible: c74 - always accepts (and reports) gains and ramps, although they are actually - meaningless in binary mode, and switching modes is not supported. */ - float x_defgain; // gain given as argument - float *x_gains; // target gains - float x_deframp; - float *x_ramps; - float x_ksr; - float *x_coefs; // current coefs - float *x_incrs; - float *x_bigincrs; - int *x_remains; -// Additions for filtering floats from secondary inlets -- Matt Barber - t_float *x_zerovec; - t_float *x_signalscalars[MATRIX_MAXINLETS]; - t_glist *x_glist; - int x_hasfeeders[MATRIX_MAXINLETS]; -}t_matrix; - -static t_class *matrix_class; - -// called only in nonbinary mode; LATER deal with changing nblock/ksr -static void matrix_retarget(t_matrix *x, int cellndx){ - float target = (x->x_cells[cellndx] ? x->x_gains[cellndx] : 0.); - if(x->x_ramps[cellndx] < MATRIX_MINRAMP){ - x->x_coefs[cellndx] = target; - x->x_remains[cellndx] = 0; - } - else{ - x->x_remains[cellndx] = - x->x_ramps[cellndx] * x->x_ksr + 0.5; // LATER rethink - x->x_incrs[cellndx] = (target - x->x_coefs[cellndx]) / (float)x->x_remains[cellndx]; - x->x_bigincrs[cellndx] = x->x_nblock * x->x_incrs[cellndx]; - } -} - -// called only in nonbinary mode; LATER deal with changing nblock/ksr -static void matrix_retarget_connect(t_matrix *x, int cellndx){ - float target = (x->x_cells[cellndx] ? x->x_gains[cellndx] = x->x_defgain : 0.); - if(x->x_ramps[cellndx] < MATRIX_MINRAMP){ - x->x_coefs[cellndx] = target; - x->x_remains[cellndx] = 0; - } - else{ - x->x_remains[cellndx] = x->x_ramps[cellndx] * x->x_ksr + 0.5; // LATER rethink - x->x_incrs[cellndx] = (target - x->x_coefs[cellndx]) / (float)x->x_remains[cellndx]; - x->x_bigincrs[cellndx] = x->x_nblock * x->x_incrs[cellndx]; - } -} - -static void matrix_float(t_matrix *x, t_float f){ - f = 0; - pd_error(x, "matrix~: no method for float"); -} - -static void matrix_list(t_matrix *x, t_symbol *s, int argc, t_atom *argv){ - if(argc < 3) // ignore if less than 3 args - return; - s = NULL; - int inlet_idx = 0, outlet_idx = 0, cell_idx = 0, onoff = 0, argnum = 0, rampset = 0; - float gain = 0, ramp = 0; - while(argc > 0){ // argument parsing - t_float argval = 0; // if not float, set equal to 0, else get value - if(argv->a_type == A_FLOAT) - argval = atom_getfloatarg(0, argc, argv); - switch(argnum){ // if more than 4 args, then just ignore; - case 0: - inlet_idx = (int)argval; - break; - case 1: - outlet_idx = (int)argval; - break; - case 2: - gain = argval; - break; - case 3: - ramp = argval; - rampset = 1; - break; - default: - break; - }; - argnum++; - argc--; - argv++; - }; -// bounds checking - if(inlet_idx < 0 || inlet_idx >= x->x_numinlets){ - pd_error(x, "matrix~: %d is not a valid inlet index!", inlet_idx); - return; - }; - if(outlet_idx < 0 || outlet_idx >= x->x_numoutlets){ - pd_error(x, "matrix~: %d is not a valid outlet index!", outlet_idx); - return; - }; - cell_idx = inlet_idx * x->x_numoutlets + outlet_idx; -// negative gain used in nonbinary mode, accepted as 1 in binary (legacy code) - onoff = (gain < -MATRIX_GAINEPSILON || gain > MATRIX_GAINEPSILON); - x->x_cells[cell_idx] = onoff; - if(x->x_gains){ //if in nonbinary mode - if(onoff) // CHECKME - x->x_gains[cell_idx] = gain; - if(rampset) - x->x_ramps[cell_idx] = (ramp < MATRIX_MINRAMP ? 0. : ramp); - matrix_retarget(x, cell_idx); - }; -} - -static void matrix_clear(t_matrix *x){ - int i; - for(i = 0; i < x->x_ncells; i++){ - x->x_cells[i] = 0; - if(x->x_gains) - matrix_retarget(x, i); - } -} - -static void matrix_connect(t_matrix *x, t_symbol *s, int argc, t_atom *argv){ - if(argc < 2) // if less than 2 args, fail gracefully - return; - t_int onoff = (s == gensym("connect")), inlet_idx, celloffset, inlet_flidx = 0; - if(argv->a_type == A_FLOAT) // first arg is inlet index (if symbol, let equal 0) - inlet_flidx = (t_int)atom_getfloatarg(0, argc, argv); - inlet_idx = inlet_flidx; - if(inlet_idx < 0 || inlet_idx >= x->x_numinlets){ // bounds checking for inlet index - pd_error(x, "matrix~: %d is not a valid inlet index!", (int)inlet_idx); - return; - }; - argc--, argv++; - celloffset = inlet_idx * x->x_numoutlets; - while(argc > 0){ // parse the rest of the args as outlet indices - t_int outlet_idx, cell_idx, outlet_flidx = 0; - if(argv->a_type == A_FLOAT) // parse arg as outlet idx, if symbol, let equal 0 - outlet_flidx = (t_int)atom_getfloatarg(0, argc, argv); - outlet_idx = outlet_flidx; - if(outlet_idx < 0 || outlet_idx >= x->x_numoutlets){ // bounds checking for outlet index - pd_error(x, "matrix~: %d is not a valid outlet index!", (int)outlet_idx); - return; - }; - argc--, argv++; - cell_idx = celloffset + outlet_idx; - x->x_cells[cell_idx] = onoff; - if(x->x_gains) // if in non-binary mode - matrix_retarget_connect(x, cell_idx); - }; -} - -static void matrix_ramp(t_matrix *x, t_floatarg f){ // CHECKED active ramps are not retargeted - if(x->x_ramps){ - x->x_deframp = (f < MATRIX_MINRAMP ? 0. : f); // CHECKED cell-specific ramps are lost - for(int i = 0; i < x->x_ncells; i++) - x->x_ramps[i] = x->x_deframp; - } -} - -static t_int *matrix01_perform(t_int *w){ - t_matrix *x = (t_matrix *)(w[1]); - int nblock = (int)(w[2]); - t_float **ivecs = x->x_ivecs; - t_float **ovecs = x->x_ovecs; - t_float **osums = x->x_osums; - int *cellp = x->x_cells; - int indx; - for(indx = 0; indx < x->x_numinlets; indx++){ - t_float *ivec = *ivecs++; - t_float **ovecp = osums; - if(indx){ - if(!magic_isnan(*x->x_signalscalars[indx])){ - pd_error(x, "matrix~: doesn't understand 'float'"); - magic_setnan(x->x_signalscalars[indx]); - } - if(!(x->x_hasfeeders[indx])) - ivec = x->x_zerovec; - } - int ondx = x->x_numoutlets; - while(ondx--){ - if(*cellp++){ - t_float *in = ivec; - t_float *out = *ovecp; - int sndx = nblock; - while(sndx--) - *out++ += *in++; - } - ovecp++; - } - } - osums = x->x_osums; - indx = x->x_numoutlets; - while(indx--){ - t_float *in = *osums++; - t_float *out = *ovecs++; - int sndx = nblock; - while(sndx--){ - *out++ = *in; - *in++ = 0.; - } - } - return(w+3); -} - -static t_int *matrixnb_perform(t_int *w){ - t_matrix *x = (t_matrix *)(w[1]); - int nblock = (int)(w[2]); - t_float **ivecs = x->x_ivecs; - t_float **ovecs = x->x_ovecs; - t_float **osums = x->x_osums; - int *cellp = x->x_cells; - float *gainp = x->x_gains; - float *coefp = x->x_coefs; - float *incrp = x->x_incrs; - float *bigincrp = x->x_bigincrs; - int *nleftp = x->x_remains; - int indx; - for(indx = 0; indx < x->x_numinlets; indx++){ - t_float *ivec = *ivecs++; - t_float **ovecp = osums; - if(indx){ - if(!magic_isnan(*x->x_signalscalars[indx])){ - pd_error(x, "matrix~: doesn't understand 'float'"); - magic_setnan(x->x_signalscalars[indx]); - } - if(!(x->x_hasfeeders[indx])) - ivec = x->x_zerovec; - } - int ondx = x->x_numoutlets; - while(ondx--){ - t_float *in = ivec; - t_float *out = *ovecp; - float nleft = *nleftp; - int sndx = nblock; - if(nleft >= nblock){ - float coef = *coefp; - float incr = *incrp; - if((*nleftp -= nblock) == 0) - *coefp = (*cellp ? *gainp : 0.); - else - *coefp += *bigincrp; - while(sndx--) - *out++ += *in++ * coef, coef += incr; - } - else if(nleft > 0){ - float coef = *coefp; - float incr = *incrp; - sndx -= nleft; - do{ - *out++ += *in++ * coef, coef += incr; - }while(--nleft); - if(*cellp){ - coef = *coefp = *gainp; - while(sndx--) - *out++ += *in++ * coef; - } - else - *coefp = 0.; - *nleftp = 0; - } - else if(*cellp){ - float coef = *coefp; - while(sndx--) - *out++ += *in++ * coef; - } - cellp++; - ovecp++; - gainp++; - coefp++; - incrp++; - bigincrp++; - nleftp++; - } - } - osums = x->x_osums; - indx = x->x_numoutlets; - while(indx--){ - t_float *in = *osums++; - t_float *out = *ovecs++; - int sndx = nblock; - while(sndx--){ - *out++ = *in; - *in++ = 0.; - } - } - return(w+3); -} - -static void matrix_dsp(t_matrix *x, t_signal **sp){ - int i, nblock = sp[0]->s_n; - t_float **vecp = x->x_ivecs; - t_signal **sigp = sp; - for(i = 0; i < x->x_numinlets; i++){ - *vecp++ = (*sigp++)->s_vec; - x->x_hasfeeders[i] = magic_inlet_connection((t_object *)x, x->x_glist, i, &s_signal); - }; - vecp = x->x_ovecs; - for(i = 0; i < x->x_numoutlets; i++) - *vecp++ = (*sigp++)->s_vec; - if(nblock != x->x_nblock){ - if(nblock > x->x_maxblock){ - size_t oldsize = x->x_maxblock * sizeof(*x->x_osums[i]), - newsize = nblock * sizeof(*x->x_osums[i]); - for(i = 0; i < x->x_numoutlets; i++) - x->x_osums[i] = resizebytes(x->x_osums[i], oldsize, newsize); - oldsize = x->x_maxblock * sizeof(*x->x_zerovec); - newsize = nblock * sizeof(*x->x_zerovec); - x->x_zerovec = resizebytes(x->x_zerovec, oldsize, newsize); - x->x_maxblock = nblock; - }; - x->x_nblock = nblock; - } - if(x->x_gains){ - x->x_ksr = sp[0]->s_sr * .001; - dsp_add(matrixnb_perform, 2, x, nblock); - } - else - dsp_add(matrix01_perform, 2, x, nblock); -} - -static void matrix_dump(t_matrix *x){ - int indx, ondx; - int *cellp = x->x_cells; - if(x->x_coefs){ // non binary mode! - float *gp = x->x_coefs; - for(indx = 0; indx < x->x_numinlets; indx++) - for(ondx = 0; ondx < x->x_numoutlets; ondx++, cellp++, gp++){ - t_atom atout[3]; - SETFLOAT(&atout[0], (t_float)indx); - SETFLOAT(&atout[1], (t_float)ondx); - SETFLOAT(&atout[2], *cellp ? *gp : 0.); - outlet_list(x->x_dumpout, &s_list, 3, atout); - } - } - else{ // binary mode - for(indx = 0; indx < x->x_numinlets; indx++) - for(ondx = 0; ondx < x->x_numoutlets; ondx++, cellp++){ - t_atom atout[3]; - SETFLOAT(&atout[0], (t_float)indx); - SETFLOAT(&atout[1], (t_float)ondx); - SETFLOAT(&atout[2], *cellp ? 1. : 0.); - outlet_list(x->x_dumpout, &s_list, 3, atout); - } - } -} - -static void matrix_dumptarget(t_matrix *x){ - int indx, ondx; - int *cellp = x->x_cells; - if(x->x_coefs){ // non binary mode! - float *gp = x->x_gains; - for(indx = 0; indx < x->x_numinlets; indx++) - for(ondx = 0; ondx < x->x_numoutlets; ondx++, cellp++, gp++){ - t_atom atout[3]; - SETFLOAT(&atout[0], (t_float)indx); - SETFLOAT(&atout[1], (t_float)ondx); - SETFLOAT(&atout[2], *cellp ? *gp : 0.); - outlet_list(x->x_dumpout, &s_list, 3, atout); - } - } - else{ // also prints in binary mode - for(indx = 0; indx < x->x_numinlets; indx++) - for(ondx = 0; ondx < x->x_numoutlets; ondx++, cellp++){ - t_atom atout[3]; - SETFLOAT(&atout[0], (t_float)indx); - SETFLOAT(&atout[1], (t_float)ondx); - SETFLOAT(&atout[2], *cellp ? 1. : 0.); - outlet_list(x->x_dumpout, &s_list, 3, atout); - } - } -} - -static void matrix_print(t_matrix *x){ // CHECKED same as 'dump' - int indx, ondx; - int *cellp = x->x_cells; - if(x->x_coefs){ // non binary mode! - float *gp = x->x_coefs; - for(indx = 0; indx < x->x_numinlets; indx++) - for(ondx = 0; ondx < x->x_numoutlets; ondx++, cellp++, gp++) - post("%d %d %g", indx, ondx, *cellp ? *gp : 0.); - } - else{ // binary mode - for(indx = 0; indx < x->x_numinlets; indx++) - for(ondx = 0; ondx < x->x_numoutlets; ondx++, cellp++) - post("%d %d %g", indx, ondx, *cellp ? 1. : 0.); - } -} - -static void *matrix_free(t_matrix *x){ - if(x->x_ivecs) - freebytes(x->x_ivecs, x->x_numinlets * sizeof(*x->x_ivecs)); - if(x->x_ovecs) - freebytes(x->x_ovecs, x->x_numoutlets * sizeof(*x->x_ovecs)); - if(x->x_osums){ - int i; - for(i = 0; i < x->x_numoutlets; i++) - freebytes(x->x_osums[i], x->x_maxblock * sizeof(*x->x_osums[i])); - freebytes(x->x_zerovec, x->x_maxblock * sizeof(*x->x_zerovec)); - freebytes(x->x_osums, x->x_numoutlets * sizeof(*x->x_osums)); - } - if(x->x_cells) - freebytes(x->x_cells, x->x_ncells * sizeof(*x->x_cells)); - if(x->x_gains) - freebytes(x->x_gains, x->x_ncells * sizeof(*x->x_gains)); - if(x->x_ramps) - freebytes(x->x_ramps, x->x_ncells * sizeof(*x->x_ramps)); - if(x->x_coefs) - freebytes(x->x_coefs, x->x_ncells * sizeof(*x->x_coefs)); - if(x->x_incrs) - freebytes(x->x_incrs, x->x_ncells * sizeof(*x->x_incrs)); - if(x->x_bigincrs) - freebytes(x->x_bigincrs, x->x_ncells * sizeof(*x->x_bigincrs)); - if(x->x_remains) - freebytes(x->x_remains, x->x_ncells * sizeof(*x->x_remains)); - return(void *)x; -} - -static void *matrix_new(t_symbol *s, int argc, t_atom *argv){ - s = NULL; - t_matrix *x = (t_matrix *)pd_new(matrix_class); - t_float rampval = MATRIX_DEFRAMP; - t_float nan32; - magic_setnan(&nan32); - x->x_numinlets = (int)MATRIX_MININLETS; - x->x_numoutlets = (int)MATRIX_MINOUTLETS; - x->x_defgain = MATRIX_DEFGAIN; - int i; - int argnum = 0; - while(argc > 0){ - if(argv->a_type == A_FLOAT){ - t_float argval = atom_getfloatarg(0, argc, argv); - switch(argnum){ - case 0: - if(argval < MATRIX_MININLETS) - x->x_numinlets = (int)MATRIX_MININLETS; - else if(argval > MATRIX_MAXINLETS){ - x->x_numinlets = (int)MATRIX_MAXINLETS; - post("matrix~: resizing to %d signal inlets", (int)MATRIX_MAXINLETS); - } - else - x->x_numinlets = (int)argval; - break; - case 1: - if(argval < MATRIX_MINOUTLETS) - x->x_numoutlets = (int)MATRIX_MINOUTLETS; - else if(argval > MATRIX_MAXOUTLETS){ - x->x_numoutlets = (int)MATRIX_MAXOUTLETS; - post("matrix~: resizing to %d signal outlets", (int)MATRIX_MAXOUTLETS); - } - else - x->x_numoutlets = (int)argval; - break; - case 2: - x->x_defgain = argval; - break; - default: - break; - }; - argc--, argv++, argnum++; - } - else if(argv->a_type == A_SYMBOL){ - t_symbol *argname = atom_getsymbolarg(0, argc, argv); - if(argname == gensym("@ramp")){ - if(argc >= 2){ - t_float argval = atom_getfloatarg(1, argc, argv); - if(argval < MATRIX_MINRAMP) - rampval = MATRIX_MINRAMP; - else - rampval = argval; - argc -= 2; - argv += 2; - } - else - goto errstate; - } - else - goto errstate; - } - else - goto errstate; - }; - x->x_ncells = x->x_numinlets * x->x_numoutlets; - x->x_ivecs = getbytes(x->x_numinlets * sizeof(*x->x_ivecs)); - x->x_ovecs = getbytes(x->x_numoutlets * sizeof(*x->x_ovecs)); - x->x_nblock = x->x_maxblock = sys_getblksize(); - x->x_osums = getbytes(x->x_numoutlets * sizeof(*x->x_osums)); - for(i = 0; i < x->x_numoutlets; i++) - x->x_osums[i] = getbytes(x->x_maxblock * sizeof(*x->x_osums[i])); - x->x_cells = getbytes(x->x_ncells * sizeof(*x->x_cells)); - // zerovec for filtering float inputs - x->x_zerovec = getbytes(x->x_maxblock * sizeof(*x->x_zerovec)); - matrix_clear(x); - if(argnum >= 3){ //non binary mode - x->x_gains = getbytes(x->x_ncells * sizeof(*x->x_gains)); - for(i = 0; i < x->x_ncells; i++) - x->x_gains[i] = x->x_defgain; - x->x_ramps = getbytes(x->x_ncells * sizeof(*x->x_ramps)); - matrix_ramp(x, rampval); - x->x_coefs = getbytes(x->x_ncells * sizeof(*x->x_coefs)); - for(i = 0; i < x->x_ncells; i++) - x->x_coefs[i] = 0.; - x->x_ksr = sys_getsr() * .001; - x->x_incrs = getbytes(x->x_ncells * sizeof(*x->x_incrs)); - x->x_bigincrs = getbytes(x->x_ncells * sizeof(*x->x_bigincrs)); - x->x_remains = getbytes(x->x_ncells * sizeof(*x->x_remains)); - for(i = 0; i < x->x_ncells; i++) - x->x_remains[i] = 0; - } - else{ - x->x_gains = 0; - x->x_ramps = 0; - x->x_coefs = 0; - x->x_incrs = 0; - x->x_bigincrs = 0; - x->x_remains = 0; - }; - for(i = 1; i < x->x_numinlets; i++){ - pd_float( (t_pd *)inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal), nan32); - x->x_signalscalars[i] = obj_findsignalscalar((t_object *)x, i); - }; - for(i = 0; i < x->x_numoutlets; i++) - outlet_new(&x->x_obj, gensym("signal")); - x->x_dumpout = outlet_new((t_object *)x, &s_list); - x->x_glist = canvas_getcurrent(); - return(x); - errstate: - pd_error(x, "matrix~: improper args"); - return(NULL); -} - -CYCLONE_OBJ_API void matrix_tilde_setup(void){ - matrix_class = class_new(gensym("matrix~"), (t_newmethod)matrix_new, - (t_method)matrix_free, sizeof(t_matrix), 0, A_GIMME, 0); - class_addmethod(matrix_class, nullfn, gensym("signal"), 0); - class_addfloat(matrix_class, matrix_float); - class_addlist(matrix_class, matrix_list); - class_addmethod(matrix_class, (t_method)matrix_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(matrix_class, (t_method)matrix_clear, gensym("clear"), 0); - class_addmethod(matrix_class, (t_method)matrix_connect, gensym("connect"), A_GIMME, 0); - class_addmethod(matrix_class, (t_method)matrix_connect, gensym("disconnect"), A_GIMME, 0); - class_addmethod(matrix_class, (t_method)matrix_ramp, gensym("ramp"), A_FLOAT, 0); - class_addmethod(matrix_class, (t_method)matrix_dump, gensym("dump"), 0); - class_addmethod(matrix_class, (t_method)matrix_dumptarget, gensym("dumptarget"), 0); - class_addmethod(matrix_class, (t_method)matrix_print, gensym("print"), 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/maximum.c b/Libraries/cyclone/cyclone_objects/binaries/audio/maximum.c deleted file mode 100644 index 667f72dc96..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/maximum.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -// LATER use hasfeeders (why?) - -#include "m_pd.h" -#include - -typedef struct _maximum { - t_object x_obj; - t_float x_input; //dummy var - t_inlet *x_inlet1; // main 1st inlet - t_inlet *x_inlet2; // 2nd inlet - t_outlet *x_outlet; -} t_maximum; - -static t_class *maximum_class; - -static t_int *maximum_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f1 > f2 ? f1 : f2); - } - return (w + 5); -} - -static void maximum_dsp(t_maximum *x, t_signal **sp) -{ - dsp_add(maximum_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -static void *maximum_new(t_floatarg f) -{ - t_maximum *x = (t_maximum *)pd_new(maximum_class); - x->x_inlet2 = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet2, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void maximum_tilde_setup(void){ - maximum_class = class_new(gensym("maximum~"), (t_newmethod)maximum_new, 0, - sizeof(t_maximum), 0, A_DEFFLOAT, 0); - class_addmethod(maximum_class, (t_method)maximum_dsp, gensym("dsp"), A_CANT, 0); - CLASS_MAINSIGNALIN(maximum_class, t_maximum, x_input); - pd_error(maximum_class, "[cyclone/maximum~] is deprecated, consider using vanilla's [max~] instead"); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/minimum.c b/Libraries/cyclone/cyclone_objects/binaries/audio/minimum.c deleted file mode 100644 index e970d9fda3..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/minimum.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -// LATER use hasfeeders (why?) - -#include "m_pd.h" -#include - -typedef struct _minimum { - t_object x_obj; - t_float x_input; //dummy var - t_inlet *x_inlet1; // main 1st inlet - t_inlet *x_inlet2; // 2nd inlet - t_outlet *x_outlet; -} t_minimum; - -static t_class *minimum_class; - -static t_int *minimum_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f1 < f2 ? f1 : f2); - } - return (w + 5); -} - -static void minimum_dsp(t_minimum *x, t_signal **sp) -{ - dsp_add(minimum_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -static void *minimum_new(t_floatarg f) -{ - t_minimum *x = (t_minimum *)pd_new(minimum_class); - x->x_inlet2 = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet2, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void minimum_tilde_setup(void){ - minimum_class = class_new(gensym("minimum~"), - (t_newmethod)minimum_new, 0, sizeof(t_minimum), 0, A_DEFFLOAT, 0); - class_addmethod(minimum_class, (t_method)minimum_dsp, gensym("dsp"), A_CANT, 0); - CLASS_MAINSIGNALIN(minimum_class, t_minimum, x_input); - pd_error(minimum_class, "[cyclone/minimum~] is deprecated, consider using vanilla's [min~] instead"); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/minmax.c b/Libraries/cyclone/cyclone_objects/binaries/audio/minmax.c deleted file mode 100644 index b1647a7f7b..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/minmax.c +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include -#include -#include "common/magicbit.h" - -typedef struct _minmax -{ - t_object x_obj; - t_inlet *x_inlet; - t_float x_min; - t_float x_max; - t_outlet *x_minout; - t_outlet *x_maxout; - - t_glist *x_glist; - t_float *x_signalscalar; - t_int x_feederflag; - t_int x_feederflag2; -} t_minmax; - -static t_class *minmax_class; - -//EXTERN t_float *obj_findsignalscalar(t_object *x, int m); - -static void minmax_bang(t_minmax *x) -{ - if (x->x_feederflag) { - outlet_float(x->x_maxout, x->x_max); - outlet_float(x->x_minout, x->x_min); - } - else { - outlet_float(x->x_maxout, 0); - outlet_float(x->x_minout, 0); - } -} - -static void minmax_reset(t_minmax *x) -{ - x->x_min = INFINITY; - x->x_max = -INFINITY; -} - -static t_int *minmax_perform(t_int *w) -{ - t_minmax *x = (t_minmax *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *outmin = (t_float *)(w[5]); - t_float *outmax = (t_float *)(w[6]); - t_float fmin = x->x_min; - t_float fmax = x->x_max; - -// MAGIC for float for error - if (!magic_isnan(*x->x_signalscalar)) - { - magic_setnan(x->x_signalscalar); - pd_error(x, "minmax~: doesn't understand 'float'"); - } - - while (nblock--) - { - t_float f = *in1++; - t_float reset; - - if (x->x_feederflag2) reset = *in2++; - else reset = 0.0; - - if (reset != 0) fmin = fmax = f; - else { - if (f < fmin) fmin = f; - if (f > fmax) fmax = f; - } - *outmin++ = fmin; - *outmax++ = fmax; - } - x->x_min = fmin; - x->x_max = fmax; - return (w + 7); -} - -static t_int *minmax_perform_no_in(t_int *w) -{ - t_minmax *x = (t_minmax *)(w[1]); - int nblock = (int)(w[2]); - t_float *outmin = (t_float *)(w[5]); - t_float *outmax = (t_float *)(w[6]); - - // MAGIC for float for error - if (!magic_isnan(*x->x_signalscalar)) - { - magic_setnan(x->x_signalscalar); - pd_error(x, "minmax~: doesn't understand 'float'"); - } - - while (nblock--) - { - *outmin++ = *outmax++ = 0; - } - return (w + 7); -} - -static void minmax_dsp(t_minmax *x, t_signal **sp) -{ - x->x_feederflag = magic_inlet_connection((t_object *)x, x->x_glist, 0, &s_signal); - x->x_feederflag2 = magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal); - if (x->x_feederflag) dsp_add(minmax_perform, 6, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); - else dsp_add(minmax_perform_no_in, 6, x, sp[0]->s_n, sp[0]->s_vec, - sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); -} - -static void *minmax_new(void) -{ - t_minmax *x = (t_minmax *)pd_new(minmax_class); - inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - outlet_new((t_object *)x, &s_signal); - outlet_new((t_object *)x, &s_signal); - x->x_glist = canvas_getcurrent(); - x->x_signalscalar = obj_findsignalscalar((t_object *)x, 1); - magic_setnan(x->x_signalscalar); - x->x_minout = outlet_new((t_object *)x, &s_float); - x->x_maxout = outlet_new((t_object *)x, &s_float); - minmax_reset(x); - return (x); -} - -CYCLONE_OBJ_API void minmax_tilde_setup(void) -{ - minmax_class = class_new(gensym("minmax~"), - (t_newmethod)minmax_new, 0, sizeof(t_minmax), 0, 0); - class_addmethod(minmax_class, nullfn, gensym("signal"), 0); - class_addmethod(minmax_class, (t_method)minmax_dsp, gensym("dsp"), A_CANT, 0); - class_addbang(minmax_class, minmax_bang); - class_addmethod(minmax_class, (t_method)minmax_reset, gensym("reset"), 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/modulo.c b/Libraries/cyclone/cyclone_objects/binaries/audio/modulo.c deleted file mode 100644 index 29dd710d0c..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/modulo.c +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2016 Porres. - -#include "m_pd.h" -#include -#include "math.h" - -// --------------------------------------------------- -// Class definition -// --------------------------------------------------- -static t_class *modulo_class; - -// --------------------------------------------------- -// Data structure definition -// --------------------------------------------------- -typedef struct _modulo -{ - t_object x_obj; - t_inlet *x_inlet; -} t_modulo; - -// --------------------------------------------------- -// Perform -// --------------------------------------------------- -static t_int *modulo_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f2 == 0. ? 0. : fmod(f1, f2)); - } - return (w + 5); -} - -// --------------------------------------------------- -// DSP Function -// --------------------------------------------------- -static void modulo_dsp(t_modulo *x, t_signal **sp) -{ - dsp_add(modulo_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -// FREE -static void *modulo_free(t_modulo *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -// --------------------------------------------------- -// Functions signature -// --------------------------------------------------- -static void *modulo_new(t_floatarg f) -{ - t_modulo *x = (t_modulo *)pd_new(modulo_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -// --------------------------------------------------- -// Setup -// --------------------------------------------------- -CYCLONE_OBJ_API void modulo_tilde_setup(void) -{ - modulo_class = class_new(gensym("modulo~"), - (t_newmethod)modulo_new, - (t_method)modulo_free, - sizeof(t_modulo), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(modulo_class, nullfn, gensym("signal"), 0); - class_addmethod(modulo_class, (t_method)modulo_dsp, gensym("dsp"), A_CANT, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/mstosamps.c b/Libraries/cyclone/cyclone_objects/binaries/audio/mstosamps.c deleted file mode 100644 index 243b2530f9..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/mstosamps.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (c) 2003 krzYszcz, and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -typedef struct _mstosamps{ - t_object x_obj; - float x_sr_khz; - float x_f; - t_outlet *x_floatout; -}t_mstosamps; - -static t_class *mstosamps_class; - -static void mstosamps_float(t_mstosamps *x, t_float f){ - outlet_float(x->x_floatout, (x->x_f = f) * x->x_sr_khz); -} - -static t_int *mstosamps_perform(t_int *w){ - t_mstosamps *x = (t_mstosamps *)(w[1]); - int n = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while(n--) - *out++ = *in++ * x->x_sr_khz; - return(w+5); -} - -static void mstosamps_dsp(t_mstosamps *x, t_signal **sp){ - x->x_sr_khz = sp[0]->s_sr * .001; - dsp_add(mstosamps_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void *mstosamps_new(void){ - t_mstosamps *x = (t_mstosamps *)pd_new(mstosamps_class); - x->x_sr_khz = sys_getsr() * .001; - x->x_f = 0; - outlet_new((t_object *)x, &s_signal); - x->x_floatout = outlet_new((t_object *)x, &s_float); - return(x); -} - -CYCLONE_OBJ_API void mstosamps_tilde_setup(void){ - mstosamps_class = class_new(gensym("mstosamps~"), - (t_newmethod)mstosamps_new, 0, sizeof(t_mstosamps), CLASS_DEFAULT, 0); - class_addmethod(mstosamps_class, (t_method)mstosamps_dsp, gensym("dsp"), A_CANT, 0); - CLASS_MAINSIGNALIN(mstosamps_class, t_mstosamps, x_f); - class_addfloat(mstosamps_class, (t_method)mstosamps_float); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/notequals.c b/Libraries/cyclone/cyclone_objects/binaries/audio/notequals.c deleted file mode 100644 index eb4c4aa3d7..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/notequals.c +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2016 Porres. - -#include "m_pd.h" -#include - -// --------------------------------------------------- -// Class definition -// --------------------------------------------------- -static t_class *notequals_class; - -// --------------------------------------------------- -// Data structure definition -// --------------------------------------------------- -typedef struct _notequals -{ - t_object x_obj; - t_inlet *x_inlet; -} t_notequals; - -// --------------------------------------------------- -// Perform -// --------------------------------------------------- -static t_int *notequals_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f1 != f2); - } - return (w + 5); -} - -// --------------------------------------------------- -// DSP Function -// --------------------------------------------------- -static void notequals_dsp(t_notequals *x, t_signal **sp) -{ - dsp_add(notequals_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -// FREE -static void *notequals_free(t_notequals *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -// --------------------------------------------------- -// Functions signature -// --------------------------------------------------- -static void *notequals_new(t_floatarg f) -{ - t_notequals *x = (t_notequals *)pd_new(notequals_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -// --------------------------------------------------- -// Setup -// --------------------------------------------------- -CYCLONE_OBJ_API void notequals_tilde_setup(void) -{ - notequals_class = class_new(gensym("notequals~"), - (t_newmethod)notequals_new, - (t_method)notequals_free, - sizeof(t_notequals), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(notequals_class, nullfn, gensym("signal"), 0); - class_addmethod(notequals_class, (t_method)notequals_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/onepole.c b/Libraries/cyclone/cyclone_objects/binaries/audio/onepole.c deleted file mode 100644 index 4e17695aec..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/onepole.c +++ /dev/null @@ -1,164 +0,0 @@ -/* Copyright (c) 2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* This is Pd's lop~ with signal-controlled cutoff. */ - -/* CHECKED scalar case: input preserved (not coefs) after changing mode */ -/* CHECKME if creation arg (or a default) restored after signal disconnection */ - -#define _USE_MATH_DEFINES -#include -#include "m_pd.h" -#include - -#define ONEPOLE_HZ 0 -#define ONEPOLE_LINEAR 1 -#define ONEPOLE_RADIANS 2 -#define ONEPOLE_MINB0 .0001 /* CHECKED 1st term of ir for b0=0 */ -#define ONEPOLE_MAXB0 .99 /* CHECKED 1st term of ir for b0=1 */ -#define ONEPOLE_MINOMEGA 0. /* CHECKME */ -#define ONEPOLE_MAXOMEGA (M_PI * .5) // later remove -#define TWO_PI (M_PI * 2.) - -typedef struct _onepole -{ - t_object x_obj; - t_inlet *x_inlet; - int x_mode; - float x_srcoef; - float x_ynm1; -} t_onepole; - -static t_class *onepole_class; - -static t_symbol *ps_hz; -static t_symbol *ps_linear; -static t_symbol *ps_radians; - -static void onepole_clear(t_onepole *x) -{ - x->x_ynm1 = 0.; -} - -static void onepole_hz(t_onepole *x) -{ - x->x_mode = ONEPOLE_HZ; -} - -static void onepole_linear(t_onepole *x) -{ - x->x_mode = ONEPOLE_LINEAR; -} - -static void onepole_radians(t_onepole *x) -{ - x->x_mode = ONEPOLE_RADIANS; -} - -/* LATER make ready for optional audio-rate modulation - (separate scalar case routine, use sic_makecostable(), etc.) */ -static t_int *onepole_perform(t_int *w) -{ - t_onepole *x = (t_onepole *)(w[1]); - int nblock = (int)(w[2]); - t_float *xin = (t_float *)(w[3]); - t_float fin0 = *(t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - int mode = x->x_mode; - float ynm1 = x->x_ynm1; - /* CHECKME sampled once per block */ - float b0; - if (mode == ONEPOLE_HZ) - { - float omega = fin0 * x->x_srcoef; - if (omega < ONEPOLE_MINOMEGA) - omega = ONEPOLE_MINOMEGA; - else if (omega > ONEPOLE_MAXOMEGA) - omega = ONEPOLE_MAXOMEGA; - /* The actual solution for a half-power cutoff is: - b0 = sqrt(sqr(2-cos(omega))-1) + cos(omega) - 1. - The sin(omega) below is only slightly better approximation than - Miller's b0=omega, except for the two highest octaves (or so), - where it is much better (but far from good). */ - b0 = sinf(omega); - } - else if (mode == ONEPOLE_LINEAR) - b0 = sinf(fin0 * (M_PI * .5)); /* CHECKME actual range of fin0 */ - else - b0 = fin0; - if (b0 < ONEPOLE_MINB0) - b0 = ONEPOLE_MINB0; - else if (b0 > ONEPOLE_MAXB0) - b0 = ONEPOLE_MAXB0; - /* b0 is the standard 1-|a1| (where |a1| is pole's radius), - specifically: a1=b0-1 => a1 in [-.9999 .. -.01] => lowpass (stable) */ - while (nblock--) - *out++ = ynm1 = b0 * (*xin++ - ynm1) + ynm1; - x->x_ynm1 = (PD_BIGORSMALL(ynm1) ? 0. : ynm1); - return (w + 6); -} - -static void onepole_dsp(t_onepole *x, t_signal **sp) -{ - x->x_srcoef = TWO_PI / sp[0]->s_sr; - onepole_clear(x); - dsp_add(onepole_perform, 5, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - - -static void *onepole_new(t_symbol *s, int ac, t_atom *av) -{ - t_onepole *x = (t_onepole *)pd_new(onepole_class); - t_float f = 1; - t_symbol *sym; - switch(ac) - { - default: - case 2: - sym=atom_getsymbol(av+1); - case 1: - f=atom_getfloat(av); - break; - case 0: - break; - } - - x->x_srcoef = TWO_PI / sys_getsr(); - /* CHECKED no int-to-float conversion (any int bashed to 0.) */ - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - onepole_clear(x); - if (sym == ps_linear) - x->x_mode = ONEPOLE_LINEAR; - else if (sym == ps_radians) - x->x_mode = ONEPOLE_RADIANS; - else - { - x->x_mode = ONEPOLE_HZ; - if (s && s != &s_ && s != ps_hz && s != gensym("Hz")) - { - /* CHECKED no warning */ - } - } - return (x); -} - -// anything for hz? -CYCLONE_OBJ_API void onepole_tilde_setup(void) -{ - ps_hz = gensym("hz"); - ps_linear = gensym("linear"); - ps_radians = gensym("radians"); - onepole_class = class_new(gensym("onepole~"), (t_newmethod)onepole_new, 0, - sizeof(t_onepole), 0, A_GIMME, 0); - class_addmethod(onepole_class, nullfn, gensym("signal"), 0); - class_addmethod(onepole_class, (t_method)onepole_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(onepole_class, (t_method)onepole_clear, gensym("clear"), 0); - class_addmethod(onepole_class, (t_method)onepole_hz, ps_hz, 0); - class_addmethod(onepole_class, (t_method)onepole_hz, gensym("Hz"), 0); - class_addmethod(onepole_class, (t_method)onepole_linear, ps_linear, 0); - class_addmethod(onepole_class, (t_method)onepole_radians, ps_radians, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/overdrive.c b/Libraries/cyclone/cyclone_objects/binaries/audio/overdrive.c deleted file mode 100644 index 6135d44780..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/overdrive.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (c) 2005 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -// Updated by Porres in 2016 - -#include -#include "m_pd.h" -#include - -typedef struct _overdrive -{ - t_object x_obj; - t_inlet *x_inlet; - float x_drivefactor; -} t_overdrive; - -static t_class *overdrive_class; - -// this is an actual behaviour in Max that was replicated in cyclone before. -// it's a design flaw, redundanct and undocumented in Max and kept for backwards -// compatibility, but won't be documented anymore (Porres 2016). -static void overdrive_float(t_overdrive *x, t_float f) -{ - x->x_drivefactor = f; - pd_float((t_pd *)x->x_inlet, x->x_drivefactor); -} - -/* CHECKED negative parameter values may cause output to go out of bounds */ -static t_int *overdrive_perform(t_int *w) -{ - t_overdrive *x = (t_overdrive *)(w[1]); - int nblock = (t_int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_float df = x->x_drivefactor; - while (nblock--) - { - float f = *in1++; - df = *in2++; - if (f >= 1.) /* CHECKED incompatible (garbage for sig~ 1.) */ - *out++ = 1.; /* CHECKED constant for > 1. */ - else if (f > 0.) - *out++ = 1. - powf(1. - f, df); /* CHECKED */ - else if (f > -1.) /* CHECKED incompatible (garbage for sig~ -1.) */ - *out++ = powf(1. + f, df) - 1.; /* CHECKED */ - else - *out++ = -1.; /* CHECKED constant for < -1. */ - } - return (w + 6); -} - -static void overdrive_dsp(t_overdrive *x, t_signal **sp) -{ - dsp_add(overdrive_perform, 5, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -// FREE -static void *overdrive_free(t_overdrive *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -static void *overdrive_new(t_floatarg f) -{ - t_overdrive *x = (t_overdrive *)pd_new(overdrive_class); - x->x_drivefactor = f; - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, x->x_drivefactor); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void overdrive_tilde_setup(void) -{ - overdrive_class = class_new(gensym("overdrive~"), - (t_newmethod)overdrive_new, (t_method)overdrive_free, - sizeof(t_overdrive), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(overdrive_class, nullfn, gensym("signal"), 0); - class_addmethod(overdrive_class, (t_method)overdrive_dsp, gensym("dsp"), A_CANT, 0); - class_addfloat(overdrive_class, (t_method)overdrive_float); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/peakamp.c b/Libraries/cyclone/cyclone_objects/binaries/audio/peakamp.c deleted file mode 100644 index dc918463bf..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/peakamp.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -typedef struct _peakamp -{ - t_object x_obj; - t_inlet *peakamp; - t_float x_value; - int x_nwait; - int x_nleft; - int x_precount; - float x_waittime; - float x_ksr; - t_clock *x_clock; -} t_peakamp; - -static t_class *peakamp_class; - -static void peakamp_tick(t_peakamp *x) -{ - outlet_float(((t_object *)x)->ob_outlet, x->x_value); - x->x_value = 0; - if ((x->x_nleft = x->x_nwait - x->x_precount) < 0) /* CHECKME */ - x->x_nleft = 0; -} - -static void peakamp_bang(t_peakamp *x) -{ - peakamp_tick(x); /* CHECKME */ -} - -static void peakamp_ft1(t_peakamp *x, t_floatarg f) -{ - if ((x->x_waittime = f) < 0.) - x->x_waittime = 0.; - if ((x->x_nwait = (int)(x->x_waittime * x->x_ksr)) < 0) - x->x_nwait = 0; -} - -static t_int *peakamp_perform(t_int *w) -{ - t_peakamp *x = (t_peakamp *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float value = x->x_value; - if (x->x_nwait) - { - if (x->x_nleft < nblock) - { - clock_delay(x->x_clock, 0); - x->x_precount = nblock - x->x_nleft; - x->x_nleft = 0; /* LATER rethink */ - } - else x->x_nleft -= nblock; - } - while (nblock--) - { - t_float f = *in++; - if (f > value) - value = f; - else if (f < -value) - value = -f; - } - x->x_value = value; - return (w + 4); -} - -static void peakamp_dsp(t_peakamp *x, t_signal **sp) -{ - x->x_ksr = sp[0]->s_sr * 0.001; - x->x_nwait = (int)(x->x_waittime * x->x_ksr); - dsp_add(peakamp_perform, 3, x, sp[0]->s_n, sp[0]->s_vec); -} - -static void peakamp_free(t_peakamp *x) -{ - if (x->x_clock) clock_free(x->x_clock); -} - -static void *peakamp_new(t_floatarg f) -{ - t_peakamp *x = (t_peakamp *)pd_new(peakamp_class); - x->x_value = 0.; - x->x_nleft = 0; - x->x_ksr = sys_getsr() * 0.001; - peakamp_ft1(x, f); - inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); - outlet_new((t_object *)x, &s_float); - x->x_clock = clock_new(x, (t_method)peakamp_tick); - return (x); -} - -CYCLONE_OBJ_API void peakamp_tilde_setup(void) -{ - peakamp_class = class_new(gensym("peakamp~"), - (t_newmethod)peakamp_new, - (t_method)peakamp_free, - sizeof(t_peakamp), 0, - A_DEFFLOAT, 0); - class_addmethod(peakamp_class, nullfn, gensym("signal"), 0); - class_addmethod(peakamp_class, (t_method) peakamp_dsp, gensym("dsp"), A_CANT, 0); - class_addbang(peakamp_class, peakamp_bang); - class_addmethod(peakamp_class, (t_method)peakamp_ft1, - gensym("ft1"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/peek.c b/Libraries/cyclone/cyclone_objects/binaries/audio/peek.c deleted file mode 100644 index 9f7c9827c8..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/peek.c +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* LATER: 'click' method */ - -#include -#include "m_pd.h" -#include -#include "signal/cybuf.h" -#define PEEK_MAXCHANNELS 64 /* LATER implement arsic resizing feature */ -#define PEEK_TICK_TIME 2 // - -typedef struct _peek -{ - t_object x_obj; - t_cybuf *x_cybuf; - int x_channum; - int x_clipmode; - int x_pokemode; - t_float x_value; - t_clock *x_clock; - double x_clocklasttick; - int x_clockset; - - t_inlet *x_vallet; - t_inlet *x_chanlet; - t_outlet *x_outlet; -} t_peek; - -static t_class *peek_class; - -static void peek_tick(t_peek *x) -{ - cybuf_redraw(x->x_cybuf); /* LATER redraw only dirty channel(s!) */ - x->x_clockset = 0; - x->x_clocklasttick = clock_getlogicaltime(); -} - -static void peek_set(t_peek *x, t_symbol *s) -{ - cybuf_setarray(x->x_cybuf, s); -} - -#define peek_doclip(f) (f < -1. ? -1. : (f > 1. ? 1. : f)) - -/* CHECKED refman's error: ``if the number received in the left inlet - specifies a sample index that does not exist in the buffer~ object's - currently allocated memory, nothing happens.'' This is plainly wrong, - at least for max/msp 4.0.7 bundle: the index is clipped (just like - in tabread/tabwrite). As a kind of an experiment, lets make this - the refman's way... */ -static void peek_float(t_peek *x, t_float f) -{ - t_cybuf * c = x->x_cybuf; - t_word *vp = c->c_vectors[0]; - //second arg is to allow error posting - cybuf_validate(c, 1); /* LATER rethink (efficiency, and complaining) */ - if (vp) - { - int ndx = (int)f; - if (ndx >= 0 && ndx < c->c_npts) - { - if (x->x_pokemode) - { - double timesince; - t_float val = x->x_value; - vp[ndx].w_float = (x->x_clipmode ? peek_doclip(val) : val); - x->x_pokemode = 0; - timesince = clock_gettimesince(x->x_clocklasttick); - if (timesince > PEEK_TICK_TIME) peek_tick(x); - else if (!x->x_clockset) - { - clock_delay(x->x_clock, PEEK_TICK_TIME - timesince); - x->x_clockset = 1; - } - } - /* CHECKED: output not clipped */ - else outlet_float(x->x_outlet, vp[ndx].w_float); - } - } -} - -static void peek_value(t_peek *x, t_floatarg f) -{ - x->x_value = f; - x->x_pokemode = 1; - /* CHECKED: poke-mode is reset only after receiving left inlet input - -- it is kept across 'channel', 'clip', and 'set' inputs. */ -} - -static void peek_channel(t_peek *x, t_floatarg f) -{ - int ch = f < 1 ? 1 : (f > CYBUF_MAXCHANS ? CYBUF_MAXCHANS : (int) f); - x->x_channum = ch; - cybuf_getchannel(x->x_cybuf, ch, 1); -} - -static void peek_clip(t_peek *x, t_floatarg f) -{ - x->x_clipmode = ((int)f != 0); -} - -static void peek_free(t_peek *x) -{ - if (x->x_clock) clock_free(x->x_clock); - inlet_free(x->x_vallet); - inlet_free(x->x_chanlet); - outlet_free(x->x_outlet); - cybuf_free(x->x_cybuf); -} - -static void *peek_new(t_symbol *s, t_floatarg f1, t_floatarg f2) -{ - //should default to 1? - int ch = (f1 > 0 ? (int)f1 : 1); - t_peek *x = (t_peek *)pd_new(peek_class); - x->x_cybuf = cybuf_init((t_class *)x, s, 1, (ch > CYBUF_MAXCHANS ? CYBUF_MAXCHANS: ch)); - if (x->x_cybuf) - { - if (ch > PEEK_MAXCHANNELS) ch = PEEK_MAXCHANNELS; - x->x_channum = ch; - /* CHECKED (refman's error) clipping is disabled by default */ - x->x_clipmode = ((int)f2 != 0); - x->x_pokemode = 0; - x->x_vallet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("value")); - x->x_chanlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("channel")); - x->x_outlet = outlet_new(&x->x_obj, &s_float); - x->x_clock = clock_new(x, (t_method)peek_tick); - x->x_clocklasttick = clock_getlogicaltime(); - x->x_clockset = 0; - } - return (x); -} - -CYCLONE_OBJ_API void peek_tilde_setup(void) -{ - peek_class = class_new(gensym("peek~"), - (t_newmethod)peek_new, - (t_method)peek_free, - sizeof(t_peek), 0, - A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addfloat(peek_class, peek_float); - class_addmethod(peek_class, (t_method)peek_set, - gensym("set"), A_SYMBOL, 0); - class_addmethod(peek_class, (t_method)peek_value, - gensym("value"), A_FLOAT, 0); - class_addmethod(peek_class, (t_method)peek_channel, - gensym("channel"), A_FLOAT, 0); - class_addmethod(peek_class, (t_method)peek_clip, - gensym("clip"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/phaseshift.c b/Libraries/cyclone/cyclone_objects/binaries/audio/phaseshift.c deleted file mode 100644 index 3633b64a1a..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/phaseshift.c +++ /dev/null @@ -1,97 +0,0 @@ -// Porres 2016 - -#define _USE_MATH_DEFINES - -#include "m_pd.h" -#include -#include - -#define PI M_PI - -typedef struct _phaseshift{ - t_object x_obj; - t_inlet *x_inlet_freq; - t_inlet *x_inlet_q; - t_outlet *x_out; - t_float x_nyq; - t_float x_x1; - t_float x_x2; - t_float x_y1; - t_float x_y2; - t_float x_lastq; -}t_phaseshift; - -static t_class *phaseshift_class; - -void phaseshift_clear(t_phaseshift *x){ - x->x_x1 = x->x_x2 = x->x_y1 = x->x_y2 = 0.; -} - -static t_int *phaseshift_perform(t_int *w){ - t_phaseshift *x = (t_phaseshift *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *in3 = (t_float *)(w[5]); - t_float *out = (t_float *)(w[6]); - t_float x1 = x->x_x1; - t_float x2 = x->x_x2; - t_float y1 = x->x_y1; - t_float y2 = x->x_y2; - t_float nyq = x->x_nyq; - t_float lastq = x->x_lastq; - while (nblock--){ - float omega, alphaQ, b0, a0, a1, yn, xn = *in1++, f = *in2++, q = *in3++; - if (q < 0) q = lastq; - lastq = q; - if (f < 10) f = 10; - if (f > nyq) f = nyq; - q = fmax(q, 0.1f); - omega = f * PI/nyq; - alphaQ = sinf(omega) / (2*q); - b0 = alphaQ + 1; - a0 = (1 - alphaQ) / b0; - a1 = -2*cosf(omega) / b0; - yn = a0*xn + a1*x1 + x2 - a1*y1 - a0*y2; - x2 = x1; - x1 = xn; - y2 = y1; - y1 = yn; - *out++ = yn; - } - x->x_x1 = x1; - x->x_x2 = x2; - x->x_y1 = y1; - x->x_y2 = y2; - x->x_lastq = lastq; - return (w + 7); -} - -static void phaseshift_dsp(t_phaseshift *x, t_signal **sp){ - x->x_nyq = sp[0]->s_sr / 2; - dsp_add(phaseshift_perform, 6, x, sp[0]->s_n, sp[0]->s_vec, - sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); -} - -static void *phaseshift_new(t_floatarg f1, t_floatarg f2){ - t_phaseshift *x = (t_phaseshift *)pd_new(phaseshift_class); - x->x_inlet_freq = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet_freq, f1); - x->x_inlet_q = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet_q, f2); - x->x_out = outlet_new((t_object *)x, &s_signal); - x->x_x1 = 0; - x->x_y1 = 0; - x->x_x2 = 0; - x->x_y2 = 0; - x->x_lastq = 1; - return (x); -} - -CYCLONE_OBJ_API void phaseshift_tilde_setup(void){ - phaseshift_class = class_new(gensym("phaseshift~"), (t_newmethod)phaseshift_new, 0, - sizeof(t_phaseshift), CLASS_DEFAULT, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(phaseshift_class, (t_method)phaseshift_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(phaseshift_class, nullfn, gensym("signal"), 0); - class_addmethod(phaseshift_class, (t_method) phaseshift_clear, gensym("clear"), 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/phasewrap.c b/Libraries/cyclone/cyclone_objects/binaries/audio/phasewrap.c deleted file mode 100644 index 04a7dd2c72..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/phasewrap.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include -#include "common/shared.h" - -typedef struct _phasewrap -{ - t_object x_obj; - t_inlet *x_inlet; -// int x_algo; -} t_phasewrap; - -static t_class *phasewrap_class; - -static t_int *phasewrap_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - t_shared_wrappy wrappy; - while (nblock--) - { - /* FIXME here we have pi -> pi, 3pi -> -pi, -pi -> -pi, -3pi -> pi, - while in msp it is pi -> -pi, 3pi -> -pi, -pi -> pi, -3pi -> pi */ - - double dnorm = *in++ * (1. / SHARED_2PI); - wrappy.w_d = dnorm + SHARED_UNITBIT0; - /* Speeding up the int-to-double conversion below would be nice, - but all attempts failed. Even this is slower (which works only - for nonnegative input): - - wrappy.w_i[SHARED_HIOFFSET] = SHARED_UNITBIT0_HIPART; - *out++ = (dnorm - (wrappy.w_d - SHARED_UNITBIT0)) * SHARED_2PI; - */ - dnorm -= wrappy.w_i[SHARED_LOWOFFSET]; - *out++ = dnorm * SHARED_2PI; - } - return (w + 4); -} - -/* This is the slowest algo. It is slower than fmod in all cases, - except for input being zero. -static t_int *phasewrap_perform1(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - { - float f = *in++; - double dnorm; - if (f < -SHARED_PI) - { - dnorm = (double)f * (1. / SHARED_2PI) + .5; - *out++ = (dnorm - (int)dnorm) * SHARED_2PI + SHARED_PI; - } - else if (f > SHARED_PI) - { - dnorm = (double)f * (1. / SHARED_2PI) + .5; - *out++ = (dnorm - (int)dnorm) * SHARED_2PI - SHARED_PI; - } - else *out++ = f; - } - return (w + 4); -} - -static t_int *phasewrap_perform2(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - while (nblock--) - { - double dnorm = *in++ + SHARED_PI; - if (dnorm < 0) - *out++ = SHARED_PI - fmod(-dnorm, SHARED_2PI); - else - *out++ = fmod(dnorm, SHARED_2PI) - SHARED_PI; - } - return (w + 4); -}*/ - -static void phasewrap_dsp(t_phasewrap *x, t_signal **sp) -{ -/* switch (x->x_algo) - { - case 1: - dsp_add(phasewrap_perform1, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); - break; - case 2: - dsp_add(phasewrap_perform2, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); - break; - default:*/ - dsp_add(phasewrap_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); - //} -} - -/*static void phasewrap__algo(t_phasewrap *x, t_floatarg f) -{ - x->x_algo = f; -}*/ - -static void *phasewrap_new(t_symbol *s, int ac, t_atom *av) -{ - t_phasewrap *x = (t_phasewrap *)pd_new(phasewrap_class); -/* if (s == gensym("_phasewrap1~")) - x->x_algo = 1; - else if (s == gensym("_phasewrap2~")) - x->x_algo = 2; - else - x->x_algo = 0;*/ - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void phasewrap_tilde_setup(void) -{ - phasewrap_class = class_new(gensym("phasewrap~"), - (t_newmethod)phasewrap_new, 0, sizeof(t_phasewrap), 0, A_GIMME, 0); -/* class_addcreator((t_newmethod)phasewrap_new, - gensym("_phasewrap1~"), A_GIMME, 0); - class_addcreator((t_newmethod)phasewrap_new, - gensym("_phasewrap2~"), A_GIMME, 0);*/ - class_addmethod(phasewrap_class, nullfn, gensym("signal"), 0); - class_addmethod(phasewrap_class, (t_method)phasewrap_dsp, gensym("dsp"), A_CANT, 0); -// class_addmethod(phasewrap_class, (t_method)phasewrap__algo, gensym("_algo"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/pink.c b/Libraries/cyclone/cyclone_objects/binaries/audio/pink.c deleted file mode 100644 index 6b65317f63..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/pink.c +++ /dev/null @@ -1,115 +0,0 @@ -// matt barber and porres (2018) for ELSE and here borrowed to Cyclone -// based on SuperCollider's pink UGen - -#include "m_pd.h" -#include -#include - -#define PINK_MAX_OCT 40 - -static t_class *pink_class; - -typedef struct _pink{ - t_object x_obj; - float x_signals[PINK_MAX_OCT]; - float x_total; - float x_sr; - int x_octaves; - int x_octaves_set; - t_cyclone_random_state x_rstate; - int x_id; -}t_pink; - -static void pink_init(t_pink *x){ - float *signals = x->x_signals; - float total = 0; - t_cyclone_random_state *rstate = &x->x_rstate; - uint32_t *s1 = &rstate->s1; - uint32_t *s2 = &rstate->s2; - uint32_t *s3 = &rstate->s3; - for(int i = 0; i < x->x_octaves - 1; ++i){ - float noise = (cyclone_random_frand(s1, s2, s3)); - total += noise; - signals[i] = noise; - } - x->x_total = total; -} - -static void pink_seed(t_pink *x, t_symbol *s, int ac, t_atom *av){ - cyclone_random_init(&x->x_rstate, cyclone_random_get_seed(s, ac, av, x->x_id)); - pink_init(x); -} - -static void pink_oct(t_pink *x, t_floatarg f){ - x->x_octaves = (int)f < 1 ? 1 : (int)f > PINK_MAX_OCT ? PINK_MAX_OCT : (int)f; - x->x_octaves_set = 0; - pink_init(x); -} - -static t_int *pink_perform(t_int *w){ - t_pink *x = (t_pink *)(w[1]); - int n = (t_int)(w[2]); - t_cyclone_random_state *rstate = (t_cyclone_random_state *)(w[3]); - float *signals = (float*)(w[4]); - t_sample *out = (t_sample *)(w[5]); - float total = x->x_total; - uint32_t *s1 = &rstate->s1; - uint32_t *s2 = &rstate->s2; - uint32_t *s3 = &rstate->s3; - while(n--){ - uint32_t rcounter = cyclone_random_trand(s1, s2, s3); - float newrand = cyclone_random_frand(s1, s2, s3); - int k = (CLZ(rcounter)); - if(k < (x->x_octaves-1)){ - float prevrand = signals[k]; - signals[k] = newrand; - total += (newrand - prevrand); - } - newrand = (cyclone_random_frand(s1, s2, s3)); - *out++ = (t_float)(total+newrand)/x->x_octaves; - } - x->x_total = total; - return(w+6); -} - -static void pink_dsp(t_pink *x, t_signal **sp){ - if(x->x_octaves_set && x->x_sr != sp[0]->s_n){ - t_float sr = x->x_sr = sp[0]->s_sr; - x->x_octaves = 1; - while(sr >= 40){ - sr *= 0.5; - x->x_octaves++; - } - pink_init(x); - } - dsp_add(pink_perform, 5, x, sp[0]->s_n, &x->x_rstate, &x->x_signals, sp[0]->s_vec); -} - -static void *pink_new(t_symbol *s, int ac, t_atom *av){ - t_pink *x = (t_pink *)pd_new(pink_class); - x->x_id = cyclone_random_get_id(); - outlet_new(&x->x_obj, &s_signal); - x->x_sr = 0; - if(ac >= 2 && (atom_getsymbol(av) == gensym("-seed"))){ - t_atom at[1]; - SETFLOAT(at, atom_getfloat(av+1)); - ac-=2, av+=2; - pink_seed(x, s, 1, at); - } - else - pink_seed(x, s, 0, NULL); - if(ac && av->a_type == A_FLOAT) - pink_oct(x, atom_getfloat(av)); - else - x->x_octaves_set = 1; - return(x); -} - -/* Disabled because of else/pink~ -CYCLONE_OBJ_API void pink_tilde_setup(void){ - pink_class = class_new(gensym("pink~"), (t_newmethod)pink_new, - 0, sizeof(t_pink), 0, A_GIMME, 0); - class_addfloat(pink_class, pink_oct); - class_addmethod(pink_class, (t_method)pink_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(pink_class, (t_method)pink_seed, gensym("seed"), A_GIMME, 0); -}*/ diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/play.c b/Libraries/cyclone/cyclone_objects/binaries/audio/play.c deleted file mode 100644 index ca8b681edf..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/play.c +++ /dev/null @@ -1,678 +0,0 @@ - -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* Derek Kwan 2016 - adding looping, loopinterp, etc. (so pretty much redone, abstracted out interpolated reading of vecs) - not sure about array sample rate vs pd sample rate and my hacks, can be investigated more - adding play_play helper func -*/ - -#include -#include -#include -#include "m_pd.h" -#include -#include "signal/cybuf.h" -#include "common/magicbit.h" -#include "common/shared.h" - - -#define PLAY_MINITIME 0.023 //minimum ms for xfade. 1/44.1 rounded up -//note, loop starts fading in at stms, starts fading out at endms -#define PLAY_LINTIME 50 //default interp time in ms -#define PLAY_LOOP 0 //loop default setting -#define PLAY_LINTERP 0 //loop interp default -/* CHECKME (the refman): if the buffer~ has more channels, channels are mixed */ - - -typedef struct _play -{ - t_object x_obj; - t_cybuf *x_cybuf; - t_glist *x_glist; - int x_hasfeeders; //if there's a signal coming in the main inlet - int x_npts; //array size in samples - t_float x_pdksr; //pd's sample rate in ms - t_float x_aksr; //array's sample rate in ms - double x_ksrrat; //sample rate ratio (array/pd) - t_float x_fadems; //xfade in ms (also known as interptime) - - t_float x_stms; //start position in ms - t_float x_endms; //end pos in ms - t_float x_durms; //duration in ms - - int x_stsamp; //start position in samp - int x_stxsamp; //end of xfade ramp from start in samp - int x_endsamp; //end pos in samp - int x_endxsamp; //end of xfade ramp from end in ms - int x_rangesamp; //length of loop in samples - int x_fadesamp; //length of fade in samples - - int x_isneg; //if rate is negative (start point > end point) - double x_rate; //rate of playback - double x_phase; //phase for float playback mode - - int x_looping; //if looping or not - int x_linterp; //if using loop interpolation or not - int x_playing; //if playing - int x_playnew; //if started playing this particular block - int x_rfirst; //if this is the first time ramping up (for linterp mode) - int x_numchans; - t_float *x_ivec; // input vector - t_float **x_ovecs; //output vectors - - t_outlet *x_donelet; -} t_play; - - - - - -static t_class *play_class; - -static void play_play(t_play *x, int toplay){ - //playing helper function, use this to start playing the array - int playing = toplay > 0 ? 1 : 0; - x->x_playing = playing; - if(playing){ - x->x_playnew = 1; - }; -} - - -//////////////////////////////////////////////// -// STOP -//////////////////////////////////////////////// -static void play_stop(t_play *x){ - if(x->x_playing){ - x->x_playing = 0; - x->x_playnew = 0; - outlet_bang(x->x_donelet); - }; -} - - -static void play_calcsamp(t_play *x){ - int endsamp; - //calculate samp values from corresponding ms values - //use array's sample rate - t_float aksr = x->x_aksr; - t_float stms = x->x_stms; - t_float endms = x->x_endms; - t_float rate; - if(x->x_durms > 0){ - rate = (endms - stms)/x->x_durms; - } - else{ - //easy, if durms == 0, just make rate = 1 (or -1 ) - if(endms >= stms){ - rate = 1.; - } - else{ - rate = -1.; - }; - }; - int isneg = rate < 0; - x->x_rate = rate; - x->x_isneg = isneg; - int npts = x->x_npts; //length of array in samples - int stsamp = x->x_stsamp = (int)(stms * aksr); - //a bit hacky - DK - endsamp = x->x_endsamp = endms >= SHARED_FLT_MAX/aksr ? SHARED_INT_MAX : (int)(endms * aksr); - //some boundschecking - if(stsamp > npts){ - stsamp = npts; - } - else if(stsamp < 0){ - stsamp = 0; - }; - - if(endsamp > npts){ - endsamp = npts; - } - else if(endsamp < 0){ - endsamp = 0; - }; - - int rangesamp = x->x_rangesamp = abs(stsamp - endsamp); - int fadesamp = (int)(x->x_fadems * aksr); - - //boundschecking - if(fadesamp > rangesamp){ - fadesamp = rangesamp; - } - else if(fadesamp < 0){ - fadesamp = 0; - }; - - int stxsamp, endxsamp; - //is rate is neg (isneg == 1), then end pts of loop come before the loop end points in the buffer, - //if pos, come after - if(isneg){ - stxsamp = stsamp - fadesamp; - endxsamp = endsamp - fadesamp; - if(stxsamp < 0){ - stxsamp = 0; - }; - if(endxsamp < 0){ - endxsamp = 0; - }; - } - else{ - stxsamp = stsamp + fadesamp; - endxsamp = endsamp + fadesamp; - if(stxsamp > npts){ - stxsamp = npts; - }; - if(endxsamp >= npts){ - endxsamp = npts; - }; - }; - - x->x_stxsamp = stxsamp; - x->x_endxsamp = endxsamp; - x->x_fadesamp = fadesamp; -} - - -static void play_set(t_play *x, t_symbol *s) -{ - cybuf_setarray(x->x_cybuf, s); - x->x_npts = x->x_cybuf->c_npts; - x->x_ksrrat = x->x_aksr/x->x_pdksr; -} - -/*static void play_arraysr(t_play *x, t_floatarg f){ - //sample rate of array in samp/sec - if(f <= 1){ - f = 1; - }; - x->x_aksr = f * 0.001; - x->x_ksrrat = x->x_aksr/x->x_pdksr; - play_calcsamp(x); -}*/ - -//////////////////////////////////////////////// -// START -//////////////////////////////////////////////// -static void play_start(t_play *x, t_symbol *s, int argc, t_atom * argv){ - s = NULL; - //args, start pos in ms, end pos in ms, duration to take between start and end - //one of the end points shouldn't be inclusive, mb end point - t_float stms = 0; - t_float endms = SHARED_FLT_MAX; - t_float durms = 0; - int argnum = 0; - while(argc){ - if(argv -> a_type == A_FLOAT){ - switch(argnum){ - case 0: - stms = atom_getfloatarg(0, argc, argv); - if(stms < 0){ - stms = 0; - } - break; - case 1: - endms = atom_getfloatarg(0, argc, argv); - if(endms < 0){ - endms = 0; - } - break; - case 2: - durms = atom_getfloatarg(0, argc, argv); - break; - default: - break; - }; - argnum++; - }; - argc--; - argv++; - }; - x->x_stms = stms; - x->x_endms = endms; - x->x_durms = durms; - //calculate sample equivalents - play_calcsamp(x); - //use play_play helper func to start playing - play_play(x, 1); -} - -static void play_interptime(t_play *x, t_floatarg fadems){ - x->x_fadems = fadems; - //calculate sample equivalents - play_calcsamp(x); -} - -//////////////////////////////////////////////// -// float -//////////////////////////////////////////////// -static void play_float(t_play *x, t_floatarg f){ - int playing = f > 0 ? 1 : 0; - if(playing){ - //play whole array at original speed - x->x_stms = 0; - x->x_endms = SHARED_FLT_MAX; - x->x_durms = 0; - play_calcsamp(x); - //use play_play helper func to start playing - play_play(x, playing); - - } - else{ - play_stop(x); - }; -} - -//////////////////////////////////////////////// -// PAUSE -//////////////////////////////////////////////// -static void play_pause(t_play *x){ - // x->x_pause = 1; - x->x_playing = 0; -} - - -//////////////////////////////////////////////// -// RESUME -//////////////////////////////////////////////// -static void play_resume(t_play *x){ -// x->x_pause = 0; - x->x_playing = 1; -} - - -//////////////////////////////////////////////// -// RESUME -//////////////////////////////////////////////// -static void play_loop(t_play *x, t_floatarg f){ - x->x_looping = f > 0 ? 1 : 0; -} - -static void play_loopinterp(t_play *x, t_floatarg f){ - x->x_linterp = f > 0 ? 1 : 0; -} - -static double play_getvecval(t_play *x, int chidx, double phase, int interp){ - int ndx; - double output; - t_word **vectable = x->x_cybuf->c_vectors; - int npts = x->x_npts; - int maxindex = (interp ? npts - 3 : npts - 1); - if (phase < 0 || phase > maxindex) - phase = 0; /* CHECKED: a value 0, not ndx 0 */ - ndx = (int)phase; - float frac, a, b, c, d, cminusb; - /* CHECKME: what kind of interpolation? (CHECKED: multi-point) */ - if (ndx < 1) - ndx = 1, frac = 0; - else if (ndx > maxindex) - ndx = maxindex, frac = 1; - else frac = phase - ndx; - t_word *vp = vectable[chidx]; - if (vp) - { - vp += ndx; - a = vp[-1].w_float; - b = vp[0].w_float; - c = vp[1].w_float; - d = vp[2].w_float; - cminusb = c-b; - output = b + frac * ( - cminusb - 0.1666667f * (1. - frac) * ( - (d - a - 3.0f * cminusb) * frac - + (d + 2.0f * a - 3.0f * b) - ) - ); - } - else output = 0; - - return output; - -} - -/* LATER optimize */ -static t_int *play_perform(t_int *w) -{ - t_play *x = (t_play *)(w[1]); - t_cybuf *cybuf = x->x_cybuf; - int nblock = (int)(w[2]); - int nch = x->x_numchans; - int chidx; //channel index - if (cybuf->c_playable) - { - float pdksr = x->x_pdksr; - int interp = 1; - int iblock; - - if(x->x_hasfeeders){ - //signal input present, indexing into array - t_float *xin = x->x_ivec; - - for (iblock = 0; iblock < nblock; iblock++) - { - float phase = *xin++ * pdksr; // converts input in ms to samples! - for(chidx=0; chidxx_ovecs+chidx); - out[iblock] = play_getvecval(x, chidx, phase, interp); - }; - }; - } - else{ - //no signal input present, auto playback mode - if(x->x_playing){ - //post("%f", x->x_phase); - double output; - double gain; - int npts = x->x_npts; - int stsamp = x->x_stsamp; - int endsamp = x->x_endsamp; - int isneg = x->x_isneg; - int looping = x->x_looping; - int linterp = x->x_linterp; - int rangesamp = x->x_rangesamp; - int ramping = 0; //if we're ramping - - if(x->x_playnew){ - //if starting to play this block - x->x_phase = (double)stsamp; - if(looping && linterp){ - x->x_rfirst = 1; - //the first ramp up shouldn't have the end of the loop fading out - }; - x->x_playnew = 0; - }; - //let's handle this in two cases, forwards playing (isneg == 0), backwards playing (isneg == 1) - for (iblock = 0; iblock < nblock; iblock++){ - double phase = x->x_phase; - double fadephase, fadegain; - if(isneg){ - - //[0---endxsamp---endsamp----stxsamp----stsamp----npts] - //backward - - //boundschecking for phase - - if(phase <= endsamp || phase < 0. || phase >= npts){ - if(looping){ - //if looping, go back to the beginning - phase = (double)stsamp; - } - else{ - //we're done playing, just output zeroes! - if(x->x_playing) - outlet_bang(x->x_donelet); - x->x_playing = 0; - }; - } - else if(phase > stsamp){ - phase = (double)stsamp; - }; - - //check looping conditions - if(looping && linterp){ - //if in the xfade period, calculate gain of fading in loop - if(phase > x->x_stxsamp && phase <= stsamp){ - gain = (double)(stsamp - phase)/(double)x->x_fadesamp; - ramping = 1; - if(x->x_rfirst == 0){ - //if not the first ramp, need the fade out ramp - fadephase = phase - (double)rangesamp; - fadegain = 1.-gain; - - //boundschecking - if(fadephase < 0){ - fadephase = 0; - } - else if(fadephase >= stsamp){ - fadephase = (double)stsamp; - }; - if(fadegain < 0){ - fadegain = 0.; - }; - }; - } - else if(x->x_rfirst){ - //if we just finished the first ramp, flag it - x->x_rfirst = 0; - }; - }; - - } - else{ - - //[0----stsamp---stxsamp-----endsamp---endxsamp----npts] - //forward - - //boundschecking for phase - if(phase >= endsamp || phase < 0.|| phase >= npts){ - if(looping){ - //if looping, go back to the beginning - phase = (double)stsamp; - } - else{ //we're done playing, just output zeroes! - if(x->x_playing) // done bang - outlet_bang(x->x_donelet); - x->x_playing = 0; - }; - } - else if(phase < stsamp){ - phase = (double)stsamp; - }; - - //check looping conditions - if(looping && linterp){ - //if in the xfade period, calculate gain of fading in loop - if(phase < x->x_stxsamp && phase >= stsamp){ - gain = (double)(phase-stsamp)/(double)x->x_fadesamp; - ramping = 1; - if(x->x_rfirst == 0){ - //if not the first ramp, need the fade out ramp - fadephase = phase + (double)rangesamp; - fadegain = 1.-gain; - - //boundschecking - if(fadephase >= npts){ - fadephase = npts - 1; - } - else if(fadephase <= stsamp){ - fadephase = (double)stsamp; - }; - if(fadegain < 0){ - fadegain = 0.; - }; - }; - } - else if(x->x_rfirst){ - //if we just finished the first ramp, flag it - x->x_rfirst = 0; - }; - }; - }; - //reading output vals (for both forwards and backwards) - int rfirst = x->x_rfirst; - - for(chidx =0; chidxx_ovecs+chidx); - //get current val - if(x->x_playing){ - output = play_getvecval(x, chidx, phase, interp); - if(ramping){ - output *= gain; - if(!rfirst){ - //if not the first ramp, need the fading out ramp - double out2 = play_getvecval(x, chidx, fadephase, interp); - out2 *= fadegain; - output += out2; - }; - }; - } - else{ - output = 0.; - }; - out[iblock] = output; - - }; - //incrementation time (for both forwards and backwards)! - x->x_phase = phase + x->x_ksrrat*x->x_rate; - }; - } - else{ - //not playing, just output zeros - goto nullstate; - }; - - }; - } - else - { - nullstate: - for(chidx =0; chidxx_ovecs+chidx); - int n = nblock; - while (n--) *out++ = 0; - }; - }; - return (w + 3); -} - -static void play_dsp(t_play *x, t_signal **sp) -{ - cybuf_checkdsp(x->x_cybuf); - int npts = x->x_cybuf->c_npts; - x->x_hasfeeders = magic_inlet_connection((t_object *)x, x->x_glist, 0, &s_signal); - t_float pdksr= sp[0]->s_sr * 0.001; - x->x_pdksr = pdksr; - x->x_ksrrat = (double)(x->x_aksr/x->x_pdksr); - - if(npts != x->x_npts){ - x->x_npts = npts; - //need to recalculate sample equivalents - play_calcsamp(x); - - }; - int i, nblock = sp[0]->s_n; - - t_signal **sigp = sp; - x->x_ivec = (*sigp++)->s_vec; - for (i = 0; i < x->x_numchans; i++){ //input vectors first - *(x->x_ovecs+i) = (*sigp++)->s_vec; - }; - dsp_add(play_perform, 2, x, nblock); - - -} - -static void *play_free(t_play *x) -{ - cybuf_free(x->x_cybuf); - freebytes(x->x_ovecs, x->x_numchans * sizeof(*x->x_ovecs)); - outlet_free(x->x_donelet); - return (void *)x; -} - -static void *play_new(t_symbol * s, int argc, t_atom * argv){ - t_symbol *arrname = s = NULL; - t_float channels = 1; - t_float lintime = PLAY_LINTIME; //default interp time in ms - int looping = PLAY_LOOP; //loop default setting - int linterp = PLAY_LINTERP; //loop interp default - int nameset = 0; //flag if name is set - while(argc){ - if(!nameset){ - if(argv->a_type == A_SYMBOL) - arrname = atom_getsymbolarg(0, argc, argv); - argc--; - argv++; - nameset = 1; - } - else{ - if(argv->a_type == A_SYMBOL){ // treat as attribute - t_symbol * cursym = atom_getsymbolarg(0, argc, argv); - argc--; - argv++; - if(argc){ - //if there's an arg left, parse it - t_float curfloat = atom_getfloatarg(0, argc, argv); - argc--; - argv++; - if(strcmp(cursym->s_name, "@interptime") == 0){ - lintime = curfloat > PLAY_MINITIME ? curfloat : PLAY_MINITIME; - } - else if(strcmp(cursym->s_name,"@loop") == 0){ - looping = curfloat > 0 ? 1 : 0; - } - else if(strcmp(cursym -> s_name, "@loopinterp") == 0){ - linterp = curfloat > 0 ? 1 : 0; - } - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - } - else{ // float - channels = atom_getfloatarg(0, argc, argv); - argc--; - argv++; - }; - }; - }; - /* one auxiliary signal: position input */ - int chn_n = (int)channels > 64 ? 64 : (int)channels; - - t_play *x = (t_play *)pd_new(play_class); - x->x_glist = canvas_getcurrent(); - x->x_hasfeeders = 0; - x->x_pdksr = (float)sys_getsr() * 0.001; - //set sample rate of array as pd's sample rate for now - x->x_aksr = x->x_pdksr; - x->x_cybuf = cybuf_init((t_class *)x, arrname, chn_n, 0); - t_cybuf * c = x->x_cybuf; - - if (c) - { - int nch = c->c_numchans; - x->x_npts = c->c_npts; - x->x_numchans = nch; - x->x_ovecs = getbytes(x->x_numchans * sizeof(*x->x_ovecs)); - while (nch--) - outlet_new((t_object *)x, &s_signal); - x->x_donelet = outlet_new(&x->x_obj, &s_bang); - x->x_playing = 0; - x->x_playnew = 0; - x->x_looping = looping; - x->x_linterp = linterp; - x->x_fadems = lintime; - //defaults for start, end, and duration - x->x_stms = 0; - x->x_endms = SHARED_FLT_MAX; - x->x_durms = 0; - } - return(x); - errstate: - pd_error(x, "play~: improper args"); - return NULL; -} - -CYCLONE_OBJ_API void play_tilde_setup(void){ - play_class = class_new(gensym("play~"), (t_newmethod)play_new, (t_method)play_free, - sizeof(t_play), 0, A_GIMME, 0); - class_domainsignalin(play_class, -1); - class_addfloat(play_class, play_float); - class_addmethod(play_class, (t_method)play_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(play_class, (t_method)play_set, gensym("set"), A_SYMBOL, 0); - class_addmethod(play_class, (t_method)play_stop, gensym("stop"), 0); - class_addmethod(play_class, (t_method)play_pause, gensym("pause"), 0); - class_addmethod(play_class, (t_method)play_resume, gensym("resume"), 0); - class_addmethod(play_class, (t_method)play_loop, gensym("loop"), A_FLOAT, 0); - class_addmethod(play_class, (t_method)play_interptime, gensym("interptime"), A_FLOAT, 0); - class_addmethod(play_class, (t_method)play_loopinterp, gensym("loopinterp"), A_FLOAT, 0); -// class_addmethod(play_class, (t_method)play_arraysr, gensym("arraysr"), A_FLOAT, 0); - class_addmethod(play_class, (t_method)play_start, gensym("start"), A_GIMME, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/plusequals.c b/Libraries/cyclone/cyclone_objects/binaries/audio/plusequals.c deleted file mode 100644 index a008679379..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/plusequals.c +++ /dev/null @@ -1,126 +0,0 @@ -// Porres 2016 - -#include "m_pd.h" -#include - -// MAGIC -#include "common/magicbit.h" - -typedef struct _plusequals -{ - t_object x_obj; - double x_sum; - t_inlet *x_triglet; -// Magic - t_glist *x_glist; - t_float *x_signalscalar; - int x_hasfeeders; - -} t_plusequals; - -static t_class *plusequals_class; - -static t_int *plusequals_perform(t_int *w) -{ - t_plusequals *x = (t_plusequals *)(w[1]); - int nblock = (t_int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - double sum = x->x_sum; -// MAGIC: poll float for error - if (!magic_isnan(*x->x_signalscalar)) - { - magic_setnan(x->x_signalscalar); - pd_error(x, "plusequals~: doesn't understand 'float'"); - } - - while (nblock--) - { - float x1 = *in1++; - float x2; -// MAGIC - if (x->x_hasfeeders) x2 = *in2++; - else x2 = 0.0; - - sum = sum * (x2 == 0); - *out++ = sum += x1; - } - x->x_sum = sum; - return (w + 6); -} - -static t_int *plusequals_perform_no_in(t_int *w) -{ - t_plusequals *x = (t_plusequals *)(w[1]); - int nblock = (t_int)(w[2]); - t_float *out = (t_float *)(w[5]); - -// MAGIC: poll float for error - if (!magic_isnan(*x->x_signalscalar)) - { - magic_setnan(x->x_signalscalar); - pd_error(x, "plusequals~: doesn't understand 'float'"); - } - - while (nblock--) - { - *out++ = 0; - } - return (w + 6); -} - -static void plusequals_dsp(t_plusequals *x, t_signal **sp) -{ - // MAGIC - x->x_hasfeeders = magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal); - magic_setnan(x->x_signalscalar); - - if (magic_inlet_connection((t_object *)x, x->x_glist, 0, &s_signal)) - dsp_add(plusequals_perform, 5, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); - else - dsp_add(plusequals_perform_no_in, 5, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - - -static void plusequals_bang(t_plusequals *x) -{ - x->x_sum = 0; -} - -static void plusequals_set(t_plusequals *x, t_floatarg f) -{ - x->x_sum = f; -} - -static void *plusequals_free(t_plusequals *x) -{ - inlet_free(x->x_triglet); - return(void *)x; -} - -static void *plusequals_new(t_floatarg f) -{ - t_plusequals *x = (t_plusequals *)pd_new(plusequals_class); - x->x_sum = f; - x->x_glist = canvas_getcurrent(); - x->x_triglet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - outlet_new((t_object *)x, &s_signal); -// MAGIC - x->x_signalscalar = obj_findsignalscalar((t_object *)x, 1); - - return (x); -} - -CYCLONE_OBJ_API void plusequals_tilde_setup(void) -{ - plusequals_class = class_new(gensym("plusequals~"), (t_newmethod)plusequals_new, - (t_method)plusequals_free, sizeof(t_plusequals), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(plusequals_class, nullfn, gensym("signal"), 0); - class_addmethod(plusequals_class, (t_method) plusequals_dsp, gensym("dsp"), A_CANT, 0); - class_addbang(plusequals_class, plusequals_bang); - class_addmethod(plusequals_class, (t_method)plusequals_set, - gensym("set"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/poke.c b/Libraries/cyclone/cyclone_objects/binaries/audio/poke.c deleted file mode 100644 index df3560738b..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/poke.c +++ /dev/null @@ -1,204 +0,0 @@ -/* Copyright (c) 2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - - -/*dearsic-ing and fragile-ing (plucked the necessary bits from it) - - note, the fragile bit was using a way to pluck the float val from a signal - ignoring usual float-to-signal conversions, this is found in pd's m_obj.c so - if something breaks wrt to inlet2, look there first - - Derek Kwan 2016 - - needed for that one x->x_indexptr, seems like not many objects use fragile anymore so decided - to stick it here, plus this is the only one that does this particular thing, -*/ - -#include "m_pd.h" -#include -#include "signal/cybuf.h" - -#define POKE_MAXCHANNELS 64 -#define POKE_REDRAWMS 500 //redraw time in ms - -union inletunion -{ - t_symbol *iu_symto; - t_gpointer *iu_pointerslot; - t_float *iu_floatslot; - t_symbol **iu_symslot; - t_sample iu_floatsignalvalue; -}; - -struct _inlet -{ - t_pd i_pd; - struct _inlet *i_next; - t_object *i_owner; - t_pd *i_dest; - t_symbol *i_symfrom; - union inletunion i_un; -}; - -// end extra stuff for x->x_indexptr - -typedef struct _poke -{ - t_object x_obj; - t_cybuf *x_cybuf; - t_sample *x_indexptr; - t_clock *x_clock; - int x_channum; //current channel number (1-indexed) - double x_clocklasttick; - int x_clockset; - double x_redrawms; //time to redraw in ms - t_inlet *x_idxlet; -} t_poke; - -static t_class *poke_class; - -static void poke_tick(t_poke *x) -{ - cybuf_redraw(x->x_cybuf); /* LATER redraw only dirty channel(s!) */ - x->x_clockset = 0; - x->x_clocklasttick = clock_getlogicaltime(); -} - -static void poke_set(t_poke *x, t_symbol *s) -{ - cybuf_setarray(x->x_cybuf, s); -} - -//redraw method/limiter -static void poke_redraw_lim(t_poke *x) -{ - double redrawms = x->x_redrawms; - double timesince = clock_gettimesince(x->x_clocklasttick); - if (timesince > redrawms ) poke_tick(x); - else if (!x->x_clockset) - { - clock_delay(x->x_clock, redrawms - timesince); - x->x_clockset = 1; - }; -} - -/* CHECKED: index 0-based, negative values block input, overflowed are clipped. - LATER revisit: incompatibly, the code below is nop for any out-of-range index - (see also peek.c) */ // <= this looks like a bug, index 0 never written with signal (porres) - -/* CHECKED: value never clipped, 'clip' not understood */ // ??? (porres) - -/* CHECKED: no float-to-signal conversion. 'Float' message is ignored - when dsp is on -- whether a signal is connected to the left inlet, or not - (if not, current index is set to zero). Incompatible (revisit LATER) */ - -// Above is not true, it should write when the dsp is on! (porres 2017) - -static void poke_float(t_poke *x, t_float f) - { - t_cybuf *c = x->x_cybuf; - t_word *vp = c->c_vectors[0]; - //second arg is to allow error posting - cybuf_validate(c, 1); // LATER rethink (efficiency, and complaining) - if (vp) - { - int index = (int)*x->x_indexptr; - if (index >= 0 && index < c->c_npts) - { - vp[index].w_float = f; - poke_redraw_lim(x); - }; - } - } - -static void poke_ft2(t_poke *x, t_floatarg f) -{ - int ch = (f < 1) ? 1 : (f > CYBUF_MAXCHANS) ? CYBUF_MAXCHANS : (int) f; - x->x_channum = ch; - cybuf_getchannel(x->x_cybuf, ch, 1); -} - -/* - static void poke_redraw_rate(t_poke *x, t_floatarg f){ - double redrawms = f > 0 ? (double)f : 1; - x->x_redrawms = redrawms; -} - -static void poke_redraw_force(t_poke *x){ - poke_tick(x); -} -*/ - -static t_int *poke_perform(t_int *w) -{ - t_poke *x = (t_poke *)(w[1]); - t_cybuf *c = x->x_cybuf; - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); // value - t_float *in2 = (t_float *)(w[4]); // index - t_word *vp = c->c_vectors[0]; - if (vp && c->c_playable) // ??? (porres) - { - poke_redraw_lim(x); - int npts = c->c_npts; - while (nblock--) - { - t_float value = *in1++; // value - int index = (int)*in2++; // index - if (index >= 0 && index < npts) vp[index].w_float = value; - } - } - return (w + 5); -} - -static void poke_dsp(t_poke *x, t_signal **sp) -{ - cybuf_checkdsp(x->x_cybuf); - dsp_add(poke_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void poke_free(t_poke *x) -{ - if (x->x_clock) clock_free(x->x_clock); - inlet_free(x->x_idxlet); - cybuf_free(x->x_cybuf); -} - -static void *poke_new(t_symbol *s, t_floatarg f) -{ - int ch = (f < 1) ? 1 : (f > CYBUF_MAXCHANS) ? CYBUF_MAXCHANS : (int)f; - t_poke *x = (t_poke *)pd_new(poke_class); - x->x_cybuf = cybuf_init((t_class *) x, s, 1, ch); - if (x) // ??? (porres) - { - x->x_channum = ch; - x->x_redrawms = POKE_REDRAWMS; //default redraw rate - -/* floats in 2nd inlet should be ignored when dsp is on - when a signal is connected (porres 2017) */ - x->x_idxlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - -/* plucked from old unstable/fragile.c. found in pd's m_obj.c, basically plucks the - float value from the signal without the float-to-signal conversion, I think... - DK */ - x->x_indexptr = &(x->x_idxlet)->i_un.iu_floatsignalvalue; - - inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft2")); - x->x_clock = clock_new(x, (t_method)poke_tick); - x->x_clocklasttick = clock_getlogicaltime(); - x->x_clockset = 0; - } - return (x); -} - -CYCLONE_OBJ_API void poke_tilde_setup(void){ - poke_class = class_new(gensym("poke~"), (t_newmethod)poke_new, - (t_method)poke_free, sizeof(t_poke), 0, A_DEFSYM, A_DEFFLOAT, 0); - class_domainsignalin(poke_class, -1); - class_addfloat(poke_class, poke_float); - class_addmethod(poke_class, (t_method)poke_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(poke_class, (t_method)poke_set, gensym("set"), A_SYMBOL, 0); - class_addmethod(poke_class, (t_method)poke_ft2, gensym("ft2"), A_FLOAT, 0); -/* class_addmethod(poke_class, (t_method)poke_redraw_rate, gensym("redraw_rate"), A_FLOAT, 0); - class_addmethod(poke_class, (t_method)poke_redraw_force, gensym("redraw"), 0);*/ -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/poltocar.c b/Libraries/cyclone/cyclone_objects/binaries/audio/poltocar.c deleted file mode 100644 index 54d9f34c3f..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/poltocar.c +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include -#include "common/magicbit.h" - -typedef struct _poltocar -{ - t_object x_obj; - t_inlet *poltocar; - t_outlet *x_out2; - t_glist *x_glist; - t_float *x_signalscalar; - t_int x_hasfeeders; -} t_poltocar; - -static t_class *poltocar_class; - -static t_int *poltocar_perform(t_int *w) -{ - t_poltocar *x = (t_poltocar *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out1 = (t_float *)(w[5]); - t_float *out2 = (t_float *)(w[6]); -// MAGIC: poll float for error - if (!magic_isnan(*x->x_signalscalar)) - { - magic_setnan(x->x_signalscalar); - pd_error(x, "poltocar~: doesn't understand 'float'"); - } - while (nblock--) - { - float amp, ph, re, im; - // MAGIC - if (x->x_hasfeeders) - { - amp = *in1++; - ph = *in2++; - re = amp * cosf(ph); - im = amp * sinf(ph); - } - else { - re = im = 0.0; // CHECKED - } - *out1++ = re; - *out2++ = im; - } - return (w + 7); -} - -static void poltocar_dsp(t_poltocar *x, t_signal **sp) -{ - x->x_hasfeeders = magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal); - dsp_add(poltocar_perform, 6, x, sp[0]->s_n, sp[0]->s_vec, - sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); -} - -static void *poltocar_new(void) -{ - t_poltocar *x = (t_poltocar *)pd_new(poltocar_class); - inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - outlet_new((t_object *)x, &s_signal); - x->x_glist = canvas_getcurrent(); - x->x_signalscalar = obj_findsignalscalar((t_object *)x, 1); - magic_setnan(x->x_signalscalar); - x->x_out2 = outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void poltocar_tilde_setup(void) -{ - poltocar_class = class_new(gensym("poltocar~"), - (t_newmethod)poltocar_new, 0, - sizeof(t_poltocar), 0, 0); - class_addmethod(poltocar_class, nullfn, gensym("signal"), 0); - class_addmethod(poltocar_class, (t_method) poltocar_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/pong.c b/Libraries/cyclone/cyclone_objects/binaries/audio/pong.c deleted file mode 100644 index 3c4d3cc31a..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/pong.c +++ /dev/null @@ -1,320 +0,0 @@ -//2016 by Derek Kwan - -#include "m_pd.h" -#include -#include -#include -#include -#include - -#if defined _WIN32 -# include /* MSVC or mingw on windows */ -#endif - -#ifndef HAVE_ALLOCA /* can work without alloca() but we never need it */ -#define HAVE_ALLOCA 1 -#endif -#define TEXT_NGETBYTE 100 /* bigger that this we use alloc, not alloca */ -#if HAVE_ALLOCA -#define ATOMS_ALLOCA(x, n) ((x) = (t_atom *)((n) < TEXT_NGETBYTE ? \ - alloca((n) * sizeof(t_atom)) : getbytes((n) * sizeof(t_atom)))) -#define ATOMS_FREEA(x, n) ( \ - ((n) < TEXT_NGETBYTE || (freebytes((x), (n) * sizeof(t_atom)), 0))) -#else -#define ATOMS_ALLOCA(x, n) ((x) = (t_atom *)getbytes((n) * sizeof(t_atom))) -#define ATOMS_FREEA(x, n) (freebytes((x), (n) * sizeof(t_atom))) -#endif - -#ifndef CYPONGTMODE_DEF -#define CYPONGTMODE_DEF 0 -#endif - -#ifndef CYPONGTLO_DEF -#define CYPONGTLO_DEF 0.f -#endif - -#ifndef CYPONGTHI_DEF -#define CYPONGTHI_DEF 1.f -#endif - -static t_class *pong_tilde_class; - -typedef struct _pong_tilde {//pong_tilde (control rate) - t_object x_obj; - int mode; //0=fold, 1 = wrap, 2 = clip, 3 = none - t_float minval; - t_float maxval; - t_float x_input; //dummy var - t_inlet *x_minlet; - t_inlet *x_maxlet; - t_outlet *x_outlet; - int x_numargs;//num of args given -} t_pong_tilde; - - - -static int pong_tilde_setmode_help(char const * mode){ -//helper function for setting mode -int retmode; //int val for mode (see struct) - if(strcmp(mode, "clip") == 0){ - retmode = 2; - } - else if(strcmp(mode, "wrap") == 0){ - retmode = 1; - } - else if(strcmp(mode, "fold") == 0){ - retmode = 0; - } - else{//default to none o/wise - retmode = 3; - }; - - return retmode; - -}; - - -static float pong_tilde_ponger(float input, float minval, float maxval, int mode){ - //pong_tilde helper function - float returnval; - float range = maxval - minval; - if(input < maxval && input >= minval){//if input in range, return input - returnval = input; - } - else if(minval == maxval){ - returnval = minval; - } - else if(mode == 0){//folding - if(input < minval){ - float diff = minval - input; //diff between input and minimum (positive) - int mag = (int)(diff/range); //case where input is more than a range away from minval - if(mag % 2 == 0){// even number of ranges away = counting up from min - diff = diff - ((float)mag)*range; - returnval = diff + minval; - } - else{// odd number of ranges away = counting down from max - diff = diff - ((float)mag)*range; - returnval = maxval - diff; - }; - } - else{ //input > maxval - float diff = input - maxval; //diff between input and max (positive) - int mag = (int)(diff/range); //case where input is more than a range away from maxval - if(mag % 2 == 0){//even number of ranges away = counting down from max - diff = diff - (float)mag*range; - returnval = maxval - diff; - } - else{//odd number of ranges away = counting up from min - diff = diff - (float)mag*range; - returnval = diff + minval; - }; - }; - } - else if (mode == 1){// wrapping - if(input < minval){ - returnval = input; - while(returnval < minval){ - returnval += range; - }; - } - else{ - returnval = fmod(input-minval,maxval-minval) + minval; - }; - } - else if(mode == 2){//clipping - if(input < minval){ - returnval = minval; - } - else{//input > maxval - returnval = maxval; - }; - } - else{//mode = 3, no effect - returnval = input; - }; - - return returnval; -} - -static void pong_tilde_setrange(t_pong_tilde *x, t_float lo, t_float hi){ - - x->minval = lo; - x->maxval = hi; - - pd_float( (t_pd *) x->x_minlet, x->minval); - pd_float( (t_pd *) x->x_maxlet, x->maxval); -} - - -static void pong_tilde_setmode(t_pong_tilde *x, t_symbol *s, int argc, t_atom *argv){ - int setmode; - if(argc > 0){ - t_symbol *arg1 = atom_getsymbolarg(0, argc, argv); - if(arg1 == &s_){ // if arg is a number - float mode = atom_getfloatarg(0, argc, argv); - setmode = (int) mode; - if( setmode < 0){ - setmode = 0; - } - else if( setmode > 3){ - setmode = 3; - }; - } - else{//if arg is a symbol - setmode = pong_tilde_setmode_help(arg1->s_name); - }; - - x->mode = setmode; - }; -} - -static t_int *pong_tilde_perform(t_int *w) -{ - t_pong_tilde *x = (t_pong_tilde *)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *in3 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - int n = (int)(w[6]); - - int mode = x->mode; - while (n--){ - float input = *in1++; - float minv = *in2++; - float maxv = *in3++; - if(minv > maxv){//checking ranges - float temp; - temp = maxv; - maxv = minv; - minv = temp; - }; - - float returnval = pong_tilde_ponger(input, minv, maxv, mode); - - *out++ = returnval; - }; - return (w+7); -} - -static void *pong_tilde_free(t_pong_tilde *x){ - inlet_free(x->x_minlet); - inlet_free(x->x_maxlet); - outlet_free(x->x_outlet); - return (void *)x; - -} - -static void pong_tilde_dsp(t_pong_tilde *x, t_signal **sp) -{ - dsp_add(pong_tilde_perform, 6, x, sp[0]->s_vec, sp[1]->s_vec, - sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n); -} - -static void *pong_tilde_new(t_symbol *s, int argc, t_atom *argv){ - //two optional args (lo, hi), then attributes for mode (str) and range (2 fl) - t_pong_tilde *x = (t_pong_tilde *)pd_new(pong_tilde_class); - int numargs = 0;//number of args read - int pastargs = 0; //if any attrs have been declared yet - x->minval = CYPONGTLO_DEF; - x-> maxval = CYPONGTHI_DEF; - x->mode = CYPONGTMODE_DEF; - - while(argc > 0 ){ - if(argv -> a_type == A_FLOAT){ //if nullpointer, should be float or int - if(!pastargs){//if we aren't past the args yet - switch(numargs){ - float mode; - int setmode; - case 0: mode =atom_getfloatarg(0, argc, argv); - setmode = (int)mode; - if(mode < 0){ - setmode = 0; - } - else if(mode > 3){ - setmode = 3; - } - x->mode = setmode; - numargs++; - argc--; - argv++; - break; - - case 1: x->minval = atom_getfloatarg(0, argc, argv); - numargs++; - argc--; - argv++; - break; - - case 2: x->maxval = atom_getfloatarg(0, argc, argv); - numargs++; - argc--; - argv++; - break; - - - default: argc--; - argv++; - break; - }; - } - else{ - argc--; - argv++; - }; - } - else if (argv->a_type == A_SYMBOL){ - t_symbol *curarg = atom_getsymbolarg(0, argc, argv); //returns nullpointer if not symbol - pastargs = 1; - int isrange = strcmp(curarg->s_name, "@range") == 0; - int ismode = strcmp(curarg->s_name, "@mode") == 0; - if(isrange && argc >= 3){ - t_symbol *arg1 = atom_getsymbolarg(1, argc, argv); - t_symbol *arg2 = atom_getsymbolarg(2, argc, argv); - if(arg1 == &s_ && arg2 == &s_){ - x->minval = atom_getfloatarg(1, argc, argv); - x->maxval = atom_getfloatarg(2, argc, argv); - argc -= 3; - argv += 3; - } - else{ - goto errstate; - };} - - else if(ismode && argc >= 2){ - t_symbol *arg3 = atom_getsymbolarg(1, argc, argv); - if(arg3 != &s_){ - x->mode = pong_tilde_setmode_help(arg3->s_name); - argc -= 2; - argv += 2; - } - else{ - goto errstate; - };} - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - }; - x->x_minlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - x->x_maxlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - pd_float( (t_pd *) x->x_minlet, x->minval); - pd_float( (t_pd *) x->x_maxlet, x->maxval); - x->x_numargs = numargs; - x->x_outlet = outlet_new(&x->x_obj, gensym("signal")); - return (x); -errstate: - pd_error(x, "pong~: improper args"); - return NULL; -} - -CYCLONE_OBJ_API void pong_tilde_setup(void){ - pong_tilde_class = class_new(gensym("pong~"), (t_newmethod)pong_tilde_new, 0, - sizeof(t_pong_tilde), CLASS_DEFAULT, A_GIMME, 0); - class_addmethod(pong_tilde_class, (t_method)pong_tilde_setrange, gensym("range"), A_FLOAT, A_FLOAT, 0); - class_addmethod(pong_tilde_class, (t_method)pong_tilde_setmode, gensym("mode"), A_GIMME, 0); - class_addmethod(pong_tilde_class, (t_method)pong_tilde_dsp, gensym("dsp"), A_CANT, 0); - CLASS_MAINSIGNALIN(pong_tilde_class, t_pong_tilde, x_input); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/pow.c b/Libraries/cyclone/cyclone_objects/binaries/audio/pow.c deleted file mode 100644 index ca4d432a25..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/pow.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include -#include "m_pd.h" -#include - -static t_class *pow_class; - -typedef struct _pow{ - t_object x_obj; - t_inlet *x_inlet; -}t_pow; - -static t_int *pow_perform(t_int *w){ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--){ - float f1 = *in1++; - float f2 = *in2++; - *out++ = (f2 == 0 && f1 < 0) || - (f2 < 0 && (f1 - (int)f1) != 0) ? - 0 : pow(f2, f1); - } - return (w + 5); -} - -static void pow_dsp(t_pow *x, t_signal **sp){ - dsp_add(pow_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -static void *pow_free(t_pow *x){ - inlet_free(x->x_inlet); - return (void *)x; -} - -static void *pow_new(t_floatarg f){ - t_pow *x = (t_pow *)pd_new(pow_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void pow_tilde_setup(void) -{ - pow_class = class_new(gensym("cyclone/pow~"), - (t_newmethod)pow_new, 0, sizeof(t_pow), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(pow_class, nullfn, gensym("signal"), 0); - class_addmethod(pow_class, (t_method) pow_dsp, gensym("dsp"), A_CANT, 0); - class_sethelpsymbol(pow_class, gensym("pow~")); - pd_error(pow_class, "[cyclone/pow~] is deprecated, consider adapting and using vanilla's [pow~] instead"); -} - -CYCLONE_OBJ_API void Pow_tilde_setup(void){ - pow_class = class_new(gensym("Pow~"), - (t_newmethod)pow_new, 0, sizeof(t_pow), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(pow_class, nullfn, gensym("signal"), 0); - class_addmethod(pow_class, (t_method) pow_dsp, gensym("dsp"), A_CANT, 0); - class_sethelpsymbol(pow_class, gensym("pow~")); - pd_error(pow_class, "Cyclone: please use [cyclone/pow~] instead of [Pow~] to suppress this error"); - pd_error(pow_class, "[cyclone/pow~] is deprecated, consider adapting and using vanilla's [pow~] instead"); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/rampsmooth.c b/Libraries/cyclone/cyclone_objects/binaries/audio/rampsmooth.c deleted file mode 100644 index 22264c3bbe..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/rampsmooth.c +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -#define RAMPSMOOTH_DEFNUP 0. -#define RAMPSMOOTH_DEFNDOWN 0. - -typedef struct _rampsmooth -{ - t_object x_obj; - t_inlet *rampsmooth; - int x_nup; - int x_ndown; - double x_upcoef; - double x_downcoef; - t_float x_last; - t_float x_target; - double x_incr; - int x_nleft; - int x_change; //if we reset coeffs -} t_rampsmooth; - -static t_class *rampsmooth_class; - -static t_int *rampsmooth_perform(t_int *w){ - t_rampsmooth *x = (t_rampsmooth *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - t_float last = x->x_last; - t_float target = x->x_target; - int change = x->x_change; - double incr = x->x_incr; - int nleft = x->x_nleft; - while (nblock--){ - t_float f = *in++; - if(f != target || change){ - target = f; - change = 0; - if(f > last){ - if(x->x_nup > 1){ - incr = (f - last) * x->x_upcoef; - nleft = x->x_nup; - *out++ = (last += incr); - continue; - } - } - else if(f < last){ - if(x->x_ndown > 1){ - incr = (f - last) * x->x_downcoef; - nleft = x->x_ndown; - *out++ = (last += incr); - continue; - } - } - incr = 0.; - nleft = 0; - *out++ = last = f; - } - else if (nleft > 0){ - *out++ = (last += incr); - if(--nleft == 1){ - incr = 0.; - last = target; - } - } - else - *out++ = target; - }; - x->x_change = change; - x->x_last = (PD_BIGORSMALL(last) ? 0. : last); - x->x_target = (PD_BIGORSMALL(target) ? 0. : target); - x->x_incr = incr; - x->x_nleft = nleft; - return (w + 5); -} - -static void rampsmooth_dsp(t_rampsmooth *x, t_signal **sp) -{ - dsp_add(rampsmooth_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void rampsmooth_rampup(t_rampsmooth *x, t_floatarg f) -{ - double upcoef; - int i = (int)f; - if (i > 1) - { - x->x_nup = i; - upcoef = 1. / (float)i; - } - else - { - x->x_nup = 0; - upcoef = 0.; - }; - if(upcoef != x->x_upcoef) - { - x->x_upcoef = upcoef; - x->x_change = 1; - }; -} - -static void rampsmooth_rampdown(t_rampsmooth *x, t_floatarg f) -{ - double downcoef; - int i = (int)f; - if (i > 1) - { - x->x_ndown = i; - downcoef = 1. / (float)i; - } - else - { - x->x_ndown = 0; - downcoef = 0.; - }; - if(downcoef != x->x_downcoef) - { - x->x_downcoef = downcoef; - x->x_change = 1; - }; -} - -static void rampsmooth_ramp(t_rampsmooth *x, t_floatarg f) -{ - rampsmooth_rampup(x, f); - rampsmooth_rampdown(x, f); -} - -static void *rampsmooth_new(t_symbol *s, int ac, t_atom *av) -{ - t_rampsmooth *x = (t_rampsmooth *)pd_new(rampsmooth_class); - float f1 = RAMPSMOOTH_DEFNUP; - float f2 = RAMPSMOOTH_DEFNDOWN; - if (ac && av->a_type == A_FLOAT) - { - f1 = av->a_w.w_float; - ac--; av++; - if (ac && av->a_type == A_FLOAT) - f2 = av->a_w.w_float; - } - rampsmooth_rampup(x, f1); - rampsmooth_rampdown(x, f2); - x->x_change = 1; - x->x_last = 0.; - x->x_target = 0.; - x->x_incr = 0.; - x->x_nleft = 0; - inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("rampup")); - inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("rampdown")); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void rampsmooth_tilde_setup(void) -{ - rampsmooth_class = class_new(gensym("rampsmooth~"), - (t_newmethod)rampsmooth_new, 0, - sizeof(t_rampsmooth), 0, A_GIMME, 0); - class_addmethod(rampsmooth_class, nullfn, gensym("signal"), 0); - class_addmethod(rampsmooth_class, (t_method) rampsmooth_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(rampsmooth_class, (t_method)rampsmooth_rampup, - gensym("rampup"), A_FLOAT, 0); - class_addmethod(rampsmooth_class, (t_method)rampsmooth_rampdown, - gensym("rampdown"), A_FLOAT, 0); - class_addmethod(rampsmooth_class, (t_method)rampsmooth_ramp, - gensym("ramp"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/rand.c b/Libraries/cyclone/cyclone_objects/binaries/audio/rand.c deleted file mode 100644 index 05bfdd8144..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/rand.c +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (c) 1997-2003 Miller Puckette, krzYszcz, and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* This is a compilation of phasor~ and noise~ code from d_osc.c. */ - -#include "m_pd.h" -#include -#include "common/shared.h" - -typedef struct _rand -{ - t_object x_obj; - t_float x_input; - double x_lastphase; - double x_nextphase; - float x_rcpsr; - float x_sr; - int x_state; - float x_target; - float x_scaling; /* LATER use phase increment */ -} t_rand; - -static t_class *rand_class; - -static t_int *rand_perform(t_int *w) -{ - t_rand *x = (t_rand *)(w[1]); - int nblock = (int)(w[2]); - t_float *rin = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - double lastph = x->x_lastphase; - double ph = x->x_nextphase; - double tfph = ph + SHARED_UNITBIT32; - t_shared_wrappy wrappy; - int32_t normhipart; - float rcpsr = x->x_rcpsr; - float sr = x->x_sr; - float target = x->x_target; - float scaling = x->x_scaling; - - wrappy.w_d = SHARED_UNITBIT32; - normhipart = wrappy.w_i[SHARED_HIOFFSET]; - - while (nblock--) - { - float rate = *rin++; - if (rate < 0) rate = 0; - if (ph > lastph) - { - int state = x->x_state; - float newtarget = ((float)((state & 0x7fffffff) - 0x40000000)) - * (float)(1.0 / 0x40000000); - x->x_state = state * 435898247 + 382842987; - x->x_scaling = scaling = target - newtarget; - x->x_target = target = newtarget; - } - *out++ = ph * scaling + target; - lastph = ph; - if (rate >= sr) rate = sr - 1; - if (rate > 0) rate = -rate; - tfph += rate * rcpsr; - wrappy.w_d = tfph; - wrappy.w_i[SHARED_HIOFFSET] = normhipart; - ph = wrappy.w_d - SHARED_UNITBIT32; - } - x->x_lastphase = lastph; - x->x_nextphase = ph; - return (w + 5); -} - -static void rand_dsp(t_rand *x, t_signal **sp) -{ - x->x_sr = sp[0]->s_sr; - x->x_rcpsr = 1. / sp[0]->s_sr; - dsp_add(rand_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void *rand_new(t_floatarg f) -{ - t_rand *x = (t_rand *)pd_new(rand_class); - /* borrowed from d_osc.c, LATER rethink */ - static int init = 307; - x->x_state = (init *= 1319); - x->x_lastphase = 0.; - x->x_nextphase = 1.; /* start from 0, force retargetting */ - x->x_target = x->x_scaling = 0; - x->x_input = (f > 0. ? f : 0.); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void rand_tilde_setup(void) -{ - rand_class = class_new(gensym("rand~"), (t_newmethod)rand_new, 0, - sizeof(t_rand), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(rand_class, (t_method)rand_dsp, gensym("dsp"), A_CANT, 0); - CLASS_MAINSIGNALIN(rand_class, t_rand, x_input); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/rdiv.c b/Libraries/cyclone/cyclone_objects/binaries/audio/rdiv.c deleted file mode 100644 index abed0b5aea..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/rdiv.c +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2016 Porres. - -#include "m_pd.h" -#include - -static t_class *rdiv_class; - -typedef struct _rdiv -{ - t_object x_obj; - t_inlet *x_inlet; -} t_rdiv; - -static t_int *rdiv_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f1 == 0. ? 0. : f2 / f1); - } - return (w + 5); -} - -static void rdiv_dsp(t_rdiv *x, t_signal **sp) -{ - dsp_add(rdiv_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -static void *rdiv_free(t_rdiv *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -static void *rdiv_new(t_floatarg f) -{ - t_rdiv *x = (t_rdiv *)pd_new(rdiv_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -CYCLONE_OBJ_API void rdiv_tilde_setup(void) -{ - rdiv_class = class_new(gensym("rdiv~"), (t_newmethod)rdiv_new, - (t_method)rdiv_free, sizeof(t_rdiv), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(rdiv_class, nullfn, gensym("signal"), 0); - class_addmethod(rdiv_class, (t_method)rdiv_dsp, gensym("dsp"), A_CANT, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/record.c b/Libraries/cyclone/cyclone_objects/binaries/audio/record.c deleted file mode 100644 index fa8bc40ab9..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/record.c +++ /dev/null @@ -1,392 +0,0 @@ - /* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. - -Derek Kwan 2016 -adding defaults for numchannels, append, loopstatus, loopstart, loopend -adding record_getarraysmp, record_startms, record_endms, record_list, record_loopstart, record_loopend -adding attribute parsing and making numchannels arg optional -rewrite record_perform, record_reset, recor_float, record_startpoint, record_endpoint -original start and end methods redirect to startms, endms methods -basically almost everything in this thing -de-arsic/cybuffing - -NOTED CHANGES IN BEHAVIOR: -start and end point inlets changed from float inlets to sig inlets -end point inlet set to 0 no longer defaults to the whole array -I can change this if necessary,.. I just figure if you're sending a phasor that -starts 0 and goes to some number, you don't want -the beginning of the ramp to default to the end of the whole array, right? -*/ - -// Porres fixed bugs with sync output, append mode, reset message and cleaned up a bit - -#include "m_pd.h" -#include "m_imp.h" -#include "signal/cybuf.h" -#include - -#define DRAWMS 500. // refractory period in ms - -static t_class *record_class, *record_proxy_class; - -typedef struct _record_proxy{ - t_object p_obj; - t_clock *p_clock; - struct _record *p_cnv; -}t_record_proxy; - -typedef struct _record{ - t_object x_obj; - t_record_proxy *x_proxy; - t_cybuf *x_cybuf; - t_inlet *x_stlet; // start inlet - t_inlet *x_endlet; // end inlet - t_outlet *x_outlet; - int x_appendmode; - int x_loopmode; - int x_phase; // writing head - t_float x_sync; // sync value - t_clock *x_clock; - double x_clocklasttick; - int x_isrunning; - int x_newrun; // if running turned from off and on for this current block - t_float x_ksr; // sample rate in ms - int x_numchans; - t_float **x_ivecs; // input vectors - t_float *x_startvec; // start position (in ms) vector - t_float *x_endvec; // endposition (in ms) vec - t_float *x_ovec; // output vector -}t_record; - -static void record_list(t_record *x, t_symbol *s, int argc, t_atom * argv){ - s = NULL; - t_float startms, endms; - switch(argc){ - case 0: // nothing passed - break; - case 1: // startms passed - startms = atom_getfloatarg(0, argc, argv); - pd_float((t_pd *)x->x_stlet, startms); - break; - default: - case 2: // both passed - startms = atom_getfloatarg(0, argc, argv); - endms = atom_getfloatarg(1, argc, argv); - pd_float((t_pd *)x->x_stlet, startms); - pd_float((t_pd *)x->x_endlet, endms); - break; - } -} - -static void record_proxy_draw(t_record_proxy *p){ - if(p->p_cnv){ - if(p->p_cnv->x_cybuf->c_playable) - cybuf_redraw(p->p_cnv->x_cybuf); - } -} - -static void record_tick(t_record *x){ - double timesince = clock_gettimesince(x->x_clocklasttick); - if(timesince >= DRAWMS){ - cybuf_redraw(x->x_cybuf); - x->x_clocklasttick = clock_getlogicaltime(); - } -} - -static void record_set(t_record *x, t_symbol *s){ - cybuf_setarray(x->x_cybuf, s ); -} - -static void record_reset(t_record *x){ - t_float loopstart = 0.; - t_float loopend = 1E+32; - if(x->x_sync > 0) - x->x_isrunning = 1; - pd_float((t_pd *)x->x_stlet, loopstart); - pd_float((t_pd *)x->x_endlet, loopend); - x->x_phase = 0.; -} - -static int record_startpoint(t_record *x, t_floatarg f){ - long long int npts = (long long int)x->x_cybuf->c_npts; - long long int startindex = (long long int)(f * x->x_ksr); - if(startindex >= npts || startindex < 0) - startindex = npts - 1; - return(startindex); -} - -static int record_endpoint(t_record *x, t_floatarg f){ - long long int npts = (long long int)x->x_cybuf->c_npts; - long long int endindex = (long long int)(f * x->x_ksr); - if(endindex >= npts || endindex < 0) - endindex = npts - 1; - return(endindex); -} - -static void record_float(t_record *x, t_float f){ - x->x_isrunning = (f != 0); - if(x->x_isrunning) - x->x_newrun = 1; - else{ - clock_delay(x->x_clock, 0); // trigger a redraw - x->x_sync = 0.; - if(!x->x_appendmode) - x->x_phase = 0.; - } -} - -static void record_append(t_record *x, t_floatarg f){ - x->x_appendmode = (f != 0); -} - -static void record_loop(t_record *x, t_floatarg f){ - x->x_loopmode = (f != 0); -} - -static void record_loopstart(t_record *x, t_float loopstart){ - pd_float((t_pd *)x->x_stlet, loopstart); -} - -static void record_loopend(t_record *x, t_float loopend){ - pd_float((t_pd *)x->x_endlet, loopend); -} - -static t_int *record_perform(t_int *w){ - t_record *x = (t_record *)(w[1]); - t_cybuf * c = x->x_cybuf; - int nch = c->c_numchans; - int nblock = (int)(w[2]); - t_float *out = x->x_ovec; - t_float *startin = x->x_startvec; - t_float *endin = x->x_endvec; - t_float startms, endms, sync; - long long int startsamp, endsamp, phase, range; - int i, j; - cybuf_validate(c, 0); - clock_delay(x->x_clock, 0); // calculate a redraw - for(i = 0; i < nblock; i++){ - startms = startin[i] < 0 ? 0 : startin[i]; - endms = endin[i] < 0 ? 0 : endin[i]; - if((startms < endms) && c->c_playable && x->x_isrunning){ - startsamp = record_startpoint(x, startms); - endsamp = record_endpoint(x, endms); - range = endsamp - startsamp; - // append mode shouldn't reset phase - if(x->x_newrun == 1 && x->x_appendmode == 0){ - // isrunning 0->1 from last block, means reset phase appropriately - x->x_newrun = 0; - x->x_phase = startsamp; - x->x_sync = 0.; - }; - phase = x->x_phase; - // boundschecking, do it here because points might changed when paused - // easier case, when we're "done" - if(phase >= endsamp){ - if(x->x_loopmode == 1) - phase = startsamp; - else{ // not looping, just stop it - x->x_isrunning = 0; - // mb a bit redundant, but just make sure x->x_sync is 1 - x->x_sync = 1; - // trigger redraw - }; - }; - // harder case up to interpretation - if(phase < startsamp) // if before startsamp, just jump to startsamp? - phase = startsamp; - if(x->x_isrunning == 1){ // if we're still running after boundschecking - for(j = 0; j < nch; j++){ - t_word *vp = c->c_vectors[j]; - t_float *insig = x->x_ivecs[j]; - if(vp) - vp[phase].w_float = insig[i]; - }; - // sync output - sync = (t_float)(phase - startsamp)/(t_float)range; - // increment stage - phase++; - x->x_phase = phase; - x->x_sync = sync; - }; - }; - // in any case, output sync value - out[i] = x->x_sync; - }; - // storing changed vars locally - if(nblock){ - pd_float((t_pd *)x->x_stlet, startms); - pd_float((t_pd *)x->x_endlet, endms); - }; - return(w+3); -} - -static void record_dsp(t_record *x, t_signal **sp){ - cybuf_checkdsp(x->x_cybuf); - x->x_ksr= sp[0]->s_sr * 0.001; - int i, nblock = sp[0]->s_n; - t_signal **sigp = sp; - for(i = 0; i < x->x_numchans; i++) // input vectors first - *(x->x_ivecs+i) = (*sigp++)->s_vec; - x->x_startvec = (*sigp++)->s_vec; - x->x_endvec = (*sigp++)->s_vec; - x->x_ovec = (*sigp++)->s_vec; - dsp_add(record_perform, 2, x, nblock); -} - -static void record_proxy_free(t_record_proxy *p){ - pd_unbind(&p->p_obj.ob_pd, gensym("pd-dsp-stopped")); - clock_free(p->p_clock); - pd_free(&p->p_obj.ob_pd); -} - -static t_record_proxy *record_proxy_new(t_record *x){ - t_record_proxy *p = (t_record_proxy*)pd_new(record_proxy_class); - p->p_cnv = x; - pd_bind(&p->p_obj.ob_pd, gensym("pd-dsp-stopped")); - p->p_clock = clock_new(p, (t_method)record_proxy_free); - return(p); -} - -static void record_free(t_record *x){ - cybuf_free(x->x_cybuf); - inlet_free(x->x_stlet); - inlet_free(x->x_endlet); - outlet_free(x->x_outlet); - freebytes(x->x_ivecs, x->x_numchans * sizeof(*x->x_ivecs)); - if(x->x_clock) - clock_free(x->x_clock); - x->x_proxy->p_cnv = NULL; -} - -static void *record_new(t_symbol *s, int argc, t_atom *argv){ - s = NULL; - t_record *x = (t_record *)pd_new(record_class); - x->x_proxy = record_proxy_new(x); - int i; - int numchan = 1; - t_float append = 0; - t_float loopstatus = 0; - t_float loopstart = 0; - t_float loopend = 1E+32; - int nameset = 0; // flag if name is set - t_symbol *arrname = NULL; - if(argc > 0){ // 1st arg is array name - if(argv->a_type == A_SYMBOL){ - arrname = atom_getsymbolarg(0, argc, argv); - nameset = 1; - } - argc--; - argv++; - }; - // NOW parse the rest of the args - while(argc > 0){ - if(argv->a_type == A_SYMBOL){ - t_symbol *curarg = atom_getsymbolarg(0, argc, argv); - if(curarg == gensym("@append")){ - if(argc >= 2){ - append = atom_getfloatarg(1, argc, argv); - argc-=2; - argv+=2; - } - else - goto errstate; - } - else if(curarg == gensym("@loop")){ - if(argc >= 2){ - loopstatus = atom_getfloatarg(1, argc, argv); - argc-=2; - argv+=2; - } - else - goto errstate; - } - else if(curarg == gensym("@loopstart")){ - if(argc >= 2){ - loopstart = atom_getfloatarg(1, argc, argv); - argc-=2; - argv+=2; - } - else - goto errstate; - } - else if(curarg == gensym("@loopend")){ - if(argc >= 2){ - loopend = atom_getfloatarg(1, argc, argv); - argc-=2; - argv+=2; - } - else - goto errstate; - } - else - goto errstate; - } - else if(argv->a_type == A_FLOAT){ - if(nameset){ - numchan = (int)atom_getfloatarg(0, argc, argv); - argc--; - argv++; - } - else - goto errstate; - } - else - goto errstate; - }; - int chn_n = numchan < 1 ? 1 : numchan > 4 ? 4 : numchan == 3 ? 2 : numchan; - // old arsic notes - chn_n number of channels, 0 nsigs 1 nauxsigs - x->x_ksr = (float)sys_getsr() * 0.001; - x->x_cybuf = cybuf_init((t_class *)x, arrname, chn_n, 0); - t_cybuf * c = x->x_cybuf; - // init - x->x_newrun = 0; - x->x_isrunning = 0; - x->x_sync = 0; - x->x_phase = 0; - if(c){ // setting channels and array sizes - x->x_numchans = c->c_numchans; - // allocate input vectors - x->x_ivecs = getbytes(x->x_numchans * sizeof(*x->x_ivecs)); - // bounds checking - if(loopstart < 0) - loopstart = 0; - cybuf_setminsize(x->x_cybuf, 2); - record_append(x, append); - record_loop(x, loopstatus); - x->x_clock = clock_new(x, (t_method)record_tick); - x->x_clocklasttick = clock_getlogicaltime(); - if(loopend < 0) - loopend = 0; - if(loopstart < 0) - loopstart = 0; - for(i = 1; i < x->x_numchans; i++) - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - x->x_stlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - pd_float((t_pd *)x->x_stlet, loopstart); - x->x_endlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - pd_float((t_pd *)x->x_endlet, loopend); - x->x_outlet = outlet_new(&x->x_obj, gensym("signal")); - }; - return(x); - errstate: - post("record~: improper args"); - return NULL; -} - -CYCLONE_OBJ_API void record_tilde_setup(void){ - record_class = class_new(gensym("record~"), (t_newmethod)record_new, - (t_method)record_free, sizeof(t_record), 0, A_GIMME, 0); - class_addfloat(record_class, record_float); - class_addmethod(record_class, (t_method)record_dsp, gensym("dsp"), A_CANT, 0); - class_addlist(record_class, (t_method)record_list); - class_domainsignalin(record_class, -1); - class_addmethod(record_class, (t_method)record_append, gensym("append"), A_FLOAT, 0); - class_addmethod(record_class, (t_method)record_loop, gensym("loop"), A_FLOAT, 0); - class_addmethod(record_class, (t_method)record_set, gensym("set"), A_SYMBOL, 0); - class_addmethod(record_class, (t_method)record_reset, gensym("reset"), 0); - class_addmethod(record_class, (t_method)record_loopstart, gensym("loopstart"), A_FLOAT, 0); - class_addmethod(record_class, (t_method)record_loopend, gensym("loopend"), A_FLOAT, 0); - record_proxy_class = class_new(0, 0, 0, sizeof(t_record_proxy), CLASS_NOINLET | CLASS_PD, 0); - class_addbang(record_proxy_class, record_proxy_draw); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/reson.c b/Libraries/cyclone/cyclone_objects/binaries/audio/reson.c deleted file mode 100644 index a13dbcfdd8..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/reson.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (c) 2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* This filter (cmusic's nres and csound's resonr) originates from - CMJv6n4 article by Smith & Angell. See also section 9.6 of - ``Introduction to Digital Filters'' by Smith. */ - -/* CHECKME if creation args (or defaults) restored after signal disconnection */ - -#define _USE_MATH_DEFINES -#include -#include "m_pd.h" -#include - -#define RESON_DEFQ .01 -#define RESON_MINQ 1e-20 /* CHECKME */ -#define RESON_MINOMEGA .0001 /* CHECKME */ -#define RESON_MAXOMEGA M_PI /* CHECKME */ -#define TWO_PI (M_PI * 2.) - -typedef struct _reson -{ - t_object x_obj; - t_inlet *x_gain_inlet; - t_inlet *x_freq_inlet; - t_inlet *x_q_inlet; - float x_srcoef; - float x_xnm1; - float x_xnm2; - float x_ynm1; - float x_ynm2; -} t_reson; - -static t_class *reson_class; - -static void reson_clear(t_reson *x) -{ - x->x_xnm1 = x->x_xnm2 = x->x_ynm1 = x->x_ynm2 = 0.; -} - -/* LATER make ready for optional audio-rate modulation - (separate scalar case routines, use sic_makecostable(), etc.) */ -static t_int *reson_perform(t_int *w) -{ - t_reson *x = (t_reson *)(w[1]); - int nblock = (int)(w[2]); - t_float *xin = (t_float *)(w[3]); - t_float *gin = (t_float *)(w[4]); - t_float fin0 = *(t_float *)(w[5]); - t_float qin0 = *(t_float *)(w[6]); - t_float *out = (t_float *)(w[7]); - float xnm1 = x->x_xnm1; - float xnm2 = x->x_xnm2; - float ynm1 = x->x_ynm1; - float ynm2 = x->x_ynm2; - /* CHECKME sampled once per block */ - float qinv = (qin0 > RESON_MINQ ? -1. / qin0 : (-1. / RESON_MINQ)); - float omega = fin0 * x->x_srcoef; - float radius, c1, c2, scale; - if (omega < RESON_MINOMEGA) - omega = RESON_MINOMEGA; - else if (omega > RESON_MAXOMEGA) - omega = RESON_MAXOMEGA; - radius = expf(omega * qinv); /* radius < 1 (because omega * qinv < 0) */ - c1 = 2. * radius * cosf(omega); - c2 = radius * radius; - scale = 1. - radius; - while (nblock--) - { - float yn, xn = *xin++; - /* CHECKED gain control */ - *out++ = yn = - *gin++ * scale * (xn - radius * xnm2) + c1 * ynm1 - c2 * ynm2; - xnm2 = xnm1; - xnm1 = xn; - ynm2 = ynm1; - ynm1 = yn; - } - x->x_xnm1 = xnm1; - x->x_xnm2 = xnm2; - /* LATER rethink */ - x->x_ynm1 = (PD_BIGORSMALL(ynm1) ? 0. : ynm1); - x->x_ynm2 = (PD_BIGORSMALL(ynm2) ? 0. : ynm2); - return (w + 8); -} - -static void reson_dsp(t_reson *x, t_signal **sp) -{ - x->x_srcoef = TWO_PI / sp[0]->s_sr; - reson_clear(x); - dsp_add(reson_perform, 7, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, - sp[4]->s_vec); -} - -static void *reson_new(t_floatarg f1, t_floatarg f2, t_floatarg f3) -{ - t_reson *x = (t_reson *)pd_new(reson_class); - x->x_srcoef = TWO_PI / sys_getsr(); - if (f1 < 0.) f1 = 0.; - if (f2 < 0.) f2 = 0.; - if (f3 <= 0.) - f3 = RESON_DEFQ; /* CHECKED */ - x->x_gain_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_gain_inlet, f1); - x->x_freq_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_freq_inlet, f2); - x->x_q_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_q_inlet, f3); - outlet_new((t_object *)x, &s_signal); - reson_clear(x); - return (x); -} - -CYCLONE_OBJ_API void reson_tilde_setup(void) -{ - reson_class = class_new(gensym("reson~"), - (t_newmethod)reson_new, 0, - sizeof(t_reson), 0, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(reson_class, nullfn, gensym("signal"), 0); - class_addmethod(reson_class, (t_method)reson_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(reson_class, (t_method)reson_clear, gensym("clear"), 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/rminus.c b/Libraries/cyclone/cyclone_objects/binaries/audio/rminus.c deleted file mode 100644 index 9138f49a79..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/rminus.c +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2016 Porres. - -#include "m_pd.h" -#include - -// --------------------------------------------------- -// Class definition -// --------------------------------------------------- -static t_class *rminus_class; - -// --------------------------------------------------- -// Data structure definition -// --------------------------------------------------- -typedef struct _rminus -{ - t_object x_obj; - t_inlet *x_inlet; -} t_rminus; - -// --------------------------------------------------- -// Perform -// --------------------------------------------------- -static t_int *rminus_perform(t_int *w) -{ - int nblock = (int)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - while (nblock--) - { - t_float f1 = *in1++; - t_float f2 = *in2++; - *out++ = (f2 - f1); - } - return (w + 5); -} - -// --------------------------------------------------- -// DSP Function -// --------------------------------------------------- -static void rminus_dsp(t_rminus *x, t_signal **sp) -{ - dsp_add(rminus_perform, 4, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -// FREE -static void *rminus_free(t_rminus *x) -{ - inlet_free(x->x_inlet); - return (void *)x; -} - -// --------------------------------------------------- -// Functions signature -// --------------------------------------------------- -static void *rminus_new(t_floatarg f) -{ - t_rminus *x = (t_rminus *)pd_new(rminus_class); - x->x_inlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet, f); - outlet_new((t_object *)x, &s_signal); - return (x); -} - -// --------------------------------------------------- -// Setup -// --------------------------------------------------- -CYCLONE_OBJ_API void rminus_tilde_setup(void) -{ - rminus_class = class_new(gensym("rminus~"), - (t_newmethod)rminus_new, - (t_method)rminus_free, - sizeof(t_rminus), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(rminus_class, nullfn, gensym("signal"), 0); - class_addmethod(rminus_class, (t_method)rminus_dsp, gensym("dsp"), A_CANT, 0); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/round.c b/Libraries/cyclone/cyclone_objects/binaries/audio/round.c deleted file mode 100644 index e98bccf507..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/round.c +++ /dev/null @@ -1,140 +0,0 @@ -//2016 by Derek Kwan - -#include "m_pd.h" -#include -#include -#include -#include - -#ifndef CYROUNDNEAR_DEF -#define CYROUNDNEAR_DEF 1 -#endif - -#ifndef CYROUNDNUM_DEF -#define CYROUNDNUM_DEF 0. -#endif - -static t_class *round_tilde_class; - -typedef struct _round_tilde -{ - t_object x_obj; - float x_nearest; //nearest attribute (1 = rounding, 0 = truncation) -} t_round_tilde; - -static void *round_tilde_new(t_symbol *s, int argc, t_atom *argv) -{ float f; - t_round_tilde *x = (t_round_tilde *)pd_new(round_tilde_class); - int numargs = 0; - int pastargs = 0;//if we haven't declared any attrs yet - x->x_nearest = CYROUNDNEAR_DEF; - f = CYROUNDNUM_DEF; - while(argc > 0 ){ - if(argv -> a_type == A_FLOAT){ //if nullpointer, should be float or int - if(!pastargs){ - switch(numargs){//we haven't declared attrs yet - case 0: f = atom_getfloatarg(0, argc, argv); - numargs++; - argc--; - argv++; - break; - default: argc--; - argv++; - break; - }; - } - else{ - argc--; - argv++; - }; - } - else if(argv -> a_type == A_SYMBOL){ - t_symbol *curarg = atom_getsymbolarg(0, argc, argv); //returns nullpointer if not symbol - pastargs = 1; - int isnear = strcmp(curarg->s_name, "@nearest") == 0; - if(isnear && argc >= 2){ - t_symbol *arg1 = atom_getsymbolarg(1, argc, argv); - if(arg1 == &s_){// is a number - x->x_nearest = atom_getfloatarg(1, argc, argv); - argc -= 2; - argv += 2; - } - else{ - goto errstate; - };} - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - }; - - pd_float( (t_pd *)inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal), f); - outlet_new(&x->x_obj, gensym("signal")); - return (x); - - errstate: - pd_error(x, "round~: improper args"); - return NULL; -} - -static t_int *round_tilde_perform(t_int *w) -{ - t_round_tilde *x = (t_round_tilde *)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - int n = (int)(w[5]); - float nearfloat; - int nearest; - nearfloat = x->x_nearest; - if(nearfloat <= 0.){ - nearest = 0; - } - else{ - nearest = 1; - }; - while (n--){ - float rounded,div; - float val = *(in1++); - float roundto = *(in2++); - if(roundto > 0.){ - div = val/roundto; //get the result of dividing the two - if(nearest == 1){//rounding - rounded = roundto*round(div); //round quotient to nearest int and multiply roundto by result - } - else{//truncation - rounded = roundto*(float)((int)div); //else lop off the decimal and multiply roundto by result - }; - } - else{//round is 0, do nothing - rounded = val; - }; - *out++ = rounded; - }; - return (w+6); -} - -static void round_tilde_nearest(t_round_tilde *x, t_float f, t_float glob){ - if(f <= 0.){ - x->x_nearest = 0; - } - else{ - x->x_nearest = 1; - }; -} -static void round_tilde_dsp(t_round_tilde *x, t_signal **sp) -{ - dsp_add(round_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); -} - -CYCLONE_OBJ_API void round_tilde_setup(void) -{ - round_tilde_class = class_new(gensym("round~"), (t_newmethod)round_tilde_new, 0, - sizeof(t_round_tilde), 0, A_GIMME, 0); - class_addmethod(round_tilde_class, nullfn, gensym("signal"), 0); - class_addmethod(round_tilde_class, (t_method)round_tilde_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(round_tilde_class, (t_method)round_tilde_nearest, gensym("nearest"), A_FLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/sah.c b/Libraries/cyclone/cyclone_objects/binaries/audio/sah.c deleted file mode 100644 index bea6182061..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/sah.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - - -#include "m_pd.h" -#include -// MAGIC: include magicbit.h for magic -#include "common/magicbit.h" -// end magic - -typedef struct _sah -{ - t_object x_obj; - t_float x_threshold; - t_float x_lastin; - t_float x_lastout; - /*MAGIC - *x_glist is a list of objects in the canvas - *x_signalscalar is a pointer to the right inlet's float field, which we're going to poll - x_hasfeeders is a flag telling us whether right inlet has feeders*/ - t_glist *x_glist; - t_float *x_signalscalar; - int x_hasfeeders; - /*end magic*/ -} t_sah; - -static t_class *sah_class; - -//*MAGIC -//This is a public function that returns float fields. It is not declared in m_pd.h, -//so we have to declare it here. The arguments are the object and the inlet number -//(indexed from zero)*/ -//EXTERN t_float *obj_findsignalscalar(t_object *x, int m); -//*end magic*/ - -static t_int *sah_perform(t_int *w) -{ - - t_sah *x = (t_sah *)(w[1]); - int nblock = (t_int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *out = (t_float *)(w[5]); - t_float threshold = x->x_threshold; - t_float lastin = x->x_lastin; - t_float lastout = x->x_lastout; - - /*MAGIC - here we poll the float in the right inlet's float field to see if it's changed. - if so, that means there's been a float input and we issue an error. Unfortunately, - it won't work if you just input the same float over and over... - */ - if (!magic_isnan(*x->x_signalscalar)) - { - magic_setnan(x->x_signalscalar); - pd_error(x, "sah~: doesn't understand 'float'"); - } - /*end magic*/ - while (nblock--) - { - t_float f; - /*MAGIC - self explanatory*/ - if (x->x_hasfeeders) - f = *in2++; - else f = 0.0; - /*end magic*/ - if (lastin <= threshold && f > threshold) /* CHECKME <=, > */ - lastout = *in1; - in1++; - lastin = f; - *out++ = lastout; - } - x->x_lastin = lastin; - x->x_lastout = lastout; - return (w + 6); -} - -static void sah_dsp(t_sah *x, t_signal **sp) -{ - /*MAGIC - Get flag for signal feeders.*/ - x->x_hasfeeders = magic_inlet_connection((t_object *)x, x->x_glist, 1, &s_signal); - /*end magic*/ - magic_setnan(x->x_signalscalar); - dsp_add(sah_perform, 5, x, sp[0]->s_n, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec); -} - -static void sah_float(t_sah *x, t_float f) -{ - x->x_threshold = f; -} - -static void *sah_new(t_floatarg f) -{ - t_sah *x = (t_sah *)pd_new(sah_class); - x->x_threshold = f; - x->x_lastin = 0; - x->x_lastout = 0; - inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - outlet_new((t_object *)x, &s_signal); - /*MAGIC - 1. get the current glist - 2. get a pointer to inlet 1's float field. */ - x->x_glist = canvas_getcurrent(); - x->x_signalscalar = obj_findsignalscalar((t_object *)x, 1); - /*end magic*/ - return (x); -} - -CYCLONE_OBJ_API void sah_tilde_setup(void) -{ - sah_class = class_new(gensym("sah~"), (t_newmethod)sah_new, 0, - sizeof(t_sah), CLASS_DEFAULT, A_DEFFLOAT, 0); - class_addmethod(sah_class, nullfn, gensym("signal"), 0); - class_addmethod(sah_class, (t_method)sah_dsp, gensym("dsp"), A_CANT, 0); - class_addfloat(sah_class, (t_method)sah_float); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/sampstoms.c b/Libraries/cyclone/cyclone_objects/binaries/audio/sampstoms.c deleted file mode 100644 index e5dfa1e54a..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/sampstoms.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) 2003 krzYszcz, and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -#include "m_pd.h" -#include - -typedef struct _sampstoms -{ - t_object x_obj; - float x_rcpksr; - float x_f; - t_outlet *x_floatout; -} t_sampstoms; - - -static t_class *sampstoms_class; - -static void sampstoms_float(t_sampstoms *x, t_float f) -{ - x->x_f = f; - outlet_float(x->x_floatout, f * x->x_rcpksr); -} - -static t_int *sampstoms_perform(t_int *w) -{ - t_sampstoms *x = (t_sampstoms *)(w[1]); - int nblock = (int)(w[2]); - t_float *in = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - float rcpksr = x->x_rcpksr; - while (nblock--) *out++ = *in++ * rcpksr; - return (w + 5); -} - -static void sampstoms_dsp(t_sampstoms *x, t_signal **sp) -{ - x->x_rcpksr = 1000. / sp[0]->s_sr; - dsp_add(sampstoms_perform, 4, x, - sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); -} - -static void *sampstoms_new(void) -{ - t_sampstoms *x = (t_sampstoms *)pd_new(sampstoms_class); - x->x_rcpksr = 1000. / sys_getsr(); /* LATER rethink */ - outlet_new((t_object *)x, &s_signal); - x->x_floatout = outlet_new((t_object *)x, &s_float); - x->x_f = 0; - return (x); -} - -CYCLONE_OBJ_API void sampstoms_tilde_setup(void) -{ - sampstoms_class = class_new(gensym("sampstoms~"), - (t_newmethod)sampstoms_new, 0, sizeof(t_sampstoms), CLASS_DEFAULT, 0); - class_addmethod(sampstoms_class, - (t_method)sampstoms_dsp, gensym("dsp"), A_CANT, 0); - CLASS_MAINSIGNALIN(sampstoms_class, t_sampstoms, x_f); - class_addfloat(sampstoms_class, - (t_method)sampstoms_float); -} \ No newline at end of file diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/scale.c b/Libraries/cyclone/cyclone_objects/binaries/audio/scale.c deleted file mode 100644 index 831b9293c6..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/scale.c +++ /dev/null @@ -1,188 +0,0 @@ -// Porres 2016 - -#include "m_pd.h" -#include -#include -#include - -#define SCALE_MININ 0. -#define SCALE_MAXIN 127. -#define SCALE_MINOUT 0. -#define SCALE_MAXOUT 1. -#define SCALE_EXPO 1. - -typedef struct _scale -{ - t_object x_obj; - t_inlet *x_inlet_1; - t_inlet *x_inlet_2; - t_inlet *x_inlet_3; - t_inlet *x_inlet_4; - t_inlet *x_inlet_5; - t_int x_classic; -} t_scale; - -static t_class *scale_class; - - -static void scale_classic(t_scale *x, t_floatarg f) -{ - x->x_classic = (int)f; -} - -static t_int *scale_perform(t_int *w) -{ - t_scale *x = (t_scale *)(w[1]); - int nblock = (int)(w[2]); - t_float *in1 = (t_float *)(w[3]); - t_float *in2 = (t_float *)(w[4]); - t_float *in3 = (t_float *)(w[5]); - t_float *in4 = (t_float *)(w[6]); - t_float *in5 = (t_float *)(w[7]); - t_float *in6 = (t_float *)(w[8]); - t_float *out = (t_float *)(w[9]); - t_int classic_flag = x->x_classic; - while (nblock--) - { - float in = *in1++; - float il = *in2++; // Input LOW - float ih = *in3++; // Input HIGH - float ol = *in4++; // Output LOW - float oh = *in5++; // Output HIGH - float p = *in6++; // power (exponential) factor - float output; - if (classic_flag != 0) - {p = p <= 1 ? 1 : p; - if (p == 1) output = ((in - il) / (ih - il) == 0) ? ol - : (((in - il) / (ih - il)) > 0) ? (ol + (oh - ol) * pow((in - il) / (ih - il), p)) - : (ol + (oh - ol) * -(pow(((-in + il) / (ih - il)), p))); - else - {output = ol + (oh - ol) * ((oh - ol) * exp((il - ih) * log(p)) * exp(in * log(p))); - if (oh - ol <= 0) output = output * -1; - - } - } - else { - p = p <= 0 ? 0 : p; - output = ((in - il) / (ih - il) == 0) ? ol : - (((in - il) / (ih - il)) > 0) ? - (ol + (oh - ol) * pow((in - il) / (ih - il), p)) : - (ol + (oh - ol) * -(pow(((-in + il) / (ih - il)), p))); - } - *out++ = output; - } - return (w + 10); -} - -static void scale_dsp(t_scale *x, t_signal **sp) -{ - dsp_add(scale_perform, 9, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, - sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, sp[5]->s_vec, sp[6]->s_vec); -} - -static void *scale_free(t_scale *x) -{ - inlet_free(x->x_inlet_1); - inlet_free(x->x_inlet_2); - inlet_free(x->x_inlet_3); - inlet_free(x->x_inlet_4); - inlet_free(x->x_inlet_5); - return (void *)x; -} - -static void *scale_new(t_symbol *s, int argc, t_atom *argv) -{ - t_scale *x = (t_scale *)pd_new(scale_class); - t_float min_in, max_in, min_out, max_out, exponential; - min_in = SCALE_MININ; - max_in = SCALE_MAXIN; - min_out = SCALE_MINOUT; - max_out = SCALE_MAXOUT; - exponential = SCALE_EXPO; - t_int classic_exp; - classic_exp = 0; - - int argnum = 0; - while(argc > 0){ - if(argv -> a_type == A_FLOAT) - { - t_float argval = atom_getfloatarg(0,argc,argv); - switch(argnum){ - case 0: - min_in = argval; - break; - case 1: - max_in = argval; - break; - case 2: - min_out = argval; - break; - case 3: - max_out = argval; - break; - case 4: - exponential = argval; - break; - default: - break; - }; - argc--; - argv++; - argnum++; - } - -// attribute - else if(argv -> a_type == A_SYMBOL){ - t_symbol *curarg = atom_getsymbolarg(0, argc, argv); - if(strcmp(curarg->s_name, "@classic")==0){ - if(argc >= 2){ - t_float argval = atom_getfloatarg(1, argc, argv); - classic_exp = (int)argval; - argc-=2; - argv+=2; - } - else{ - goto errstate; - }; - } - else{ - goto errstate; - }; - - } - else{ - goto errstate; - }; - }; - - x->x_inlet_1 = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet_1, min_in); - x->x_inlet_2 = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet_2, max_in); - x->x_inlet_3 = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet_3, min_out); - x->x_inlet_4 = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet_4, max_out); - x->x_inlet_5 = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); - pd_float((t_pd *)x->x_inlet_5, exponential); - - outlet_new((t_object *)x, &s_signal); - - x->x_classic = classic_exp; - - return (x); - errstate: - pd_error(x, "scale~: improper args"); - return NULL; -} - -CYCLONE_OBJ_API void scale_tilde_setup(void) -{ - scale_class = class_new(gensym("scale~"), - (t_newmethod)scale_new, - (t_method)scale_free, - sizeof(t_scale), 0, A_GIMME, 0); - class_addmethod(scale_class, nullfn, gensym("signal"), 0); - class_addmethod(scale_class, (t_method)scale_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(scale_class, (t_method) scale_classic, gensym("classic"), A_DEFFLOAT, 0); -} diff --git a/Libraries/cyclone/cyclone_objects/binaries/audio/scope.c b/Libraries/cyclone/cyclone_objects/binaries/audio/scope.c deleted file mode 100644 index c37afa044a..0000000000 --- a/Libraries/cyclone/cyclone_objects/binaries/audio/scope.c +++ /dev/null @@ -1,1403 +0,0 @@ -/* Copyright (c) 2002-2005 krzYszcz and others. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "LICENSE.txt," in this distribution. - -- LATER cache gui commands & think about resizing - mouse events aren't bound to any of scope~'s - 'widget', but to a special item created only for a selected scope~. For the other scheme see the - 'comment' class (no indicator there, though - neither a handle, nor a pointer change). One way - or the other, the traffic from the gui layer should be kept possibly low, at least in run-mode. - -- 2016 = Derek Kwan: haven't cleaned out old dependencies (grow/loud/fitter/forky). Methods (bufsize, - period, calccount, range, delay, trigger, triglevel, frgb/brgb) are rewritten, as well as attr - declaration. Wrote color version that take vals 0-1 instead of 0-255. -- Matt didn't put what he did but he's the one who did more stuff on this for 0.3, like creating a - properties window and implementing the magic stuff -- 2017-20 = Porres finished cleaning dependencies (sic/grow/loud/fitter/forky/all_guis/math), -cleaned up and revised the code drastically, fixed a couple of regression bugs from 0.3, improved -tcl/tk handling avoiding potential errors, fixed issues with GOP visibility, changed the click mechanism, -handle managemente, added a receive symbol, visible inlets and implemented zoom; */ - -#include "common/api.h" -#include "m_pd.h" -#include "g_canvas.h" -#include "common/magicbit.h" -#include -#include - -#define SCOPE_MINSIZE 18 -#define SCOPE_MINPERIOD 2 -#define SCOPE_MAXPERIOD 8192 -#define SCOPE_MINBUFSIZE 8 -#define SCOPE_MAXBUFSIZE 256 -#define SCOPE_MINDELAY 0 -#define SCOPE_SELBDWIDTH 2 -#define HANDLE_SIZE 12 -#define SCOPE_GUICHUNK 128 // performance-related hacks, LATER investigate - -typedef struct _edit_proxy{ - t_object p_obj; - t_symbol *p_sym; - t_clock *p_clock; - struct _scope *p_cnv; -}t_edit_proxy; - -typedef struct _scope{ - t_object x_obj; - t_inlet *x_rightinlet; - t_glist *x_glist; - t_canvas *x_cv; - t_edit_proxy *x_proxy; - unsigned char x_bg[3], x_fg[3], x_gg[3]; - float x_xbuffer[SCOPE_MAXBUFSIZE*4]; - float x_ybuffer[SCOPE_MAXBUFSIZE*4]; - float x_xbuflast[SCOPE_MAXBUFSIZE*4]; - float x_ybuflast[SCOPE_MAXBUFSIZE*4]; - float x_min, x_max; - float x_trigx, x_triglevel; - float x_ksr; - float x_currx, x_curry; - int x_select; - int x_width, x_height; - int x_drawstyle; - int x_delay; - int x_trigmode; - int x_bufsize, x_lastbufsize; - int x_period; - int x_bufphase, x_precount, x_phase; - int x_xymode, x_frozen, x_retrigger; - int x_zoom; - int x_edit; - t_float *x_signalscalar; - int x_rcv_set; - int x_flag; - int x_r_flag; - t_symbol *x_receive; - t_symbol *x_rcv_raw; - t_symbol *x_bindsym; - t_clock *x_clock; - t_pd *x_handle; -}t_scope; - -typedef struct _handle{ - t_pd h_pd; - t_scope *h_master; - t_symbol *h_bindsym; - char h_pathname[64], h_outlinetag[64]; - int h_dragon, h_dragx, h_dragy; -}t_handle; - -static t_class *scope_class, *handle_class, *edit_proxy_class; -static t_widgetbehavior scope_widgetbehavior; - -static void scope_getrect(t_gobj *z, t_glist *gl, int *xp1, int *yp1, int *xp2, int *yp2); - -// ----------------- DRAW ---------------------------------------------------------------- -static void scope_draw_handle(t_scope *x, int state){ - t_handle *sh = (t_handle *)x->x_handle; - // always destroy (otherwise it may already exist) - sys_vgui("destroy %s\n", sh->h_pathname); - if(state){ - sys_vgui("canvas %s -width %d -height %d -bg blue -highlightthickness %d -cursor bottom_right_corner\n", - sh->h_pathname, HANDLE_SIZE, HANDLE_SIZE, 2*x->x_zoom); - int x1, y1, x2, y2; - scope_getrect((t_gobj *)x, x->x_glist, &x1, &y1, &x2, &y2); - sys_vgui(".x%lx.c create window %d %d -anchor nw -width %d -height %d -window %s -tags all%lx\n", - x->x_cv, - x2 - HANDLE_SIZE*x->x_zoom + 1, - y2 - HANDLE_SIZE*x->x_zoom + 1, - HANDLE_SIZE*x->x_zoom, - HANDLE_SIZE*x->x_zoom, - sh->h_pathname, - x); - sys_vgui("bind %s