Loading...
Searching...
No Matches
juce_AudioSourcePlayer.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API AudioSourcePlayer : public AudioIODeviceCallback
{
public:
//==============================================================================
AudioSourcePlayer();
~AudioSourcePlayer() override;
//==============================================================================
void setSource (AudioSource* newSource);
AudioSource* getCurrentSource() const noexcept { return source; }
void setGain (float newGain) noexcept;
float getGain() const noexcept { return gain; }
//==============================================================================
void audioDeviceIOCallbackWithContext (const float* const* inputChannelData,
int totalNumInputChannels,
float* const* outputChannelData,
int totalNumOutputChannels,
int numSamples,
const AudioIODeviceCallbackContext& context) override;
void audioDeviceAboutToStart (AudioIODevice* device) override;
void audioDeviceStopped() override;
void prepareToPlay (double sampleRate, int blockSize);
private:
//==============================================================================
CriticalSection readLock;
AudioSource* source = nullptr;
double sampleRate = 0;
int bufferSize = 0;
float* channels[128];
float* outputChans[128];
const float* inputChans[128];
AudioBuffer<float> tempBuffer;
float lastGain = 1.0f;
std::atomic<float> gain { 1.0f };
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSourcePlayer)
};
} // namespace juce
juce::AudioBuffer
Definition juce_AudioSampleBuffer.h:34
juce::AudioIODeviceCallback
Definition juce_AudioIODevice.h:55
juce::AudioIODevice
Definition juce_AudioIODevice.h:151
juce::AudioSourcePlayer::setSource
void setSource(AudioSource *newSource)
Definition juce_AudioSourcePlayer.cpp:35
juce::AudioSourcePlayer::AudioSourcePlayer
AudioSourcePlayer()
Definition juce_AudioSourcePlayer.cpp:26
juce::AudioSourcePlayer::getGain
float getGain() const noexcept
Definition juce_AudioSourcePlayer.h:79
juce::AudioSourcePlayer::getCurrentSource
AudioSource * getCurrentSource() const noexcept
Definition juce_AudioSourcePlayer.h:69
juce::AudioSource
Definition juce_AudioSource.h:110
juce::CriticalSection
Definition juce_CriticalSection.h:43
juce::AudioIODeviceCallbackContext
Definition juce_AudioIODevice.h:34