├── clients
└── oooooooo
│ ├── src
│ ├── Perlin.cpp
│ ├── DisplayUtils.h
│ ├── Window.cpp
│ ├── Serializable.h
│ ├── Window.h
│ ├── HelpSystem.h
│ ├── Commands.cpp
│ ├── DisplayMessage.h
│ ├── AudioFile.h
│ ├── KeyboardHandler.h
│ ├── AudioFile.cpp
│ ├── DrawFunctions.h
│ ├── Poll.h
│ ├── VUMeter.h
│ ├── DisplayRing.h
│ ├── IntroAnimation.h
│ ├── OscInterface.h
│ ├── LFO.cpp
│ ├── Display.h
│ ├── Perlin.h
│ ├── VUMeter.cpp
│ ├── Commands.h
│ ├── SessionRecorder.h
│ ├── HelpSystem.cpp
│ ├── DisplayMessage.cpp
│ ├── LFO.h
│ ├── Parameter.h
│ ├── BufDiskWorker.h
│ ├── main.cpp
│ └── Parameters.h
│ ├── third-party
│ └── .DS_Store
│ └── tests
│ └── pulsefile.scd
├── oooooooo.png
├── softcut-lib
├── waf
├── include
│ └── softcut
│ │ ├── Types.h
│ │ ├── Svf.h
│ │ ├── Interpolate.h
│ │ ├── FadeCurves.h
│ │ ├── TestBuffers.h
│ │ ├── SoftClip.h
│ │ ├── SubHead.h
│ │ ├── ReadWriteHead.h
│ │ └── Voice.h
├── CMakeLists.txt
├── wscript
└── src
│ ├── Svf.cpp
│ └── FadeCurves.cpp
├── .gitignore
├── external
├── windows
│ ├── SDL2.dll
│ ├── libFLAC.dll
│ ├── liblo-7.dll
│ ├── zlib1.dll
│ ├── SDL2_ttf.dll
│ ├── libbz2-1.dll
│ ├── libintl-8.dll
│ ├── libogg-0.dll
│ ├── libopus-0.dll
│ ├── libbrotlidec.dll
│ ├── libgraphite2.dll
│ ├── libiconv-2.dll
│ ├── libmp3lame-0.dll
│ ├── libmpg123-0.dll
│ ├── libpcre2-8-0.dll
│ ├── libpng16-16.dll
│ ├── libsndfile-1.dll
│ ├── libstdc++-6.dll
│ ├── libvorbis-0.dll
│ ├── libfreetype-6.dll
│ ├── libgcc_s_seh-1.dll
│ ├── libglib-2.0-0.dll
│ ├── libharfbuzz-0.dll
│ ├── libvorbisenc-2.dll
│ ├── libbrotlicommon.dll
│ ├── libwinpthread-1.dll
│ ├── copy_dlls.py
│ └── dlls.txt
└── faust
│ └── architecture
│ └── faust
│ ├── gui
│ ├── Styles
│ │ ├── Blue.qrc
│ │ ├── Grey.qrc
│ │ ├── Default.qrc
│ │ ├── Salmon.qrc
│ │ ├── Default.qss
│ │ ├── Grey.qss
│ │ └── Blue.qss
│ ├── meta.h
│ ├── JSONControl.h
│ ├── JuceStateUI.h
│ ├── UI.h
│ ├── Esp32Reader.h
│ └── JuceReader.h
│ ├── dsp
│ ├── cpp-dsp-adapter.h
│ ├── faust-engine.h
│ ├── dsp-multifun.h
│ ├── proxy-dsp.h
│ ├── dsp-checker.h
│ └── proxy-osc-dsp.h
│ ├── vst
│ └── voice.h
│ ├── export.h
│ ├── misc.h
│ ├── midi
│ ├── teensy-midi.h
│ ├── gramophone-midi.h
│ └── daisy-midi.h
│ ├── audio
│ ├── audio.h
│ ├── channels.h
│ └── osc-dsp.h
│ └── sound-file.h
├── CMakeLists.txt
├── dsp
├── CMakeLists.txt
├── tapefx
│ ├── Follower.cpp
│ ├── CMakeLists.txt
│ ├── Follower.h
│ ├── TapeFX.h
│ └── TapeFX.cpp
├── utilities
│ ├── CMakeLists.txt
│ ├── Utilities.h
│ └── Utilities.cpp
└── fverb
│ ├── CMakeLists.txt
│ ├── FVerb.h
│ └── FVerb.cpp
├── Makefile
├── readme-macos.md
├── readme-contributing.md
├── notes.md
├── tests
└── test1.scd
└── .github
└── workflows
├── ci.yml
└── release.yml
/clients/oooooooo/src/Perlin.cpp:
--------------------------------------------------------------------------------
1 | #include "Perlin.h"
--------------------------------------------------------------------------------
/oooooooo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/oooooooo.png
--------------------------------------------------------------------------------
/softcut-lib/waf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/softcut-lib/waf
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.json
2 | build/*
3 | *.wav
4 | AppDir/*
5 | *.AppImage
6 | appimagetool*
7 | *.flac
8 |
--------------------------------------------------------------------------------
/external/windows/SDL2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/SDL2.dll
--------------------------------------------------------------------------------
/external/windows/libFLAC.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libFLAC.dll
--------------------------------------------------------------------------------
/external/windows/liblo-7.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/liblo-7.dll
--------------------------------------------------------------------------------
/external/windows/zlib1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/zlib1.dll
--------------------------------------------------------------------------------
/external/windows/SDL2_ttf.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/SDL2_ttf.dll
--------------------------------------------------------------------------------
/external/windows/libbz2-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libbz2-1.dll
--------------------------------------------------------------------------------
/external/windows/libintl-8.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libintl-8.dll
--------------------------------------------------------------------------------
/external/windows/libogg-0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libogg-0.dll
--------------------------------------------------------------------------------
/external/windows/libopus-0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libopus-0.dll
--------------------------------------------------------------------------------
/external/windows/libbrotlidec.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libbrotlidec.dll
--------------------------------------------------------------------------------
/external/windows/libgraphite2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libgraphite2.dll
--------------------------------------------------------------------------------
/external/windows/libiconv-2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libiconv-2.dll
--------------------------------------------------------------------------------
/external/windows/libmp3lame-0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libmp3lame-0.dll
--------------------------------------------------------------------------------
/external/windows/libmpg123-0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libmpg123-0.dll
--------------------------------------------------------------------------------
/external/windows/libpcre2-8-0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libpcre2-8-0.dll
--------------------------------------------------------------------------------
/external/windows/libpng16-16.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libpng16-16.dll
--------------------------------------------------------------------------------
/external/windows/libsndfile-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libsndfile-1.dll
--------------------------------------------------------------------------------
/external/windows/libstdc++-6.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libstdc++-6.dll
--------------------------------------------------------------------------------
/external/windows/libvorbis-0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libvorbis-0.dll
--------------------------------------------------------------------------------
/external/windows/libfreetype-6.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libfreetype-6.dll
--------------------------------------------------------------------------------
/external/windows/libgcc_s_seh-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libgcc_s_seh-1.dll
--------------------------------------------------------------------------------
/external/windows/libglib-2.0-0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libglib-2.0-0.dll
--------------------------------------------------------------------------------
/external/windows/libharfbuzz-0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libharfbuzz-0.dll
--------------------------------------------------------------------------------
/external/windows/libvorbisenc-2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libvorbisenc-2.dll
--------------------------------------------------------------------------------
/clients/oooooooo/third-party/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/clients/oooooooo/third-party/.DS_Store
--------------------------------------------------------------------------------
/external/windows/libbrotlicommon.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libbrotlicommon.dll
--------------------------------------------------------------------------------
/external/windows/libwinpthread-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schollz/oooooooo/HEAD/external/windows/libwinpthread-1.dll
--------------------------------------------------------------------------------
/external/faust/architecture/faust/gui/Styles/Blue.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | Blue.qss
4 |
5 |
6 |
--------------------------------------------------------------------------------
/external/faust/architecture/faust/gui/Styles/Grey.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | Grey.qss
4 |
5 |
6 |
--------------------------------------------------------------------------------
/external/faust/architecture/faust/gui/Styles/Default.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | Default.qss
4 |
5 |
6 |
--------------------------------------------------------------------------------
/external/faust/architecture/faust/gui/Styles/Salmon.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | Salmon.qss
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.17)
2 |
3 | add_subdirectory(dsp)
4 | project(softcut)
5 | add_subdirectory(softcut-lib)
6 | add_subdirectory(clients/oooooooo)
7 |
--------------------------------------------------------------------------------
/dsp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # ./dsp/CMakeLists.txt
2 | cmake_minimum_required(VERSION 3.17)
3 |
4 | project(dsp)
5 |
6 | # Add the subdirectories
7 | add_subdirectory(utilities)
8 | add_subdirectory(fverb)
9 | add_subdirectory(tapefx)
10 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/DisplayUtils.h:
--------------------------------------------------------------------------------
1 | // DisplayUtils.h
2 | #ifndef DISPLAY_UTILS_H
3 | #define DISPLAY_UTILS_H
4 |
5 | // Functions to get current window dimensions
6 | int get_window_width();
7 | int get_window_height();
8 |
9 | #endif // DISPLAY_UTILS_H
--------------------------------------------------------------------------------
/clients/oooooooo/src/Window.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by emb on 1/25/19.
3 | //
4 |
5 | #include "Window.h"
6 |
7 | using namespace softcut_jack_osc;
8 |
9 | const float Window::raisedCosShort[Window::raisedCosShortLen] = {
10 | #include "cos_win.inc"
11 | };
--------------------------------------------------------------------------------
/dsp/tapefx/Follower.cpp:
--------------------------------------------------------------------------------
1 | #include "Follower.h"
2 |
3 | float Follower::process(float x) {
4 | const auto abs_x = std::abs(x);
5 | if (abs_x > y_) {
6 | y_ = a_ * y_ + (1 - a_) * abs_x;
7 | } else {
8 | y_ = b_ * y_ + (1 - b_) * abs_x;
9 | }
10 | return y_;
11 | }
--------------------------------------------------------------------------------
/softcut-lib/include/softcut/Types.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 11/10/18.
3 | //
4 |
5 | #ifndef Softcut_TYPES_H
6 | #define Softcut_TYPES_H
7 |
8 | namespace softcut {
9 | typedef double sample_t;
10 | typedef double phase_t;
11 | typedef double rate_t;
12 | } // namespace softcut
13 | #endif // Softcut_TYPES_H
14 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 |
2 | builder: build
3 | cd build && cmake --build . --config Release -- -j$(nproc)
4 |
5 | build:
6 | mkdir -p build
7 | cd build && cmake -DCMAKE_BUILD_TYPE=Release ..
8 |
9 | run: builder
10 | ./build/clients/oooooooo/oooooooo
11 |
12 | test:
13 | sclang tests/test1.scd
14 |
15 | clean:
16 | rm -rf build
--------------------------------------------------------------------------------
/clients/oooooooo/src/Serializable.h:
--------------------------------------------------------------------------------
1 | // Add to a new file like "Serializable.h"
2 | #pragma once
3 | #include "JSON.hpp"
4 | using JSON = nlohmann::json;
5 |
6 | class Serializable {
7 | public:
8 | virtual ~Serializable() = default;
9 | virtual JSON toJSON() const = 0;
10 | virtual void fromJSON(const JSON& json) = 0;
11 | };
--------------------------------------------------------------------------------
/dsp/tapefx/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.17)
2 | set(CMAKE_CXX_STANDARD 17)
3 |
4 | project(tapefx)
5 |
6 | # Ensure the source file is included
7 | add_library(tapefx STATIC Follower.cpp TapeFX.cpp)
8 |
9 | # Make sure the headers are available
10 | target_include_directories(tapefx PUBLIC
11 | ${CMAKE_CURRENT_SOURCE_DIR}
12 | )
13 |
14 | target_compile_options(tapefx PRIVATE -O3)
--------------------------------------------------------------------------------
/dsp/utilities/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.17)
2 | set(CMAKE_CXX_STANDARD 17)
3 |
4 | project(utilities)
5 |
6 | # Ensure the source file is included
7 | add_library(utilities STATIC Utilities.cpp)
8 |
9 | # Make sure the headers are available
10 | target_include_directories(utilities PUBLIC
11 | ${CMAKE_CURRENT_SOURCE_DIR}
12 | )
13 |
14 | target_compile_options(utilities PRIVATE -O3)
--------------------------------------------------------------------------------
/clients/oooooooo/src/Window.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by emb on 1/25/19.
3 | //
4 |
5 | #ifndef CRONE_WINDOW_H
6 | #define CRONE_WINDOW_H
7 |
8 | #include
9 |
10 | namespace softcut_jack_osc {
11 |
12 | class Window {
13 | public:
14 | // raised-cosine window
15 | static constexpr size_t raisedCosShortLen = 48 * 50;
16 | static const float raisedCosShort[raisedCosShortLen];
17 | };
18 |
19 | } // namespace softcut_jack_osc
20 |
21 | #endif // CRONE_WINDOW_H
22 |
--------------------------------------------------------------------------------
/dsp/fverb/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.17)
2 | set(CMAKE_CXX_STANDARD 17)
3 |
4 | project(fverb)
5 |
6 |
7 | # Add your own library
8 | add_library(fverb STATIC FVerb.cpp)
9 |
10 | # Include Faust headers and your own headers
11 | target_include_directories(fverb PUBLIC
12 | ${CMAKE_CURRENT_SOURCE_DIR}
13 | ${CMAKE_CURRENT_SOURCE_DIR}/..
14 | ${CMAKE_CURRENT_SOURCE_DIR}/../../external/faust/architecture
15 | )
16 |
17 | target_compile_options(fverb PRIVATE -O3)
18 |
--------------------------------------------------------------------------------
/dsp/utilities/Utilities.h:
--------------------------------------------------------------------------------
1 | #ifndef UTILITIES_H
2 | #define UTILITIES_H
3 | #pragma once
4 |
5 | #include
6 | #include
7 |
8 | // Declaration of the FormatString function
9 | std::string FormatString(const char* format, ...);
10 |
11 | float MidiToFreq(float midi);
12 |
13 | float LinLin(float in, float inMin, float inMax, float outMin, float outMax);
14 |
15 | float FClamp(float x, float min, float max);
16 |
17 | float DBAmp(float db);
18 |
19 | float AmpDB(float amp);
20 |
21 | #endif
--------------------------------------------------------------------------------
/readme-macos.md:
--------------------------------------------------------------------------------
1 | to build and use `softcut_jack_osc` on macOS, JACK must be installed and running. also some packages dependencies need to be installed via macports or homebrew:
2 |
3 | ```
4 | sudo port install jack
5 | sudo port install libsndfile1-dev
6 | sudo port install liblo
7 | ```
8 |
9 | to use the software, `jackd` must be running:
10 |
11 | ```
12 | jackd -d coreaudio
13 | ```
14 |
15 | and the selected audio device must have at least 2 channels of I/O. (i find it easiest to use an aggregate device on mac laptops.)
--------------------------------------------------------------------------------
/softcut-lib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.17)
2 | project(softcut)
3 | set(CMAKE_CXX_STANDARD 14)
4 |
5 | set(SRC
6 | src/Voice.cpp
7 | src/ReadWriteHead.cpp
8 | src/SubHead.cpp
9 | src/FadeCurves.cpp
10 | src/Svf.cpp)
11 |
12 | include_directories(include src)
13 |
14 | # tapefx
15 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../dsp)
16 |
17 | if(APPLE)
18 | include_directories(/usr/local/include)
19 | endif()
20 |
21 | add_library(softcut STATIC ${SRC})
22 |
23 | target_link_libraries(softcut tapefx)
24 |
25 | target_compile_options(softcut PRIVATE -O3)
--------------------------------------------------------------------------------
/softcut-lib/wscript:
--------------------------------------------------------------------------------
1 | def options(opt):
2 | opt.load('compiler_cxx')
3 |
4 | def configure(conf):
5 | conf.load('compiler_cxx')
6 |
7 | def build(bld):
8 | softcut_sources = [
9 | 'src/FadeCurves.cpp',
10 | 'src/ReadWriteHead.cpp',
11 | 'src/SubHead.cpp',
12 | 'src/Svf.cpp',
13 | 'src/Voice.cpp',
14 | ]
15 |
16 | bld.stlib(
17 | target = 'softcut',
18 | features = 'cxx cxxstlib',
19 | source = softcut_sources,
20 | includes = ['include'],
21 | cflags = ['-O3', '-Wall', '-Wextra'],
22 | cxxflags = ['--std=c++14']
23 | )
24 |
--------------------------------------------------------------------------------
/dsp/fverb/FVerb.h:
--------------------------------------------------------------------------------
1 | // src/effects/FVerb.h
2 | #pragma once
3 |
4 | #include // for size_t
5 |
6 | #include "../utilities/Utilities.h" // for FClamp
7 |
8 | class FVerbDSP; // Forward declaration for the Faust class
9 |
10 | class FVerb {
11 | public:
12 | FVerb() = default;
13 | ~FVerb();
14 |
15 | void Init(float sample_rate);
16 | void Process(float** out, int numSamples);
17 | void SetDecay(float decay);
18 | void SetTailDensity(float x);
19 | void SetInputDiffision1(float x);
20 | void SetInputDiffision2(float x);
21 |
22 | private:
23 | FVerbDSP* dsp;
24 | float** inputs = nullptr;
25 | float** outputs = nullptr;
26 | };
--------------------------------------------------------------------------------
/dsp/tapefx/Follower.h:
--------------------------------------------------------------------------------
1 | #ifndef LIB_FOLLOWER_H
2 | #define LIB_FOLLOWER_H
3 |
4 | #include
5 |
6 | class Follower {
7 | public:
8 | Follower(){};
9 | Follower(float sampleRate)
10 | : a_(std::exp(-1.0 / (0.001 * sampleRate))), // Attack time = 1ms
11 | b_(std::exp(-1.0 / (0.020 * sampleRate))), // Decay time = 20ms
12 | y_(0) {}
13 | Follower(float sampleRate, float attack, float decay)
14 | : a_(std::exp(-1.0 / (attack * sampleRate))), // Attack time = 1ms
15 | b_(std::exp(-1.0 / (decay * sampleRate))), // Decay time = 20ms
16 | y_(0) {}
17 |
18 | float process(float x);
19 |
20 | private:
21 | float a_, b_, y_;
22 | };
23 |
24 | #endif
--------------------------------------------------------------------------------
/dsp/tapefx/TapeFX.h:
--------------------------------------------------------------------------------
1 | #ifndef LIB_TAPEEMU_H
2 | #define LIB_TAPEEMU_H
3 |
4 | #include "Follower.h"
5 |
6 | typedef double sample_t;
7 |
8 | class TapeFX {
9 | public:
10 | TapeFX();
11 | void Init(float sample_rate);
12 | void Process(sample_t **out, unsigned int numFrames);
13 | void ProcessMono(sample_t *out, unsigned int numFrames);
14 | void SetBias(float bias);
15 | void SetPregain(float pregain);
16 | float getFollowerValue() { return follow_; }
17 | float GetBias() { return bias_; }
18 | float GetPregain() { return pregain_; }
19 |
20 | private:
21 | sample_t dc_input_l_, dc_output_l_, dc_gain_;
22 | sample_t dc_input_r_, dc_output_r_;
23 | float bias_, pregain_;
24 | Follower follower;
25 | sample_t follow_;
26 | };
27 | #endif
28 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/HelpSystem.h:
--------------------------------------------------------------------------------
1 | #ifndef HELP_SYSTEM_H
2 | #define HELP_SYSTEM_H
3 | #pragma once
4 |
5 | #include
6 | #include
7 |
8 | #include
9 | #include
10 |
11 | class HelpSystem {
12 | public:
13 | HelpSystem();
14 | ~HelpSystem();
15 |
16 | void Init(TTF_Font* font);
17 | void Toggle();
18 | void Render(SDL_Renderer* renderer, int windowWidth);
19 |
20 | bool isVisible() const { return helpVisible; }
21 |
22 | private:
23 | TTF_Font* font;
24 | bool helpVisible;
25 | float fadeAlpha; // 0.0 = fully transparent, 1.0 = fully opaque
26 | float fadeTarget; // Target alpha value
27 | float fadeStep; // Amount to change alpha per frame
28 |
29 | std::vector helpMessages;
30 | };
31 | #endif
--------------------------------------------------------------------------------
/clients/oooooooo/src/Commands.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 11/3/18.
3 | //
4 |
5 | #include "Commands.h"
6 |
7 | #include
8 |
9 | #include "SoftcutClient.h"
10 |
11 | using namespace softcut_jack_osc;
12 |
13 | Commands Commands::softcutCommands;
14 |
15 | Commands::Commands() = default;
16 |
17 | void Commands::post(Commands::Id id, float f) {
18 | CommandPacket p(id, -1, f);
19 | q.enqueue(p);
20 | }
21 |
22 | void Commands::post(Commands::Id id, int i, float f) {
23 | CommandPacket p(id, i, f);
24 | q.enqueue(p);
25 | }
26 |
27 | void Commands::post(Commands::Id id, int i, int j) {
28 | CommandPacket p(id, i, j);
29 | q.enqueue(p);
30 | }
31 |
32 | void Commands::post(Commands::Id id, int i, int j, float f) {
33 | CommandPacket p(id, i, j, f);
34 | q.enqueue(p);
35 | }
36 |
37 | void Commands::handlePending(SoftcutClient *client) {
38 | CommandPacket p;
39 | while (q.try_dequeue(p)) {
40 | client->handleCommand(&p);
41 | }
42 | }
--------------------------------------------------------------------------------
/clients/oooooooo/src/DisplayMessage.h:
--------------------------------------------------------------------------------
1 | #ifndef MESSAGE_H
2 | #define MESSAGE_H
3 |
4 | #include
5 | #include
6 |
7 | #include
8 | #include
9 |
10 | class DisplayMessage {
11 | public:
12 | DisplayMessage();
13 |
14 | void Init(TTF_Font* font);
15 | void SetMessage(const std::string& message, int displaySeconds);
16 | void Update();
17 | void Render(SDL_Renderer* renderer, int windowWidth, int windowHeight);
18 | bool IsActive() const;
19 |
20 | private:
21 | enum class State { IDLE, FADING_IN, DISPLAYING, FADING_OUT };
22 |
23 | TTF_Font* font_;
24 | std::string currentMessage_;
25 | State state_;
26 | float alpha_;
27 |
28 | std::chrono::steady_clock::time_point startTime_;
29 | std::chrono::steady_clock::time_point displayEndTime_;
30 |
31 | int displayDurationMs_;
32 | const int FADE_DURATION_MS = 500; // 500ms fade in/out
33 |
34 | SDL_Color textColor_;
35 | };
36 |
37 | #endif // MESSAGE_H
--------------------------------------------------------------------------------
/clients/oooooooo/src/AudioFile.h:
--------------------------------------------------------------------------------
1 | #ifndef AUDIO_FILE_H
2 | #define AUDIO_FILE_H
3 |
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | class AudioFile {
10 | public:
11 | // Constructor takes a file path
12 | AudioFile(const std::string& filePath);
13 |
14 | // Destructor to clean up resources
15 | ~AudioFile();
16 |
17 | // Check if file loaded successfully
18 | bool isValid() const;
19 |
20 | // Get error message if loading failed
21 | std::string getError() const;
22 |
23 | // Get sample rate of the audio file
24 | int getSampleRate() const;
25 |
26 | // Get number of channels in the audio file
27 | int getChannelCount() const;
28 |
29 | // Get total number of frames
30 | sf_count_t getFrameCount() const;
31 |
32 | private:
33 | SNDFILE* file; // Handle to the sound file
34 | SF_INFO fileInfo; // File information structure
35 | std::string errorMsg; // Storage for error message
36 | };
37 |
38 | #endif // AUDIO_FILE_H
--------------------------------------------------------------------------------
/clients/oooooooo/src/KeyboardHandler.h:
--------------------------------------------------------------------------------
1 | #ifndef KEYBOARD_HANDLER_H
2 | #define KEYBOARD_HANDLER_H
3 | #pragma once
4 |
5 | #include
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | #include "Parameters.h"
12 | #include "SoftcutClient.h"
13 |
14 | class Display;
15 |
16 | class KeyboardHandler {
17 | public:
18 | KeyboardHandler() = default;
19 | ~KeyboardHandler() = default;
20 |
21 | void Init(SoftcutClient* sc, Parameters* params, int numVoices,
22 | Display* display) {
23 | softcut_ = sc;
24 | params_ = params;
25 | numVoices_ = numVoices;
26 | display_ = display;
27 | }
28 |
29 | void handleKeyDown(SDL_Keycode key, bool isRepeat, SDL_Keymod modifiers,
30 | int* selectedLoop);
31 | void handleKeyUp(SDL_Keycode key, int selectedLoop);
32 |
33 | private:
34 | SoftcutClient* softcut_;
35 | Parameters* params_;
36 | int numVoices_;
37 | int voiceToCopy_ = -1;
38 | Display* display_;
39 |
40 | std::unordered_map keysHeld_;
41 | };
42 |
43 | #endif
--------------------------------------------------------------------------------
/clients/oooooooo/src/AudioFile.cpp:
--------------------------------------------------------------------------------
1 | #include "AudioFile.h"
2 |
3 | AudioFile::AudioFile(const std::string& filePath) : file(nullptr) {
4 | // Initialize fileInfo structure
5 | memset(&fileInfo, 0, sizeof(fileInfo));
6 |
7 | // Try to open the audio file
8 | file = sf_open(filePath.c_str(), SFM_READ, &fileInfo);
9 |
10 | // Check if file opened successfully
11 | if (!file) {
12 | // Store the error message
13 | errorMsg = sf_strerror(nullptr);
14 | }
15 | }
16 |
17 | AudioFile::~AudioFile() {
18 | // Close the file if it's open
19 | if (file) {
20 | sf_close(file);
21 | file = nullptr;
22 | }
23 | }
24 |
25 | bool AudioFile::isValid() const { return file != nullptr; }
26 |
27 | std::string AudioFile::getError() const { return errorMsg; }
28 |
29 | int AudioFile::getSampleRate() const {
30 | if (!isValid()) {
31 | return 0;
32 | }
33 | return fileInfo.samplerate;
34 | }
35 |
36 | int AudioFile::getChannelCount() const {
37 | if (!isValid()) {
38 | return 0;
39 | }
40 | return fileInfo.channels;
41 | }
42 |
43 | sf_count_t AudioFile::getFrameCount() const {
44 | if (!isValid()) {
45 | return 0;
46 | }
47 | return fileInfo.frames;
48 | }
--------------------------------------------------------------------------------
/external/windows/copy_dlls.py:
--------------------------------------------------------------------------------
1 | import os
2 | import shutil
3 |
4 | # C:\msys64\mingw64\bin
5 | mingw64_bin = os.path.join("C:\\", "msys64", "mingw64", "bin")
6 | print(mingw64_bin)
7 |
8 | total_size = 0 # Variable to track the total size of copied DLLs
9 |
10 | with open("dlls.txt", "r") as dlls_txt:
11 | for line in dlls_txt:
12 | fields = line.split()
13 | # get the field with mingw64/bin in it
14 | dll_name = ""
15 | for field in fields:
16 | if "/mingw64/bin" in field:
17 | dll_name = field.split("/")[-1]
18 | break
19 | dll_name = dll_name.replace("/mingw64/bin/", "")
20 | file_name = os.path.join(mingw64_bin, dll_name)
21 | file_name = os.path.normpath(os.path.join(mingw64_bin, dll_name))
22 | try:
23 | shutil.copy(file_name, ".")
24 | file_size = os.path.getsize(file_name) # Get the size of the copied file
25 | total_size += file_size
26 | print(f"Copied {file_name} to current directory")
27 | except Exception as e:
28 | print(f"Error copying {file_name}: {e}")
29 |
30 | # Convert total size to MB and print it
31 | total_size_mb = total_size / (1024 * 1024)
32 | print(f"Total size of copied DLLs: {total_size_mb:.2f} MB")
33 |
--------------------------------------------------------------------------------
/readme-contributing.md:
--------------------------------------------------------------------------------
1 | ## repository structure
2 |
3 | ### current branches:
4 |
5 | - `main`: currently active development branch. pretty much every PR should be opened against `main` (with possible exception of hotfixes for norns.) may have bugs.
6 |
7 | - `norns-latest`: this will attempt to track the commit pointed at by the `softcut` submodule in the main branch of `monome/norns` repo.
8 |
9 | - `v1.5`: current version branch. `main` should be merged into here whenever it's deemed stable enough for testing.
10 |
11 | - `wip/v2`: this branch contains "backlogged" changes intended for a v2 overhaul. involves extensive and complicated changes to the processing architecture. it's not yet working, hence the backlog, but it reopresents enough work to be worth saving. will be "salvaging" changes from here to release as v1.5.
12 |
13 | ### working branches:
14 |
15 | other working branches branches may exist, and should preferably be named using a prefix and a slash. we suggest:
16 |
17 | `fix/` - for bugfixes and (measurable!) performance improvements.
18 |
19 | `feature/`- for new user-facing features
20 |
21 | `dev/` for primarily developer-facing work, like refactoring
22 |
23 | (if you are part of the `monome` organization, you're welcome to make development branch in the monome repo instead of your personal fork.)
24 |
--------------------------------------------------------------------------------
/clients/oooooooo/tests/pulsefile.scd:
--------------------------------------------------------------------------------
1 | n = NetAddr("localhost", 9999);
2 |
3 | ~setup = {
4 |
5 | // load file
6 | f = "/home/emb/code/softcut-lib/pulse.wav";
7 |
8 | n.sendMsg("/softcut/buffer/clear");
9 | n.sendMsg("/softcut/buffer/read_mono", f, 0, 0, 0.5, 0, 0);
10 |
11 | // n.sendMsg("/softcut/buffer/write_mono", "/home/emb/code/softcut-lib/pulse_cutloop.wav", 0, 1.0, 0);
12 |
13 | n.sendMsg("/set/enabled/cut", 0, 1);
14 | n.sendMsg("/set/level/cut", 0, 0.5);
15 | n.sendMsg("/set/pan/cut", 0, 0);
16 |
17 | n.sendMsg("/set/param/cut/buffer", 0, 0);
18 |
19 | n.sendMsg("/set/param/cut/loop_start", 0, 0);
20 | n.sendMsg("/set/param/cut/loop_end", 0, 1);
21 | n.sendMsg("/set/param/cut/loop_flag", 0, 0);
22 |
23 | n.sendMsg("/set/param/cut/fade_time", 0, 0);
24 |
25 | n.sendMsg("/set/param/cut/post_filter_lp", 0, 0);
26 | n.sendMsg("/set/param/cut/post_filter_hp", 0, 0);
27 | n.sendMsg("/set/param/cut/post_filter_bp", 0, 0);
28 | n.sendMsg("/set/param/cut/post_filter_br", 0, 0);
29 | n.sendMsg("/set/param/cut/post_filter_dry", 0, 1);
30 | n.sendMsg("/set/param/cut/play_flag", 0, 1);
31 |
32 | };
33 |
34 | ~bang = {
35 | n.sendMsg("/set/param/cut/position", 0, 0);
36 | };
37 |
38 | r = Routine {
39 |
40 | var delta = 0.5;
41 | ~setup.value;
42 | 0.2.wait;
43 |
44 | 20.do({
45 | ~bang.value;
46 | delta = delta * 0.9;
47 | delta.wait;
48 | });
49 | }.play;
--------------------------------------------------------------------------------
/clients/oooooooo/src/DrawFunctions.h:
--------------------------------------------------------------------------------
1 | // DrawFunctions.h
2 | #ifndef DRAW_FUNCTIONS_H
3 | #define DRAW_FUNCTIONS_H
4 |
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | #include "Perlin.h"
11 |
12 | // Initialize font and perlin noise
13 | void initializeDrawingResources(TTF_Font** font, PerlinNoise* perlin);
14 | void cleanupDrawingResources();
15 |
16 | // Text drawing function
17 | void drawText(SDL_Renderer* renderer, TTF_Font* font, const std::string& text,
18 | int x, int y, uint8_t color);
19 |
20 | // Draw a bar for the volume level with a text label
21 | void drawBar(SDL_Renderer* renderer, TTF_Font* font, int x, int y, int width,
22 | int height, float fill, float lfo, float lfo_min, float lfo_max,
23 | const std::string& label, bool selected);
24 |
25 | // Draw a ring with a position indicator
26 | void drawRing(SDL_Renderer* renderer, PerlinNoise* perlin, float id, float x,
27 | float y, int radius, float position, float thickness,
28 | float* noiseTimeValue, bool show_notch = true,
29 | bool sketchy = false);
30 |
31 | // Utility functions for hit testing
32 | bool isPointInBar(int x, int y, int bar_x, int bar_y, int bar_width,
33 | int bar_height);
34 | bool isPointInLoop(int x, int y, int loop_x, int loop_y, int radius);
35 |
36 | #endif // DRAW_FUNCTIONS_H
--------------------------------------------------------------------------------
/softcut-lib/include/softcut/Svf.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 11/8/18.
3 | //
4 | // state variable filter
5 | // after Hal Chamberlin, Andy Simper
6 |
7 | #ifndef Softcut_SVF_H
8 | #define Softcut_SVF_H
9 |
10 | #include
11 |
12 | class Svf {
13 | public:
14 | Svf();
15 | float getNextSample(float x);
16 | void setSampleRate(float sr);
17 | void setFc(float fc);
18 | void setRq(float rq);
19 | void setLpMix(float mix);
20 | void setHpMix(float mix);
21 | void setBpMix(float mix);
22 | void setBrMix(float mix);
23 | void reset();
24 | void update(float x);
25 | void calcWarp();
26 | void calcCoeffs();
27 | void clearState();
28 |
29 | float getFc();
30 |
31 | private:
32 | static const float MAX_NORM_FC;
33 | float lpMix;
34 | float hpMix;
35 | float bpMix;
36 | float brMix;
37 | float minFc;
38 | float maxFc;
39 | float pi_sr;
40 |
41 | // sample rate
42 | float sr;
43 | // corner frequency in hz
44 | float fc;
45 | // reciprocal of Q in [0,1]
46 | float rq;
47 | // intermediate coefficients
48 | float g;
49 | float g1;
50 | float g2;
51 | float g3;
52 | float g4;
53 | // state variables
54 | float v0;
55 | float v1;
56 | float v2;
57 | float v0z;
58 | float v1z;
59 | float v2z;
60 | float v3;
61 | // outputs
62 | float lp; // lowpass
63 | float hp; // highpass
64 | float bp; // bandpass
65 | float br; // bandreject
66 | };
67 |
68 | #endif // Softcut_SVF_H
69 |
--------------------------------------------------------------------------------
/notes.md:
--------------------------------------------------------------------------------
1 | idea for new voice computation structure,
2 |
3 | should allow "duck" and "follow" featurees without compromising performance.
4 | implementation complexity is reasonable;
5 | the cost is some extra RAM usage (perhaps several KB per voice.)
6 |
7 | 1. allocate a number of buffers at least as big as the largest expected blocksize. each buffer will contain the value of a parameter for a whole block:
8 | - active subhead index
9 | - each subhead state:
10 | - read phase
11 | - write phase
12 | - pre+fade level
13 | - rec+fade level
14 |
15 | 2. each process block can be decomposed without looping over all voices on each sample.
16 |
17 | ## normal mode:
18 |
19 | same as present operation, with some potential speed gain due to memory locality:
20 |
21 | - update positions
22 | - update fade levels
23 | - peek+poke, mix
24 |
25 | ## "follow" mode:
26 |
27 | here, one voice is always hard-synced to another, but with different buffer data and mix parameters. this allows stereo operation among other things.
28 |
29 | - copy positions
30 | - copy fade levels
31 | - peek+poke, mix
32 |
33 | ## duck mode:
34 |
35 | one voice uses another's write index as a reference; output level is attenuated when this voice's read position crosses that voice's record position.
36 |
37 | - update positions
38 | - update fade levels, comparing with reference position
39 | - peek+poke, mix
40 |
41 |
42 | ### details
43 |
44 | - can use `std::array` and `std::copy` for state buffers
45 | -
46 |
--------------------------------------------------------------------------------
/softcut-lib/include/softcut/Interpolate.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 12/8/17.
3 | //
4 |
5 | #ifndef Softcut_INTERPOLATE_H
6 | #define Softcut_INTERPOLATE_H
7 |
8 | namespace softcut {
9 | class Interpolate {
10 | public:
11 | template
12 | static inline T hermite(T x, T y0, T y1, T y2, T y3) {
13 | // 4-point, 3rd-order Hermite (x-form)
14 | #if 0
15 | T c0 = y1;
16 | T c1 = 0.5 * (y2 - y0);
17 | T c2 = y0 - 2.5 * y1 + 2. * y2 - 0.5 * y3;
18 | T c3 = 0.5 * (y3 - y0) + 1.5 * (y1 - y2);
19 | return ((c3 * x + c2) * x + c1) * x + c0;
20 | #else // inlined:
21 | return (((0.5 * (y3 - y0) + 1.5 * (y1 - y2)) * x +
22 | (y0 - 2.5 * y1 + 2. * y2 - 0.5 * y3)) *
23 | x +
24 | 0.5 * (y2 - y0)) *
25 | x +
26 | y1;
27 | #endif
28 | }
29 |
30 | // super-simple interpolation into a table.
31 | // this makes assumptions for speed:
32 | // - allocated table size is >= N+1
33 | // - index is in [0, 1]
34 | template
35 | static inline T tabLinear(T* buf, float x) {
36 | // FIXME: tidy/speed
37 | const float fi = x * (N - 2);
38 | auto i = static_cast(fi);
39 | const float a = buf[i];
40 | const float b = buf[i + 1];
41 | const float c = (fi - static_cast(i));
42 | return a + c * (b - a);
43 | }
44 | };
45 | } // namespace softcut
46 |
47 | #endif // Softcut_INTERPOLATE_H
48 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/Poll.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by emb on 11/30/18.
3 | //
4 |
5 | #ifndef CRONE_POLL_H
6 | #define CRONE_POLL_H
7 |
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 | namespace softcut_jack_osc {
19 | class Poll {
20 | public:
21 | typedef std::function Callback;
22 |
23 | explicit Poll(std::string name) {
24 | std::ostringstream os;
25 | os << "/poll/" << name;
26 | path = os.str();
27 | }
28 |
29 | void setCallback(Callback c) { cb = std::move(c); }
30 |
31 | void start() {
32 | shouldStop = false;
33 | th = std::make_unique(std::thread([this] {
34 | while (!shouldStop) {
35 | this->cb(path.c_str());
36 | std::this_thread::sleep_for(std::chrono::milliseconds(period));
37 | }
38 | }));
39 | th->detach();
40 | }
41 |
42 | void stop() {
43 | // in c++ there's no way to safely and non-cooperatively interrupt a thread.
44 | shouldStop = true;
45 | // i am reasonably sure this won't leak...
46 | th.reset();
47 | }
48 |
49 | void setPeriod(int ms) { period = ms; }
50 |
51 | private:
52 | Callback cb;
53 | std::atomic period;
54 | std::atomic shouldStop;
55 | std::unique_ptr th;
56 | std::string path;
57 | lo_address addr;
58 | };
59 |
60 | } // namespace softcut_jack_osc
61 |
62 | #endif // CRONE_POLL_H
63 |
--------------------------------------------------------------------------------
/softcut-lib/include/softcut/FadeCurves.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 11/15/18.
3 | //
4 | // static class for producing curves in fade period
5 | //
6 | // FIXME: this should be an object owned by SoftcutHead, passed to child
7 | // SubHeads
8 |
9 | #ifndef Softcut_FADECURVES_H
10 | #define Softcut_FADECURVES_H
11 |
12 | namespace softcut {
13 |
14 | class FadeCurves {
15 | public:
16 | typedef enum { Linear = 0, Sine = 1, Raised = 2 } Shape;
17 |
18 | // initialize with defaults
19 | void init();
20 | void setRecDelayRatio(float x);
21 | void setPreWindowRatio(float x);
22 | void setMinRecDelayFrames(unsigned int x);
23 | void setMinPreWindowFrames(unsigned int x);
24 | // set curve shape
25 | void setPreShape(Shape x);
26 | void setRecShape(Shape x);
27 | // x is assumed to be in [0,1]
28 | float getRecFadeValue(float x);
29 |
30 | float getPreFadeValue(float x);
31 |
32 | private:
33 | void calcPreFade();
34 | void calcRecFade();
35 |
36 | private:
37 | // xfade curve buffers
38 | static constexpr unsigned int fadeBufSize = 1001;
39 |
40 | // record delay and pre window in fade, as proportion of fade time
41 | float recDelayRatio;
42 | float preWindowRatio;
43 | // minimum record delay/pre window, in frames
44 | unsigned int recDelayMinFrames;
45 | unsigned int preWindowMinFrames;
46 | float recFadeBuf[fadeBufSize];
47 | float preFadeBuf[fadeBufSize];
48 | Shape recShape;
49 | Shape preShape;
50 | };
51 | } // namespace softcut
52 |
53 | #endif // Softcut_FADECURVES_H
54 |
--------------------------------------------------------------------------------
/dsp/utilities/Utilities.cpp:
--------------------------------------------------------------------------------
1 | #include "Utilities.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | float MidiToFreq(float midi) {
10 | return powf(2.0f, (midi - 69.0f) / 12.0f) * 440.0f;
11 | }
12 |
13 | float LinLin(float in, float inMin, float inMax, float outMin, float outMax) {
14 | return (in - inMin) / (inMax - inMin) * (outMax - outMin) + outMin;
15 | }
16 |
17 | float FClamp(float x, float min, float max) {
18 | return std::max(min, std::min(x, max));
19 | }
20 |
21 | // Format a string similar to sprintf but returning a std::string
22 | std::string FormatString(const char* format, ...) {
23 | // First, determine the required buffer size
24 | va_list args;
25 | va_start(args, format);
26 | // Use vsnprintf with a null buffer and 0 size to calculate required size
27 | int size = vsnprintf(nullptr, 0, format, args) + 1; // +1 for null terminator
28 | va_end(args);
29 |
30 | // Allocate the buffer
31 | char* buffer = new char[size];
32 |
33 | // Format the string into the buffer
34 | va_start(args, format);
35 | vsnprintf(buffer, size, format, args);
36 | va_end(args);
37 |
38 | // Create a string and clean up
39 | std::string result(buffer);
40 | delete[] buffer;
41 |
42 | return result;
43 | }
44 |
45 | float DBAmp(float db) { return powf(10.0f, db / 20.0f); }
46 |
47 | float AmpDB(float amp) {
48 | if (amp < 0.001) {
49 | return -64.0f; // Avoid log(0) which is undefined
50 | }
51 | return 20.0f * log10f(amp);
52 | }
--------------------------------------------------------------------------------
/clients/oooooooo/src/VUMeter.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created on 05/07/2025.
3 | //
4 |
5 | #ifndef CRONE_VUMETER_H
6 | #define CRONE_VUMETER_H
7 |
8 | #include
9 |
10 | #include
11 | #include
12 |
13 | #include "softcut/Types.h"
14 |
15 | using namespace softcut;
16 |
17 | class VUMeter {
18 | public:
19 | VUMeter();
20 |
21 | // Initialize with sample rate
22 | void setSampleRate(float sr);
23 |
24 | // Set attack time in seconds
25 | void setAttackTime(float timeInSeconds);
26 |
27 | // Set release/decay time in seconds
28 | void setDecayTime(float timeInSeconds);
29 |
30 | // Process a mono buffer and update the VU level
31 | void process(const sample_t* buffer, size_t numFrames);
32 |
33 | // Get the current VU level in dB (thread-safe)
34 | float getLevel() const;
35 |
36 | // Convert linear amplitude to dB
37 | static float ampToDB(float amp);
38 |
39 | // Convert dB to linear amplitude
40 | static float dBToAmp(float db);
41 |
42 | // Reset the meter
43 | void reset();
44 |
45 | private:
46 | std::atomic
47 | currentLevelDB; // Current level in dB (atomic for thread safety)
48 | float attackCoeff; // Attack coefficient
49 | float decayCoeff; // Decay/release coefficient
50 | float currentPeak; // Current peak value in linear amplitude
51 | float sampleRate; // Current sample rate
52 | float attackTime; // Attack time in seconds
53 | float decayTime; // Decay time in seconds
54 |
55 | // Recalculate coefficients when times change
56 | void updateCoefficients();
57 | };
58 |
59 | #endif // CRONE_VUMETER_H
--------------------------------------------------------------------------------
/clients/oooooooo/src/DisplayRing.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | #include "DrawFunctions.h"
5 | #include "Parameters.h"
6 | #include "SoftcutClient.h"
7 | #include "Utilities.h"
8 |
9 | using namespace softcut_jack_osc;
10 |
11 | class DisplayRing {
12 | public:
13 | DisplayRing() = default;
14 | ~DisplayRing() = default;
15 | void Init(SoftcutClient *softCutClient, Parameters *p, int i);
16 | void Update(float width_, float height_);
17 | void RegisterClick(float mouseX, float mouseY);
18 | void HandleDrag(float mouseX, float mouseY, float width, float height);
19 | void StopDrag();
20 | void Render(SDL_Renderer *renderer, PerlinNoise *perlinGenerator,
21 | float *noiseTimeValue, float mainContentFadeAlpha_,
22 | bool isSelected);
23 | bool ClickedRing();
24 | bool ClickedRadius();
25 | float GetClickedRadius() { return clicked_radius_angle_normalized_; }
26 | bool IsDragging() const { return dragging_; }
27 | int GetId() const { return id_; }
28 | float GetDistanceToCenter() const { return distance_to_center_; }
29 |
30 | private:
31 | SoftcutClient *softCutClient_ = nullptr;
32 | Parameters *params_ = nullptr;
33 | int id_;
34 | float pos_;
35 | float dur_;
36 | float pregain_;
37 | float start_;
38 | float end_;
39 | float pan_;
40 | float x_;
41 | float y_;
42 | float radius_;
43 | float position_;
44 | float thickness_;
45 | bool clicked_ring_ = false;
46 | float distance_to_center_ = 0;
47 | bool dragging_ = false;
48 | bool clicked_radius_ = false;
49 | float clicked_radius_angle_normalized_ = 0;
50 | float breath_time_ = 0.0f; // Track time for breathing animation
51 | };
--------------------------------------------------------------------------------
/external/faust/architecture/faust/dsp/cpp-dsp-adapter.h:
--------------------------------------------------------------------------------
1 | /************************** BEGIN cpp-dsp-adapter.h **********************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | ************************************************************************/
24 |
25 | #ifndef CPP_mydsp_adapter_H
26 | #define CPP_mydsp_adapter_H
27 |
28 | #if defined(SOUNDFILE)
29 | #include "faust/gui/SoundUI.h"
30 | #endif
31 |
32 | class dsp;
33 |
34 | // Factory API
35 | dsp* createmydsp();
36 |
37 | #endif
38 | /************************** END cpp-dsp-adapter.h **************************/
39 |
--------------------------------------------------------------------------------
/softcut-lib/include/softcut/TestBuffers.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 11/16/18.
3 | //
4 |
5 | #ifndef Softcut_TESTBUFFERS_H
6 | #define Softcut_TESTBUFFERS_H
7 |
8 | #include
9 | #include
10 |
11 | namespace softcut {
12 | class TestBuffers {
13 | public:
14 | typedef enum { Read, Write, Fade, State, Pre, Rec, numChannels } Channel;
15 | enum { numFrames = 131072, frameMask = 131071 };
16 |
17 | float buf[numChannels][numFrames]{};
18 | unsigned int idx = 0;
19 |
20 | void init() {
21 | for (int ch = 0; ch < numChannels; ++ch) {
22 | for (int fr = 0; fr < numFrames; ++fr) {
23 | buf[ch][fr] = 0.f;
24 | }
25 | }
26 | }
27 |
28 | void update(float readPhase, float writePhase, float fade, float state,
29 | float pre, float rec) {
30 | buf[Read][idx] = readPhase;
31 | buf[Write][idx] = writePhase;
32 | buf[Fade][idx] = fade;
33 | buf[State][idx] = state;
34 | buf[Pre][idx] = pre;
35 | buf[Rec][idx] = rec;
36 | idx = (idx + 1) & frameMask;
37 | }
38 |
39 | // print buffer contents in matlab format
40 | void print() {
41 | using std::endl;
42 | std::ofstream ofs("Softcut_test_buffers.m", std::ofstream::out);
43 | ofs << "function y = Softcut_test_buffers() " << endl;
44 | ofs << " y = [" << endl;
45 | for (int ch = 0; ch < numChannels; ++ch) {
46 | ofs << " [ ";
47 | for (int fr = 0; fr < numFrames; ++fr) {
48 | ofs << buf[ch][fr] << " ";
49 | }
50 | ofs << " ]," << endl << endl;
51 | }
52 | ofs << " ];" << endl;
53 | ofs << "end" << endl;
54 |
55 | ofs.close();
56 | }
57 | };
58 | } // namespace softcut
59 |
60 | #endif // Softcut_TESTBUFFERS_H
61 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/IntroAnimation.h:
--------------------------------------------------------------------------------
1 | // IntroAnimation.h
2 | #ifndef INTRO_ANIMATION_H
3 | #define INTRO_ANIMATION_H
4 | #pragma once
5 |
6 | #include
7 | #include
8 |
9 | #include
10 | #include
11 |
12 | #ifndef M_PI
13 | #define M_PI 3.14159265358979323846
14 | #endif
15 |
16 | class IntroAnimation {
17 | public:
18 | IntroAnimation();
19 | ~IntroAnimation();
20 |
21 | void Init(TTF_Font* font); // Changed to accept font
22 | void Update();
23 | void Render(SDL_Renderer* renderer, int windowWidth, int windowHeight);
24 |
25 | bool isComplete() const { return animationComplete; }
26 | void Start();
27 | void Stop();
28 |
29 | private:
30 | struct TrailPoint {
31 | float x, y;
32 | float alpha;
33 | int pixelSize;
34 | };
35 |
36 | bool animationComplete;
37 | bool animationRunning;
38 | float animationTime;
39 | float animationDuration;
40 |
41 | // Circle animation properties
42 | float circleAngle;
43 | float circleRadius;
44 | float centerX, centerY;
45 |
46 | // Trailing effect
47 | std::vector trail;
48 | int maxTrailLength;
49 |
50 | // Visual parameters
51 | float rotationSpeed;
52 | SDL_Color dotColor;
53 | SDL_Color trailColor;
54 | int dotSize;
55 |
56 | // Font for text display
57 | TTF_Font* font;
58 |
59 | void updateTrail(float currentX, float currentY);
60 | void renderPixelatedDot(SDL_Renderer* renderer, float x, float y, int size,
61 | SDL_Color color, float alpha);
62 | void renderCenterText(SDL_Renderer* renderer, int windowWidth,
63 | int windowHeight,
64 | float globalAlpha); // Updated signature
65 | };
66 |
67 | #endif
--------------------------------------------------------------------------------
/external/faust/architecture/faust/gui/meta.h:
--------------------------------------------------------------------------------
1 | /************************** BEGIN meta.h *******************************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | ************************************************************************/
24 |
25 | #ifndef __meta__
26 | #define __meta__
27 |
28 | #include "faust/export.h"
29 |
30 | /**
31 | The base class of Meta handler to be used in dsp::metadata(Meta* m) method to retrieve (key, value) metadata.
32 | */
33 | struct FAUST_API Meta {
34 | virtual ~Meta() {}
35 | virtual void declare(const char* key, const char* value) = 0;
36 | };
37 |
38 | #endif
39 | /************************** END meta.h **************************/
40 |
--------------------------------------------------------------------------------
/external/faust/architecture/faust/vst/voice.h:
--------------------------------------------------------------------------------
1 | /************************** BEGIN voice.h **************************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | *********************************************************************/
24 |
25 | #ifndef __VST_VOICE_H__
26 | #define __VST_VOICE_H__
27 |
28 | class Voice : public vstUI {
29 |
30 | public:
31 | Voice(int sample_rate)
32 | : vstUI(), m_dsp()
33 | {
34 | m_dsp.init(sample_rate);
35 | m_dsp.buildUserInterface(this);
36 | }
37 |
38 | mydsp m_dsp;
39 |
40 | }; //end of Voice class
41 |
42 | #endif
43 | /************************** END voice.h **************************/
44 |
--------------------------------------------------------------------------------
/softcut-lib/include/softcut/SoftClip.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 11/9/18.
3 | //
4 |
5 | #ifndef Softcut_SOFTCLIP_H
6 | #define Softcut_SOFTCLIP_H
7 |
8 | #include
9 |
10 | #include "softcut/Utilities.h"
11 |
12 | namespace softcut {
13 |
14 | // two-stage quadratic soft clipper with variable gain
15 | // nice odd harmonics, kinda carbon-mic sound
16 | class SoftClip {
17 | private:
18 | float t; // threshold (beginning of knee)
19 | float g; // gain multiplier
20 | float a; // parabolic coefficient
21 | float b; // parabolic offset ( = max level)
22 | // update quad multiplier from current settings
23 | void calcCoeffs() {
24 | // match derivative at knee point
25 | // FIXME: should be able to factor this such that b=1 always, user sets g
26 | // only
27 | float t_1 = t - 1.f;
28 | if (t_1 < 0.f) {
29 | a = g / (2.f * t_1);
30 | b = g * t - (a * t_1 * t_1);
31 | } else {
32 | a = 0.f;
33 | b = 1.f;
34 | }
35 | }
36 |
37 | public:
38 | SoftClip(float t_ = 0.68f, float g_ = 1.2f) : t(t_), g(g_) { calcCoeffs(); }
39 |
40 | float processSample(float x) {
41 | float ax = fabs(x);
42 | const float sx = fsign(x);
43 |
44 | if (ax > 1.f) {
45 | ax = 1.f;
46 | }
47 |
48 | if (ax < t) {
49 | return x * g;
50 | } else {
51 | const float q = ax - 1.f;
52 | const float y = (a * q * q) + b;
53 | return sx * y;
54 | }
55 | }
56 |
57 | void setGain(float r) {
58 | g = r;
59 | calcCoeffs();
60 | }
61 |
62 | void setLowThresh(float amp) {
63 | t = amp;
64 | calcCoeffs();
65 | }
66 |
67 | float getGain() { return g; }
68 |
69 | float getLowThresh() { return t; }
70 |
71 | float getHighThreshDb() { return b; }
72 | };
73 | } // namespace softcut
74 |
75 | #endif // Softcut_SOFTCLIP_H
76 |
--------------------------------------------------------------------------------
/softcut-lib/src/Svf.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 11/8/18.
3 | //
4 |
5 | #include "softcut/Svf.h"
6 |
7 | #include
8 |
9 | const float Svf::MAX_NORM_FC = 0.4;
10 |
11 | Svf::Svf() = default;
12 |
13 | float Svf::getNextSample(float x) {
14 | update(x);
15 | return lp * lpMix + hp * hpMix + bp * bpMix + br * brMix;
16 | }
17 |
18 | void Svf::setSampleRate(float aSr) {
19 | sr = aSr;
20 | pi_sr = M_PI / sr;
21 | minFc = 10.f;
22 | maxFc = sr * MAX_NORM_FC;
23 | calcWarp();
24 | calcCoeffs();
25 | }
26 |
27 | void Svf::setFc(float aFc) {
28 | fc = (aFc > maxFc) ? maxFc : aFc;
29 | fc = (fc < minFc) ? minFc : fc;
30 | calcWarp();
31 | calcCoeffs();
32 | }
33 |
34 | void Svf::setRq(float aRq) {
35 | rq = aRq;
36 | calcCoeffs();
37 | }
38 |
39 | void Svf::setLpMix(float mix) { lpMix = mix; }
40 |
41 | void Svf::setHpMix(float mix) { hpMix = mix; }
42 |
43 | void Svf::setBpMix(float mix) { bpMix = mix; }
44 |
45 | void Svf::setBrMix(float mix) { brMix = mix; }
46 |
47 | void Svf::reset() { clearState(); }
48 |
49 | void Svf::calcWarp() {
50 | // NB: wasn't actually able to beat `tan` for performance+accuracy sweet spot
51 | // on raspi with aggressive optimizations
52 | g = static_cast(tan(fc * pi_sr));
53 | }
54 |
55 | void Svf::calcCoeffs() {
56 | g1 = g / (1.f + g * (g + rq));
57 | g2 = 2.f * (g + rq) * g1;
58 | g3 = g * g1;
59 | g4 = 2.f * g1;
60 | }
61 |
62 | void Svf::clearState() {
63 | v0z = 0;
64 | v1 = 0;
65 | v2 = 0;
66 | }
67 |
68 | void Svf::update(float in) {
69 | // update
70 | v0 = in;
71 | v1z = v1;
72 | v2z = v2;
73 | v3 = v0 + v0z - 2.f * v2z;
74 | v1 += g1 * v3 - g2 * v1z;
75 | v2 += g3 * v3 + g4 * v1z;
76 | v0z = v0;
77 | // output
78 | lp = v2;
79 | bp = v1;
80 | hp = v0 - rq * v1 - v2;
81 | br = v0 - rq * v1;
82 | }
83 |
84 | float Svf::getFc() { return fc; }
--------------------------------------------------------------------------------
/external/faust/architecture/faust/gui/JSONControl.h:
--------------------------------------------------------------------------------
1 | /************************** BEGIN JSONControl.h **************************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | *************************************************************************/
24 |
25 | #ifndef __JSON_CONTROL__
26 | #define __JSON_CONTROL__
27 |
28 | #include
29 |
30 | #ifndef FAUSTFLOAT
31 | #define FAUSTFLOAT float
32 | #endif
33 |
34 | struct FAUST_API JSONControl {
35 |
36 | virtual std::string getJSON() { return ""; }
37 |
38 | virtual void setParamValue(const std::string& path, FAUSTFLOAT value) {}
39 |
40 | virtual FAUSTFLOAT getParamValue(const std::string& path) { return 0; }
41 |
42 | virtual ~JSONControl()
43 | {}
44 |
45 | };
46 |
47 | #endif
48 | /************************** END JSONControl.h **************************/
49 |
--------------------------------------------------------------------------------
/dsp/tapefx/TapeFX.cpp:
--------------------------------------------------------------------------------
1 | #include "TapeFX.h"
2 |
3 | #include
4 |
5 | TapeFX::TapeFX() {}
6 |
7 | namespace {
8 | inline float db2amp_(float db) { return powf(10.0f, db / 20.0f); }
9 |
10 | inline float amp2db_(float amp) { return 20.0f * log10(amp); }
11 | } // namespace
12 |
13 | void TapeFX::Init(float sample_rate) {
14 | follower = Follower(sample_rate);
15 | dc_input_l_ = 0;
16 | dc_output_l_ = 0;
17 | dc_input_r_ = 0;
18 | dc_output_r_ = 0;
19 | dc_gain_ = 0.99;
20 | bias_ = 0.0f;
21 | pregain_ = 1.0f;
22 | follow_ = 0;
23 | }
24 |
25 | void TapeFX::SetBias(float bias) { bias_ = bias; }
26 |
27 | void TapeFX::SetPregain(float pregain) { pregain_ = pregain; }
28 |
29 | void TapeFX::ProcessMono(sample_t *out, unsigned int numFrames) {
30 | for (size_t i = 0; i < numFrames; i++) {
31 | // pregain
32 | out[i] *= pregain_;
33 | follow_ = follower.process(out[i]);
34 | // dc bias with follower
35 | out[i] = tanhf(out[i] + (follow_ * bias_));
36 | // DC blocking
37 | sample_t in = out[i];
38 | out[i] = in - dc_input_l_ + (dc_gain_ * dc_output_l_);
39 | dc_output_l_ = out[i];
40 | dc_input_l_ = in;
41 | // extra tanh
42 | out[i] = tanhf(out[i]);
43 | }
44 | }
45 |
46 | void TapeFX::Process(sample_t **out, unsigned int numFrames) {
47 | for (size_t i = 0; i < numFrames; i++) {
48 | // pregain
49 | out[0][i] *= pregain_;
50 | out[1][i] *= pregain_;
51 |
52 | follow_ = follower.process(out[0][i]);
53 |
54 | // dc bias with follower
55 | out[0][i] = tanhf(out[0][i] + (follow_ * bias_));
56 | out[1][i] = tanhf(out[1][i] + (follow_ * bias_));
57 |
58 | // DC blocking
59 | sample_t in = out[0][i];
60 | out[0][i] = in - dc_input_l_ + (dc_gain_ * dc_output_l_);
61 | dc_output_l_ = out[0][i];
62 | dc_input_l_ = in;
63 | in = out[1][i];
64 | out[1][i] = in - dc_input_r_ + (dc_gain_ * dc_output_r_);
65 | dc_output_r_ = out[1][i];
66 | dc_input_r_ = in;
67 |
68 | // extra tanh
69 | out[0][i] = tanhf(out[0][i]);
70 | out[1][i] = tanhf(out[1][i]);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/tests/test1.scd:
--------------------------------------------------------------------------------
1 | s.waitForBoot({
2 | Routine {
3 | "running tests".postln;
4 | n = NetAddr("localhost", 9999);
5 |
6 | // Load audio file
7 | "load file".postln;
8 | n.sendMsg("/softcut/buffer/clear");
9 | n.sendMsg("/softcut/buffer/read_mono", "/home/zns/Documents/oooooooo/amen_beats8_bpm172.wav", 0, 0, -1, 0, 0);
10 | n.sendMsg("/softcut/buffer/read_mono", "/home/zns/Documents/oooooooo/strega.wav", 0, 30, -1, 0, 0);
11 | 1.wait;
12 |
13 | // Configure and enable voice 0
14 | 2.do({
15 | arg i;
16 | n.sendMsg("/set/enabled/cut", i, 1);
17 | n.sendMsg("/set/level/cut", i, 1.0 + (1.0 * i));
18 | n.sendMsg("/set/param/cut/rate", i, 41000/48000);
19 | n.sendMsg("/set/pan/cut", i, 0);
20 | n.sendMsg("/set/param/cut/buffer", i, 0);
21 | n.sendMsg("/set/param/cut/loop_start", i, 30*i);
22 | n.sendMsg("/set/param/cut/loop_end", i, 60/172*4.0+(30*i));
23 | n.sendMsg("/set/param/cut/loop_flag", i, 1);
24 | n.sendMsg("/set/param/cut/fade_time", i, 60/172);
25 | n.sendMsg("/set/param/cut/post_filter_dry", i, 1);
26 | n.sendMsg("/set/param/cut/play_flag", i, 1);
27 | n.sendMsg("/set/param/cut/position", i, 0);
28 |
29 | });
30 |
31 | "play_flag".postln;
32 |
33 | // Reverb test settings
34 | 3.wait;
35 | "reverb on".postln;
36 | n.sendMsg("/set/reverb/enabled", 1.0);
37 | n.sendMsg("/set/reverb/mix", 1.0);
38 | n.sendMsg("/set/reverb/send", 1, 1.0);
39 | 3.wait;
40 | "reverb off".postln;
41 | n.sendMsg("/set/reverb/send", 1, 0.0);
42 | 3.wait;
43 | "tapefx on".postln;
44 | n.sendMsg("/set/param/cut/tape_pregain", 0, 8.0);
45 | n.sendMsg("/set/param/cut/tape_bias", 0, 1.0);
46 |
47 | // n.sendMsg("/set/reverb/param/decay", 2.0);
48 | // n.sendMsg("/set/reverb/param/tail_density", 0.75);
49 | // n.sendMsg("/set/reverb/param/input_diffusion1", 0.3);
50 | // n.sendMsg("/set/reverb/param/input_diffusion2", 0.4);
51 | }.play;
52 | });
53 |
--------------------------------------------------------------------------------
/softcut-lib/include/softcut/SubHead.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 4/21/18.
3 | //
4 |
5 | /*
6 | * this class implements one half of a crossfaded read/write sch.
7 | */
8 |
9 | #ifndef Softcut_SUBHEAD_H
10 | #define Softcut_SUBHEAD_H
11 |
12 | #include "FadeCurves.h"
13 | #include "Resampler.h"
14 | #include "SoftClip.h"
15 | #include "Types.h"
16 |
17 | namespace softcut {
18 |
19 | typedef enum { Playing = 0, Stopped = 1, FadeIn = 2, FadeOut = 3 } State;
20 | typedef enum { None, Stop, LoopPos, LoopNeg } Action;
21 |
22 | class SubHead {
23 | friend class ReadWriteHead;
24 |
25 | public:
26 | void init(FadeCurves *fc);
27 | void setSampleRate(float sr);
28 |
29 | private:
30 | sample_t peek4();
31 | unsigned int wrapBufIndex(int x);
32 |
33 | protected:
34 | static constexpr int blockSize = 2048;
35 | sample_t peek();
36 | //! poke
37 | //! @param in: input value
38 | //! @param pre: scaling level for previous buffer content
39 | //! @param rec: scaling level for new content
40 | void poke(sample_t in, float pre, float rec);
41 | Action updatePhase(phase_t start, phase_t end, bool loop);
42 | void updateFade(float inc);
43 |
44 | // getters
45 | phase_t phase() { return phase_; }
46 | float fade() { return fade_; }
47 | float trig() { return trig_; }
48 | State state() { return state_; }
49 |
50 | // setters
51 | void setState(State state);
52 | void setPhase(phase_t phase);
53 |
54 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
55 | // **NB** buffer size must be a power of two!!!!
56 | void setBuffer(sample_t *buf, unsigned int frames);
57 | void setRate(rate_t rate);
58 | FadeCurves *fadeCurves;
59 |
60 | private:
61 | Resampler resamp_;
62 | SoftClip clip_;
63 |
64 | sample_t *buf_; // output buffer
65 | unsigned int wrIdx_; // write index
66 | unsigned int bufFrames_;
67 | unsigned int bufMask_;
68 |
69 | State state_;
70 | rate_t rate_;
71 | int inc_dir_;
72 | phase_t phase_;
73 | float fade_;
74 | float trig_; // output trigger value
75 | bool active_;
76 | int recOffset_;
77 |
78 | float preFade_;
79 | float recFade_;
80 |
81 | void setRecOffsetSamples(int d);
82 | };
83 |
84 | } // namespace softcut
85 |
86 | #endif // Softcut_SUBHEAD_H
87 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/OscInterface.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | //
4 | // Created by ezra on 11/4/18.
5 | //
6 |
7 | #ifndef CRONE_OSCINTERFACE_H
8 | #define CRONE_OSCINTERFACE_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 | #include
16 |
17 | #include "SoftcutClient.h"
18 | #include "Poll.h"
19 |
20 | // FIXME: didn't realize that liblo has a perfectly ok-looking cpp interface already. this could be cleaner.
21 | // having a custom method wrapper is probably fine, easier to refactor if we move to different IPC.
22 |
23 | namespace softcut_jack_osc {
24 | using std::string;
25 |
26 | class OscInterface {
27 |
28 | private:
29 | static lo_server_thread st;
30 | static lo_address clientAddress;
31 |
32 | static bool quitFlag;
33 | static string port;
34 | static unsigned int numMethods;
35 | enum { MaxNumMethods = 256 };
36 |
37 | // OscMethod: thin wrapper for passing lambdas to OSC server thread
38 | class OscMethod {
39 | typedef void(*Handler)(lo_arg **argv, int argc);
40 | public:
41 | string path;
42 | string format;
43 | OscMethod() = default;
44 | OscMethod(string p, string f, Handler h);
45 | Handler handler{};
46 | };
47 |
48 | static std::array methods;
49 | static std::unique_ptr vuPoll;
50 | static std::unique_ptr phasePoll;
51 | static SoftcutClient *softCutClient;
52 |
53 | private:
54 | typedef void(*Handler)(lo_arg **argv, int argc);
55 | static void handleLoError(int num, const char *m, const char *path) {
56 | std::cerr << "liblo error: " << num << "; " << m << "; " << path << std::endl;
57 | }
58 |
59 | static void addServerMethod(const char* path, const char* format, Handler handler);
60 |
61 | static void addServerMethods();
62 |
63 |
64 | public:
65 | static void init(SoftcutClient *sc);
66 | static void deinit();
67 | static void printServerMethods();
68 |
69 | static bool shouldQuit() { return quitFlag; }
70 | static std::string getPortNumber() { return port; }
71 | };
72 | }
73 |
74 | #endif //CRONE_OSCINTERFACE_H
75 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/LFO.cpp:
--------------------------------------------------------------------------------
1 | #include "LFO.h"
2 |
3 | #include
4 |
5 | static inline float Polyblep(float phase_inc, float t);
6 |
7 | float LFO::Process() {
8 | float out, t;
9 | switch (waveform_) {
10 | case WAVE_SIN:
11 | out = sinf(phase_ * 3.1415927410125732421875f * 2.0f);
12 | break;
13 | case WAVE_TRI:
14 | t = -1.0f + (2.0f * phase_);
15 | out = 2.0f * (fabsf(t) - 0.5f);
16 | break;
17 | case WAVE_SAW:
18 | out = -1.0f * (((phase_ * 2.0f)) - 1.0f);
19 | break;
20 | case WAVE_RAMP:
21 | out = ((phase_ * 2.0f)) - 1.0f;
22 | break;
23 | case WAVE_SQUARE:
24 | out = phase_ < pw_ ? (1.0f) : -1.0f;
25 | break;
26 | case WAVE_POLYBLEP_TRI:
27 | t = phase_;
28 | out = phase_ < 0.5f ? 1.0f : -1.0f;
29 | out += Polyblep(phase_inc_, t);
30 | out -= Polyblep(phase_inc_, (t + 0.5f) - static_cast((t + 0.5f)));
31 | // Leaky Integrator:
32 | // y[n] = A + x[n] + (1 - A) * y[n-1]
33 | out = phase_inc_ * out + (1.0f - phase_inc_) * last_out_;
34 | last_out_ = out;
35 | out *= 4.f; // normalize amplitude after leaky integration
36 | break;
37 | case WAVE_POLYBLEP_SAW:
38 | t = phase_;
39 | out = (2.0f * t) - 1.0f;
40 | out -= Polyblep(phase_inc_, t);
41 | out *= -1.0f;
42 | break;
43 | case WAVE_POLYBLEP_SQUARE:
44 | t = phase_;
45 | out = phase_ < pw_ ? 1.0f : -1.0f;
46 | out += Polyblep(phase_inc_, t);
47 | out -= Polyblep(phase_inc_, (t + (1.0f - pw_)) -
48 | static_cast((t + (1.0f - pw_))));
49 | out *= 0.707f; // ?
50 | break;
51 | default:
52 | out = 0.0f;
53 | break;
54 | }
55 | phase_ += phase_inc_;
56 | if (phase_ > 1.0f) {
57 | phase_ -= 1.0f;
58 | eoc_ = true;
59 | } else {
60 | eoc_ = false;
61 | }
62 | eor_ = (phase_ - phase_inc_ < 0.5f && phase_ >= 0.5f);
63 |
64 | out_ = out * amp_ + add_;
65 | return out_;
66 | }
67 |
68 | float LFO::CalcPhaseInc(float f) { return f * sr_recip_; }
69 |
70 | static float Polyblep(float phase_inc, float t) {
71 | float dt = phase_inc;
72 | if (t < dt) {
73 | t /= dt;
74 | return t + t - t * t - 1.0f;
75 | } else if (t > 1.0f - dt) {
76 | t = (t - 1.0f) / dt;
77 | return t * t + t + t + 1.0f;
78 | } else {
79 | return 0.0f;
80 | }
81 | }
--------------------------------------------------------------------------------
/clients/oooooooo/src/Display.h:
--------------------------------------------------------------------------------
1 | #ifndef DISPLAY_H
2 | #define DISPLAY_H
3 |
4 | #include
5 | #include
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include "DisplayMessage.h"
14 | #include "DisplayRing.h"
15 | #include "DrawFunctions.h"
16 | #include "HelpSystem.h"
17 | #include "IntroAnimation.h"
18 | #include "KeyboardHandler.h"
19 | #include "Parameters.h"
20 | #include "Perlin.h"
21 | #include "SoftcutClient.h"
22 |
23 | using namespace softcut_jack_osc;
24 |
25 | class Display {
26 | public:
27 | void requestShutdown() { running_ = false; }
28 | // Define a callback type for quit notification
29 | using QuitCallback = std::function;
30 |
31 | Display(int width = 1200, int height = 900);
32 | ~Display();
33 |
34 | void init(SoftcutClient* sc, int numVoices);
35 |
36 | void start();
37 | void stop();
38 | bool isRunning() const { return running_; }
39 | void SetMessage(const std::string& message, int secondsToDisplay);
40 |
41 | // Set the callback to be called when window is closed
42 | void setQuitCallback(QuitCallback callback) { quitCallback_ = callback; }
43 |
44 | private:
45 | void renderLoop();
46 |
47 | // Window properties
48 | int width_;
49 | int height_;
50 |
51 | // SDL components
52 | SDL_Window* window_;
53 | SDL_Renderer* renderer_;
54 |
55 | // State
56 | std::atomic running_;
57 |
58 | // Thread
59 | std::unique_ptr displayThread_;
60 |
61 | // Quit callback
62 | QuitCallback quitCallback_;
63 |
64 | // SofcutClient
65 | int numVoices_;
66 | SoftcutClient* softCutClient_ = nullptr;
67 | DisplayRing* displayRings_;
68 |
69 | // Keyboard
70 | KeyboardHandler keyboardHandler_;
71 |
72 | // Display
73 | TTF_Font* font = nullptr;
74 | PerlinNoise perlinGenerator;
75 | float noiseTimeValue = 0.0f;
76 | int selected_loop = 0;
77 | bool mouse_dragging = false;
78 | bool dragging_bar = false;
79 | int dragged_parameter = -1;
80 |
81 | // Parameters
82 | Parameters* params_ = nullptr;
83 | int param_count_ = Parameters::PARAM_COUNT;
84 |
85 | // Help System
86 | HelpSystem helpSystem_;
87 |
88 | // Intro Animation
89 | IntroAnimation introAnimation_;
90 | float mainContentFadeAlpha_;
91 |
92 | // Display Message
93 | DisplayMessage displayMessage_;
94 | };
95 |
96 | #endif // DISPLAY_H
--------------------------------------------------------------------------------
/external/faust/architecture/faust/export.h:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | ***************************************************************************/
24 |
25 | #ifndef __export__
26 | #define __export__
27 |
28 | // Version as a global string
29 | #define FAUSTVERSION "2.79.3"
30 |
31 | // Version as separated [major,minor,patch] values
32 | #define FAUSTMAJORVERSION 2
33 | #define FAUSTMINORVERSION 79
34 | #define FAUSTPATCHVERSION 3
35 |
36 | // Use FAUST_API for code that is part of the external API but is also compiled in faust and libfaust
37 | // Use LIBFAUST_API for code that is compiled in faust and libfaust
38 |
39 | #ifdef _WIN32
40 | #pragma warning (disable: 4251)
41 | #ifdef FAUST_EXE
42 | #define FAUST_API
43 | #define LIBFAUST_API
44 | #elif FAUST_LIB
45 | #define FAUST_API __declspec(dllexport)
46 | #define LIBFAUST_API __declspec(dllexport)
47 | #else
48 | #define FAUST_API
49 | #define LIBFAUST_API
50 | #endif
51 | #else
52 | #ifdef FAUST_EXE
53 | #define FAUST_API
54 | #define LIBFAUST_API
55 | #else
56 | #define FAUST_API __attribute__((visibility("default")))
57 | #define LIBFAUST_API __attribute__((visibility("default")))
58 | #endif
59 | #endif
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/Perlin.h:
--------------------------------------------------------------------------------
1 | #ifndef PERLIN_H
2 | #define PERLIN_H
3 | #pragma once
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | // Perlin noise implementation
10 | class PerlinNoise {
11 | private:
12 | std::vector p;
13 |
14 | public:
15 | PerlinNoise() {
16 | // Initialize the permutation vector with values 0-255
17 | p.resize(256);
18 | std::iota(p.begin(), p.end(), 0);
19 |
20 | // Randomize the permutation vector using a seed
21 | std::random_device rd;
22 | std::mt19937 engine(rd());
23 | std::shuffle(p.begin(), p.end(), engine);
24 |
25 | // Duplicate the permutation vector
26 | p.insert(p.end(), p.begin(), p.end());
27 | }
28 |
29 | // Fade function as defined by Ken Perlin
30 | double fade(double t) const { return t * t * t * (t * (t * 6 - 15) + 10); }
31 |
32 | // Linear interpolation
33 | double lerp(double t, double a, double b) const { return a + t * (b - a); }
34 |
35 | // Gradient function
36 | double grad(int hash, double x, double y, double z) const {
37 | // Convert low 4 bits of hash into 12 gradient directions
38 | int h = hash & 15;
39 | double u = h < 8 ? x : y, v = h < 4 ? y : h == 12 || h == 14 ? x : z;
40 | return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
41 | }
42 |
43 | // Return a noise value in the range [-1, 1]
44 | double noise(double x, double y, double z = 0) const {
45 | // Find the unit cube that contains the point
46 | int X = static_cast(std::floor(x)) & 255;
47 | int Y = static_cast(std::floor(y)) & 255;
48 | int Z = static_cast(std::floor(z)) & 255;
49 |
50 | // Find relative x, y, z of point in cube
51 | x -= std::floor(x);
52 | y -= std::floor(y);
53 | z -= std::floor(z);
54 |
55 | // Compute fade curves for each of x, y, z
56 | double u = fade(x);
57 | double v = fade(y);
58 | double w = fade(z);
59 |
60 | // Hash coordinates of the 8 cube corners
61 | int A = p[X] + Y;
62 | int AA = p[A] + Z;
63 | int AB = p[A + 1] + Z;
64 | int B = p[X + 1] + Y;
65 | int BA = p[B] + Z;
66 | int BB = p[B + 1] + Z;
67 |
68 | // And add blended results from 8 corners of cube
69 | return lerp(
70 | w,
71 | lerp(v, lerp(u, grad(p[AA], x, y, z), grad(p[BA], x - 1, y, z)),
72 | lerp(u, grad(p[AB], x, y - 1, z), grad(p[BB], x - 1, y - 1, z))),
73 | lerp(v,
74 | lerp(u, grad(p[AA + 1], x, y, z - 1),
75 | grad(p[BA + 1], x - 1, y, z - 1)),
76 | lerp(u, grad(p[AB + 1], x, y - 1, z - 1),
77 | grad(p[BB + 1], x - 1, y - 1, z - 1))));
78 | }
79 | };
80 |
81 | #endif // PERLIN_H
--------------------------------------------------------------------------------
/dsp/fverb/FVerb.cpp:
--------------------------------------------------------------------------------
1 | // src/effects/FVerb.cpp
2 | #include "FVerb.h"
3 |
4 | #include
5 |
6 | #include "../utilities/Utilities.h" // for FClamp
7 | #include "FVerbDSP.h" // Include the Faust-generated header
8 | #include "faust/gui/MapUI.h" // Include MapUI for parameter control
9 |
10 | void FVerb::Init(float sample_rate) {
11 | // Initialize the DSP with the sample rate
12 | dsp = new FVerbDSP();
13 |
14 | // Initialize the DSP parameters
15 | dsp->init(sample_rate);
16 | dsp->SetParamValue(FVerbDSP::PREDELAY, 150);
17 | SetDecay(82);
18 | SetTailDensity(80);
19 | SetInputDiffision1(70);
20 | SetInputDiffision2(75);
21 | }
22 |
23 | void FVerb::SetDecay(float decay) {
24 | // Set the decay parameter in the DSP
25 | dsp->SetParamValue(FVerbDSP::DECAY, FClamp(decay, 0.0f, 100.0f));
26 | }
27 |
28 | void FVerb::SetTailDensity(float x) {
29 | // Set the decay parameter in the DSP
30 | dsp->SetParamValue(FVerbDSP::TAIL_DENSITY, FClamp(x, 0.0f, 100.0f));
31 | }
32 |
33 | void FVerb::SetInputDiffision1(float x) {
34 | // Set the decay parameter in the DSP
35 | dsp->SetParamValue(FVerbDSP::INPUT_DIFFUSION_1, FClamp(x, 0.0f, 100.0f));
36 | }
37 |
38 | void FVerb::SetInputDiffision2(float x) {
39 | // Set the decay parameter in the DSP
40 | dsp->SetParamValue(FVerbDSP::INPUT_DIFFUSION_2, FClamp(x, 0.0f, 100.0f));
41 | }
42 |
43 | FVerb::~FVerb() {
44 | // Properly clean up all memory
45 | if (dsp) {
46 | delete dsp;
47 | }
48 |
49 | if (inputs) {
50 | for (int i = 0; i < 2; i++) {
51 | if (inputs[i]) delete[] inputs[i];
52 | }
53 | delete[] inputs;
54 | }
55 |
56 | if (outputs) {
57 | for (int i = 0; i < 2; i++) {
58 | if (outputs[i]) delete[] outputs[i];
59 | }
60 | delete[] outputs;
61 | }
62 | }
63 |
64 | void FVerb::Process(float** out, int numSamples) {
65 | if (inputs == nullptr || outputs == nullptr) {
66 | // Allocate input/output buffers
67 | inputs = new float*[2]; // 2 channels
68 | outputs = new float*[2]; // 2 channels
69 |
70 | for (int i = 0; i < 2; i++) {
71 | inputs[i] = new float[numSamples];
72 | outputs[i] = new float[numSamples];
73 | }
74 | }
75 |
76 | // Copy input from out to inputs
77 | for (int i = 0; i < 2; i++) {
78 | for (int j = 0; j < numSamples; j++) {
79 | inputs[i][j] = out[i][j];
80 | }
81 | }
82 |
83 | // Process through Faust DSP using its compute method
84 | dsp->compute(numSamples, inputs, outputs);
85 |
86 | // Copy outputs back to out (if needed)
87 | for (int i = 0; i < 2; i++) {
88 | for (int j = 0; j < numSamples; j++) {
89 | out[i][j] = outputs[i][j];
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/external/faust/architecture/faust/gui/Styles/Default.qss:
--------------------------------------------------------------------------------
1 | QPushButton{
2 | min-width : 80px;
3 | border: 2px solid grey;
4 | border-radius: 6px;
5 | margin-top: 1ex;
6 | border-color: #811453;
7 | background-color: transparent;
8 | }
9 |
10 | QPushButton:hover{
11 | border: 2px;
12 | border-radius: 6px;
13 | border-color: #811453;
14 | background-color: #6A455D;
15 | }
16 |
17 | QPushButton:pressed{
18 | background-color: #6A455D;
19 | border-radius: 6px;
20 | border-color: #811453;
21 | }
22 |
23 | QGroupBox{
24 | subcontrol: .QGroupBox;
25 | margin-top: 3ex;
26 | font-size: 10pt;
27 | font-weight: bold;
28 | color: black;
29 | }
30 |
31 | QGroupBox::title {
32 | subcontrol-origin: margin;
33 | subcontrol-position: top center;
34 | padding: 0 5px;
35 | color: black;
36 | }
37 |
38 | QMainWindow {
39 | margin-top: 3ex;
40 | font-size:10pt;
41 | font-weight:bold;
42 | color: black;
43 | }
44 |
45 | QPlainTextEdit, QTextEdit{
46 | background-color: transparent;
47 | border: 2px solid gray;
48 | border-radius: 5px;
49 | top: 3px;
50 | margin-top: 3ex;
51 | font-size:12pt;
52 | font-weight:bold;
53 | color: black;
54 | }
55 |
56 | QTextBrowser {
57 | color: black;
58 | }
59 | QTextBrowser:document{
60 | text-decoration: underline;
61 | color: black;
62 | font: Menlo;
63 | font-size: 14px
64 | }
65 |
66 | QLabel{
67 | color : black;
68 | background: transparent;
69 | }
70 |
71 | QSlider::groove:vertical {
72 | background: red;
73 | position: absolute;
74 | left: 13px; right: 13px;
75 | }
76 |
77 | QSlider::handle:vertical {
78 | height: 40px;
79 | width: 30px;
80 | background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E67E30, stop : 0.05 #AD4F09, stop: 0.3 #E67E30, stop : 0.90 #AD4F09, stop: 0.91 #AD4F09);
81 | margin: 0 -5px;
82 | border-radius: 5px;
83 | }
84 |
85 | QSlider::add-page:vertical {
86 | background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,
87 | stop: 0 #6A455D, stop : 0.5 #6A455D);
88 | }
89 |
90 | QSlider::sub-page:vertical {
91 | background: grey;
92 | }
93 |
94 | QSlider::groove:horizontal {
95 | background: red;
96 | position: absolute;
97 | top: 14px; bottom: 14px;
98 | }
99 |
100 | QSlider::handle:horizontal {
101 | width: 40px;
102 | background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #E67E30, stop : 0.05 #AD4F09, stop: 0.3 #E67E30, stop : 0.90 #AD4F09, stop: 0.91 #AD4F09);
103 | margin: -5px 0;
104 | border-radius: 5px;
105 | }
106 |
107 | QSlider::sub-page:horizontal {
108 | background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6A455D, stop : 0.5 #6A455D);
109 | }
110 |
111 | QSlider::add-page:horizontal {
112 | background: grey;
113 | }
114 |
115 | QListWidget{
116 | background-color: transparent;
117 | }
--------------------------------------------------------------------------------
/clients/oooooooo/src/VUMeter.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created on 05/07/2025.
3 | //
4 |
5 | #include "VUMeter.h"
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | VUMeter::VUMeter()
12 | : currentLevelDB(-100.0f) // Start at a very low level (effectively silent)
13 | ,
14 | attackCoeff(0.0f),
15 | decayCoeff(0.0f),
16 | currentPeak(0.0f),
17 | sampleRate(48000.0f) // Default to common sample rate
18 | ,
19 | attackTime(0.01f) // 10ms attack (fast)
20 | ,
21 | decayTime(0.3f) // 300ms decay (slow)
22 | {
23 | updateCoefficients();
24 | }
25 |
26 | void VUMeter::setSampleRate(float sr) {
27 | sampleRate = sr;
28 | updateCoefficients();
29 | }
30 |
31 | void VUMeter::setAttackTime(float timeInSeconds) {
32 | attackTime = timeInSeconds;
33 | updateCoefficients();
34 | }
35 |
36 | void VUMeter::setDecayTime(float timeInSeconds) {
37 | decayTime = timeInSeconds;
38 | updateCoefficients();
39 | }
40 |
41 | void VUMeter::updateCoefficients() {
42 | // Calculate time constants as coefficients
43 | // Formula: coeff = exp(-1.0 / (time * sampleRate))
44 | attackCoeff = std::exp(-1.0f / (attackTime * sampleRate));
45 | decayCoeff = std::exp(-1.0f / (decayTime * sampleRate));
46 | }
47 |
48 | float VUMeter::ampToDB(float amp) {
49 | // Avoid log of zero or negative values
50 | const float minAmp = 1.0e-6f; // -120dB
51 | if (amp < minAmp) {
52 | return -100.0f; // Return a very low dB value for near-silence
53 | }
54 |
55 | // Convert amplitude to dB, reference is 1.0
56 | return 20.0f * std::log10(amp);
57 | }
58 |
59 | float VUMeter::dBToAmp(float db) { return std::pow(10.0f, db / 20.0f); }
60 |
61 | void VUMeter::process(const sample_t* buffer, size_t numFrames) {
62 | if (numFrames == 0) return;
63 |
64 | // Find peak in this buffer
65 | float bufferPeak = 0.0f;
66 | for (size_t i = 0; i < numFrames; ++i) {
67 | float absValue = std::fabs(static_cast(buffer[i]));
68 | bufferPeak = std::max(bufferPeak, absValue);
69 | }
70 |
71 | // Apply envelope follower (fast attack, slow decay)
72 | if (bufferPeak > currentPeak) {
73 | // Attack phase - quick response to peaks
74 | currentPeak = attackCoeff * currentPeak + (1.0f - attackCoeff) * bufferPeak;
75 | } else {
76 | // Decay/release phase - slow fall-off
77 | currentPeak = decayCoeff * currentPeak + (1.0f - decayCoeff) * bufferPeak;
78 | }
79 |
80 | // Convert to dB and update the atomic value for thread-safe access
81 | currentLevelDB.store(ampToDB(currentPeak));
82 | }
83 |
84 | float VUMeter::getLevel() const { return currentLevelDB.load(); }
85 |
86 | void VUMeter::reset() {
87 | currentPeak = 0.0f;
88 | currentLevelDB.store(-100.0f);
89 | }
90 |
--------------------------------------------------------------------------------
/external/faust/architecture/faust/dsp/faust-engine.h:
--------------------------------------------------------------------------------
1 | /************************** BEGIN faust-engine.h ***********************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | ************************************************************************/
24 |
25 | #ifndef __faust_engine__
26 | #define __faust_engine__
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | void* create(int, int); // To be implemented
33 | void destroy(void*);
34 |
35 | bool start(void*);
36 | void stop(void*);
37 |
38 | bool isRunning(void*);
39 |
40 | uintptr_t keyOn(void*, int, int);
41 | int keyOff(void*, int);
42 |
43 | void propagateMidi(void*, int, double, int, int, int, int);
44 |
45 | const char* getJSONUI(void*);
46 | const char* getJSONMeta(void*);
47 |
48 | int getParamsCount(void*);
49 |
50 | void setParamValue(void*, const char*, float);
51 | float getParamValue(void*, const char*);
52 |
53 | void setParamIdValue(void*, int, float);
54 | float getParamIdValue(void*, int);
55 |
56 | void setVoiceParamValue(void*, const char*, uintptr_t, float);
57 | float getVoiceParamValue(void*, const char*, uintptr_t);
58 |
59 | const char* getParamAddress(void*, int);
60 |
61 | void propagateAcc(void*, int, float);
62 | void setAccConverter(void*, int, int, int, float, float, float);
63 |
64 | void propagateGyr(void*, int, float);
65 | void setGyrConverter(void*, int, int, int, float, float, float);
66 |
67 | float getCPULoad(void*);
68 | int getScreenColor(void*);
69 |
70 | #ifdef __cplusplus
71 | }
72 | #endif
73 |
74 | #endif // __faust_engine__
75 | /************************** END faust-engine.h **************************/
76 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/Commands.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 11/3/18.
3 | //
4 |
5 | #ifndef CRONE_COMMANDS_H
6 | #define CRONE_COMMANDS_H
7 |
8 | // #include
9 | #include "readerwriterqueue/readerwriterqueue.h"
10 |
11 | namespace softcut_jack_osc {
12 |
13 | class SoftcutClient;
14 |
15 | class Commands {
16 | public:
17 | typedef enum {
18 | //-- softcut commands
19 |
20 | // mix
21 | SET_ENABLED_CUT,
22 | SET_LEVEL_CUT,
23 | SET_PAN_CUT,
24 | // level of individual input channel -> cut voice
25 | // (separate commands just to avoid a 3rd parameter)
26 | SET_LEVEL_IN_CUT,
27 | SET_LEVEL_CUT_CUT,
28 |
29 | // params
30 | SET_CUT_REC_FLAG,
31 | SET_CUT_PLAY_FLAG,
32 |
33 | SET_CUT_RATE,
34 | SET_CUT_LOOP_START,
35 | SET_CUT_LOOP_END,
36 | SET_CUT_LOOP_FLAG,
37 | SET_CUT_POSITION,
38 |
39 | SET_CUT_FADE_TIME,
40 | SET_CUT_REC_LEVEL,
41 | SET_CUT_PRE_LEVEL,
42 | SET_CUT_REC_OFFSET,
43 |
44 | SET_CUT_PRE_FILTER_FC,
45 | SET_CUT_PRE_FILTER_FC_MOD,
46 | SET_CUT_PRE_FILTER_RQ,
47 | SET_CUT_PRE_FILTER_LP,
48 | SET_CUT_PRE_FILTER_HP,
49 | SET_CUT_PRE_FILTER_BP,
50 | SET_CUT_PRE_FILTER_BR,
51 | SET_CUT_PRE_FILTER_DRY,
52 |
53 | SET_CUT_POST_FILTER_FC,
54 | SET_CUT_POST_FILTER_RQ,
55 | SET_CUT_POST_FILTER_LP,
56 | SET_CUT_POST_FILTER_HP,
57 | SET_CUT_POST_FILTER_BP,
58 | SET_CUT_POST_FILTER_BR,
59 | SET_CUT_POST_FILTER_DRY,
60 |
61 | SET_CUT_LEVEL_SLEW_TIME,
62 | SET_CUT_PAN_SLEW_TIME,
63 | SET_CUT_RECPRE_SLEW_TIME,
64 | SET_CUT_RATE_SLEW_TIME,
65 | SET_CUT_VOICE_SYNC,
66 | SET_CUT_BUFFER,
67 |
68 | SET_CUT_REC_ONCE,
69 | SET_CUT_TAPE_BIAS,
70 | SET_CUT_TAPE_PREGAIN,
71 | NUM_COMMANDS,
72 | } Id;
73 |
74 | public:
75 | Commands();
76 | void post(Commands::Id id, float f);
77 | void post(Commands::Id id, int i, float f);
78 | void post(Commands::Id id, int i, int j);
79 | void post(Commands::Id id, int i, int j, float f);
80 |
81 | void handlePending(SoftcutClient *client);
82 |
83 | struct CommandPacket {
84 | CommandPacket() = default;
85 | CommandPacket(Commands::Id i, int i0, float f)
86 | : id(i), idx_0(i0), idx_1(-1), value(f) {}
87 | CommandPacket(Commands::Id i, int i0, int i1)
88 | : id(i), idx_0(i0), idx_1(i1) {}
89 | CommandPacket(Commands::Id i, int i0, int i1, float f)
90 | : id(i), idx_0(i0), idx_1(i1), value(f) {}
91 | Id id;
92 | int idx_0{};
93 | int idx_1{};
94 | float value{};
95 | };
96 |
97 | static Commands softcutCommands;
98 |
99 | private:
100 | // boost::lockfree::spsc_queue > q;
102 | moodycamel::ReaderWriterQueue q;
103 | };
104 |
105 | } // namespace softcut_jack_osc
106 |
107 | #endif // CRONE_COMMANDS_H
108 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/SessionRecorder.h:
--------------------------------------------------------------------------------
1 | #ifndef SESSION_RECORDER_H
2 | #define SESSION_RECORDER_H
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | // Use double as sample type to match softcut
13 | using sample_t = double;
14 |
15 | class SessionRecorder {
16 | public:
17 | SessionRecorder();
18 | ~SessionRecorder();
19 |
20 | // Start recording with timestamp-based filenames
21 | void startRecording(int numVoices, float sampleRate);
22 |
23 | // Stop recording and close files
24 | void stopRecording();
25 |
26 | // Check if currently recording
27 | bool isRecording() const { return recording_.load(); }
28 |
29 | // Called from audio thread - captures audio frames
30 | void captureMainMix(const sample_t* left, const sample_t* right,
31 | size_t numFrames);
32 | void captureVoice(int voice, const sample_t* left, const sample_t* right,
33 | size_t numFrames);
34 |
35 | private:
36 | std::atomic recording_;
37 | std::string sessionTimestamp_;
38 | int numVoices_;
39 | float sampleRate_;
40 |
41 | // Ring buffers for thread-safe audio capture
42 | static const size_t RING_BUFFER_SIZE = 48000 * 10; // 10 seconds at 48kHz
43 | struct VoiceBuffer {
44 | std::vector buffer;
45 | std::atomic writePos;
46 | std::atomic readPos;
47 | std::unique_ptr file;
48 | std::atomic hasAudio;
49 | std::atomic hasLogged;
50 | std::string filename;
51 |
52 | VoiceBuffer() : writePos(0), readPos(0), hasAudio(false), hasLogged(false) {}
53 | VoiceBuffer(VoiceBuffer&& other) noexcept
54 | : buffer(std::move(other.buffer)),
55 | writePos(other.writePos.load()),
56 | readPos(other.readPos.load()),
57 | file(std::move(other.file)),
58 | hasAudio(other.hasAudio.load()),
59 | hasLogged(other.hasLogged.load()),
60 | filename(std::move(other.filename)) {}
61 | VoiceBuffer& operator=(VoiceBuffer&& other) noexcept {
62 | if (this != &other) {
63 | buffer = std::move(other.buffer);
64 | writePos.store(other.writePos.load());
65 | readPos.store(other.readPos.load());
66 | file = std::move(other.file);
67 | hasAudio.store(other.hasAudio.load());
68 | hasLogged.store(other.hasLogged.load());
69 | filename = std::move(other.filename);
70 | }
71 | return *this;
72 | }
73 | // Delete copy constructor and assignment
74 | VoiceBuffer(const VoiceBuffer&) = delete;
75 | VoiceBuffer& operator=(const VoiceBuffer&) = delete;
76 | };
77 |
78 | VoiceBuffer mainMixBuffer_;
79 | std::vector voiceBuffers_;
80 |
81 | // Worker thread for writing to disk
82 | std::unique_ptr writerThread_;
83 | std::atomic writerRunning_;
84 |
85 | void writerThreadFunc();
86 | std::string generateTimestamp();
87 | std::string generateFilename(const std::string& voiceId);
88 | void initializeBuffer(VoiceBuffer& buffer, int channels);
89 | size_t writeAvailableData(VoiceBuffer& buffer);
90 | };
91 |
92 | #endif // SESSION_RECORDER_H
93 |
--------------------------------------------------------------------------------
/softcut-lib/include/softcut/ReadWriteHead.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ezra on 12/6/17.
3 | //
4 |
5 | #ifndef CUTFADEVOICE_CUTFADEVOICELOGIC_H
6 | #define CUTFADEVOICE_CUTFADEVOICELOGIC_H
7 |
8 | #include
9 |
10 | #include "FadeCurves.h"
11 | #include "SubHead.h"
12 | #include "TestBuffers.h"
13 | #include "Types.h"
14 |
15 | namespace softcut {
16 |
17 | class ReadWriteHead {
18 | public:
19 | void init(FadeCurves *fc);
20 |
21 | // per-sample update functions
22 | void processSample(sample_t in, sample_t *out);
23 | void processSampleNoRead(sample_t in, sample_t *out);
24 | void processSampleNoWrite(sample_t in, sample_t *out);
25 |
26 | void setSampleRate(float sr);
27 | void setBuffer(sample_t *buf, uint32_t size);
28 | void setRate(rate_t x);
29 |
30 | // set loop (region) start point in seconds
31 | void setLoopStartSeconds(float x);
32 | // set loop (region) end point in seconds
33 | void setLoopEndSeconds(float x);
34 | void setFadeTime(float secs);
35 | void setLoopFlag(bool val);
36 |
37 | void setRecOnceFlag(bool val);
38 | bool getRecOnceDone();
39 | bool getRecOnceActive();
40 |
41 | // set amplitudes
42 | void setRec(float x);
43 | void setPre(float x);
44 |
45 | // enqueue a position change with crossfade
46 | void cutToPos(float seconds);
47 |
48 | // immediately put both subheads in stopped state
49 | void stop();
50 | // immediately start playing from current position (no fadein)
51 | void run();
52 |
53 | float getDuration() { return (end - start) / sr; }
54 |
55 | float getLoopStart() { return start / sr; }
56 |
57 | float getLoopEnd() { return end / sr; }
58 |
59 | void setRecOffsetSamples(int d);
60 |
61 | phase_t getActivePhase();
62 | rate_t getRate();
63 |
64 | protected:
65 | friend class SubHead;
66 |
67 | private:
68 | // fade in to new position (given in samples)
69 | // assumption: phase is in range!
70 | void cutToPhase(phase_t newPhase);
71 | void enqueueCrossfade(phase_t newPhase);
72 | void dequeueCrossfade();
73 | void takeAction(Action act);
74 |
75 | sample_t mixFade(sample_t x, sample_t y, float a,
76 | float b); // mix two inputs with phases
77 | void calcFadeInc();
78 |
79 | private:
80 | SubHead head[2];
81 |
82 | sample_t *buf; // audio buffer (allocated elsewhere)
83 | float sr; // sample rate
84 | phase_t start; // start/end points
85 | phase_t end;
86 | phase_t queuedCrossfade;
87 | bool queuedCrossfadeFlag;
88 | float fadeTime; // fade time in seconds
89 | float fadeInc; // linear fade increment per sample
90 |
91 | int active; // current active play head index (0 or 1)
92 | bool loopFlag; // set to loop, unset for 1-shot
93 | float pre; // pre-record level
94 | float rec; // record level
95 | bool recOnceFlag; // set to record one full loop
96 | bool recOnceDone; // triggers done to tell voice to unset rec flag
97 | int recOnceHead; // keeps track of which subhead is writing
98 |
99 | rate_t rate; // current rate
100 | TestBuffers testBuf;
101 | };
102 | } // namespace softcut
103 | #endif // CUTFADEVOICE_CUTFADEVOICELOGIC_H
104 |
--------------------------------------------------------------------------------
/external/faust/architecture/faust/dsp/dsp-multifun.h:
--------------------------------------------------------------------------------
1 | /************************** BEGIN dsp-multifun.h **************************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | ***************************************************************************/
24 |
25 | #ifndef dsp_multifun_H
26 | #define dsp_multifun_H
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | #include "faust/dsp/dsp-adapter.h"
33 | #include "faust/gui/meta.h"
34 | #include "mydspgeneric.h"
35 |
36 | /*
37 | A DSP decorator that loads the CPU optimised version of the code and instantiate it.
38 | This file is used by the 'faust2object' tool to produce a single multi CPU aware .o file,
39 | to be compiled and linked with the mydspmulti class.
40 |
41 | To test: c++ -std=c++11 FOOmulti.cpp FOOgeneric.cpp -o FOOmulti
42 | */
43 | class mydspmulti : public decorator_dsp {
44 |
45 | private:
46 |
47 | struct Meta1 : Meta
48 | {
49 | std::string fOptions;
50 |
51 | void declare(const char* key, const char* value)
52 | {
53 | if (strcmp("compile_options", key) == 0) {
54 | fOptions = value;
55 | }
56 | }
57 | };
58 |
59 | public:
60 |
61 | // Create a DS/US + Filter adapted DSP
62 | mydspmulti():decorator_dsp()
63 | {
64 | std::string error;
65 | fDSP = createSRAdapter(createmydspgeneric(), error, DOWN_SAMPLING, UP_SAMPLING, FILTER_TYPE);
66 | Meta1 meta;
67 | fDSP->metadata(&meta);
68 | std::cout << "Faust compile options : " << meta.fOptions << std::endl;
69 | }
70 |
71 | virtual ~mydspmulti()
72 | {}
73 |
74 | };
75 |
76 | // Factory API
77 | dsp* createmydspmulti() { return new mydspmulti(); }
78 |
79 | #endif
80 |
81 | #ifdef TEST
82 | int main()
83 | {
84 | mydspmulti multi;
85 | std::cout << multi.getNumInputs() << std::endl;
86 | std::cout << multi.getNumOutputs() << std::endl;
87 | }
88 | #endif
89 |
90 | /************************** END dsp-multifun.h **************************/
91 |
--------------------------------------------------------------------------------
/clients/oooooooo/src/HelpSystem.cpp:
--------------------------------------------------------------------------------
1 | #include "HelpSystem.h"
2 |
3 | #include
4 |
5 | HelpSystem::HelpSystem()
6 | : font(nullptr),
7 | helpVisible(false),
8 | fadeAlpha(0.0f),
9 | fadeTarget(0.0f),
10 | fadeStep(0.05f) {
11 | // Initialize help messages
12 | helpMessages = {
13 | "basics",
14 | "h toggles help",
15 | "tab toggles menu",
16 | "1-8 selects loop",
17 | "up/down selects parameter",
18 | "left/right adjusts parameter",
19 | "ctrl + a copies parameter to all",
20 | "click edge to cut to position",
21 | "click and drag middle to adjust",
22 | "and pan",
23 | "",
24 | "playing/recording",
25 | "p toggles play",
26 | "r toggles record",
27 | "ctl + r pirmes recording",
28 | "shift + r records once",
29 | "",
30 | "lfos",
31 | "l toggles lfo",
32 | "ctrl + l toggles lfo on all",
33 | "+/- adjusts lfo period",
34 | "ctrl+left/right adjusts min lfo",
35 | "alt+left/right adjusts max lfo",
36 | "",
37 | "saving/loading",
38 | "drag-and-drop audio file to load",
39 | "s saves parameters",
40 | "ctrl+s saves audio",
41 | "o loads parameters",
42 | "ctrl+o loads audio",
43 | "y toggles session recording",
44 | };
45 | }
46 |
47 | HelpSystem::~HelpSystem() { font = nullptr; }
48 |
49 | void HelpSystem::Init(TTF_Font* font) { this->font = font; }
50 |
51 | void HelpSystem::Toggle() {
52 | helpVisible = !helpVisible;
53 | fadeTarget = helpVisible ? 1.0f : 0.0f;
54 | }
55 |
56 | void HelpSystem::Render(SDL_Renderer* renderer, int windowWidth) {
57 | // Update fade alpha based on target
58 | if (fadeAlpha < fadeTarget) {
59 | fadeAlpha += fadeStep;
60 | if (fadeAlpha > fadeTarget) fadeAlpha = fadeTarget;
61 | } else if (fadeAlpha > fadeTarget) {
62 | fadeAlpha -= fadeStep;
63 | if (fadeAlpha < fadeTarget) fadeAlpha = fadeTarget;
64 | }
65 | // Only proceed if we have a font and some alpha
66 | if (!font || fadeAlpha <= 0.01f) return;
67 |
68 | // Calculate the alpha value for SDL (0-255)
69 | uint8_t alpha = static_cast(fadeAlpha * 255);
70 |
71 | // Set up position for text on right side of screen
72 | int textX = windowWidth - 360; // 450 pixels from right edge
73 | int textY = 20; // Start 10 pixels from top
74 | int lineHeight = 20; // Spacing between lines
75 |
76 | // Ensure text position is always visible
77 | textX = std::max(10, textX);
78 |
79 | // Draw each help message
80 | for (const auto& message : helpMessages) {
81 | SDL_Color textColor = {255, 255, 255, alpha}; // Gray with current alpha
82 | SDL_Surface* textSurface =
83 | TTF_RenderText_Blended(font, message.c_str(), textColor);
84 |
85 | if (textSurface) {
86 | SDL_Texture* textTexture =
87 | SDL_CreateTextureFromSurface(renderer, textSurface);
88 | if (textTexture) {
89 | SDL_Rect textRect = {textX, textY, textSurface->w, textSurface->h};
90 | SDL_RenderCopy(renderer, textTexture, nullptr, &textRect);
91 | SDL_DestroyTexture(textTexture);
92 | }
93 | SDL_FreeSurface(textSurface);
94 | }
95 |
96 | // Move down for next line
97 | textY += lineHeight;
98 | }
99 | }
--------------------------------------------------------------------------------
/clients/oooooooo/src/DisplayMessage.cpp:
--------------------------------------------------------------------------------
1 | #include "DisplayMessage.h"
2 |
3 | #include
4 |
5 | DisplayMessage::DisplayMessage()
6 | : font_(nullptr),
7 | state_(State::IDLE),
8 | alpha_(0.0f),
9 | displayDurationMs_(0),
10 | textColor_({255, 255, 255, 255}) {}
11 |
12 | void DisplayMessage::Init(TTF_Font* font) { font_ = font; }
13 |
14 | void DisplayMessage::SetMessage(const std::string& message,
15 | int displaySeconds) {
16 | currentMessage_ = message;
17 | displayDurationMs_ = displaySeconds * 1000;
18 | state_ = State::FADING_IN;
19 | alpha_ = 0.0f;
20 | startTime_ = std::chrono::steady_clock::now();
21 | displayEndTime_ = startTime_ + std::chrono::milliseconds(FADE_DURATION_MS +
22 | displayDurationMs_);
23 | }
24 |
25 | void DisplayMessage::Update() {
26 | if (state_ == State::IDLE) {
27 | return;
28 | }
29 |
30 | auto now = std::chrono::steady_clock::now();
31 | auto elapsed =
32 | std::chrono::duration_cast(now - startTime_)
33 | .count();
34 |
35 | switch (state_) {
36 | case State::FADING_IN:
37 | if (elapsed < FADE_DURATION_MS) {
38 | alpha_ = static_cast(elapsed) / FADE_DURATION_MS;
39 | } else {
40 | alpha_ = 1.0f;
41 | state_ = State::DISPLAYING;
42 | }
43 | break;
44 |
45 | case State::DISPLAYING:
46 | if (elapsed > FADE_DURATION_MS + displayDurationMs_) {
47 | state_ = State::FADING_OUT;
48 | }
49 | break;
50 |
51 | case State::FADING_OUT:
52 | if (elapsed < FADE_DURATION_MS + displayDurationMs_ + FADE_DURATION_MS) {
53 | float fadeOutProgress = static_cast(elapsed - FADE_DURATION_MS -
54 | displayDurationMs_) /
55 | FADE_DURATION_MS;
56 | alpha_ = 1.0f - fadeOutProgress;
57 | } else {
58 | alpha_ = 0.0f;
59 | state_ = State::IDLE;
60 | currentMessage_.clear();
61 | }
62 | break;
63 |
64 | case State::IDLE:
65 | // Already handled above
66 | break;
67 | }
68 | }
69 |
70 | void DisplayMessage::Render(SDL_Renderer* renderer,
71 | int windowWidth [[maybe_unused]],
72 | int windowHeight [[maybe_unused]]) {
73 | if (state_ == State::IDLE || alpha_ <= 0.0f || currentMessage_.empty() ||
74 | !font_) {
75 | return;
76 | }
77 |
78 | SDL_Color color = textColor_;
79 | color.a = static_cast(255 * alpha_);
80 |
81 | // Create surface and texture
82 | SDL_Surface* surface =
83 | TTF_RenderText_Blended(font_, currentMessage_.c_str(), color);
84 | if (!surface) {
85 | return;
86 | }
87 |
88 | SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
89 | if (!texture) {
90 | SDL_FreeSurface(surface);
91 | return;
92 | }
93 | // Position the message in the bottom-right corner with some padding
94 | int padding = 10;
95 | int x = padding;
96 | int y = windowHeight - surface->h - padding;
97 |
98 | SDL_Rect destRect = {x, y, surface->w, surface->h};
99 | SDL_RenderCopy(renderer, texture, nullptr, &destRect);
100 |
101 | // Clean up
102 | SDL_DestroyTexture(texture);
103 | SDL_FreeSurface(surface);
104 | }
105 |
106 | bool DisplayMessage::IsActive() const { return state_ != State::IDLE; }
--------------------------------------------------------------------------------
/external/faust/architecture/faust/gui/JuceStateUI.h:
--------------------------------------------------------------------------------
1 | /************************** BEGIN JuceStateUI.h **************************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | ************************************************************************/
24 |
25 | #ifndef JuceStateUI_H
26 | #define JuceStateUI_H
27 |
28 | #include "../JuceLibraryCode/JuceHeader.h"
29 |
30 | #include "faust/gui/MapUI.h"
31 |
32 | // A class to save/restore DSP state using JUCE, which also set default values at construction time.
33 |
34 | struct JuceStateUI : public MapUI {
35 |
36 | bool fRestored;
37 |
38 | JuceStateUI():fRestored(false) {}
39 | virtual ~JuceStateUI() {}
40 |
41 | void getStateInformation (juce::MemoryBlock& destData)
42 | {
43 | juce::MemoryOutputStream stream (destData, true);
44 |
45 | // Write path and values
46 | if (sizeof(FAUSTFLOAT) == sizeof(float)) {
47 | for (const auto& it : getFullpathMap()) {
48 | stream.writeString(it.first);
49 | stream.writeFloat(*it.second);
50 | }
51 | } else {
52 | for (const auto& it : getFullpathMap()) {
53 | stream.writeString(it.first);
54 | stream.writeDouble(*it.second);
55 | }
56 | }
57 | }
58 |
59 | void setStateInformation (const void* data, int sizeInBytes)
60 | {
61 | fRestored = true;
62 | juce::MemoryInputStream stream (data, static_cast (sizeInBytes), false);
63 | std::string path;
64 |
65 | // Read path then value and try to restore them
66 | if (sizeof(FAUSTFLOAT) == sizeof(float)) {
67 | while ((path = stream.readString().toStdString()) != "") {
68 | setParamValue(path, stream.readFloat());
69 | }
70 | } else {
71 | while ((path = stream.readString().toStdString()) != "") {
72 | setParamValue(path, stream.readDouble());
73 | }
74 | }
75 | }
76 |
77 | // -- active widgets
78 | // use MapUI derived methods
79 |
80 | // -- passive widgets
81 | // empty si we don't want to save/restore them
82 | void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT fmin, FAUSTFLOAT fmax) {}
83 | void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT fmin, FAUSTFLOAT fmax) {}
84 |
85 | };
86 |
87 | #endif
88 | /************************** END JuceStateUI.h **************************/
89 |
--------------------------------------------------------------------------------
/external/faust/architecture/faust/gui/UI.h:
--------------------------------------------------------------------------------
1 | /************************** BEGIN UI.h *****************************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | ********************************************************************/
24 |
25 | #ifndef __UI_H__
26 | #define __UI_H__
27 |
28 | #include "faust/export.h"
29 |
30 | #ifndef FAUSTFLOAT
31 | #define FAUSTFLOAT float
32 | #endif
33 |
34 | /*******************************************************************************
35 | * UI : Faust DSP User Interface
36 | * User Interface as expected by the buildUserInterface() method of a DSP.
37 | * This abstract class contains only the method that the Faust compiler can
38 | * generate to describe a DSP user interface.
39 | ******************************************************************************/
40 |
41 | struct Soundfile;
42 |
43 | template
44 | struct FAUST_API UIReal {
45 |
46 | UIReal() {}
47 | virtual ~UIReal() {}
48 |
49 | // -- widget's layouts
50 |
51 | virtual void openTabBox(const char* label) = 0;
52 | virtual void openHorizontalBox(const char* label) = 0;
53 | virtual void openVerticalBox(const char* label) = 0;
54 | virtual void closeBox() = 0;
55 |
56 | // -- active widgets
57 |
58 | virtual void addButton(const char* label, REAL* zone) = 0;
59 | virtual void addCheckButton(const char* label, REAL* zone) = 0;
60 | virtual void addVerticalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0;
61 | virtual void addHorizontalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0;
62 | virtual void addNumEntry(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0;
63 |
64 | // -- passive widgets
65 |
66 | virtual void addHorizontalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0;
67 | virtual void addVerticalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0;
68 |
69 | // -- soundfiles
70 |
71 | virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) = 0;
72 |
73 | // -- metadata declarations
74 |
75 | virtual void declare(REAL* /*zone*/, const char* /*key*/, const char* /*val*/) {}
76 |
77 | // To be used by LLVM client
78 | virtual int sizeOfFAUSTFLOAT() { return sizeof(FAUSTFLOAT); }
79 | };
80 |
81 | struct FAUST_API UI : public UIReal {
82 | UI() {}
83 | virtual ~UI() {}
84 | #ifdef DAISY_NO_RTTI
85 | virtual bool isSoundUI() const { return false; }
86 | virtual bool isMidiInterface() const { return false; }
87 | #endif
88 | };
89 |
90 | #endif
91 | /************************** END UI.h **************************/
92 |
--------------------------------------------------------------------------------
/external/faust/architecture/faust/misc.h:
--------------------------------------------------------------------------------
1 | /************************** BEGIN misc.h *******************************
2 | FAUST Architecture File
3 | Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
4 | ---------------------------------------------------------------------
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 |
19 | EXCEPTION : As a special exception, you may create a larger work
20 | that contains this FAUST architecture section and distribute
21 | that work under terms of your choice, so long as this FAUST
22 | architecture section is not modified.
23 | ***************************************************************************/
24 |
25 | #ifndef __misc__
26 | #define __misc__
27 |
28 | #include
29 | #include