Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
FormantShifterLogger Class Reference

#include <FormantShifterLogger.h>

Inheritance diagram for FormantShifterLogger:
[legend]
Collaboration diagram for FormantShifterLogger:
[legend]

Public Member Functions

 FormantShifterLogger (int sampleRate, int logTimeInSamples)
 
 ~FormantShifterLogger () override
 
void NewSamplesComing (int sampleCount) override
 
void Log (int value, const char *name) const override
 
void Log (const float *samples, size_t size, const char *name) const override
 
void Log (const std::complex< float > *samples, size_t size, const char *name, const std::function< float(const std::complex< float > &)> &transform) const override
 
void ProcessFinished (std::complex< float > *spectrum, size_t fftSize) override
 If not already, disables the logging and marks the spectrum with an audible event to make clear where in the signal the logging took place. (Of course not for use in production :D) More...
 
- Public Member Functions inherited from FormantShifterLoggerInterface
virtual ~FormantShifterLoggerInterface ()=default
 
virtual void NewSamplesComing (int sampleCount)=0
 
virtual void Log (int value, const char *name) const =0
 
virtual void Log (const float *samples, size_t size, const char *name) const =0
 
virtual void Log (const std::complex< float > *samples, size_t size, const char *name, const std::function< float(const std::complex< float > &)> &transform) const =0
 
virtual void ProcessFinished (std::complex< float > *spectrum, size_t fftSize)=0
 If not already, disables the logging and marks the spectrum with an audible event to make clear where in the signal the logging took place. (Of course not for use in production :D) More...
 

Private Attributes

const int mSampleRate
 
const int mLogSample
 
bool mWasLogged = false
 
std::unique_ptr< std::ofstream > mOfs
 
int mSampleCount = 0
 

Detailed Description


Audacity: A Digital Audio Editor

FormantShifterLogger.h

Implements FormantShifterLoggerInterface, and also provides tuning utilities to override algorithm parameters.

Matthieu Hodgkinson

Definition at line 20 of file FormantShifterLogger.h.

Constructor & Destructor Documentation

◆ FormantShifterLogger()

FormantShifterLogger::FormantShifterLogger ( int  sampleRate,
int  logTimeInSamples 
)

Definition at line 38 of file FormantShifterLogger.cpp.

◆ ~FormantShifterLogger()

FormantShifterLogger::~FormantShifterLogger ( )
override

Definition at line 44 of file FormantShifterLogger.cpp.

45{
46}

Member Function Documentation

◆ Log() [1/3]

void FormantShifterLogger::Log ( const float *  samples,
size_t  size,
const char *  name 
) const
overridevirtual

Implements FormantShifterLoggerInterface.

Definition at line 68 of file FormantShifterLogger.cpp.

70{
71 if (!mOfs)
72 // Keep it lightweight if we're not logging.
73 return;
74 PrintPythonVector(*mOfs, samples, samples + size, name);
75}
const TranslatableString name
Definition: Distortion.cpp:76
std::unique_ptr< std::ofstream > mOfs
void PrintPythonVector(std::ofstream &ofs, Iterator begin, Iterator end, const char *name)

References mOfs, name, anonymous_namespace{FormantShifterLogger.cpp}::PrintPythonVector(), and size.

Here is the call graph for this function:

◆ Log() [2/3]

void FormantShifterLogger::Log ( const std::complex< float > *  samples,
size_t  size,
const char *  name,
const std::function< float(const std::complex< float > &)> &  transform 
) const
overridevirtual

Implements FormantShifterLoggerInterface.

Definition at line 77 of file FormantShifterLogger.cpp.

80{
81 if (!mOfs)
82 return;
83 std::vector<float> v(cvSize);
84 std::transform(cv, cv + cvSize, v.begin(), transform);
85 PrintPythonVector(*mOfs, v.begin(), v.end(), name);
86}

References mOfs, name, and anonymous_namespace{FormantShifterLogger.cpp}::PrintPythonVector().

Here is the call graph for this function:

◆ Log() [3/3]

void FormantShifterLogger::Log ( int  value,
const char *  name 
) const
overridevirtual

Implements FormantShifterLoggerInterface.

Definition at line 62 of file FormantShifterLogger.cpp.

63{
64 if (mOfs)
65 *mOfs << name << " = " << value << "\n";
66}

References mOfs, and name.

◆ NewSamplesComing()

void FormantShifterLogger::NewSamplesComing ( int  sampleCount)
overridevirtual

Implements FormantShifterLoggerInterface.

Definition at line 48 of file FormantShifterLogger.cpp.

49{
52 {
53 // Ready for logging.
54 mOfs = std::make_unique<std::ofstream>(
56 "/FormantShifterLog.py");
57 *mOfs << "sampleRate = " << mSampleRate << "\n";
58 mWasLogged = true;
59 }
60}
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19

References TimeAndPitchExperimentalSettings::GetLogDir(), mLogSample, mOfs, mSampleCount, mSampleRate, and mWasLogged.

Here is the call graph for this function:

◆ ProcessFinished()

void FormantShifterLogger::ProcessFinished ( std::complex< float > *  spectrum,
size_t  fftSize 
)
overridevirtual

If not already, disables the logging and marks the spectrum with an audible event to make clear where in the signal the logging took place. (Of course not for use in production :D)

Implements FormantShifterLoggerInterface.

Definition at line 88 of file FormantShifterLogger.cpp.

90{
91 if (!mOfs)
92 return;
93 // Such a spectrum of only (1 + 0j) is that of a click, which should be
94 // audible ...
95 std::fill(spectrum, spectrum + fftSize / 2 + 1, 1.f);
96 mOfs.reset();
97}

References mOfs.

Member Data Documentation

◆ mLogSample

const int FormantShifterLogger::mLogSample
private

Definition at line 45 of file FormantShifterLogger.h.

Referenced by NewSamplesComing().

◆ mOfs

std::unique_ptr<std::ofstream> FormantShifterLogger::mOfs
private

Definition at line 47 of file FormantShifterLogger.h.

Referenced by Log(), NewSamplesComing(), and ProcessFinished().

◆ mSampleCount

int FormantShifterLogger::mSampleCount = 0
private

Definition at line 48 of file FormantShifterLogger.h.

Referenced by NewSamplesComing().

◆ mSampleRate

const int FormantShifterLogger::mSampleRate
private

Definition at line 44 of file FormantShifterLogger.h.

Referenced by NewSamplesComing().

◆ mWasLogged

bool FormantShifterLogger::mWasLogged = false
private

Definition at line 46 of file FormantShifterLogger.h.

Referenced by NewSamplesComing().


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