OpenShot Audio Library | OpenShotAudio: juce_ResamplingAudioSource.h Source File

OpenShot Audio Library | OpenShotAudio 0.3.0

Loading...
Searching...
No Matches
juce_ResamplingAudioSource.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 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
34 class JUCE_API ResamplingAudioSource : public AudioSource
35{
36public:
37 //==============================================================================
45 ResamplingAudioSource (AudioSource* inputSource,
46 bool deleteInputWhenDeleted,
47 int numChannels = 2);
48
50 ~ResamplingAudioSource() override;
51
60 void setResamplingRatio (double samplesInPerOutputSample);
61
66 double getResamplingRatio() const noexcept { return ratio; }
67
69 void flushBuffers();
70
71 //==============================================================================
72 void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override;
73 void releaseResources() override;
74 void getNextAudioBlock (const AudioSourceChannelInfo&) override;
75
76private:
77 //==============================================================================
78 OptionalScopedPointer<AudioSource> input;
79 double ratio = 1.0, lastRatio = 1.0;
80 AudioBuffer<float> buffer;
81 int bufferPos = 0, sampsInBuffer = 0;
82 double subSampleOffset = 0.0;
83 double coefficients[6];
84 SpinLock ratioLock;
85 CriticalSection callbackLock;
86 const int numChannels;
87 HeapBlock<float*> destBuffers;
88 HeapBlock<const float*> srcBuffers;
89
90 void setFilterCoefficients (double c1, double c2, double c3, double c4, double c5, double c6);
91 void createLowPass (double proportionalRate);
92
93 struct FilterState
94 {
95 double x1, x2, y1, y2;
96 };
97
98 HeapBlock<FilterState> filterStates;
99 void resetFilters();
100
101 void applyFilter (float* samples, int num, FilterState& fs);
102
103 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResamplingAudioSource)
104};
105
106} // namespace juce
juce::AudioBuffer
Definition: juce_AudioSampleBuffer.h:34
juce::AudioSource
Definition: juce_AudioSource.h:110
juce::CriticalSection
Definition: juce_CriticalSection.h:43
juce::HeapBlock
Definition: juce_HeapBlock.h:87
juce::OptionalScopedPointer
Definition: juce_OptionalScopedPointer.h:38
juce::ResamplingAudioSource
Definition: juce_ResamplingAudioSource.h:35
juce::ResamplingAudioSource::getResamplingRatio
double getResamplingRatio() const noexcept
Definition: juce_ResamplingAudioSource.h:66
juce::SpinLock
Definition: juce_SpinLock.h:42
juce::AudioSourceChannelInfo
Definition: juce_AudioSource.h:33