Mercurial > hg > svcore
view data/model/AggregateWaveModel.cpp @ 1196:c7b9c902642f spectrogram-minor-refactor
Fix threshold in spectrogram -- it wasn't working in the last release.
There is a new protocol for this. Formerly the threshold parameter had a
range from -50dB to 0 with the default at -50, and -50 treated internally
as "no threshold". However, there was a hardcoded, hidden internal threshold
for spectrogram colour mapping at -80dB with anything below this being rounded
to zero. Now the threshold parameter has range -81 to -1 with the default
at -80, -81 is treated internally as "no threshold", and there is no hidden
internal threshold. So the default behaviour is the same as before, an
effective -80dB threshold, but it is now possible to change this in both
directions. Sessions reloaded from prior versions may look slightly different
because, if the session says there should be no threshold, there will now
actually be no threshold instead of having the hidden internal one.
Still need to do something in the UI to make it apparent that the -81dB
setting removes the threshold entirely. This is at least no worse than the
previous, also obscured, magic -50dB setting.
author | Chris Cannam |
---|---|
date | Mon, 01 Aug 2016 16:21:01 +0100 |
parents | 5cbf71022679 |
children | 54af1e21705c |
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* Sonic Visualiser An audio file viewer and annotation editor. Centre for Digital Music, Queen Mary, University of London. This file copyright 2007 QMUL. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information. */ #include "AggregateWaveModel.h" #include <iostream> #include <QTextStream> using namespace std; PowerOfSqrtTwoZoomConstraint AggregateWaveModel::m_zoomConstraint; AggregateWaveModel::AggregateWaveModel(ChannelSpecList channelSpecs) : m_components(channelSpecs) { for (ChannelSpecList::const_iterator i = channelSpecs.begin(); i != channelSpecs.end(); ++i) { if (i->model->getSampleRate() != channelSpecs.begin()->model->getSampleRate()) { SVDEBUG << "AggregateWaveModel::AggregateWaveModel: WARNING: Component models do not all have the same sample rate" << endl; break; } } } AggregateWaveModel::~AggregateWaveModel() { } bool AggregateWaveModel::isOK() const { for (ChannelSpecList::const_iterator i = m_components.begin(); i != m_components.end(); ++i) { if (!i->model->isOK()) return false; } return true; } bool AggregateWaveModel::isReady(int *completion) const { if (completion) *completion = 100; bool ready = true; for (ChannelSpecList::const_iterator i = m_components.begin(); i != m_components.end(); ++i) { int completionHere = 100; if (!i->model->isReady(&completionHere)) ready = false; if (completion && completionHere < *completion) { *completion = completionHere; } } return ready; } sv_frame_t AggregateWaveModel::getFrameCount() const { sv_frame_t count = 0; for (ChannelSpecList::const_iterator i = m_components.begin(); i != m_components.end(); ++i) { sv_frame_t thisCount = i->model->getEndFrame() - i->model->getStartFrame(); if (thisCount > count) count = thisCount; } return count; } int AggregateWaveModel::getChannelCount() const { return int(m_components.size()); } sv_samplerate_t AggregateWaveModel::getSampleRate() const { if (m_components.empty()) return 0; return m_components.begin()->model->getSampleRate(); } vector<float> AggregateWaveModel::getData(int channel, sv_frame_t start, sv_frame_t count) const { int ch0 = channel, ch1 = channel; if (channel == -1) { ch0 = 0; ch1 = getChannelCount()-1; } vector<float> result(count, 0.f); sv_frame_t longest = 0; for (int c = ch0; c <= ch1; ++c) { auto here = m_components[c].model->getData(m_components[c].channel, start, count); if (sv_frame_t(here.size()) > longest) { longest = sv_frame_t(here.size()); } for (sv_frame_t i = 0; in_range_for(here, i); ++i) { result[i] += here[i]; } } result.resize(longest); return result; } vector<vector<float>> AggregateWaveModel::getMultiChannelData(int fromchannel, int tochannel, sv_frame_t start, sv_frame_t count) const { sv_frame_t min = count; vector<vector<float>> result; for (int c = fromchannel; c <= tochannel; ++c) { auto here = getData(c, start, count); if (sv_frame_t(here.size()) < min) { min = sv_frame_t(here.size()); } result.push_back(here); } if (min < count) { for (auto &v : result) v.resize(min); } return result; } int AggregateWaveModel::getSummaryBlockSize(int desired) const { //!!! complete return desired; } void AggregateWaveModel::getSummaries(int, sv_frame_t, sv_frame_t, RangeBlock &, int &) const { //!!! complete } AggregateWaveModel::Range AggregateWaveModel::getSummary(int, sv_frame_t, sv_frame_t) const { //!!! complete return Range(); } int AggregateWaveModel::getComponentCount() const { return int(m_components.size()); } AggregateWaveModel::ModelChannelSpec AggregateWaveModel::getComponent(int c) const { return m_components[c]; } void AggregateWaveModel::componentModelChanged() { emit modelChanged(); } void AggregateWaveModel::componentModelChangedWithin(sv_frame_t start, sv_frame_t end) { emit modelChangedWithin(start, end); } void AggregateWaveModel::componentModelCompletionChanged() { emit completionChanged(); } void AggregateWaveModel::toXml(QTextStream &, QString , QString ) const { //!!! complete }