mirror of
https://github.com/alexkay/spek.git
synced 2025-06-15 14:52:24 +03:00
Close the file after processing, fixes #26
This commit is contained in:
parent
a380a77bdd
commit
b8e472fcfb
@ -227,6 +227,9 @@ static void * reader_func(void *pp)
|
|||||||
// Force the worker to quit.
|
// Force the worker to quit.
|
||||||
reader_sync(p, -1);
|
reader_sync(p, -1);
|
||||||
pthread_join(p->worker_thread, NULL);
|
pthread_join(p->worker_thread, NULL);
|
||||||
|
|
||||||
|
// Notify the client.
|
||||||
|
p->cb(-1, NULL, p->cb_data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,9 +32,14 @@ SpekHaveSampleEvent::SpekHaveSampleEvent(const SpekHaveSampleEvent& other)
|
|||||||
SetEventType(SPEK_HAVE_SAMPLE);
|
SetEventType(SPEK_HAVE_SAMPLE);
|
||||||
this->bands = other.bands;
|
this->bands = other.bands;
|
||||||
this->sample = other.sample;
|
this->sample = other.sample;
|
||||||
this->values = (float *)malloc(this->bands * sizeof(float));
|
if (other.values) {
|
||||||
memcpy(this->values, other.values, this->bands * sizeof(float));
|
this->values = (float *)malloc(this->bands * sizeof(float));
|
||||||
this->free_values = true;
|
memcpy(this->values, other.values, this->bands * sizeof(float));
|
||||||
|
this->free_values = true;
|
||||||
|
} else {
|
||||||
|
this->values = NULL;
|
||||||
|
this->free_values = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SpekHaveSampleEvent::~SpekHaveSampleEvent()
|
SpekHaveSampleEvent::~SpekHaveSampleEvent()
|
||||||
|
@ -58,7 +58,8 @@ static wxString trim(wxDC& dc, const wxString& s, int length, bool trim_end);
|
|||||||
SpekSpectrogram::SpekSpectrogram(wxFrame *parent) :
|
SpekSpectrogram::SpekSpectrogram(wxFrame *parent) :
|
||||||
wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE),
|
wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE),
|
||||||
pipeline(NULL),
|
pipeline(NULL),
|
||||||
properties(NULL),
|
duration(0.0),
|
||||||
|
sample_rate(0),
|
||||||
palette(RULER, BANDS),
|
palette(RULER, BANDS),
|
||||||
image(1, 1),
|
image(1, 1),
|
||||||
prev_width(-1)
|
prev_width(-1)
|
||||||
@ -99,6 +100,7 @@ void SpekSpectrogram::save(const wxString& path)
|
|||||||
|
|
||||||
void SpekSpectrogram::on_idle(wxIdleEvent& evt)
|
void SpekSpectrogram::on_idle(wxIdleEvent& evt)
|
||||||
{
|
{
|
||||||
|
// TODO: remove?
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +128,11 @@ void SpekSpectrogram::on_have_sample(SpekHaveSampleEvent& event)
|
|||||||
int sample = event.get_sample();
|
int sample = event.get_sample();
|
||||||
const float *values = event.get_values();
|
const float *values = event.get_values();
|
||||||
|
|
||||||
|
if (sample == -1) {
|
||||||
|
this->stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: check image size, quit if wrong.
|
// TODO: check image size, quit if wrong.
|
||||||
for (int y = 0; y < bands; y++) {
|
for (int y = 0; y < bands; y++) {
|
||||||
double level = log10(1.0 - THRESHOLD + values[y]) / log10_threshold;
|
double level = log10(1.0 - THRESHOLD + values[y]) / log10_threshold;
|
||||||
@ -235,7 +242,6 @@ void SpekSpectrogram::render(wxDC& dc)
|
|||||||
dc.SetFont(small_font);
|
dc.SetFont(small_font);
|
||||||
|
|
||||||
// Time ruler.
|
// Time ruler.
|
||||||
double duration = this->properties->duration;
|
|
||||||
int time_factors[] = {1, 2, 5, 10, 20, 30, 1*60, 2*60, 5*60, 10*60, 20*60, 30*60, 0};
|
int time_factors[] = {1, 2, 5, 10, 20, 30, 1*60, 2*60, 5*60, 10*60, 20*60, 30*60, 0};
|
||||||
SpekRuler time_ruler(
|
SpekRuler time_ruler(
|
||||||
LPAD,
|
LPAD,
|
||||||
@ -244,16 +250,16 @@ void SpekSpectrogram::render(wxDC& dc)
|
|||||||
// TODO: i18n
|
// TODO: i18n
|
||||||
wxT("00:00"),
|
wxT("00:00"),
|
||||||
time_factors,
|
time_factors,
|
||||||
(int)duration,
|
(int)this->duration,
|
||||||
1.5,
|
1.5,
|
||||||
(w - LPAD - RPAD) / duration,
|
(w - LPAD - RPAD) / this->duration,
|
||||||
0.0,
|
0.0,
|
||||||
time_formatter
|
time_formatter
|
||||||
);
|
);
|
||||||
time_ruler.draw(dc);
|
time_ruler.draw(dc);
|
||||||
|
|
||||||
// Frequency ruler.
|
// Frequency ruler.
|
||||||
int freq = this->properties->sample_rate / 2;
|
int freq = this->sample_rate / 2;
|
||||||
int freq_factors[] = {1000, 2000, 5000, 10000, 20000, 0};
|
int freq_factors[] = {1000, 2000, 5000, 10000, 20000, 0};
|
||||||
SpekRuler freq_ruler(
|
SpekRuler freq_ruler(
|
||||||
LPAD,
|
LPAD,
|
||||||
@ -328,8 +334,10 @@ void SpekSpectrogram::start()
|
|||||||
this
|
this
|
||||||
);
|
);
|
||||||
spek_pipeline_start(this->pipeline);
|
spek_pipeline_start(this->pipeline);
|
||||||
this->properties = spek_pipeline_properties(this->pipeline);
|
const spek_audio_properties *properties = spek_pipeline_properties(this->pipeline);
|
||||||
this->desc = spek_audio_desc(this->properties);
|
this->desc = spek_audio_desc(properties);
|
||||||
|
this->duration = properties->duration;
|
||||||
|
this->sample_rate = properties->sample_rate;
|
||||||
} else {
|
} else {
|
||||||
this->image.Create(1, 1);
|
this->image.Create(1, 1);
|
||||||
}
|
}
|
||||||
@ -342,7 +350,6 @@ void SpekSpectrogram::stop()
|
|||||||
if (this->pipeline) {
|
if (this->pipeline) {
|
||||||
spek_pipeline_close(this->pipeline);
|
spek_pipeline_close(this->pipeline);
|
||||||
this->pipeline = NULL;
|
this->pipeline = NULL;
|
||||||
this->properties = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +44,10 @@ private:
|
|||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
spek_pipeline *pipeline;
|
spek_pipeline *pipeline;
|
||||||
const spek_audio_properties *properties;
|
|
||||||
wxString path;
|
wxString path;
|
||||||
wxString desc;
|
wxString desc;
|
||||||
|
double duration;
|
||||||
|
int sample_rate;
|
||||||
wxImage palette;
|
wxImage palette;
|
||||||
wxImage image;
|
wxImage image;
|
||||||
int prev_width;
|
int prev_width;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user