mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
add back various functionality to waveviews such as zero line, amplitude scaling
This commit is contained in:
parent
e3db2d3ca5
commit
a0044e5f71
8 changed files with 155 additions and 40 deletions
|
|
@ -330,10 +330,10 @@ AudioRegionView::fade_out_active_changed ()
|
||||||
void
|
void
|
||||||
AudioRegionView::region_scale_amplitude_changed ()
|
AudioRegionView::region_scale_amplitude_changed ()
|
||||||
{
|
{
|
||||||
ENSURE_GUI_THREAD (*this, &AudioRegionView::region_scale_amplitude_changed)
|
double g = audio_region()->scale_amplitude ();
|
||||||
|
|
||||||
for (uint32_t n = 0; n < waves.size(); ++n) {
|
for (uint32_t n = 0; n < waves.size(); ++n) {
|
||||||
waves[n]->rebuild ();
|
waves[n]->set_amplitude (g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -766,8 +766,8 @@ AudioRegionView::set_colors ()
|
||||||
waves[n]->set_outline_color (ARDOUR_UI::config()->canvasvar_WaveForm.get());
|
waves[n]->set_outline_color (ARDOUR_UI::config()->canvasvar_WaveForm.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
waves[n]->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
|
waves[n]->set_clip_color (ARDOUR_UI::config()->canvasvar_WaveFormClip.get());
|
||||||
waves[n]->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
|
waves[n]->set_zero_color (ARDOUR_UI::config()->canvasvar_ZeroLine.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -780,7 +780,7 @@ AudioRegionView::setup_waveform_visibility ()
|
||||||
this when waveforms are hidden.
|
this when waveforms are hidden.
|
||||||
*/
|
*/
|
||||||
// CAIROCANVAS
|
// CAIROCANVAS
|
||||||
//waves[n]->set_samples_per_pixel (_samples_per_pixel);
|
// waves[n]->set_samples_per_pixel (_samples_per_pixel);
|
||||||
waves[n]->show();
|
waves[n]->show();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -909,14 +909,22 @@ AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/)
|
||||||
wave->set_fill_color (ARDOUR_UI::config()->canvasvar_WaveFormFill.get());
|
wave->set_fill_color (ARDOUR_UI::config()->canvasvar_WaveFormFill.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
wave->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
|
wave->set_clip_color (ARDOUR_UI::config()->canvasvar_WaveFormClip.get());
|
||||||
wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
|
wave->set_zero_color (ARDOUR_UI::config()->canvasvar_ZeroLine.get());
|
||||||
// CAIROCANVAS
|
// CAIROCANVAS
|
||||||
// wave->property_zero_line() = true;
|
// wave->property_zero_line() = true;
|
||||||
|
|
||||||
wave->set_region_start (_region->start());
|
wave->set_region_start (_region->start());
|
||||||
wave->property_rectified() = Config->get_waveform_shape() == Rectified;
|
|
||||||
wave->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
|
switch (Config->get_waveform_shape()) {
|
||||||
|
case Rectified:
|
||||||
|
wave->set_shape (WaveView::Rectified);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
wave->set_shape (WaveView::Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
wave->set_logscaled (Config->get_waveform_scale() == Logarithmic);
|
||||||
|
|
||||||
if (!Config->get_show_waveforms ()) {
|
if (!Config->get_show_waveforms ()) {
|
||||||
wave->hide();
|
wave->hide();
|
||||||
|
|
@ -1025,8 +1033,17 @@ AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent */*
|
||||||
void
|
void
|
||||||
AudioRegionView::setup_waveform_shape ()
|
AudioRegionView::setup_waveform_shape ()
|
||||||
{
|
{
|
||||||
|
WaveView::Shape shape;
|
||||||
|
|
||||||
|
switch (Config->get_waveform_shape()) {
|
||||||
|
case Rectified:
|
||||||
|
shape = WaveView::Rectified;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shape = WaveView::Normal;
|
||||||
|
}
|
||||||
for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
|
for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
|
||||||
(*wave)->property_rectified() = Config->get_waveform_shape() == Rectified;
|
(*wave)->set_shape (shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1034,7 +1051,7 @@ void
|
||||||
AudioRegionView::setup_waveform_scale ()
|
AudioRegionView::setup_waveform_scale ()
|
||||||
{
|
{
|
||||||
for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
|
for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
|
||||||
(*wave)->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
|
(*wave)->set_logscaled (Config->get_waveform_scale() == Logarithmic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,8 @@ AudioGhostRegion::set_colors ()
|
||||||
for (uint32_t n=0; n < waves.size(); ++n) {
|
for (uint32_t n=0; n < waves.size(); ++n) {
|
||||||
waves[n]->set_outline_color (ARDOUR_UI::config()->canvasvar_GhostTrackWave.get());
|
waves[n]->set_outline_color (ARDOUR_UI::config()->canvasvar_GhostTrackWave.get());
|
||||||
waves[n]->set_fill_color (fill_color);
|
waves[n]->set_fill_color (fill_color);
|
||||||
waves[n]->property_clip_color() = ARDOUR_UI::config()->canvasvar_GhostTrackWaveClip.get();
|
waves[n]->set_clip_color (ARDOUR_UI::config()->canvasvar_GhostTrackWaveClip.get());
|
||||||
waves[n]->property_zero_color() = ARDOUR_UI::config()->canvasvar_GhostTrackZeroLine.get();
|
waves[n]->set_zero_color (ARDOUR_UI::config()->canvasvar_GhostTrackZeroLine.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ TapeAudioRegionView::~TapeAudioRegionView()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TapeAudioRegionView::update (uint32_t n)
|
TapeAudioRegionView::update (uint32_t /*n*/)
|
||||||
{
|
{
|
||||||
/* check that all waves are build and ready */
|
/* check that all waves are build and ready */
|
||||||
|
|
||||||
|
|
@ -88,7 +88,8 @@ TapeAudioRegionView::update (uint32_t n)
|
||||||
}
|
}
|
||||||
|
|
||||||
ENSURE_GUI_THREAD (*this, &TapeAudioRegionView::update, n);
|
ENSURE_GUI_THREAD (*this, &TapeAudioRegionView::update, n);
|
||||||
waves[n]->rebuild ();
|
// CAIROCANVAS
|
||||||
|
// waves[n]->rebuild ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,19 @@ Canvas::item_shown_or_hidden (Item* item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called when an item has a change to its visual properties
|
||||||
|
* that do NOT affect its bounding box.
|
||||||
|
* @param item Item that has been modified.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Canvas::item_visual_property_changed (Item* item)
|
||||||
|
{
|
||||||
|
boost::optional<Rect> bbox = item->bounding_box ();
|
||||||
|
if (bbox) {
|
||||||
|
queue_draw_item_area (item, bbox.get ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Called when an item has changed, but not moved.
|
/** Called when an item has changed, but not moved.
|
||||||
* @param item Item that has changed.
|
* @param item Item that has changed.
|
||||||
* @param pre_change_bounding_box The bounding box of item before the change,
|
* @param pre_change_bounding_box The bounding box of item before the change,
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,11 @@ public:
|
||||||
/** Called when an item is being destroyed */
|
/** Called when an item is being destroyed */
|
||||||
virtual void item_going_away (Item *, boost::optional<Rect>) {}
|
virtual void item_going_away (Item *, boost::optional<Rect>) {}
|
||||||
void item_shown_or_hidden (Item *);
|
void item_shown_or_hidden (Item *);
|
||||||
|
void item_visual_property_changed (Item*);
|
||||||
void item_changed (Item *, boost::optional<Rect>);
|
void item_changed (Item *, boost::optional<Rect>);
|
||||||
void item_moved (Item *, boost::optional<Rect>);
|
void item_moved (Item *, boost::optional<Rect>);
|
||||||
|
|
||||||
virtual Cairo::RefPtr<Cairo::Context> context () = 0;
|
virtual Cairo::RefPtr<Cairo::Context> context () = 0;
|
||||||
|
|
||||||
std::list<Rect> const & renders () const {
|
std::list<Rect> const & renders () const {
|
||||||
return _renders;
|
return _renders;
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,11 @@ namespace ArdourCanvas {
|
||||||
class WaveView : virtual public Item, public Outline, public Fill
|
class WaveView : virtual public Item, public Outline, public Fill
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum Shape {
|
||||||
|
Normal,
|
||||||
|
Rectified,
|
||||||
|
};
|
||||||
|
|
||||||
WaveView (Group *, boost::shared_ptr<ARDOUR::AudioRegion>);
|
WaveView (Group *, boost::shared_ptr<ARDOUR::AudioRegion>);
|
||||||
|
|
||||||
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
|
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
|
||||||
|
|
@ -58,8 +63,17 @@ public:
|
||||||
|
|
||||||
void region_resized ();
|
void region_resized ();
|
||||||
|
|
||||||
/* XXX */
|
void set_show_zero_line (bool);
|
||||||
void rebuild () {}
|
bool show_zero_line() const { return _show_zero; }
|
||||||
|
void set_zero_color (Color);
|
||||||
|
void set_clip_color (Color);
|
||||||
|
void set_amplitude (double);
|
||||||
|
double amplitude() const { return _amplitude; }
|
||||||
|
void set_logscaled (bool);
|
||||||
|
bool logscaled() const { return _logscaled; }
|
||||||
|
|
||||||
|
void set_shape (Shape);
|
||||||
|
Shape shape() const;
|
||||||
|
|
||||||
#ifdef CANVAS_COMPATIBILITY
|
#ifdef CANVAS_COMPATIBILITY
|
||||||
void*& property_gain_src () {
|
void*& property_gain_src () {
|
||||||
|
|
@ -68,22 +82,9 @@ public:
|
||||||
void*& property_gain_function () {
|
void*& property_gain_function () {
|
||||||
return _foo_void;
|
return _foo_void;
|
||||||
}
|
}
|
||||||
bool& property_rectified () {
|
|
||||||
return _foo_bool;
|
|
||||||
}
|
|
||||||
bool& property_logscaled () {
|
|
||||||
return _foo_bool;
|
|
||||||
}
|
|
||||||
double& property_amplitude_above_axis () {
|
double& property_amplitude_above_axis () {
|
||||||
return _foo_double;
|
return _foo_double;
|
||||||
}
|
}
|
||||||
Color& property_clip_color () {
|
|
||||||
return _foo_uint;
|
|
||||||
}
|
|
||||||
Color& property_zero_color () {
|
|
||||||
return _foo_uint;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void* _foo_void;
|
void* _foo_void;
|
||||||
bool _foo_bool;
|
bool _foo_bool;
|
||||||
|
|
@ -114,7 +115,7 @@ private:
|
||||||
void clear_image ();
|
void clear_image ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Coord position (float) const;
|
Coord position (Coord) const;
|
||||||
|
|
||||||
WaveView const * _wave_view;
|
WaveView const * _wave_view;
|
||||||
int _start;
|
int _start;
|
||||||
|
|
@ -135,6 +136,13 @@ private:
|
||||||
double _samples_per_pixel;
|
double _samples_per_pixel;
|
||||||
Coord _height;
|
Coord _height;
|
||||||
Color _wave_color;
|
Color _wave_color;
|
||||||
|
bool _show_zero;
|
||||||
|
Color _zero_color;
|
||||||
|
Shape _shape;
|
||||||
|
Color _clip_color;
|
||||||
|
bool _logscaled;
|
||||||
|
double _amplitude;
|
||||||
|
|
||||||
/** The `start' value to use for the region; we can't use the region's
|
/** The `start' value to use for the region; we can't use the region's
|
||||||
* value as the crossfade editor needs to alter it.
|
* value as the crossfade editor needs to alter it.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,9 @@ Text::compute_bounding_box () const
|
||||||
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
|
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
|
||||||
|
|
||||||
layout->set_text (_text);
|
layout->set_text (_text);
|
||||||
layout->set_font_description (*_font_description);
|
if (_font_description) {
|
||||||
|
layout->set_font_description (*_font_description);
|
||||||
|
}
|
||||||
layout->set_alignment (_alignment);
|
layout->set_alignment (_alignment);
|
||||||
Pango::Rectangle const r = layout->get_ink_extents ();
|
Pango::Rectangle const r = layout->get_ink_extents ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "canvas/wave_view.h"
|
#include "canvas/wave_view.h"
|
||||||
#include "canvas/utils.h"
|
#include "canvas/utils.h"
|
||||||
|
#include "canvas/canvas.h"
|
||||||
|
|
||||||
#include <gdkmm/general.h>
|
#include <gdkmm/general.h>
|
||||||
|
|
||||||
|
|
@ -46,6 +47,12 @@ WaveView::WaveView (Group* parent, boost::shared_ptr<ARDOUR::AudioRegion> region
|
||||||
, _samples_per_pixel (0)
|
, _samples_per_pixel (0)
|
||||||
, _height (64)
|
, _height (64)
|
||||||
, _wave_color (0xffffffff)
|
, _wave_color (0xffffffff)
|
||||||
|
, _show_zero (true)
|
||||||
|
, _zero_color (0xff0000ff)
|
||||||
|
, _shape (Normal)
|
||||||
|
, _clip_color (0xff0000ff)
|
||||||
|
, _logscaled (false)
|
||||||
|
, _amplitude (1.0)
|
||||||
, _region_start (0)
|
, _region_start (0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -215,6 +222,65 @@ WaveView::region_resized ()
|
||||||
_bounding_box_dirty = true;
|
_bounding_box_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WaveView::set_logscaled (bool yn)
|
||||||
|
{
|
||||||
|
if (_logscaled != yn) {
|
||||||
|
_logscaled = yn;
|
||||||
|
invalidate_whole_cache ();
|
||||||
|
_canvas->item_visual_property_changed (this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WaveView::set_amplitude (double a)
|
||||||
|
{
|
||||||
|
if (_amplitude != a) {
|
||||||
|
_amplitude = a;
|
||||||
|
invalidate_whole_cache ();
|
||||||
|
_canvas->item_visual_property_changed (this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WaveView::set_zero_color (Color c)
|
||||||
|
{
|
||||||
|
if (_zero_color != c) {
|
||||||
|
_zero_color = c;
|
||||||
|
invalidate_whole_cache ();
|
||||||
|
_canvas->item_visual_property_changed (this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WaveView::set_clip_color (Color c)
|
||||||
|
{
|
||||||
|
if (_clip_color != c) {
|
||||||
|
_clip_color = c;
|
||||||
|
invalidate_whole_cache ();
|
||||||
|
_canvas->item_visual_property_changed (this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WaveView::set_show_zero_line (bool yn)
|
||||||
|
{
|
||||||
|
if (_show_zero != yn) {
|
||||||
|
_show_zero = yn;
|
||||||
|
invalidate_whole_cache ();
|
||||||
|
_canvas->item_visual_property_changed (this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WaveView::set_shape (Shape s)
|
||||||
|
{
|
||||||
|
if (_shape != s) {
|
||||||
|
_shape = s;
|
||||||
|
_canvas->item_visual_property_changed (this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WaveView::set_region_start (frameoffset_t start)
|
WaveView::set_region_start (frameoffset_t start)
|
||||||
{
|
{
|
||||||
|
|
@ -262,20 +328,27 @@ WaveView::CacheEntry::image ()
|
||||||
_wave_view->setup_outline_context (context);
|
_wave_view->setup_outline_context (context);
|
||||||
context->move_to (0.5, position (_peaks[0].min));
|
context->move_to (0.5, position (_peaks[0].min));
|
||||||
for (int i = 1; i < _n_peaks; ++i) {
|
for (int i = 1; i < _n_peaks; ++i) {
|
||||||
context->line_to (i + 0.5, position (_peaks[i].max));
|
context->line_to (i + 0.5, position (_wave_view->amplitude() * _peaks[i].max));
|
||||||
}
|
}
|
||||||
context->stroke ();
|
context->stroke ();
|
||||||
|
|
||||||
context->move_to (0.5, position (_peaks[0].min));
|
context->move_to (0.5, position (_peaks[0].min));
|
||||||
for (int i = 1; i < _n_peaks; ++i) {
|
for (int i = 1; i < _n_peaks; ++i) {
|
||||||
context->line_to (i + 0.5, position (_peaks[i].min));
|
context->line_to (i + 0.5, position (_wave_view->amplitude() * _peaks[i].min));
|
||||||
}
|
}
|
||||||
context->stroke ();
|
context->stroke ();
|
||||||
|
|
||||||
set_source_rgba (context, _wave_view->_fill_color);
|
set_source_rgba (context, _wave_view->_fill_color);
|
||||||
for (int i = 0; i < _n_peaks; ++i) {
|
for (int i = 0; i < _n_peaks; ++i) {
|
||||||
context->move_to (i + 0.5, position (_peaks[i].max) - 1);
|
context->move_to (i + 0.5, position (_wave_view->amplitude() * (_peaks[i].max)) - 1);
|
||||||
context->line_to (i + 0.5, position (_peaks[i].min) + 1);
|
context->line_to (i + 0.5, position (_wave_view->amplitude() * (_peaks[i].min)) + 1);
|
||||||
|
context->stroke ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_wave_view->show_zero_line()) {
|
||||||
|
set_source_rgba (context, _wave_view->_zero_color);
|
||||||
|
context->move_to (0, position (0.0));
|
||||||
|
context->line_to (_n_peaks, position (0.0));
|
||||||
context->stroke ();
|
context->stroke ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -285,9 +358,9 @@ WaveView::CacheEntry::image ()
|
||||||
|
|
||||||
|
|
||||||
Coord
|
Coord
|
||||||
WaveView::CacheEntry::position (float s) const
|
WaveView::CacheEntry::position (Coord s) const
|
||||||
{
|
{
|
||||||
return (s + 1) * _wave_view->_height / 2;
|
return (s+1.0) * (_wave_view->_height / 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -297,4 +370,4 @@ WaveView::CacheEntry::clear_image ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue