comparison layer/SpectrogramLayer.cpp @ 1061:861f40fc9958 spectrogram-minor-refactor

Don't need these
author Chris Cannam
date Wed, 15 Jun 2016 14:43:51 +0100
parents 5eb4d79334b9
children 38ecdd5924ac
comparison
equal deleted inserted replaced
1060:5eb4d79334b9 1061:861f40fc9958
2365 fft->getPhasesAt(sx, values.data(), minbin, bincount); 2365 fft->getPhasesAt(sx, values.data(), minbin, bincount);
2366 } else { 2366 } else {
2367 fft->getMagnitudesAt(sx, values.data(), minbin, bincount); 2367 fft->getMagnitudesAt(sx, values.data(), minbin, bincount);
2368 } 2368 }
2369 2369
2370 return move(values); 2370 return values;
2371 } 2371 }
2372 2372
2373 vector<float> 2373 vector<float>
2374 SpectrogramLayer::getColumnFromGenericModel(DenseThreeDimensionalModel *model, 2374 SpectrogramLayer::getColumnFromGenericModel(DenseThreeDimensionalModel *model,
2375 int sx, // column number in model 2375 int sx, // column number in model
2380 throw std::logic_error("can't use phase scale with generic 3d model"); 2380 throw std::logic_error("can't use phase scale with generic 3d model");
2381 } 2381 }
2382 2382
2383 auto col = model->getColumn(sx); 2383 auto col = model->getColumn(sx);
2384 2384
2385 return move(vector<float>(col.data() + minbin, 2385 return vector<float>(col.data() + minbin,
2386 col.data() + minbin + bincount)); 2386 col.data() + minbin + bincount);
2387 } 2387 }
2388 2388
2389 vector<float> 2389 vector<float>
2390 SpectrogramLayer::scaleColumn(const vector<float> &in) const 2390 SpectrogramLayer::scaleColumn(const vector<float> &in) const
2391 { 2391 {
2397 out.reserve(in.size()); 2397 out.reserve(in.size());
2398 float scale = 2.f / float(m_fftSize); 2398 float scale = 2.f / float(m_fftSize);
2399 for (auto v: in) { 2399 for (auto v: in) {
2400 out.push_back(v * scale); 2400 out.push_back(v * scale);
2401 } 2401 }
2402 return move(out); 2402 return out;
2403 } 2403 }
2404 2404
2405 static bool 2405 static bool
2406 is_peak(const vector<float> &values, int ix) 2406 is_peak(const vector<float> &values, int ix)
2407 { 2407 {
2521 } 2521 }
2522 2522
2523 for (auto v: in) { 2523 for (auto v: in) {
2524 out.push_back(v * scale); 2524 out.push_back(v * scale);
2525 } 2525 }
2526 return move(out); 2526 return out;
2527 } 2527 }
2528 2528
2529 vector<float> 2529 vector<float>
2530 SpectrogramLayer::peakPickColumn(const vector<float> &in) const 2530 SpectrogramLayer::peakPickColumn(const vector<float> &in) const
2531 { 2531 {
2532 if (m_binDisplay != PeakBins) return in; 2532 if (m_binDisplay == AllBins) return in;
2533 2533
2534 vector<float> out(in.size(), 0.f); 2534 vector<float> out(in.size(), 0.f);
2535 2535
2536 for (int i = 0; in_range_for(in, i); ++i) { 2536 for (int i = 0; in_range_for(in, i); ++i) {
2537 if (is_peak(in, i)) { 2537 if (is_peak(in, i)) {
2538 out[i] = in[i]; 2538 out[i] = in[i];
2539 } 2539 }
2540 } 2540 }
2541 2541
2542 return move(out); 2542 return out;
2543 } 2543 }
2544 2544
2545 vector<float> 2545 vector<float>
2546 SpectrogramLayer::applyDisplayGain(const vector<float> &in) const 2546 SpectrogramLayer::applyDisplayGain(const vector<float> &in) const
2547 { 2547 {
2550 vector<float> out; 2550 vector<float> out;
2551 out.reserve(in.size()); 2551 out.reserve(in.size());
2552 for (auto v: in) { 2552 for (auto v: in) {
2553 out.push_back(v * m_gain); 2553 out.push_back(v * m_gain);
2554 } 2554 }
2555 return move(out); 2555 return out;
2556 } 2556 }
2557 2557
2558 // order: 2558 // order:
2559 // get column -> scale -> distribute/interpolate -> record extents -> normalise -> peak pick -> apply display gain 2559 // get column -> scale -> distribute/interpolate -> record extents -> normalise -> peak pick -> apply display gain
2560 2560