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

The processing power of the KwidgetRecorder that performs the recording of the plugins output and writes it to a temp File in a temp directory. More...

#include <KwidgetProcessor_Recorder.h>

Inheritance diagram for krotos::KwidgetProcessor_Recorder:
krotos::KwidgetProcessor

Public Types

using Parameters = Kwidget_Recorder::Parameters
 

Public Member Functions

 KwidgetProcessor_Recorder (Kwidget &owner)
 
 ~KwidgetProcessor_Recorder ()
 
void prepare (double sampleRate, int samplesPerBlock) override
 
void process (AudioBuffer< float > &buffer) override
 
void noteOn (int midiNoteNumber, float velocity, int) override
 
void noteOff (float velocity) override
 
void stopRecording ()
 
- Public Member Functions inherited from krotos::KwidgetProcessor
 KwidgetProcessor (Kwidget &owner)
 
 ~KwidgetProcessor () override=default
 
void prepareToPlay (double, int) override final
 
void processBlock (AudioBuffer< float > &buffer, MidiBuffer &) override final
 
virtual bool isActive ()
 
virtual void noteCleared ()
 
std::shared_ptr< KAttachmentgetAttachment (const String &paramID)
 
int getNumModulators () const
 
ModulatorgetModulator (int index)
 
const String & getKwidgetType () const
 
const String & getKwidgetID () const
 
void updateAttachments ()
 

Private Member Functions

bool bufferIsSilent (AudioSampleBuffer &inputBuffer)
 
void stop ()
 
void startRecording ()
 
void resetWriter ()
 
void run () override
 
void updateReleaseTime ()
 Update the cached release time from the internal settings file.
 

Private Attributes

volatile std::atomic< bool > m_recording {false}
 
volatile std::atomic< bool > m_stopRecordingRequest
 
volatile std::atomic< int > m_inactiveFramesBeforeStop {0}
 
int m_lastSamplesPerBlock {0}
 
int m_postRollSamples {0}
 
int m_tailFramesCounter {0}
 
bool m_recordingPending {false}
 
File m_writingFile
 
String m_latestFileName
 
double m_sampleRate {0.0}
 
TimeSliceThread m_backgroundThread {getOwner().getKwidgetID() + "thread"}
 
std::unique_ptr< AudioFormatWriter::ThreadedWriter > m_threadedWriter
 
CriticalSection m_writerLock
 
std::atomic< AudioFormatWriter::ThreadedWriter * > m_activeWriter {nullptr}
 
const int NUM_BUFFER_SAMPLES {32768}
 
const int NUM_BUFFER_CHANNELS {2}
 
Uuid m_uniqueId
 
File m_tempDir
 
const float minus_infinity_dB = -100.0f
 
Kwidget_Recorderm_kwidgetRecorder
 

Additional Inherited Members

- Protected Member Functions inherited from krotos::KwidgetProcessor
void nextBlock (int numSamples)
 
void nextSample ()
 
void addModulator (bool useAudioRate)
 
void addParameterAttachments (std::vector< AttachmentInfo >)
 
void addParameterCallback (const String &paramID, std::function< void(float)> callback)
 
KwidgetgetOwner () const
 

Detailed Description

The processing power of the KwidgetRecorder that performs the recording of the plugins output and writes it to a temp File in a temp directory.

This class is designed to perform the recording in a multithreaded way. It uses a JUCE::ThreadWriter object that provides a FIFO for an AudioFormatWriter, allowing you to push incoming data into a buffer which will be flushed to disk by a background thread.

It is written as a passive module responding to midi Messages from outside, namely note on and note off, global AutoPlay changes and Timers killing the recording process.

Member Typedef Documentation

◆ Parameters

Constructor & Destructor Documentation

◆ KwidgetProcessor_Recorder()

krotos::KwidgetProcessor_Recorder::KwidgetProcessor_Recorder ( Kwidget & owner)

◆ ~KwidgetProcessor_Recorder()

krotos::KwidgetProcessor_Recorder::~KwidgetProcessor_Recorder ( )

Member Function Documentation

◆ bufferIsSilent()

bool krotos::KwidgetProcessor_Recorder::bufferIsSilent ( AudioSampleBuffer & inputBuffer)
private

Returns whether the contents of the supplied buffer is silence - TODO: consider placing this into the AudioBuffer class

Parameters
inputBufferA reference to the AudioSampleBuffer which you want to test
Returns
boolean true if silent

◆ noteOff()

void krotos::KwidgetProcessor_Recorder::noteOff ( float velocity)
overridevirtual

Override this method to process a note off event, if necessary.

Parameters
velocityThe relative velocity of the note event (between 0 and 1).

