У меня есть функция audioReceived (float * input, int bufferSize, int nChannels)
, внутри которой я хочу вызвать функцию из библиотеки, которой требуется const float *const *inputBuffers
.
Очевидно, что приведение const float *const *inputBuffers = (const float* const*)input;
компилируется, но это ужасная идея, вылетает программа, убивает котят и т. Д. Никому никогда не нужно изменять исходный float* input
, это входящие аудиоданные, которые обрабатываются.
Как мне сделать это правильно?
РЕДАКТИРОВАТЬ: Вот еще немного кода. audioReceived
это:
void testApp::audioReceived (float * input, int bufferSize, int nChannels){
Vamp::RealTime rt = Vamp::RealTime::fromMilliseconds(ofGetSystemTime());
float const *const tmp[] = { input, 0 };
Vamp::Plugin::FeatureSet fs = myPlugin->process(tmp, rt);
}
Библиотечная функция process
фактически определена в базовом классе:
/**
* Process a single block of input data.
*
* If the plugin's inputDomain is TimeDomain, inputBuffers will
* point to one array of floats per input channel, and each of
* these arrays will contain blockSize consecutive audio samples
* (the host will zero-pad as necessary). The timestamp in this
* case will be the real time in seconds of the start of the
* supplied block of samples.
*
* If the plugin's inputDomain is FrequencyDomain, inputBuffers
* will point to one array of floats per input channel, and each
* of these arrays will contain blockSize/2+1 consecutive pairs of
* real and imaginary component floats corresponding to bins
* 0..(blockSize/2) of the FFT output. That is, bin 0 (the first
* pair of floats) contains the DC output, up to bin blockSize/2
* which contains the Nyquist-frequency output. There will
* therefore be blockSize+2 floats per channel in total. The
* timestamp will be the real time in seconds of the centre of the
* FFT input window (i.e. the very first block passed to process
* might contain the FFT of half a block of zero samples and the
* first half-block of the actual data, with a timestamp of zero).
*
* Return any features that have become available after this
* process call. (These do not necessarily have to fall within
* the process block, except for OneSamplePerStep outputs.)
*/
virtual FeatureSet process(const float *const *inputBuffers,
RealTime timestamp) = 0;
и вот в фактическом заголовке:
FeatureSet process(const float *const *inputBuffers, Vamp::RealTime timestamp);
Я думаю, что EXC_BAD_ACCESS
может быть следствием библиотечной функции, которая хочет массив с нулевым заполнением, а я не даю его. (a) Это звучит разумно, и (b) Если да, то пришло ли время задать другой вопрос SO?
Спасибо всем за вашу помощь, это очень поучительно / разъясняюще / познавательно / интересно.