LMMS
Loading...
Searching...
No Matches
juce_WaveShaper.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28namespace dsp
29{
30
36template <typename FloatType, typename Function = FloatType (*) (FloatType)>
38{
39 Function functionToUse;
40
41 //==============================================================================
43 void prepare (const ProcessSpec&) noexcept {}
44
45 //==============================================================================
47 template <typename SampleType>
48 SampleType JUCE_VECTOR_CALLTYPE processSample (SampleType inputSample) const noexcept
49 {
50 return functionToUse (inputSample);
51 }
52
54 template <typename ProcessContext>
55 void process (const ProcessContext& context) const noexcept
56 {
57 if (context.isBypassed)
58 {
59 if (context.usesSeparateInputAndOutputBlocks())
60 context.getOutputBlock().copyFrom (context.getInputBlock());
61 }
62 else
63 {
64 AudioBlock<FloatType>::process (context.getInputBlock(),
65 context.getOutputBlock(),
67 }
68 }
69
70 void reset() noexcept {}
71};
72
73//==============================================================================
74#if JUCE_CXX17_IS_AVAILABLE && ! ((JUCE_MAC || JUCE_IOS) && JUCE_CLANG && __clang_major__ < 10)
75template <typename Functor>
76static WaveShaper<typename std::invoke_result<Functor>, Functor> CreateWaveShaper (Functor functionToUse) { return {functionToUse}; }
77#else
78template <typename Functor>
79static WaveShaper<typename std::result_of<Functor>, Functor> CreateWaveShaper (Functor functionToUse) { return {functionToUse}; }
80#endif
81
82} // namespace dsp
83} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
static void process(AudioBlock< Src1SampleType > inBlock, AudioBlock< Src2SampleType > outBlock, FunctionType &&function)
Definition juce_AudioBlock.h:576
#define JUCE_VECTOR_CALLTYPE
Definition juce_dsp.h:100
Definition juce_AudioBlock.h:29
static WaveShaper< typename std::result_of< Functor >, Functor > CreateWaveShaper(Functor functionToUse)
Definition juce_WaveShaper.h:79
Definition carla_juce.cpp:31
Definition juce_ProcessContext.h:38
Definition juce_WaveShaper.h:38
Function functionToUse
Definition juce_WaveShaper.h:39
void prepare(const ProcessSpec &) noexcept
Definition juce_WaveShaper.h:43
SampleType JUCE_VECTOR_CALLTYPE processSample(SampleType inputSample) const noexcept
Definition juce_WaveShaper.h:48
void process(const ProcessContext &context) const noexcept
Definition juce_WaveShaper.h:55
void reset() noexcept
Definition juce_WaveShaper.h:70