strawberry-audio-player-win.../src/moodbar/moodbarbuilder.h

52 lines
1.4 KiB
C
Raw Normal View History

2019-04-18 15:03:01 +02:00
/* 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/>.
*/
#ifndef MOODBARBUILDER_H
#define MOODBARBUILDER_H
2020-02-09 02:29:35 +01:00
#include <QtGlobal>
2019-04-18 15:03:01 +02:00
#include <QList>
#include <QByteArray>
class MoodbarBuilder {
public:
2020-04-07 16:49:15 +02:00
explicit MoodbarBuilder();
2019-04-18 15:03:01 +02:00
void Init(int bands, int rate_hz);
2021-01-26 16:48:04 +01:00
void AddFrame(const double *magnitudes, int size);
2019-04-18 15:03:01 +02:00
QByteArray Finish(int width);
private:
struct Rgb {
Rgb() : r(0), g(0), b(0) {}
Rgb(double r_, double g_, double b_) : r(r_), g(g_), b(b_) {}
double r, g, b;
};
int BandFrequency(int band) const;
2021-01-26 16:48:04 +01:00
static void Normalize(QList<Rgb> *vals, double Rgb::*member);
2019-04-18 15:03:01 +02:00
QList<uint> barkband_table_;
int bands_;
int rate_hz_;
QList<Rgb> frames_;
};
#endif // MOODBARBUILDER_H