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_Inactive: opt_base += "Inactive/"; break;
case AudioStyle_Selected: opt_base += "Active/"; break;
case AudioStyle_Primary: opt_base += "Selected/"; break;
case AudioStyle_Selected: opt_base += "Selection/"; break;
case AudioStyle_Primary: opt_base += "Primary/"; break;
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.
cache_bitmap_maxsize = std::min<size_t>(max_size/8, 0x1000000);
// 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)
: colors_normal(new AudioColorScheme(12, color_scheme_name, AudioStyle_Normal))
, colors_primary(new AudioColorScheme(12, color_scheme_name, AudioStyle_Primary))
, colors_inactive(new AudioColorScheme(12, color_scheme_name, AudioStyle_Inactive))
, derivation_size(8)
: derivation_size(8)
, derivation_dist(8)
#ifdef WITH_FFTW3
, dft_plan(0)
@ -116,6 +113,9 @@ AudioSpectrumRenderer::AudioSpectrumRenderer(std::string const& color_scheme_nam
, dft_output(0)
#endif
{
colors.reserve(AudioStyle_MAX);
for (int i = 0; i < AudioStyle_MAX; ++i)
colors.push_back(AudioColorScheme(12, color_scheme_name, i));
}
AudioSpectrumRenderer::~AudioSpectrumRenderer()
@ -256,7 +256,7 @@ void AudioSpectrumRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
ptrdiff_t stride = img.GetWidth()*3;
int imgheight = img.GetHeight();
const AudioColorScheme *pal = GetColorScheme(style);
const AudioColorScheme *pal = &colors[style];
/// @todo Make minband and maxband configurable
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)
{
// Get the colour of silence
wxColour col = GetColorScheme(style)->get(0.0f);
wxColour col = colors[style].get(0.0f);
dc.SetBrush(wxBrush(col));
dc.SetPen(wxPen(col));
dc.DrawRectangle(rect);
@ -326,12 +326,3 @@ void AudioSpectrumRenderer::AgeCache(size_t max_size)
if (cache)
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
agi::scoped_ptr<AudioSpectrumCache> cache;
/// Colour table used for regular rendering
agi::scoped_ptr<AudioColorScheme> colors_normal;
/// 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;
/// Colour tables used for rendering
std::vector<AudioColorScheme> colors;
/// Binary logarithm of number of samples to use in deriving frequency-power data
size_t derivation_size;
@ -116,9 +110,6 @@ class AudioSpectrumRenderer : public AudioRendererBitmapProvider {
/// Pre-allocated scratch area for storing raw audio data
std::vector<int16_t> audio_scratch;
/// Get the color scheme for a rendering style
const AudioColorScheme *GetColorScheme(AudioRenderingStyle style) const;
public:
/// @brief Constructor
/// @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)
: colors_normal(new AudioColorScheme(6, color_scheme_name, AudioStyle_Normal))
, colors_primary(new AudioColorScheme(6, color_scheme_name, AudioStyle_Primary))
, colors_inactive(new AudioColorScheme(6, color_scheme_name, AudioStyle_Inactive))
, audio_buffer(0)
: audio_buffer(0)
, 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()
{
delete[] audio_buffer;
@ -80,7 +79,7 @@ void AudioWaveformRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
wxRect rect(wxPoint(0, 0), bmp.GetSize());
int midpoint = rect.height / 2;
const AudioColorScheme *pal = GetColorScheme(style);
const AudioColorScheme *pal = &colors[style];
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)
{
const AudioColorScheme *pal = GetColorScheme(style);
const AudioColorScheme *pal = &colors[style];
wxColor line(pal->get(1.0));
wxColor bg(pal->get(0.0));
@ -182,16 +181,6 @@ void AudioWaveformRenderer::OnSetMillisecondsPerPixel()
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 ret;
ret.push_back(_("Maximum"));

View file

@ -37,23 +37,16 @@
#ifndef AGI_PRE
#include <stdint.h>
#include <vector>
#endif
#include <libaegisub/scoped_ptr.h>
class AudioColorScheme;
#include "audio_renderer.h"
class AudioWaveformRenderer : public AudioRendererBitmapProvider {
/// Colour table used for regular rendering
agi::scoped_ptr<AudioColorScheme> colors_normal;
/// 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;
/// Colour tables used for rendering
std::vector<AudioColorScheme> colors;
/// Pre-allocated buffer for audio fetched from provider
char *audio_buffer;
@ -61,9 +54,6 @@ class AudioWaveformRenderer : public AudioRendererBitmapProvider {
/// 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;
void OnSetProvider();
void OnSetMillisecondsPerPixel();

View file

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

View file

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