Krotos Modules 3
Loading...
Searching...
No Matches
krotos::KrotosAudioBuffer Class Reference

#include <KrotosAudioBuffer.h>

Inheritance diagram for krotos::KrotosAudioBuffer:
krotos::KrotosAudioBufferDSP krotos::SampleEngine

Public Types

enum  BufferType { Samples = 0 , Spectral }
 
enum  InterpolationType {
  Linear = 0 , Cubic , Cosine , Cubic3d ,
  NUM_TYPES
}
 

Public Member Functions

 KrotosAudioBuffer ()
 
 KrotosAudioBuffer (int channels, int size)
 
 KrotosAudioBuffer (const AudioBuffer< float > &buffer)
 Creates a krotos buffer from a juce buffer.
 
 KrotosAudioBuffer (const AudioBuffer< float > &buffer, int numOfChannels)
 Creates a krotos buffer from a juce buffer but with a new number of channels, this constructor tries to be as efficient as possible by not reallocating or clearing the extra space.
 
 ~KrotosAudioBuffer ()
 
float getPeak (int channel) const
 
float getRMS (int channel) const
 
void setSize (int newNumChannels, int numSamples, bool keepExistingContent=true, bool clearExtraSpace=true, bool avoidReallocating=true)
 
void setSize (KrotosAudioBuffer &prototypeBuffer)
 
void copyFrom (int destChannel, const float *source, int numSamples)
 
void copyFrom (KrotosAudioBuffer &sourceBuffer)
 
void addFrom (int destChannel, const float *source, int numSamples)
 
void addFrom (KrotosAudioBuffer &srcBuffer)
 
void processWetDry (KrotosAudioBuffer &wetBuffer, SmoothedFloat &wetDryValue)
 
void processGain (SmoothedFloat &gainFactor)
 
void processGain (float gainFactor)
 
void processPan (SmoothedFloat &panValue)
 
bool processClamp (float clampValue)
 
void fillWithNoise ()
 
void processMute (MuteStateMachine &state)
 
void setDataValid (bool state)
 
bool isDataValid () const
 
void setSampleRate (float sampleRate)
 
float getSampleRate (void)
 
void setSourceSampleRate (float sampleRate)
 
float getSourceSampleRate (void)
 
float getNativeNoteFrequency (void)
 
void setInterpolationType (InterpolationType newInterpolationType)
 
StereoSample makeRamp (StereoSample startValue, int samples)
 Create a ramp in the buffer.
 
StereoSample getLastSample ()
 Get the last stereo sample from the audio buffer.
 
StereoSample getInterpolatedSample (double index)
 Get a stereo sample from the audio buffer.
 
float getInterpolatedSampleMono (float playHead)
 
KrotosAudioBuffer getMonoBuffer ()
 
void reverse (int channel, int startSample, int numSamples)
 
void reverse (int startSample, int numSamples)
 
juce::AudioBuffer< float > & getJuceAudioBuffer ()
 
void equalPowerCrossFadeFrom (const KrotosAudioBuffer &previousBuffer)
 
float findAbsMax ()
 
void normaliseTo (float scale)
 

Static Public Member Functions

static KrotosAudioBuffer mixToMono (KrotosAudioBuffer &multiChannelBuffer)
 

Private Member Functions

float getCubic3dInterpolationSample (double playhead, const float *buffer)
 
float getCosineInterpolationSample (double playhead, const float *buffer)
 
float getCubicInterpolationSample (double playhead, const float *buffer)
 

Private Attributes

bool m_isDataValid {true}
 
InterpolationType m_interpoltationType {InterpolationType::Cubic3d}
 
float m_sampleRate {48000.0f}
 
float m_sourceSampleRate {48000.0f}
 

Static Private Attributes

static const float FREQ_Hz_NOTE_C3 {130.813705f}
 
static const float FREQ_Hz_NOTE_D3 {146.83f}
 
static const float FREQ_Hz_NOTE_C4 {261.63f}
 

Member Enumeration Documentation

◆ BufferType

Enumerator
Samples 
Spectral 

◆ InterpolationType

Enumerator
Linear 
Cubic 
Cosine 
Cubic3d 
NUM_TYPES 

