Audacity 3.2.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
NyquistEffect::NyxContext Struct Reference
Collaboration diagram for NyquistEffect::NyxContext:
[legend]

Public Types

using ProgressReport = std::function< bool(double)>
 
using Buffer = std::unique_ptr< float[]>
 

Public Member Functions

 NyxContext (ProgressReport progressReport, double scale, double progressTot)
 
int GetCallback (float *buffer, int channel, int64_t start, int64_t len, int64_t totlen)
 
int PutCallback (float *buffer, int channel, int64_t start, int64_t len, int64_t totlen)
 

Static Public Member Functions

static int StaticGetCallback (float *buffer, int channel, int64_t start, int64_t len, int64_t totlen, void *userdata)
 
static int StaticPutCallback (float *buffer, int channel, int64_t start, int64_t len, int64_t totlen, void *userdata)
 

Public Attributes

WaveTrackmCurChannelGroup {}
 
WaveChannelmCurTrack [2] {}
 
sampleCount mCurStart {}
 
unsigned mCurNumChannels {}
 Not used in the callbacks. More...
 
Buffer mCurBuffer [2]
 used only in GetCallback More...
 
sampleCount mCurBufferStart [2] {}
 
size_t mCurBufferLen [2] {}
 
sampleCount mCurLen {}
 
WaveTrack::Holder mOutputTrack
 
double mProgressIn {}
 
double mProgressOut {}
 
const ProgressReport mProgressReport
 
const double mScale
 
const double mProgressTot
 
std::exception_ptr mpException {}
 

Detailed Description

Reads and writes Audacity's track objects, interchanging with Nyquist sound objects (implemented in the library layer written in C)

Definition at line 668 of file Nyquist.cpp.

Member Typedef Documentation

◆ Buffer

using NyquistEffect::NyxContext::Buffer = std::unique_ptr<float[]>

Definition at line 692 of file Nyquist.cpp.

◆ ProgressReport

using NyquistEffect::NyxContext::ProgressReport = std::function<bool(double)>

Definition at line 669 of file Nyquist.cpp.

Constructor & Destructor Documentation

◆ NyxContext()

NyquistEffect::NyxContext::NyxContext ( ProgressReport  progressReport,
double  scale,
double  progressTot 
)
inline

Definition at line 671 of file Nyquist.cpp.

672 : mProgressReport{ move(progressReport) }
673 , mScale{ scale }
674 , mProgressTot{ progressTot }
675 {}
const double mProgressTot
Definition: Nyquist.cpp:705
const ProgressReport mProgressReport
Definition: Nyquist.cpp:703

Member Function Documentation

◆ GetCallback()

int NyquistEffect::NyxContext::GetCallback ( float *  buffer,
int  channel,
int64_t  start,
int64_t  len,
int64_t  totlen 
)

Definition at line 2562 of file Nyquist.cpp.

