本文整理汇总了C++中poco::SharedPtr::elementWiseDivision方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedPtr::elementWiseDivision方法的具体用法?C++ SharedPtr::elementWiseDivision怎么用?C++ SharedPtr::elementWiseDivision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::SharedPtr
的用法示例。
在下文中一共展示了SharedPtr::elementWiseDivision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exportComponents
//.........这里部分代码省略.........
logger().debug("Exporting components for source #" +
Poco::NumberFormatter::format(sourceIndex));
for (vector<int>::const_iterator it = sourceIt->begin();
it != sourceIt->end(); ++it)
{
if (*it < 1 || *it > _nrOfComponents) {
logger().error(nameAndTaskID() + ": invalid component index: " +
Poco::NumberFormatter::format(*it));
continue;
}
int i = *it - 1;
logger().debug(nameAndTaskID() + " exporting component #" +
Poco::NumberFormatter::format(i));
// Compute the component's magnitude spectrum.
Poco::SharedPtr<Matrix> magnitudeSpectrum = new Matrix(
magnitudeSpectraMatrix(0).rows(),
gainsMatrix().cols());
// NMD case
if (_nrOfSpectra > 1) {
magnitudeSpectrum->zero();
RowVector componentGains = gainsMatrix().nthRow(i);
for (unsigned int t = 0; t < _nrOfSpectra; t++) {
ColVector componentSpectrum = magnitudeSpectraMatrix(t).nthColumn(i);
magnitudeSpectrum->add(componentSpectrum * componentGains);
componentGains.shiftRight();
}
}
// "NMF" case (separated for efficiency)
else {
ColVector componentSpectrum = magnitudeSpectraMatrix(0).nthColumn(i);
RowVector componentGains = gainsMatrix().nthRow(i);
*magnitudeSpectrum = componentSpectrum * componentGains;
}
// revert transformation to component spectrogram
magnitudeSpectrum = revertTransforms(magnitudeSpectrum);
if (wienerRec) {
// (Component/Whole) reconstruction
reconst->floor(1e-6);
magnitudeSpectrum->elementWiseDivision(*reconst, magnitudeSpectrum);
// Use as filter for original spectrogram
magnitudeSpectrum->elementWiseMultiplication(ftMagMatrix(),
magnitudeSpectrum);
}
// Mix the components to a single spectrogram that is exported after
// the loop.
if (_mixExportedComponents) {
if (mixedSpectrogram.isNull()) {
mixedSpectrogram = new Matrix(magnitudeSpectrum->rows(),
magnitudeSpectrum->cols());
mixedSpectrogram->zero();
}
mixedSpectrogram->add(*magnitudeSpectrum);
}
// Export components individually.
else {
// Construct the filename.
string prefix = getExportPrefix();
const int numDigits = (int)(1 + log10f((float)_nrOfComponents));
stringstream ss;
ss << prefix;
if (compIndices.size() > 1) {
const int numDigitsS = (int)(1 + log10f((float)compIndices.size()));
ss << '_' << setfill('0') << setw(numDigitsS) << sourceIndex;
}
ss << '_' << setfill('0') << setw(numDigits) << *it;
if (exportAsMatrix) {
magnitudeSpectrum->dump(ss.str() + ".dat");
}
if (exportAsWave) {
// Convert component spectrogram to time signal and save it as WAV.
spectrogramToAudioFile(magnitudeSpectrum, ss.str() + ".wav");
}
}
}
// Export the mixed source spectrogram to a single audio file.
if (_mixExportedComponents) {
// Construct the filename.
stringstream ss;
ss << getExportPrefix();
const int numDigitsS = (int)(1 + log10f((float)compIndices.size()));
ss << "_source" << setfill('0') << setw(numDigitsS) << sourceIndex;
// Convert component spectrogram to time signal and save it as WAV.
string filename = ss.str();
logger().debug(nameAndTaskID() + ": creating mixed audio file " +
filename);
if (exportAsMatrix) {
mixedSpectrogram->dump(filename + ".dat");
}
if (exportAsWave) {
spectrogramToAudioFile(mixedSpectrogram, filename + ".wav");
}
}
}
}