mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
start putting some relevant elements into the AudioClipEditor
This commit is contained in:
parent
12dc428a60
commit
757debb711
2 changed files with 99 additions and 20 deletions
|
|
@ -28,12 +28,16 @@
|
||||||
#include "canvas/debug.h"
|
#include "canvas/debug.h"
|
||||||
#include "canvas/utils.h"
|
#include "canvas/utils.h"
|
||||||
|
|
||||||
|
#include "waveview/wave_view.h"
|
||||||
|
|
||||||
|
#include "ardour/audioregion.h"
|
||||||
#include "ardour/location.h"
|
#include "ardour/location.h"
|
||||||
#include "ardour/profile.h"
|
#include "ardour/profile.h"
|
||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
|
|
||||||
#include "widgets/ardour_button.h"
|
#include "widgets/ardour_button.h"
|
||||||
|
|
||||||
|
#include "audio_clip_editor.h"
|
||||||
#include "audio_clock.h"
|
#include "audio_clock.h"
|
||||||
#include "automation_line.h"
|
#include "automation_line.h"
|
||||||
#include "control_point.h"
|
#include "control_point.h"
|
||||||
|
|
@ -41,13 +45,12 @@
|
||||||
#include "region_view.h"
|
#include "region_view.h"
|
||||||
#include "ui_config.h"
|
#include "ui_config.h"
|
||||||
|
|
||||||
#include "audio_clip_editor.h"
|
|
||||||
|
|
||||||
#include "pbd/i18n.h"
|
#include "pbd/i18n.h"
|
||||||
|
|
||||||
using namespace Gtk;
|
using namespace Gtk;
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace ArdourCanvas;
|
using namespace ArdourCanvas;
|
||||||
|
using namespace ArdourWaveView;
|
||||||
using std::min;
|
using std::min;
|
||||||
using std::max;
|
using std::max;
|
||||||
|
|
||||||
|
|
@ -55,32 +58,97 @@ using std::max;
|
||||||
|
|
||||||
AudioClipEditor::AudioClipEditor ()
|
AudioClipEditor::AudioClipEditor ()
|
||||||
{
|
{
|
||||||
// set_homogenous (true);
|
set_background_color (UIConfiguration::instance().color (X_("theme:bg")));
|
||||||
// set_row_spacing (4);
|
|
||||||
|
|
||||||
set_background_color (UIConfiguration::instance().color (X_("theme:darkest")));
|
|
||||||
|
|
||||||
const double scale = UIConfiguration::instance().get_ui_scale();
|
const double scale = UIConfiguration::instance().get_ui_scale();
|
||||||
const double width = 600. * scale;
|
|
||||||
const double height = 210. * scale;
|
|
||||||
|
|
||||||
// name = string_compose ("trigger %1", _trigger.index());
|
|
||||||
|
|
||||||
frame = new Rectangle (this);
|
|
||||||
|
|
||||||
ArdourCanvas::Rect r (0, 0, width, height);
|
|
||||||
frame->set (r);
|
|
||||||
frame->set_outline_all ();
|
|
||||||
|
|
||||||
|
frame = new Rectangle (root());
|
||||||
|
frame->name = "audio clip editor frame";
|
||||||
|
frame->set_fill_color (UIConfiguration::instance().color (X_("theme:contrasting")));
|
||||||
|
frame->set_outline_color (UIConfiguration::instance().color (X_("theme:darkest")));
|
||||||
frame->Event.connect (sigc::mem_fun (*this, &AudioClipEditor::event_handler));
|
frame->Event.connect (sigc::mem_fun (*this, &AudioClipEditor::event_handler));
|
||||||
|
|
||||||
// selection_connection = PublicEditor::instance().get_selection().TriggersChanged.connect (sigc::mem_fun (*this, &TriggerBoxUI::selection_changed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioClipEditor::~AudioClipEditor ()
|
AudioClipEditor::~AudioClipEditor ()
|
||||||
{
|
{
|
||||||
|
drop_waves ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioClipEditor::drop_waves ()
|
||||||
|
{
|
||||||
|
for (auto & wave : waves) {
|
||||||
|
delete wave;
|
||||||
|
}
|
||||||
|
|
||||||
|
waves.clear ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioClipEditor::set_region (boost::shared_ptr<AudioRegion> r)
|
||||||
|
{
|
||||||
|
drop_waves ();
|
||||||
|
|
||||||
|
uint32_t n_chans = r->n_channels ();
|
||||||
|
|
||||||
|
for (uint32_t n = 0; n < n_chans; ++n) {
|
||||||
|
WaveView* wv = new WaveView (this, r);
|
||||||
|
wv->set_channel (n);
|
||||||
|
waves.push_back (wv);
|
||||||
|
}
|
||||||
|
|
||||||
|
int h = get_allocation().get_height ();
|
||||||
|
|
||||||
|
if (h) {
|
||||||
|
set_wave_heights (h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioClipEditor::on_size_allocate (Gtk::Allocation& alloc)
|
||||||
|
{
|
||||||
|
GtkCanvas::on_size_allocate (alloc);
|
||||||
|
|
||||||
|
ArdourCanvas::Rect r (1, 1, alloc.get_width() - 2, alloc.get_height() - 2);
|
||||||
|
frame->set (r);
|
||||||
|
|
||||||
|
set_wave_heights (r.height() - 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioClipEditor::set_wave_heights (int h)
|
||||||
|
{
|
||||||
|
if (waves.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t n = 0;
|
||||||
|
Distance ht = h / waves.size();
|
||||||
|
|
||||||
|
for (auto & wave : waves) {
|
||||||
|
wave->set_height (ht);
|
||||||
|
wave->set_y_position (n * ht);
|
||||||
|
wave->set_samples_per_pixel (8192);
|
||||||
|
wave->set_show_zero_line (false);
|
||||||
|
wave->set_clip_level (1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioClipEditor::set_waveform_colors ()
|
||||||
|
{
|
||||||
|
Gtkmm2ext::Color clip = UIConfiguration::instance().color ("clipped waveform");
|
||||||
|
Gtkmm2ext::Color zero = UIConfiguration::instance().color ("zero line");
|
||||||
|
Gtkmm2ext::Color fill = UIConfiguration::instance().color ("waveform fill");
|
||||||
|
Gtkmm2ext::Color outline = UIConfiguration::instance().color ("waveform outline");
|
||||||
|
|
||||||
|
for (auto & wave : waves) {
|
||||||
|
wave->set_fill_color (fill);
|
||||||
|
wave->set_outline_color (outline);
|
||||||
|
wave->set_clip_color (clip);
|
||||||
|
wave->set_zero_color (zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
bool
|
bool
|
||||||
AudioClipEditor::event_handler (GdkEvent* ev)
|
AudioClipEditor::event_handler (GdkEvent* ev)
|
||||||
{
|
{
|
||||||
|
|
@ -110,7 +178,7 @@ AudioClipEditorBox::AudioClipEditorBox ()
|
||||||
pack_start(_header_label, false, false, 6);
|
pack_start(_header_label, false, false, 6);
|
||||||
|
|
||||||
editor = manage (new AudioClipEditor);
|
editor = manage (new AudioClipEditor);
|
||||||
editor->set_size_request(600,120);
|
// editor->set_size_request(600,120);
|
||||||
|
|
||||||
pack_start(*editor, true, true);
|
pack_start(*editor, true, true);
|
||||||
editor->show();
|
editor->show();
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,10 @@ namespace ArdourCanvas {
|
||||||
class Polygon;
|
class Polygon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace ArdourWaveView {
|
||||||
|
class WaveView;
|
||||||
|
}
|
||||||
|
|
||||||
class ClipEditorBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr
|
class ClipEditorBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -56,17 +60,24 @@ public:
|
||||||
virtual void set_region (boost::shared_ptr<ARDOUR::Region>) =0;
|
virtual void set_region (boost::shared_ptr<ARDOUR::Region>) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class AudioClipEditor : public ArdourCanvas::GtkCanvas
|
class AudioClipEditor : public ArdourCanvas::GtkCanvas
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioClipEditor ();
|
AudioClipEditor ();
|
||||||
~AudioClipEditor ();
|
~AudioClipEditor ();
|
||||||
|
|
||||||
|
void set_region (boost::shared_ptr<ARDOUR::AudioRegion>);
|
||||||
|
void on_size_allocate (Gtk::Allocation&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ArdourCanvas::Rectangle* frame;
|
ArdourCanvas::Rectangle* frame;
|
||||||
bool event_handler (GdkEvent* ev);
|
bool event_handler (GdkEvent* ev);
|
||||||
|
|
||||||
|
std::vector<ArdourWaveView::WaveView *> waves;
|
||||||
|
|
||||||
|
void drop_waves ();
|
||||||
|
void set_wave_heights (int);
|
||||||
|
void set_waveform_colors ();
|
||||||
};
|
};
|
||||||
|
|
||||||
class AudioClipEditorBox : public ClipEditorBox
|
class AudioClipEditorBox : public ClipEditorBox
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue