mirror of
https://github.com/alexkay/spek.git
synced 2025-04-17 00:52:20 +03:00
MIN/MAX macros are not portable
This commit is contained in:
parent
979862e2b9
commit
8436464c16
@ -19,6 +19,16 @@
|
||||
#ifndef SPEK_UTILS_H_
|
||||
#define SPEK_UTILS_H_
|
||||
|
||||
inline int spek_max(int a, int b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
inline int spek_min(int a, int b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
// Compare version numbers, e.g. 1.9.2 < 1.10.0
|
||||
int spek_vercmp(const char *a, const char *b);
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <wx/dcbuffer.h>
|
||||
|
||||
@ -25,6 +24,7 @@ extern "C" {
|
||||
#include <spek-audio.h>
|
||||
#include <spek-palette.h>
|
||||
#include <spek-pipeline.h>
|
||||
#include <spek-utils.h>
|
||||
}
|
||||
|
||||
#include "spek-audio-desc.hh"
|
||||
@ -119,13 +119,13 @@ void SpekSpectrogram::on_char(wxKeyEvent& evt)
|
||||
bool up = evt.GetKeyCode() == WXK_UP;
|
||||
|
||||
if (C && up) {
|
||||
this->lrange = MIN(this->lrange + 1, this->urange - 1);
|
||||
this->lrange = spek_min(this->lrange + 1, this->urange - 1);
|
||||
} else if (C && dn) {
|
||||
this->lrange = MAX(this->lrange - 1, MIN_RANGE);
|
||||
this->lrange = spek_max(this->lrange - 1, MIN_RANGE);
|
||||
} else if (CS && up) {
|
||||
this->urange = MIN(this->urange + 1, MAX_RANGE);
|
||||
this->urange = spek_min(this->urange + 1, MAX_RANGE);
|
||||
} else if (CS && dn) {
|
||||
this->urange = MAX(this->urange - 1, this->lrange + 1);
|
||||
this->urange = spek_max(this->urange - 1, this->lrange + 1);
|
||||
} else {
|
||||
evt.Skip();
|
||||
return;
|
||||
@ -166,7 +166,7 @@ void SpekSpectrogram::on_have_sample(SpekHaveSampleEvent& event)
|
||||
// TODO: check image size, quit if wrong.
|
||||
double range = log(1.0 + this->urange - this->lrange);
|
||||
for (int y = 0; y < bands; y++) {
|
||||
double value = MIN(this->urange, MAX(this->lrange, values[y]));
|
||||
double value = fmin(this->urange, fmax(this->lrange, values[y]));
|
||||
double level = log(1.0 + value - this->lrange) / range;
|
||||
uint32_t color = spek_palette_spectrum(level);
|
||||
this->image.SetRGB(
|
||||
|
Loading…
x
Reference in New Issue
Block a user