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

Generates sounds by decimating and reconstructing audio samples. More...

#include <ReformerOscillator.h>

Inheritance diagram for krotos::ReformerOscillator:
krotos::Oscillator

Public Types

enum  GranularParam {
  Start = 0 , PuckX , PuckY , Nearest ,
  StartRand , Size , SizeRand , Rate ,
  RateRand , Width , WidthRand , Pan ,
  PanRand , Detune , DetuneMod , DetuneRand ,
  Level , GranularLevel , LevelMod , LevelRand ,
  Popcorn , Quench , Robin , SALoop ,
  Autoplay , Shape , GrainLim , Tracking ,
  Normalise , Mute , Solo , Proximity ,
  Radius , NUM_PARAMS
}
 

Public Member Functions

 ReformerOscillator ()
 
 ~ReformerOscillator () override
 
void setSampleRate (double sampleRate) override
 Sets the sample rate which the granular oscillator uses to calculate its output.
 
void setBlockSize (size_t blockSize)
 
double getSampleRate () override
 Returns the sample rate which which you set with the setSampleRate method.
 
void setFrequency (float frequency) override
 Sets the target frequency which you want the oscillator to output.
 
float getFrequency () override
 Gets the target frequency which you set with the setFrequency method.
 
void setPhaseOffset (float) override
 
void reset () override
 
void setPhase (double) override
 
double getPhase () override
 
int getNumActiveGrains () override
 Returns the number of grains currently active for this instance of the oscillator.
 
StereoSample getNextStereoSample (size_t sampleIndex) override
 Updates the granular engine and returns the next audio value.
 
void setGranularParameter (size_t paramIndex, const float *newValue)
 Updates the granular engine and returns the next audio value.
 
void setGranularParameters (std::vector< const float * > &newParams)
 Sets multiple internal parameter to new values.
 
void setSampleData (SampleEngine *sampleEngine)
 Sets the oscillator's internal reference to the SampleEngine structure it is to use.
 
void startNote (int midiNote, float velocity, int voiceIndex)
 Starts the oscillator playing, usually called by key down event.
 
const float getVelocity ()
 Returns the value of the velocity as a float in [0...1].
 
void stopNote ()
 Signals the oscillator to begin key up behaviour, usually called by key up event The oscillator may continue playing if it is generating a tail.
 
void clearNote ()
 Signals the oscillator to stop immediately, and return any grains to pool.
 
int getVoiceIndex () const
 
bool isAutoplayEnabled () const
 
bool isDrone () const
 
bool isStopped () const
 
bool isKeyDown () const
 
- Public Member Functions inherited from krotos::Oscillator
virtual ~Oscillator ()=default
 

Private Member Functions

void flushGranular ()
 
float cube (float val)
 
void setTaggingType (bool isOn)
 
void setTrackingEnable (bool isOn)
 
void setHardLoopEnable (bool isOn)
 
void killNANs (StereoSample &sample)
 
GrainlaunchGrain (float paramSize, float paramStart, float paramSpray, Grain::Flavour flavour, float gain=-1.f)
 
double calculatePlayheadPosition (double startPosition, float halfSpray, float referenceGrainsize)
 
float getRateRandFactor ()
 
StereoSample getNextStereoGranularSample ()
 
void generateGrains (StereoSample &sampleAccumulator)
 

Private Attributes

juce::Random m_rand {1234}
 
PhaseGenerator m_voicePhase
 
PhaseGenerator m_popcornTimer
 
float m_playbackHz {0.0f}
 
float m_playbackHzDetuned {0.0f}
 
double m_samplerate {48000.0}
 
float m_grainRate {0.0f}
 
float m_StartIndex {0.0f}
 
AudioDescriptor m_closestDescriptor
 
SampleEnginem_sampleEngine {nullptr}
 
std::vector< Grain * > m_activeGrains
 
int m_length {0}
 
std::vector< const float * > m_parameters
 
bool m_stopped {false}
 
bool m_keyDown {false}
 