2564{
2565 if (mCurBuffer[ch]) {
2566 if ((mCurStart + start) < mCurBufferStart[ch] ||
2567 (mCurStart + start) + len >
2568 mCurBufferStart[ch] + mCurBufferLen[ch]) {
2569 mCurBuffer[ch].reset();
2570 }
2571 }
2572
2573 if (!mCurBuffer[ch]) {
2574 mCurBufferStart[ch] = (mCurStart + start);
2576
2577 if (mCurBufferLen[ch] < (size_t) len)
2578 mCurBufferLen[ch] = mCurTrack[ch]->GetIdealBlockSize();
2579
2582
2583 // C++20
2584 // mCurBuffer[ch] = std::make_unique_for_overwrite(mCurBufferLen[ch]);
2585 mCurBuffer[ch] = Buffer{ safenew float[ mCurBufferLen[ch] ] };
2586 try {
2587 mCurTrack[ch]->GetFloats( mCurBuffer[ch].get(),
2589 }
2590 catch ( ... ) {
2591 // Save the exception object for re-throw when out of the library
2592 mpException = std::current_exception();
2593 return -1;
2594 }
2595 }
2596
2597 // We have guaranteed above that this is nonnegative and bounded by
2598 // mCurBufferLen[ch]:
2599 auto offset = (mCurStart + start - mCurBufferStart[ch]).as_size_t();
2600 const void *src = &mCurBuffer[ch][offset];
2601 std::memcpy(buffer, src, len * sizeof(float));
2602
2603 if (ch == 0) {
2604 double progress = mScale * ((start + len) / mCurLen.as_double());
2605 if (progress > mProgressIn)
2606 mProgressIn = progress;
2608 return -1;
2609 }
2610
2611 return 0;
2612}
#define safenew
Definition: MemoryX.h:10
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:22
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=FillFormat::fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
"narrow" overload fetches from the unique channel
Definition: WaveTrack.h:129
size_t GetBestBlockSize(sampleCount t) const
A hint for sizing of well aligned fetches.
Definition: WaveTrack.h:850
double as_double() const
Definition: SampleCount.h:46
std::exception_ptr mpException
Definition: Nyquist.cpp:707
WaveChannel * mCurTrack[2]
Definition: Nyquist.cpp:687
std::unique_ptr< float[]> Buffer
Definition: Nyquist.cpp:692
Buffer mCurBuffer[2]
used only in GetCallback
Definition: Nyquist.cpp:693
sampleCount mCurBufferStart[2]
Definition: Nyquist.cpp:694

References limitSampleBufferSize(), and safenew.

Referenced by StaticGetCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PutCallback()

int NyquistEffect::NyxContext::PutCallback ( float *  buffer,
int  channel,
int64_t  start,
int64_t  len,
int64_t  totlen 
)

Definition at line 2621 of file Nyquist.cpp.

2623{
2624 // Don't let C++ exceptions propagate through the Nyquist library
2625 return GuardedCall<int>( [&] {
2626 if (channel == 0) {
2627 double progress = mScale * ((float)(start + len) / totlen);
2628 if (progress > mProgressOut)
2629 mProgressOut = progress;
2631 return -1;
2632 }
2633
2634 auto iChannel = mOutputTrack->Channels().begin();
2635 std::advance(iChannel, channel);
2636 const auto pChannel = *iChannel;
2637 pChannel->Append((samplePtr)buffer, floatSample, len);
2638
2639 return 0; // success
2640 }, MakeSimpleGuard(-1)); // translate all exceptions into failure
2641}
SimpleGuard< R > MakeSimpleGuard(R value) noexcept(noexcept(SimpleGuard< R >{ value }))
Convert a value to a handler function returning that value, suitable for GuardedCall<R>
char * samplePtr
Definition: SampleFormat.h:57
WaveTrack::Holder mOutputTrack
Definition: Nyquist.cpp:698

References floatSample, anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, and MakeSimpleGuard().

Referenced by StaticPutCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StaticGetCallback()

int NyquistEffect::NyxContext::StaticGetCallback ( float *  buffer,
int  channel,
int64_t  start,
int64_t  len,
int64_t  totlen,
void *  userdata 
)
static

Definition at line 2555 of file Nyquist.cpp.

2557{
2558 auto This = static_cast<NyxContext*>(userdata);
2559 return This->GetCallback(buffer, channel, start, len, totlen);
2560}
NyxContext(ProgressReport progressReport, double scale, double progressTot)
Definition: Nyquist.cpp:671

References GetCallback().

Referenced by NyquistEffect::ProcessOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StaticPutCallback()

int NyquistEffect::NyxContext::StaticPutCallback ( float *  buffer,
int  channel,
int64_t  start,
int64_t  len,
int64_t  totlen,
void *  userdata 
)
static

Definition at line 2614 of file Nyquist.cpp.

2616{
2617 auto This = static_cast<NyxContext*>(userdata);
2618 return This->PutCallback(buffer, channel, start, len, totlen);
2619}

References PutCallback().

Referenced by NyquistEffect::ProcessOne().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mCurBuffer

Buffer NyquistEffect::NyxContext::mCurBuffer[2]

used only in GetCallback

Definition at line 693 of file Nyquist.cpp.

◆ mCurBufferLen

size_t NyquistEffect::NyxContext::mCurBufferLen[2] {}

Definition at line 695 of file Nyquist.cpp.

◆ mCurBufferStart

sampleCount NyquistEffect::NyxContext::mCurBufferStart[2] {}

Definition at line 694 of file Nyquist.cpp.

◆ mCurChannelGroup

WaveTrack* NyquistEffect::NyxContext::mCurChannelGroup {}

Definition at line 686 of file Nyquist.cpp.

Referenced by NyquistEffect::ProcessOne().

◆ mCurLen

sampleCount NyquistEffect::NyxContext::mCurLen {}

Definition at line 696 of file Nyquist.cpp.

Referenced by NyquistEffect::ProcessOne().

◆ mCurNumChannels

unsigned NyquistEffect::NyxContext::mCurNumChannels {}

Not used in the callbacks.

Definition at line 690 of file Nyquist.cpp.

Referenced by NyquistEffect::ProcessOne().

◆ mCurStart

sampleCount NyquistEffect::NyxContext::mCurStart {}

Definition at line 688 of file Nyquist.cpp.

◆ mCurTrack

WaveChannel* NyquistEffect::NyxContext::mCurTrack[2] {}

Definition at line 687 of file Nyquist.cpp.

Referenced by NyquistEffect::ProcessOne().

◆ mOutputTrack

WaveTrack::Holder NyquistEffect::NyxContext::mOutputTrack

Definition at line 698 of file Nyquist.cpp.

Referenced by NyquistEffect::ProcessOne().

◆ mpException

std::exception_ptr NyquistEffect::NyxContext::mpException {}

Definition at line 707 of file Nyquist.cpp.

Referenced by NyquistEffect::ProcessOne().

◆ mProgressIn

double NyquistEffect::NyxContext::mProgressIn {}

Definition at line 700 of file Nyquist.cpp.

◆ mProgressOut

double NyquistEffect::NyxContext::mProgressOut {}

Definition at line 701 of file Nyquist.cpp.

◆ mProgressReport

const ProgressReport NyquistEffect::NyxContext::mProgressReport

Definition at line 703 of file Nyquist.cpp.

◆ mProgressTot

const double NyquistEffect::NyxContext::mProgressTot

Definition at line 705 of file Nyquist.cpp.

◆ mScale

const double NyquistEffect::NyxContext::mScale

Definition at line 704 of file Nyquist.cpp.


The documentation for this struct was generated from the following file: