MCPcopy Create free account
hub / github.com/audacity/audacity / resampleCB

Function resampleCB

libraries/lib-builtin-effects/SBSMSBase.cpp:90–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88};
89
90long resampleCB(void *cb_data, SBSMSFrame *data)
91{
92 ResampleBuf *r = (ResampleBuf*) cb_data;
93
94 auto blockSize = limitSampleBufferSize(
95 r->leftTrack->GetBestBlockSize(r->offset),
96 r->end - r->offset
97 );
98
99 // Get the samples from the tracks and put them in the buffers.
100 // I don't know if we can safely propagate errors through sbsms, and it
101 // does not seem to let us report error codes, so use this roundabout to
102 // stop the effect early.
103 try {
104 r->leftTrack->GetFloats(
105 (r->leftBuffer.get()), r->offset, blockSize);
106 r->rightTrack->GetFloats(
107 (r->rightBuffer.get()), r->offset, blockSize);
108 }
109 catch ( ... ) {
110 // Save the exception object for re-throw when out of the library
111 r->mpException = std::current_exception();
112 data->size = 0;
113 return 0;
114 }
115
116 // convert to sbsms audio format
117 for(decltype(blockSize) i=0; i<blockSize; i++) {
118 r->buf[i][0] = r->leftBuffer[i];
119 r->buf[i][1] = r->rightBuffer[i];
120 }
121
122 data->buf = r->buf.get();
123 data->size = blockSize;
124 if(r->bPitch) {
125 float t0 = r->processed.as_float() / r->iface->getSamplesToInput();
126 float t1 = (r->processed + blockSize).as_float() / r->iface->getSamplesToInput();
127 data->ratio0 = r->iface->getStretch(t0);
128 data->ratio1 = r->iface->getStretch(t1);
129 } else {
130 data->ratio0 = r->ratio;
131 data->ratio1 = r->ratio;
132 }
133 r->processed += blockSize;
134 r->offset += blockSize;
135 return blockSize;
136}
137
138long postResampleCB(void *cb_data, SBSMSFrame *data)
139{

Callers

nothing calls this directly

Calls 5

limitSampleBufferSizeFunction · 0.85
GetBestBlockSizeMethod · 0.45
GetFloatsMethod · 0.45
getMethod · 0.45
getStretchMethod · 0.45

Tested by

no test coverage detected