Point< float > m_puckPosition {0.f, 0.f}
 
size_t m_blockSize {128}
 
int m_voiceIndex {-1}
 
SlewLimiter m_channelCrossfade
 
bool m_taggingType {false}
 
bool m_trackingEnable {false}
 
bool m_loopingEnable {false}
 
bool m_normalisationEnable {false}
 
size_t m_sampleIndex {0}
 
float m_velocity {1.0f}
 
float m_detuneModVal {0.0f}
 
const float AMPLITUDE_FIDDLE_FACTOR {0.6f}
 
const float FADE_POINT_MIN {0.000001f}
 
bool m_isDrone {false}
 
bool m_autoplayEnabled {false}
 
size_t m_nearestGrainIndex {0}
 
size_t m_nearestPopGrainIndex {0}
 
std::mt19937 m_g
 
std::size_t m_k {1}
 
std::deque< size_t > m_grainHistory
 
bool m_proximityMode = false
 
bool m_proximityTrigger = false
 

Detailed Description

Generates sounds by decimating and reconstructing audio samples.

Member Enumeration Documentation

◆ GranularParam

Enumerates the parameters which are used to control generation of grains

Enumerator
Start 
PuckX 
PuckY 
Nearest 
StartRand 
Size 
SizeRand 
Rate 
RateRand 
Width 
WidthRand 
Pan 
PanRand 
Detune 
DetuneMod 
DetuneRand 
Level 
GranularLevel 
LevelMod 
LevelRand 
Popcorn 
Quench 
Robin 
SALoop 
Autoplay 
Shape 
GrainLim 
Tracking 
Normalise 
Mute 
Solo 
Proximity 
Radius 
NUM_PARAMS 

Constructor & Destructor Documentation

◆ ReformerOscillator()

krotos::ReformerOscillator::ReformerOscillator ( )

ReformerOscillator Constructor

◆ ~ReformerOscillator()

krotos::ReformerOscillator::~ReformerOscillator ( )
inlineoverride

ReformerOscillator Destructor

Member Function Documentation

◆ calculatePlayheadPosition()

double krotos::ReformerOscillator::calculatePlayheadPosition ( double startPosition,
float halfSpray,
float referenceGrainsize )
private

◆ clearNote()

void krotos::ReformerOscillator::clearNote ( )

Signals the oscillator to stop immediately, and return any grains to pool.

◆ cube()

float krotos::ReformerOscillator::cube ( float val)
inlineprivate

◆ flushGranular()

void krotos::ReformerOscillator::flushGranular ( )
private

◆ generateGrains()

void krotos::ReformerOscillator::generateGrains ( StereoSample & sampleAccumulator)
private

Accumulates audio from all the playing grains

◆ getFrequency()

float krotos::ReformerOscillator::getFrequency ( )
inlineoverridevirtual

Gets the target frequency which you set with the setFrequency method.

Returns
frequency Frequency in Hz

Implements krotos::Oscillator.

◆ getNextStereoGranularSample()

StereoSample krotos::ReformerOscillator::getNextStereoGranularSample ( )
inlineprivate

◆ getNextStereoSample()

StereoSample krotos::ReformerOscillator::getNextStereoSample ( size_t sampleIndex)
inlineoverridevirtual

Updates the granular engine and returns the next audio value.

Returns
A stereo pair of samples

Implements krotos::Oscillator.

◆ getNumActiveGrains()

int krotos::ReformerOscillator::getNumActiveGrains ( )
inlineoverridevirtual

Returns the number of grains currently active for this instance of the oscillator.

Returns
frequency Frequency in Hz

Reimplemented from krotos::Oscillator.

◆ getPhase()

double krotos::ReformerOscillator::getPhase ( )
inlineoverridevirtual

Implements krotos::Oscillator.

◆ getRateRandFactor()

float krotos::ReformerOscillator::getRateRandFactor ( )
inlineprivate

◆ getSampleRate()

double krotos::ReformerOscillator::getSampleRate ( )
inlineoverridevirtual

Returns the sample rate which which you set with the setSampleRate method.

Returns
Sample rate in Hz

Implements krotos::Oscillator.

◆ getVelocity()

const float krotos::ReformerOscillator::getVelocity ( )

Returns the value of the velocity as a float in [0...1].

◆ getVoiceIndex()

int krotos::ReformerOscillator::getVoiceIndex ( ) const
inline

◆ isAutoplayEnabled()

bool krotos::ReformerOscillator::isAutoplayEnabled ( ) const
inline

◆ isDrone()

bool krotos::ReformerOscillator::isDrone ( ) const
inline

◆ isKeyDown()

bool krotos::ReformerOscillator::isKeyDown ( ) const
inline

◆ isStopped()

bool krotos::ReformerOscillator::isStopped ( ) const
inline

◆ killNANs()

void krotos::ReformerOscillator::killNANs ( StereoSample & sample)
inlineprivate

◆ launchGrain()

Grain * krotos::ReformerOscillator::launchGrain ( float paramSize,
float paramStart,
float paramSpray,
Grain::Flavour flavour,
float gain = -1.f )
private

◆ reset()

void krotos::ReformerOscillator::reset ( )
inlineoverridevirtual

Resets the phase offset for PWM to 0

Implements krotos::Oscillator.

◆ setBlockSize()

void krotos::ReformerOscillator::setBlockSize ( size_t blockSize)
inline

◆ setFrequency()

void krotos::ReformerOscillator::setFrequency ( float frequency)
inlineoverridevirtual

Sets the target frequency which you want the oscillator to output.

Parameters
frequencyFrequency in Hz

Implements krotos::Oscillator.

◆ setGranularParameter()

void krotos::ReformerOscillator::setGranularParameter ( size_t paramIndex,
const float * newValue )

Updates the granular engine and returns the next audio value.

Returns
A mono sample

Sets an internal parameter to a new value

Parameters
paramIndexThe index of the parameter (enum GranularParam)
newValueThe new value to set the parameter with

◆ setGranularParameters()

void krotos::ReformerOscillator::setGranularParameters ( std::vector< const float * > & newParams)
inline

Sets multiple internal parameter to new values.

Parameters
newParamsA vector containing new parameters, must be ordered as in enum GranularParam

◆ setHardLoopEnable()

void krotos::ReformerOscillator::setHardLoopEnable ( bool isOn)
inlineprivate

◆ setPhase()

void krotos::ReformerOscillator::setPhase ( double )
inlineoverridevirtual

Implements krotos::Oscillator.

◆ setPhaseOffset()

void krotos::ReformerOscillator::setPhaseOffset ( float )
inlineoverridevirtual

The following overridden methods are interface methods which are not used in the granular oscillator at present

Implements krotos::Oscillator.

◆ setSampleData()

void krotos::ReformerOscillator::setSampleData ( SampleEngine * sampleEngine)

Sets the oscillator's internal reference to the SampleEngine structure it is to use.

Parameters
sampleEnginePointer to an instance of SampleEngine

◆ setSampleRate()

void krotos::ReformerOscillator::setSampleRate ( double sampleRate)
inlineoverridevirtual

Sets the sample rate which the granular oscillator uses to calculate its output.

The following overridden methods implement the Oscillator interface

Parameters
sampleRateSample rate in Hz

Implements krotos::Oscillator.

◆ setTaggingType()

void krotos::ReformerOscillator::setTaggingType ( bool isOn)
inlineprivate

◆ setTrackingEnable()

void krotos::ReformerOscillator::setTrackingEnable ( bool isOn)
inlineprivate

◆ startNote()

void krotos::ReformerOscillator::startNote ( int midiNote,
float velocity,
int voiceIndex )

Starts the oscillator playing, usually called by key down event.

Parameters
velocityValue of velocity in [0...1]

◆ stopNote()

void krotos::ReformerOscillator::stopNote ( )

Signals the oscillator to begin key up behaviour, usually called by key up event The oscillator may continue playing if it is generating a tail.

Member Data Documentation

◆ AMPLITUDE_FIDDLE_FACTOR

const float krotos::ReformerOscillator::AMPLITUDE_FIDDLE_FACTOR {0.6f}
private

◆ FADE_POINT_MIN

const float krotos::ReformerOscillator::FADE_POINT_MIN {0.000001f}
private

◆ m_activeGrains

std::vector<Grain*> krotos::ReformerOscillator::m_activeGrains
private

◆ m_autoplayEnabled

bool krotos::ReformerOscillator::m_autoplayEnabled {false}
private

◆ m_blockSize

size_t krotos::ReformerOscillator::m_blockSize {128}
private

◆ m_channelCrossfade

SlewLimiter krotos::ReformerOscillator::m_channelCrossfade
private

◆ m_closestDescriptor

AudioDescriptor krotos::ReformerOscillator::m_closestDescriptor
private

◆ m_detuneModVal

float krotos::ReformerOscillator::m_detuneModVal {0.0f}
private

◆ m_g

std::mt19937 krotos::ReformerOscillator::m_g
private

◆ m_grainHistory

std::deque<size_t> krotos::ReformerOscillator::m_grainHistory
private

◆ m_grainRate

float krotos::ReformerOscillator::m_grainRate {0.0f}
private

◆ m_isDrone

bool krotos::ReformerOscillator::m_isDrone {false}
private

◆ m_k

std::size_t krotos::ReformerOscillator::m_k {1}
private

◆ m_keyDown

bool krotos::ReformerOscillator::m_keyDown {false}
private

◆ m_length

int krotos::ReformerOscillator::m_length {0}
private

◆ m_loopingEnable

bool krotos::ReformerOscillator::m_loopingEnable {false}
private

◆ m_nearestGrainIndex

size_t krotos::ReformerOscillator::m_nearestGrainIndex {0}
private

◆ m_nearestPopGrainIndex

size_t krotos::ReformerOscillator::m_nearestPopGrainIndex {0}
private

◆ m_normalisationEnable

bool krotos::ReformerOscillator::m_normalisationEnable {false}
private

◆ m_parameters

std::vector<const float*> krotos::ReformerOscillator::m_parameters
private

◆ m_playbackHz

float krotos::ReformerOscillator::m_playbackHz {0.0f}
private

◆ m_playbackHzDetuned

float krotos::ReformerOscillator::m_playbackHzDetuned {0.0f}
private

◆ m_popcornTimer

PhaseGenerator krotos::ReformerOscillator::m_popcornTimer
private

◆ m_proximityMode

bool krotos::ReformerOscillator::m_proximityMode = false
private

◆ m_proximityTrigger

bool krotos::ReformerOscillator::m_proximityTrigger = false
private

◆ m_puckPosition

Point<float> krotos::ReformerOscillator::m_puckPosition {0.f, 0.f}
private

◆ m_rand

juce::Random krotos::ReformerOscillator::m_rand {1234}
private

◆ m_sampleEngine

SampleEngine* krotos::ReformerOscillator::m_sampleEngine {nullptr}
private

◆ m_sampleIndex

size_t krotos::ReformerOscillator::m_sampleIndex {0}
private

◆ m_samplerate

double krotos::ReformerOscillator::m_samplerate {48000.0}
private

◆ m_StartIndex

float krotos::ReformerOscillator::m_StartIndex {0.0f}
private

◆ m_stopped

bool krotos::ReformerOscillator::m_stopped {false}
private

◆ m_taggingType

bool krotos::ReformerOscillator::m_taggingType {false}
private

◆ m_trackingEnable

bool krotos::ReformerOscillator::m_trackingEnable {false}
private

◆ m_velocity

float krotos::ReformerOscillator::m_velocity {1.0f}
private

◆ m_voiceIndex

int krotos::ReformerOscillator::m_voiceIndex {-1}
private

◆ m_voicePhase

PhaseGenerator krotos::ReformerOscillator::m_voicePhase
private

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