Constructor & Destructor Documentation

◆ KrotosAudioBuffer() [1/4]

krotos::KrotosAudioBuffer::KrotosAudioBuffer ( )

◆ KrotosAudioBuffer() [2/4]

krotos::KrotosAudioBuffer::KrotosAudioBuffer ( int channels,
int size )

◆ KrotosAudioBuffer() [3/4]

krotos::KrotosAudioBuffer::KrotosAudioBuffer ( const AudioBuffer< float > & buffer)
inlineexplicit

Creates a krotos buffer from a juce buffer.

Parameters
buffer

◆ KrotosAudioBuffer() [4/4]

krotos::KrotosAudioBuffer::KrotosAudioBuffer ( const AudioBuffer< float > & buffer,
int numOfChannels )
explicit

Creates a krotos buffer from a juce buffer but with a new number of channels, this constructor tries to be as efficient as possible by not reallocating or clearing the extra space.

Parameters
bufferthe juce audio buffer
numOfChannelsthe number of channels you want the krotos buffer to have

◆ ~KrotosAudioBuffer()

krotos::KrotosAudioBuffer::~KrotosAudioBuffer ( )

Member Function Documentation

◆ addFrom() [1/2]

void krotos::KrotosAudioBuffer::addFrom ( int destChannel,
const float * source,
int numSamples )

◆ addFrom() [2/2]

void krotos::KrotosAudioBuffer::addFrom ( KrotosAudioBuffer & srcBuffer)

◆ copyFrom() [1/2]

void krotos::KrotosAudioBuffer::copyFrom ( int destChannel,
const float * source,
int numSamples )

◆ copyFrom() [2/2]

void krotos::KrotosAudioBuffer::copyFrom ( KrotosAudioBuffer & sourceBuffer)

◆ equalPowerCrossFadeFrom()

void krotos::KrotosAudioBuffer::equalPowerCrossFadeFrom ( const KrotosAudioBuffer & previousBuffer)

◆ fillWithNoise()

void krotos::KrotosAudioBuffer::fillWithNoise ( )

◆ findAbsMax()

float krotos::KrotosAudioBuffer::findAbsMax ( )
inline

Find the absolute maximum value of the data in the buffer.

◆ getCosineInterpolationSample()

float krotos::KrotosAudioBuffer::getCosineInterpolationSample ( double playhead,
const float * buffer )
private

◆ getCubic3dInterpolationSample()

float krotos::KrotosAudioBuffer::getCubic3dInterpolationSample ( double playhead,
const float * buffer )
private

◆ getCubicInterpolationSample()

float krotos::KrotosAudioBuffer::getCubicInterpolationSample ( double playhead,
const float * buffer )
private

◆ getInterpolatedSample()

StereoSample krotos::krotos::KrotosAudioBuffer::getInterpolatedSample ( double index)
inline

Get a stereo sample from the audio buffer.

Parameters
indexThe integer part indexes the sample and the fractional part interpolates between the sample and the next sample
Returns
Returns left and right audio values in a StereoSample. If source is mono, returns the same signal in left and right

◆ getInterpolatedSampleMono()

float krotos::KrotosAudioBuffer::getInterpolatedSampleMono ( float playHead)
inline

◆ getJuceAudioBuffer()

juce::AudioBuffer< float > & krotos::KrotosAudioBuffer::getJuceAudioBuffer ( )

◆ getLastSample()

StereoSample krotos::krotos::KrotosAudioBuffer::getLastSample ( )

Get the last stereo sample from the audio buffer.

Returns
Returns left and right audio values in a StereoSample. If source is mono, returns the same signal in left and right

◆ getMonoBuffer()

KrotosAudioBuffer krotos::KrotosAudioBuffer::getMonoBuffer ( )

◆ getNativeNoteFrequency()

float krotos::KrotosAudioBuffer::getNativeNoteFrequency ( void )

◆ getPeak()

float krotos::KrotosAudioBuffer::getPeak ( int channel) const

◆ getRMS()

float krotos::KrotosAudioBuffer::getRMS ( int channel) const

◆ getSampleRate()

float krotos::KrotosAudioBuffer::getSampleRate ( void )

◆ getSourceSampleRate()

float krotos::KrotosAudioBuffer::getSourceSampleRate ( void )

◆ isDataValid()

bool krotos::krotos::KrotosAudioBuffer::isDataValid ( ) const

◆ makeRamp()

StereoSample krotos::krotos::KrotosAudioBuffer::makeRamp ( StereoSample startValue,
int samples )

Create a ramp in the buffer.

Parameters
startValueRamp starts at startValue and heads towards 0
samplesNumber of samples to get from startValue to 0
Returns
Returns last value in buffer in case 0 not reached before the end of the buffer

◆ mixToMono()

KrotosAudioBuffer krotos::KrotosAudioBuffer::mixToMono ( KrotosAudioBuffer & multiChannelBuffer)
static

◆ normaliseTo()

void krotos::KrotosAudioBuffer::normaliseTo ( float scale)

Normalise the buffer to +- scale.

◆ processClamp()

bool krotos::KrotosAudioBuffer::processClamp ( float clampValue)

◆ processGain() [1/2]

void krotos::KrotosAudioBuffer::processGain ( float gainFactor)
Todo
Add smoothed values and LIN to DB or constant energy

◆ processGain() [2/2]

void krotos::krotos::KrotosAudioBuffer::processGain ( SmoothedFloat & gainFactor)

◆ processMute()

void krotos::KrotosAudioBuffer::processMute ( MuteStateMachine & state)

◆ processPan()

void krotos::krotos::KrotosAudioBuffer::processPan ( SmoothedFloat & panValue)
Todo
Add smoothed values and LIN to DB or constant energy

If we got here we are trying to pan a buffer which deosn't have 2 channels

Todo
Do we want to invent a scheme for multi-channel panning?

◆ processWetDry()

void krotos::KrotosAudioBuffer::processWetDry ( KrotosAudioBuffer & wetBuffer,
SmoothedFloat & wetDryValue )
Todo
Add smoothed values and LIN to DB or constant energy

◆ reverse() [1/2]

void krotos::KrotosAudioBuffer::reverse ( int channel,
int startSample,
int numSamples )

◆ reverse() [2/2]

void krotos::krotos::KrotosAudioBuffer::reverse ( int startSample,
int numSamples )

Reverses a part of the buffer.

◆ setDataValid()

void krotos::KrotosAudioBuffer::setDataValid ( bool state)

◆ setInterpolationType()

void krotos::KrotosAudioBuffer::setInterpolationType ( InterpolationType newInterpolationType)
inline

◆ setSampleRate()

void krotos::KrotosAudioBuffer::setSampleRate ( float sampleRate)

◆ setSize() [1/2]

void krotos::KrotosAudioBuffer::setSize ( int newNumChannels,
int numSamples,
bool keepExistingContent = true,
bool clearExtraSpace = true,
bool avoidReallocating = true )

◆ setSize() [2/2]

void krotos::KrotosAudioBuffer::setSize ( KrotosAudioBuffer & prototypeBuffer)

◆ setSourceSampleRate()

void krotos::KrotosAudioBuffer::setSourceSampleRate ( float sampleRate)

Member Data Documentation

◆ FREQ_Hz_NOTE_C3

const float krotos::KrotosAudioBuffer::FREQ_Hz_NOTE_C3 {130.813705f}
staticprivate

◆ FREQ_Hz_NOTE_C4

const float krotos::KrotosAudioBuffer::FREQ_Hz_NOTE_C4 {261.63f}
staticprivate

◆ FREQ_Hz_NOTE_D3

const float krotos::KrotosAudioBuffer::FREQ_Hz_NOTE_D3 {146.83f}
staticprivate

◆ m_interpoltationType

InterpolationType krotos::KrotosAudioBuffer::m_interpoltationType {InterpolationType::Cubic3d}
private

◆ m_isDataValid

bool krotos::KrotosAudioBuffer::m_isDataValid {true}
private

◆ m_sampleRate

float krotos::KrotosAudioBuffer::m_sampleRate {48000.0f}
private

◆ m_sourceSampleRate

float krotos::KrotosAudioBuffer::m_sourceSampleRate {48000.0f}
private

The documentation for this class was generated from the following files: