Add support for the Selected style to the audio renderers

Originally committed to SVN as r6570.
This commit is contained in:
Thomas Goyne 2012-03-12 00:07:16 +00:00
parent 812e2e8025
commit aba0b5db11
8 changed files with 35 additions and 74 deletions

View file

@ -57,8 +57,8 @@ AudioColorScheme::AudioColorScheme(int prec, std::string const& scheme_name, int
{ {
case AudioStyle_Normal: opt_base += "Normal/"; break; case AudioStyle_Normal: opt_base += "Normal/"; break;
case AudioStyle_Inactive: opt_base += "Inactive/"; break; case AudioStyle_Inactive: opt_base += "Inactive/"; break;
case AudioStyle_Selected: opt_base += "Active/"; break; case AudioStyle_Selected: opt_base += "Selection/"; break;
case AudioStyle_Primary: opt_base += "Selected/"; break; case AudioStyle_Primary: opt_base += "Primary/"; break;
default: throw agi::InternalError("Unknown audio rendering styling", 0); default: throw agi::InternalError("Unknown audio rendering styling", 0);
} }

View file

@ -173,7 +173,7 @@ void AudioRenderer::SetCacheMaxSize(size_t max_size)
// bitmap cache should be plenty even if working with a one hour audio clip. // bitmap cache should be plenty even if working with a one hour audio clip.
cache_bitmap_maxsize = std::min<size_t>(max_size/8, 0x1000000); cache_bitmap_maxsize = std::min<size_t>(max_size/8, 0x1000000);
// The renderer gets whatever is left. // The renderer gets whatever is left.
cache_renderer_maxsize = max_size - 2*cache_bitmap_maxsize; cache_renderer_maxsize = max_size - 4*cache_bitmap_maxsize;
} }

View file

@ -105,10 +105,7 @@ public:
AudioSpectrumRenderer::AudioSpectrumRenderer(std::string const& color_scheme_name) AudioSpectrumRenderer::AudioSpectrumRenderer(std::string const& color_scheme_name)
: colors_normal(new AudioColorScheme(12, color_scheme_name, AudioStyle_Normal)) : derivation_size(8)
, colors_primary(new AudioColorScheme(12, color_scheme_name, AudioStyle_Primary))
, colors_inactive(new AudioColorScheme(12, color_scheme_name, AudioStyle_Inactive))
, derivation_size(8)
, derivation_dist(8) , derivation_dist(8)
#ifdef WITH_FFTW3 #ifdef WITH_FFTW3
, dft_plan(0) , dft_plan(0)
@ -116,6 +113,9 @@ AudioSpectrumRenderer::AudioSpectrumRenderer(std::string const& color_scheme_nam
, dft_output(0) , dft_output(0)
#endif #endif
{ {
colors.reserve(AudioStyle_MAX);
for (int i = 0; i < AudioStyle_MAX; ++i)
colors.push_back(AudioColorScheme(12, color_scheme_name, i));
} }
AudioSpectrumRenderer::~AudioSpectrumRenderer() AudioSpectrumRenderer::~AudioSpectrumRenderer()
@ -256,7 +256,7 @@ void AudioSpectrumRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
ptrdiff_t stride = img.GetWidth()*3; ptrdiff_t stride = img.GetWidth()*3;
int imgheight = img.GetHeight(); int imgheight = img.GetHeight();
const AudioColorScheme *pal = GetColorScheme(style); const AudioColorScheme *pal = &colors[style];
/// @todo Make minband and maxband configurable /// @todo Make minband and maxband configurable
int minband = 0; int minband = 0;
@ -315,7 +315,7 @@ void AudioSpectrumRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
void AudioSpectrumRenderer::RenderBlank(wxDC &dc, const wxRect &rect, AudioRenderingStyle style) void AudioSpectrumRenderer::RenderBlank(wxDC &dc, const wxRect &rect, AudioRenderingStyle style)
{ {
// Get the colour of silence // Get the colour of silence
wxColour col = GetColorScheme(style)->get(0.0f); wxColour col = colors[style].get(0.0f);
dc.SetBrush(wxBrush(col)); dc.SetBrush(wxBrush(col));
dc.SetPen(wxPen(col)); dc.SetPen(wxPen(col));
dc.DrawRectangle(rect); dc.DrawRectangle(rect);
@ -326,12 +326,3 @@ void AudioSpectrumRenderer::AgeCache(size_t max_size)
if (cache) if (cache)
cache->Age(max_size); cache->Age(max_size);
} }
const AudioColorScheme *AudioSpectrumRenderer::GetColorScheme(AudioRenderingStyle style) const
{
switch (style)
{
case AudioStyle_Primary: return colors_primary.get();
case AudioStyle_Inactive: return colors_inactive.get();
default: return colors_normal.get();
}
}

View file

@ -63,14 +63,8 @@ class AudioSpectrumRenderer : public AudioRendererBitmapProvider {
/// Internal cache management for the spectrum /// Internal cache management for the spectrum
agi::scoped_ptr<AudioSpectrumCache> cache; agi::scoped_ptr<AudioSpectrumCache> cache;
/// Colour table used for regular rendering /// Colour tables used for rendering
agi::scoped_ptr<AudioColorScheme> colors_normal; std::vector<AudioColorScheme> colors;
/// Colour table used for rendering the audio selection
agi::scoped_ptr<AudioColorScheme> colors_primary;
/// Colour table used for rendering inactive lines
agi::scoped_ptr<AudioColorScheme> colors_inactive;
/// Binary logarithm of number of samples to use in deriving frequency-power data /// Binary logarithm of number of samples to use in deriving frequency-power data
size_t derivation_size; size_t derivation_size;
@ -116,9 +110,6 @@ class AudioSpectrumRenderer : public AudioRendererBitmapProvider {
/// Pre-allocated scratch area for storing raw audio data /// Pre-allocated scratch area for storing raw audio data
std::vector<int16_t> audio_scratch; std::vector<int16_t> audio_scratch;
/// Get the color scheme for a rendering style
const AudioColorScheme *GetColorScheme(AudioRenderingStyle style) const;
public: public:
/// @brief Constructor /// @brief Constructor
/// @param color_scheme_name Name of the color scheme to use /// @param color_scheme_name Name of the color scheme to use

View file

@ -59,15 +59,14 @@ enum {
}; };
AudioWaveformRenderer::AudioWaveformRenderer(std::string const& color_scheme_name) AudioWaveformRenderer::AudioWaveformRenderer(std::string const& color_scheme_name)
: colors_normal(new AudioColorScheme(6, color_scheme_name, AudioStyle_Normal)) : audio_buffer(0)
, colors_primary(new AudioColorScheme(6, color_scheme_name, AudioStyle_Primary))
, colors_inactive(new AudioColorScheme(6, color_scheme_name, AudioStyle_Inactive))
, audio_buffer(0)
, render_averages(OPT_GET("Audio/Display/Waveform Style")->GetInt() == Waveform_MaxAvg) , render_averages(OPT_GET("Audio/Display/Waveform Style")->GetInt() == Waveform_MaxAvg)
{ {
colors.reserve(AudioStyle_MAX);
for (int i = 0; i < AudioStyle_MAX; ++i)
colors.push_back(AudioColorScheme(6, color_scheme_name, i));
} }
AudioWaveformRenderer::~AudioWaveformRenderer() AudioWaveformRenderer::~AudioWaveformRenderer()
{ {
delete[] audio_buffer; delete[] audio_buffer;
@ -80,7 +79,7 @@ void AudioWaveformRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
wxRect rect(wxPoint(0, 0), bmp.GetSize()); wxRect rect(wxPoint(0, 0), bmp.GetSize());
int midpoint = rect.height / 2; int midpoint = rect.height / 2;
const AudioColorScheme *pal = GetColorScheme(style); const AudioColorScheme *pal = &colors[style];
int pixel_samples = (pixel_ms * provider->GetSampleRate() + 500) / 1000; int pixel_samples = (pixel_ms * provider->GetSampleRate() + 500) / 1000;
@ -153,7 +152,7 @@ void AudioWaveformRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
void AudioWaveformRenderer::RenderBlank(wxDC &dc, const wxRect &rect, AudioRenderingStyle style) void AudioWaveformRenderer::RenderBlank(wxDC &dc, const wxRect &rect, AudioRenderingStyle style)
{ {
const AudioColorScheme *pal = GetColorScheme(style); const AudioColorScheme *pal = &colors[style];
wxColor line(pal->get(1.0)); wxColor line(pal->get(1.0));
wxColor bg(pal->get(0.0)); wxColor bg(pal->get(0.0));
@ -182,16 +181,6 @@ void AudioWaveformRenderer::OnSetMillisecondsPerPixel()
audio_buffer = 0; audio_buffer = 0;
} }
const AudioColorScheme *AudioWaveformRenderer::GetColorScheme(AudioRenderingStyle style) const
{
switch (style)
{
case AudioStyle_Primary: return colors_primary.get();
case AudioStyle_Inactive: return colors_inactive.get();
default: return colors_normal.get();
}
}
wxArrayString AudioWaveformRenderer::GetWaveformStyles() { wxArrayString AudioWaveformRenderer::GetWaveformStyles() {
wxArrayString ret; wxArrayString ret;
ret.push_back(_("Maximum")); ret.push_back(_("Maximum"));

View file

@ -37,23 +37,16 @@
#ifndef AGI_PRE #ifndef AGI_PRE
#include <stdint.h> #include <stdint.h>
#include <vector>
#endif #endif
#include <libaegisub/scoped_ptr.h>
class AudioColorScheme; class AudioColorScheme;
#include "audio_renderer.h" #include "audio_renderer.h"
class AudioWaveformRenderer : public AudioRendererBitmapProvider { class AudioWaveformRenderer : public AudioRendererBitmapProvider {
/// Colour table used for regular rendering /// Colour tables used for rendering
agi::scoped_ptr<AudioColorScheme> colors_normal; std::vector<AudioColorScheme> colors;
/// Colour table used for rendering the audio selection
agi::scoped_ptr<AudioColorScheme> colors_primary;
/// Colour table used for rendering inactive lines
agi::scoped_ptr<AudioColorScheme> colors_inactive;
/// Pre-allocated buffer for audio fetched from provider /// Pre-allocated buffer for audio fetched from provider
char *audio_buffer; char *audio_buffer;
@ -61,9 +54,6 @@ class AudioWaveformRenderer : public AudioRendererBitmapProvider {
/// Whether to render max+avg or just max /// Whether to render max+avg or just max
bool render_averages; bool render_averages;
/// Get the color scheme for a rendering style
const AudioColorScheme *GetColorScheme(AudioRenderingStyle style) const;
void OnSetProvider(); void OnSetProvider();
void OnSetMillisecondsPerPixel(); void OnSetMillisecondsPerPixel();

View file

@ -36,7 +36,7 @@
/// overlap inactive, which should overlap normal regions. /// overlap inactive, which should overlap normal regions.
enum AudioRenderingStyle { enum AudioRenderingStyle {
/// Regular audio with no special properties /// Regular audio with no special properties
AudioStyle_Normal, AudioStyle_Normal = 0,
/// Audio belonging to objects that are not part of the current selection /// Audio belonging to objects that are not part of the current selection
AudioStyle_Inactive, AudioStyle_Inactive,
/// Audio belonging to objects that are part of the current selection, /// Audio belonging to objects that are part of the current selection,

View file

@ -126,15 +126,15 @@
"Lightness Offset" : 0.0, "Lightness Offset" : 0.0,
"Lightness Scale" : 100.0 "Lightness Scale" : 100.0
}, },
"Active" : { "Selection" : {
"Hue Offset" : 85.0, "Hue Offset" : 80.0,
"Hue Scale" : 0.0, "Hue Scale" : 0.0,
"Saturation Offset" : 255.0, "Saturation Offset" : 255.0,
"Saturation Scale" : 0.0, "Saturation Scale" : 0.0,
"Lightness Offset" : 0.0, "Lightness Offset" : 10.0,
"Lightness Scale" : 0.0 "Lightness Scale" : 175.0
}, },
"Selected" : { "Primary" : {
"Hue Offset" : 85.0, "Hue Offset" : 85.0,
"Hue Scale" : 0.0, "Hue Scale" : 0.0,
"Saturation Offset" : 128.0, "Saturation Offset" : 128.0,
@ -163,6 +163,14 @@
"Lightness Scale" : 255.0 "Lightness Scale" : 255.0
}, },
"Inactive" : { "Inactive" : {
"Hue Offset" : 191.0,
"Hue Scale" : -128.0,
"Saturation Offset" : 63.0,
"Saturation Scale" : 192.0,
"Lightness Offset" : 32.0,
"Lightness Scale" : 192.0
},
"Selection" : {
"Hue Offset" : 191.0, "Hue Offset" : 191.0,
"Hue Scale" : -128.0, "Hue Scale" : -128.0,
"Saturation Offset" : 127.0, "Saturation Offset" : 127.0,
@ -170,15 +178,7 @@
"Lightness Offset" : 32.0, "Lightness Offset" : 32.0,
"Lightness Scale" : 192.0 "Lightness Scale" : 192.0
}, },
"Active" : { "Primary" : {
"Hue Offset" : 191.0,
"Hue Scale" : -128.0,
"Saturation Offset" : 127.0,
"Saturation Scale" : 128.0,
"Lightness Offset" : 0.0,
"Lightness Scale" : 0.0
},
"Selected" : {
"Hue Offset" : 191.0, "Hue Offset" : 191.0,
"Hue Scale" : -128.0, "Hue Scale" : -128.0,
"Saturation Offset" : 127.0, "Saturation Offset" : 127.0,