Reimplemented from krotos::KwidgetProcessor.

◆ noteOn()

void krotos::KwidgetProcessor_Recorder::noteOn ( int midiNoteNumber,
float velocity,
int voiceIndex )
overridevirtual

Override this method to process a note on event, if necessary.

Parameters
midiNoteNumberThe integer value of the MIDI note.
See also
juce::MidiMessage::getMidiNoteInHertz()

velocity The relative velocity of the note event (between 0 and 1). voiceIndex Optionally pass in a voice index, used ultimately to identify the voice associated with a playing note Defaults to -1 if unused

Reimplemented from krotos::KwidgetProcessor.

◆ prepare()

void krotos::KwidgetProcessor_Recorder::prepare ( double sampleRate,
int samplesPerBlock )
overridevirtual

Override this method to inform your processor of the sample rate and maximum block size.

Implements krotos::KwidgetProcessor.

◆ process()

void krotos::KwidgetProcessor_Recorder::process ( AudioBuffer< float > & buffer)
overridevirtual

Override this method to process a buffer of audio.

Implements krotos::KwidgetProcessor.

◆ resetWriter()

void krotos::KwidgetProcessor_Recorder::resetWriter ( )
private

Clear pointer to m_activeWriter and reset threadedWriter.

◆ run()

void krotos::KwidgetProcessor_Recorder::run ( )
overrideprivate

◆ startRecording()

void krotos::KwidgetProcessor_Recorder::startRecording ( )
private

◆ stop()

void krotos::KwidgetProcessor_Recorder::stop ( )
private

Stop audio recording, and copy the writing file over to the temp file.

◆ stopRecording()

void krotos::KwidgetProcessor_Recorder::stopRecording ( )

Start the thread which will stop the recording

◆ updateReleaseTime()

void krotos::KwidgetProcessor_Recorder::updateReleaseTime ( )
private

Update the cached release time from the internal settings file.

Member Data Documentation

◆ m_activeWriter

std::atomic<AudioFormatWriter::ThreadedWriter*> krotos::KwidgetProcessor_Recorder::m_activeWriter {nullptr}
private

◆ m_backgroundThread

TimeSliceThread krotos::KwidgetProcessor_Recorder::m_backgroundThread {getOwner().getKwidgetID() + "thread"}
private

◆ m_inactiveFramesBeforeStop

volatile std::atomic<int> krotos::KwidgetProcessor_Recorder::m_inactiveFramesBeforeStop {0}
private

◆ m_kwidgetRecorder

Kwidget_Recorder* krotos::KwidgetProcessor_Recorder::m_kwidgetRecorder
private

◆ m_lastSamplesPerBlock

int krotos::KwidgetProcessor_Recorder::m_lastSamplesPerBlock {0}
private

◆ m_latestFileName

String krotos::KwidgetProcessor_Recorder::m_latestFileName
private

◆ m_postRollSamples

int krotos::KwidgetProcessor_Recorder::m_postRollSamples {0}
private

◆ m_recording

volatile std::atomic<bool> krotos::KwidgetProcessor_Recorder::m_recording {false}
private

◆ m_recordingPending

bool krotos::KwidgetProcessor_Recorder::m_recordingPending {false}
private

◆ m_sampleRate

double krotos::KwidgetProcessor_Recorder::m_sampleRate {0.0}
private

◆ m_stopRecordingRequest

volatile std::atomic<bool> krotos::KwidgetProcessor_Recorder::m_stopRecordingRequest
private
Initial value:
{
false}

◆ m_tailFramesCounter

int krotos::KwidgetProcessor_Recorder::m_tailFramesCounter {0}
private

◆ m_tempDir

File krotos::KwidgetProcessor_Recorder::m_tempDir
private

◆ m_threadedWriter

std::unique_ptr<AudioFormatWriter::ThreadedWriter> krotos::KwidgetProcessor_Recorder::m_threadedWriter
private

◆ m_uniqueId

Uuid krotos::KwidgetProcessor_Recorder::m_uniqueId
private

◆ m_writerLock

CriticalSection krotos::KwidgetProcessor_Recorder::m_writerLock
private

◆ m_writingFile

File krotos::KwidgetProcessor_Recorder::m_writingFile
private

◆ minus_infinity_dB

const float krotos::KwidgetProcessor_Recorder::minus_infinity_dB = -100.0f
private

◆ NUM_BUFFER_CHANNELS

const int krotos::KwidgetProcessor_Recorder::NUM_BUFFER_CHANNELS {2}
private

◆ NUM_BUFFER_SAMPLES

const int krotos::KwidgetProcessor_Recorder::NUM_BUFFER_SAMPLES {32768}
private

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