Add option to disable rendering the sample averages in the waveform renderer

Originally committed to SVN as r6063.
This commit is contained in:
Thomas Goyne 2011-12-22 21:19:21 +00:00
parent 0201b8ea9b
commit 55f8cb3685
5 changed files with 38 additions and 4 deletions

View file

@ -1252,6 +1252,7 @@ void AudioDisplay::OnAudioOpen(AudioProvider *provider)
connections.push_back(controller->AddSelectionChangedListener(&AudioDisplay::OnSelectionChanged, this));
connections.push_back(controller->AddStyleRangesChangedListener(&AudioDisplay::OnStyleRangesChanged, this));
connections.push_back(OPT_SUB("Audio/Spectrum", &AudioDisplay::ReloadRenderingSettings, this));
connections.push_back(OPT_SUB("Audio/Display/Waveform Style", &AudioDisplay::ReloadRenderingSettings, this));
connections.push_back(OPT_SUB("Colour/Audio Display/Spectrum", &AudioDisplay::ReloadRenderingSettings, this));
connections.push_back(OPT_SUB("Colour/Audio Display/Waveform", &AudioDisplay::ReloadRenderingSettings, this));
connections.push_back(OPT_SUB("Audio/Renderer/Spectrum/Quality", &AudioDisplay::ReloadRenderingSettings, this));

View file

@ -48,12 +48,22 @@
#include "block_cache.h"
#include "colorspace.h"
#include "include/aegisub/audio_provider.h"
#include "main.h"
enum {
/// Only render the peaks
Waveform_MaxOnly = 0,
/// Render the peaks and averages
Waveform_MaxAvg,
Waveform_Continuous
};
AudioWaveformRenderer::AudioWaveformRenderer(std::string const& color_scheme_name)
: colors_normal(new AudioColorScheme(6, color_scheme_name, AudioStyle_Normal))
, colors_selected(new AudioColorScheme(6, color_scheme_name, AudioStyle_Selected))
, colors_inactive(new AudioColorScheme(6, color_scheme_name, AudioStyle_Inactive))
, audio_buffer(0)
, render_averages(OPT_GET("Audio/Display/Waveform Style")->GetInt() == Waveform_MaxAvg)
{
}
@ -123,12 +133,18 @@ void AudioWaveformRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
dc.SetPen(pen_peaks);
dc.DrawLine(x, midpoint - peak_max, x, midpoint - peak_min);
dc.SetPen(pen_avgs);
dc.DrawLine(x, midpoint - avg_max, x, midpoint - avg_min);
if (render_averages) {
dc.SetPen(pen_avgs);
dc.DrawLine(x, midpoint - avg_max, x, midpoint - avg_min);
}
}
// Horizontal zero-point line
dc.SetPen(wxPen(pal->get(1.0f)));
if (render_averages)
dc.SetPen(wxPen(pal->get(1.0f)));
else
dc.SetPen(pen_peaks);
dc.DrawLine(0, midpoint, rect.width, midpoint);
}
@ -173,3 +189,10 @@ const AudioColorScheme *AudioWaveformRenderer::GetColorScheme(AudioRenderingStyl
default: return colors_normal.get();
}
}
wxArrayString AudioWaveformRenderer::GetWaveformStyles() {
wxArrayString ret;
ret.push_back(_("Maximum"));
ret.push_back(_("Maximum + Average"));
return ret;
}

View file

@ -58,6 +58,9 @@ class AudioWaveformRenderer : public AudioRendererBitmapProvider {
/// Pre-allocated buffer for audio fetched from provider
char *audio_buffer;
/// Whether to render max+avg or just max
bool render_averages;
/// Get the color scheme for a rendering style
const AudioColorScheme *GetColorScheme(AudioRenderingStyle style) const;
@ -86,4 +89,7 @@ public:
///
/// Does nothing for waveform renderer, since it does not have a backend cache
void AgeCache(size_t max_size) { }
/// Get a list of waveform rendering modes
static wxArrayString GetWaveformStyles();
};

View file

@ -49,7 +49,8 @@
"Snap" : {
"Keyframes" : false,
"Other Lines" : false
}
},
"Waveform Style" : 1
},
"Downmixer" : "ConvertToMono",
"Grab Times on Select" : true,

View file

@ -41,6 +41,7 @@
#include "preferences.h"
#include "audio_renderer_waveform.h"
#include "colour_button.h"
#include "command/command.h"
#include "compat.h"
@ -167,6 +168,8 @@ Audio::Audio(wxTreebook *book, Preferences *parent): OptionPage(book, parent, _(
OptionAdd(display, _("Keyframes"), "Audio/Display/Draw/Keyframes in Dialogue Mode");
OptionAdd(display, _("Karaoke keyframes"), "Audio/Display/Draw/Keyframes in Karaoke Mode");
OptionAdd(display, _("Video position"), "Audio/Display/Draw/Video Position");
CellSkip(display);
OptionChoice(display, _("Waveform Style"), AudioWaveformRenderer::GetWaveformStyles(), "Audio/Display/Waveform Style");
wxFlexGridSizer *color = PageSizer(_("Color Schemes"));
wxArrayString schemes = vec_to_arrstr(OPT_GET("Audio/Colour Schemes")->GetListString());