Skip to content

Commit

Permalink
Style code format clean
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed Feb 9, 2023
1 parent 201f8ed commit d32eae4
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 179 deletions.
5 changes: 2 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);

QString language = SpekPreferences::get().get_language();
if(language.isEmpty()) {
if (language.isEmpty()) {
language = QLocale().name();
}

QTranslator translator;
if(!translator.load(app.applicationDirPath() + "/po/" + language + ".ln"))
{
if (!translator.load(app.applicationDirPath() + "/po/" + language + ".ln")) {
app.quit();
return -1;
}
Expand Down
6 changes: 4 additions & 2 deletions src/spek-audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ enum class AudioError
BAD_SAMPLE_FORMAT,
};

inline bool operator!(AudioError error) {
inline bool operator!(AudioError error)
{
return error == AudioError::OK;
}

inline std::ostream& operator<<(std::ostream& os, AudioError error) {
inline std::ostream& operator<<(std::ostream& os, AudioError error)
{
return os << static_cast<int>(error);
}

Expand Down
10 changes: 5 additions & 5 deletions src/spek-fft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ void FFTPlanImpl::execute()
av_rdft_calc(this->cx, this->get_input());

// Calculate magnitudes.
int n = this->get_input_size();
float n2 = n * n;
const int n = this->get_input_size();
const float n2 = n * n;
this->set_output(0, 10.0f * log10f(this->get_input(0) * this->get_input(0) / n2));
this->set_output(n / 2, 10.0f * log10f(this->get_input(1) * this->get_input(1) / n2));
for(int i = 1; i < n / 2; i++) {
float re = this->get_input(i * 2);
float im = this->get_input(i * 2 + 1);
for (int i = 1; i < n / 2; i++) {
const float re = this->get_input(i * 2);
const float im = this->get_input(i * 2 + 1);
this->set_output(i, 10.0f * log10f((re * re + im * im) / n2));
}
}
44 changes: 17 additions & 27 deletions src/spek-palette.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ static QVector<QColor> globalGolors = { QColor(0, 0, 0),
void createGradientTable()
{
int numbers = 6;
for(int i = 0; i < GRADIENT_TABLE_SIZE; i++)
{
for (int i = 0; i < GRADIENT_TABLE_SIZE; i++) {
double position = (double)i/GRADIENT_TABLE_SIZE;
/* if position > 1 then we have repetition of colors it maybe useful */
if(position > 1.0)
{
if(position - int(position) == 0.0)
{
if (position > 1.0) {
if (position - int(position) == 0.0) {
position = 1.0;
}
else
{
} else {
position = position - int(position);
}
}
Expand All @@ -42,20 +37,15 @@ void createGradientTable()
const double f = m - n; // fraction of m

globalTableGolors[i] = 0xFF0000;
if(n < numbers)
{
if (n < numbers) {
globalTableGolors[i] = ((uint32_t)((globalGolors[n].red()) + f * ((globalGolors[n+1].red()) - (globalGolors[n].red()))) & 0xFF) << 16 |
((uint32_t)((globalGolors[n].green()) + f * ((globalGolors[n+1].green()) - (globalGolors[n].green()))) & 0xFF) << 8 |
((uint32_t)((globalGolors[n].blue()) + f * ((globalGolors[n+1].blue()) - (globalGolors[n].blue()))) & 0xFF) << 0;
}
else if(n == numbers)
{
} else if (n == numbers) {
globalTableGolors[i] = ((uint32_t)(globalGolors[n].red()) & 0xFF) << 16 |
((uint32_t)(globalGolors[n].green()) & 0xFF) << 8 |
((uint32_t)(globalGolors[n].blue()) & 0xFF) << 0;
}
else
{
} else {
globalTableGolors[i] = 0xFFFFFF;
}
}
Expand Down Expand Up @@ -97,16 +87,15 @@ static uint32_t spectrum(double level)
cf *= 255.0;

// Pack RGB values into a 32-bit uint.
uint32_t rr = (uint32_t) (r * cf + 0.5);
uint32_t gg = (uint32_t) (g * cf + 0.5);
uint32_t bb = (uint32_t) (b * cf + 0.5);
const uint32_t rr = (uint32_t) (r * cf + 0.5);
const uint32_t gg = (uint32_t) (g * cf + 0.5);
const uint32_t bb = (uint32_t) (b * cf + 0.5);
return (rr << 16) + (gg << 8) + bb;
}

uint32_t spectrogram(double level)
{
if(!globalTableInit)
{
if (!globalTableInit) {
createGradientTable();
globalTableInit = true;
}
Expand Down Expand Up @@ -140,19 +129,20 @@ static uint32_t sox(double level)
}

// Pack RGB values into a 32-bit uint.
uint32_t rr = (uint32_t) (r * 255.0 + 0.5);
uint32_t gg = (uint32_t) (g * 255.0 + 0.5);
uint32_t bb = (uint32_t) (b * 255.0 + 0.5);
const uint32_t rr = (uint32_t) (r * 255.0 + 0.5);
const uint32_t gg = (uint32_t) (g * 255.0 + 0.5);
const uint32_t bb = (uint32_t) (b * 255.0 + 0.5);
return (rr << 16) + (gg << 8) + bb;
}

static uint32_t mono(double level)
{
uint32_t v = (uint32_t) (level * 255.0 + 0.5);
const uint32_t v = (uint32_t) (level * 255.0 + 0.5);
return (v << 16) + (v << 8) + v;
}

uint32_t spek_palette(Palette palette, double level) {
uint32_t spek_palette(Palette palette, double level)
{
switch (palette) {
case PALETTE_SPECTRUM:
return spectrum(level);
Expand Down
Loading

0 comments on commit d32eae4

Please sign in to comment.