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 2570 of file Nyquist.cpp.

2572{
2573 if (mCurBuffer[ch]) {
2574 if ((mCurStart + start) < mCurBufferStart[ch] ||
2575 (mCurStart + start) + len >
2576 mCurBufferStart[ch] + mCurBufferLen[ch]) {
2577 mCurBuffer[ch].reset();
2578 }
2579 }
2580
2581 if (!mCurBuffer[ch]) {
2582 mCurBufferStart[ch] = (mCurStart + start);
2584
2585 if (mCurBufferLen[ch] < (size_t) len)
2586 mCurBufferLen[ch] = mCurTrack[ch]->GetIdealBlockSize();
2587
2590
2591 // C++20
2592 // mCurBuffer[ch] = std::make_unique_for_overwrite(mCurBufferLen[ch]);
2593 mCurBuffer[ch] = Buffer{ safenew float[ mCurBufferLen[ch] ] };
2594 try {
2595 mCurTrack[ch]->GetFloats( mCurBuffer[ch].get(),
2597 }
2598 catch ( ... ) {
2599 // Save the exception object for re-throw when out of the library
2600 mpException = std::current_exception();
2601 return -1;
2602 }
2603 }
2604
2605 // We have guaranteed above that this is nonnegative and bounded by
2606 // mCurBufferLen[ch]:
2607 auto offset = (mCurStart + start - mCurBufferStart[ch]).as_size_t();
2608 const void *src = &mCurBuffer[ch][offset];
2609 std::memcpy(buffer, src, len * sizeof(float));
2610
2611 if (ch == 0) {
2612 double progress = mScale * ((start + len) / mCurLen.as_double());
2613 if (progress > mProgressIn)
2614 mProgressIn = progress;
2616 return -1;
2617 }
2618
2619 return 0;
2620}
#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:851
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 2629 of file Nyquist.cpp.

2631{
2632 // Don't let C++ exceptions propagate through the Nyquist library
2633 return GuardedCall<int>( [&] {
2634 if (channel == 0) {
2635 double progress = mScale * ((float)(start + len) / totlen);
2636 if (progress > mProgressOut)
2637 mProgressOut = progress;
2639 return -1;
2640 }
2641
2642 auto iChannel = mOutputTrack->Channels().begin();
2643 std::advance(iChannel, channel);
2644 const auto pChannel = *iChannel;
2645 pChannel->Append((samplePtr)buffer, floatSample, len);
2646
2647 return 0; // success
2648 }, MakeSimpleGuard(-1)); // translate all exceptions into failure
2649}
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 2563 of file Nyquist.cpp.

2565{
2566 auto This = static_cast<NyxContext*>(userdata);
2567 return This->GetCallback(buffer, channel, start, len, totlen);
2568}
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 2622 of file Nyquist.cpp.

2624{
2625 auto This = static_cast<NyxContext*>(userdata);
2626 return This->PutCallback(buffer, channel, start, len, totlen);
2627}

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: