OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce_WaveShaper.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
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 5 End-User License
11 Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
12 27th April 2017).
13
14 End User License Agreement: www.juce.com/juce-5-licence
15 Privacy Policy: www.juce.com/juce-5-privacy-policy
16
17 Or: You may also use this code under the terms of the GPL v3 (see
18 www.gnu.org/licenses).
19
20 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 DISCLAIMED.
23
24 ==============================================================================
25*/
26
27namespace juce
28{
29namespace dsp
30{
31
37template <typename FloatType, typename Function = FloatType (*) (FloatType)>
39{
40 Function functionToUse;
41
42 //==============================================================================
44 void prepare (const ProcessSpec&) noexcept {}
45
46 //==============================================================================
48 template <typename SampleType>
49 SampleType JUCE_VECTOR_CALLTYPE processSample (SampleType inputSample) const noexcept
50 {
51 return functionToUse (inputSample);
52 }
53
55 template <typename ProcessContext>
56 void process (const ProcessContext& context) const noexcept
57 {
58 if (context.isBypassed)
59 {
60 if (context.usesSeparateInputAndOutputBlocks())
61 context.getOutputBlock().copyFrom (context.getInputBlock());
62 }
63 else
64 {
66 context.getOutputBlock(),
67 functionToUse);
68 }
69 }
70
71 void reset() noexcept {}
72};
73
74//==============================================================================
75// Although clang supports C++17, their standard library still has no invoke_result
76// support. Remove the "|| JUCE_CLANG" once clang supports this properly!
77#if (! JUCE_CXX17_IS_AVAILABLE) || JUCE_CLANG
78template <typename Functor>
79static WaveShaper<typename std::result_of<Functor>, Functor> CreateWaveShaper (Functor functionToUse) { return {functionToUse}; }
80#else
81template <typename Functor>
82static WaveShaper<typename std::invoke_result<Functor>, Functor> CreateWaveShaper (Functor functionToUse) { return {functionToUse}; }
83#endif
84
85} // namespace dsp
86} // namespace juce
static void process(AudioBlock< Src1SampleType > inBlock, AudioBlock< Src2SampleType > outBlock, FunctionType &&function)
void prepare(const ProcessSpec &) noexcept
SampleType JUCE_VECTOR_CALLTYPE processSample(SampleType inputSample) const noexcept
void process(const ProcessContext &context) const noexcept