moodbar: Formatting
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
/* This file was part of Clementine.
|
||||
Copyright 2014, David Sansome <me@davidsansome.com>
|
||||
|
||||
Strawberry 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Strawberry is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2014, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2019-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
@@ -22,6 +26,7 @@
|
||||
#include <QByteArray>
|
||||
|
||||
#include "moodbarbuilder.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/arraysize.h"
|
||||
|
||||
namespace {
|
||||
@@ -33,11 +38,11 @@ constexpr int sBarkBandCount = arraysize(sBarkBands);
|
||||
|
||||
MoodbarBuilder::MoodbarBuilder() : bands_(0), rate_hz_(0) {}
|
||||
|
||||
int MoodbarBuilder::BandFrequency(int band) const {
|
||||
int MoodbarBuilder::BandFrequency(const int band) const {
|
||||
return ((rate_hz_ / 2) * band + rate_hz_ / 4) / bands_;
|
||||
}
|
||||
|
||||
void MoodbarBuilder::Init(int bands, int rate_hz) {
|
||||
void MoodbarBuilder::Init(const int bands, const int rate_hz) {
|
||||
|
||||
bands_ = bands;
|
||||
rate_hz_ = rate_hz;
|
||||
@@ -56,18 +61,14 @@ void MoodbarBuilder::Init(int bands, int rate_hz) {
|
||||
|
||||
}
|
||||
|
||||
void MoodbarBuilder::AddFrame(const double *magnitudes, int size) {
|
||||
void MoodbarBuilder::AddFrame(const double *magnitudes, const int size) {
|
||||
|
||||
if (size > barkband_table_.length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate total magnitudes for different bark bands.
|
||||
double bands[sBarkBandCount];
|
||||
for (int i = 0; i < sBarkBandCount; ++i) {
|
||||
bands[i] = 0.0;
|
||||
}
|
||||
|
||||
double bands[sBarkBandCount]{};
|
||||
for (int i = 0; i < size; ++i) {
|
||||
bands[barkband_table_[i]] += magnitudes[i];
|
||||
}
|
||||
@@ -160,7 +161,7 @@ void MoodbarBuilder::Normalize(QList<Rgb> *vals, double Rgb::*member) {
|
||||
|
||||
}
|
||||
|
||||
QByteArray MoodbarBuilder::Finish(int width) {
|
||||
QByteArray MoodbarBuilder::Finish(const int width) {
|
||||
|
||||
QByteArray ret;
|
||||
ret.resize(width * 3);
|
||||
@@ -191,6 +192,7 @@ QByteArray MoodbarBuilder::Finish(int width) {
|
||||
*(data++) = static_cast<char>(rgb.b / n);
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user