mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
fix computation of silence text, and its display. it is still not on top of the canvas, which is a small problem
git-svn-id: svn://localhost/ardour2/branches/3.0@8227 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
0a62044c2c
commit
ebf3762fa9
8 changed files with 146 additions and 120 deletions
|
|
@ -81,6 +81,11 @@ style "verbose_canvas_cursor"
|
|||
font_name = "@FONT_BOLD_LARGER@"
|
||||
}
|
||||
|
||||
style "silence_text"
|
||||
{
|
||||
font_name = "@FONT_BOLD_NORMAL@"
|
||||
}
|
||||
|
||||
style "marker_text"
|
||||
{
|
||||
font_name = "@FONT_SMALL@"
|
||||
|
|
@ -1463,6 +1468,7 @@ class "GtkProgressBar" style:highest "ardour_progressbars"
|
|||
widget "*PaddedButton" style:highest "padded_button"
|
||||
widget "*FirstActionMessage" style:highest "first_action_message"
|
||||
widget "*VerboseCanvasCursor" style:highest "verbose_canvas_cursor"
|
||||
widget "*SilenceText" style:highest "silence_text"
|
||||
widget "*MarkerText" style:highest "marker_text"
|
||||
widget "*TimeAxisViewItemName*" style:highest "time_axis_view_item_name"
|
||||
widget "*EditModeSelector" style:highest "medium_bold_entry"
|
||||
|
|
|
|||
|
|
@ -72,6 +72,11 @@ style "verbose_canvas_cursor"
|
|||
font_name = "@FONT_BOLD_LARGER@"
|
||||
}
|
||||
|
||||
style "silence_text"
|
||||
{
|
||||
font_name = "@FONT_BOLD_NORMAL@"
|
||||
}
|
||||
|
||||
style "marker_text"
|
||||
{
|
||||
font_name = "@FONT_NORMAL@"
|
||||
|
|
@ -1264,6 +1269,7 @@ class "GtkProgressBar" style:highest "ardour_progressbars"
|
|||
widget "*PaddedButton" style:highest "padded_button"
|
||||
widget "*FirstActionMessage" style:highest "first_action_message"
|
||||
widget "*VerboseCanvasCursor" style:highest "verbose_canvas_cursor"
|
||||
widget "*SilenceText" style:highest "silence_text"
|
||||
widget "*MarkerText" style:highest "marker_text"
|
||||
widget "*TimeAxisViewItemName*" style:highest "time_axis_view_item_name"
|
||||
#widget "*ExportProgress" style:highest "default_generic"
|
||||
|
|
|
|||
|
|
@ -4559,7 +4559,9 @@ Editor::strip_region_silence ()
|
|||
d.drop_rects ();
|
||||
|
||||
if (r == Gtk::RESPONSE_OK) {
|
||||
StripSilence s (*_session, d.silences(), d.fade_length());
|
||||
ARDOUR::AudioIntervalMap silences;
|
||||
d.silences (silences);
|
||||
StripSilence s (*_session, silences, d.fade_length());
|
||||
apply_filter (s, _("strip silence"), &d);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,117 +220,137 @@ RegionView::~RegionView ()
|
|||
}
|
||||
|
||||
void
|
||||
RegionView::set_silent_frames (const AudioIntervalResult& silences)
|
||||
RegionView::set_silent_frames (const AudioIntervalResult& silences, double threshold)
|
||||
{
|
||||
framecnt_t shortest = max_framecnt;
|
||||
framecnt_t shortest_audible = max_framecnt;
|
||||
bool seen_audible = false;
|
||||
|
||||
/* remove old silent frames */
|
||||
drop_silent_frames ();
|
||||
|
||||
if (!silences.empty()) {
|
||||
if (silences.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t const color = ARDOUR_UI::config()->canvasvar_Silence.get();
|
||||
framecnt_t last_end;
|
||||
framepos_t start;
|
||||
framepos_t end;
|
||||
bool in_silence;
|
||||
bool seen_audible = false;
|
||||
AudioIntervalResult::const_iterator s;
|
||||
uint32_t const color = ARDOUR_UI::config()->canvasvar_Silence.get();
|
||||
|
||||
if (silences.front().first != 0) {
|
||||
/* use initial non-silent segment as shortest */
|
||||
shortest_audible = silences.front().first;
|
||||
seen_audible = true;
|
||||
}
|
||||
start = _region->start();
|
||||
s = silences.begin();
|
||||
|
||||
for (AudioIntervalResult::const_iterator i = silences.begin(); i != silences.end(); ++i) {
|
||||
if (s->first == start) {
|
||||
/* segment starting at zero is silent */
|
||||
end = s->second;
|
||||
in_silence = true;
|
||||
} else {
|
||||
/* segment starting at zero is audible, and begins at the start of the region in the source */
|
||||
end = s->first;
|
||||
in_silence = false;
|
||||
}
|
||||
|
||||
if ((*i).first > last_end) {
|
||||
/* (audible) gap between the end of the last interval and this one */
|
||||
shortest_audible = min (shortest_audible, (*i).first - last_end);
|
||||
while (start < _region->start() + _region->length()) {
|
||||
|
||||
framecnt_t interval_duration = end - start;
|
||||
|
||||
if (interval_duration > 0) {
|
||||
if (in_silence) {
|
||||
|
||||
ArdourCanvas::SimpleRect* cr = new ArdourCanvas::SimpleRect (*group);
|
||||
_silent_frames.push_back (cr);
|
||||
|
||||
/* coordinates for the rect are relative to the regionview origin */
|
||||
|
||||
cr->property_x1() = trackview.editor().frame_to_pixel (s->first - _region->start());
|
||||
cr->property_x2() = trackview.editor().frame_to_pixel (s->second - _region->start());
|
||||
cr->property_y1() = 1;
|
||||
cr->property_y2() = _height - 2;
|
||||
cr->property_outline_pixels() = 0;
|
||||
cr->property_fill_color_rgba () = color;
|
||||
|
||||
if (interval_duration < shortest) {
|
||||
shortest = interval_duration;
|
||||
}
|
||||
|
||||
} else if (interval_duration > 0) {
|
||||
seen_audible = true;
|
||||
if (interval_duration < shortest_audible) {
|
||||
shortest_audible = interval_duration;
|
||||
}
|
||||
}
|
||||
|
||||
start = end;
|
||||
in_silence = !in_silence;
|
||||
++s;
|
||||
|
||||
ArdourCanvas::SimpleRect* cr = new ArdourCanvas::SimpleRect (*group);
|
||||
_silent_frames.push_back (cr);
|
||||
|
||||
/* coordinates for the rect are relative to the regionview origin */
|
||||
|
||||
cr->property_x1() = trackview.editor().frame_to_pixel ((*i).first - _region->start());
|
||||
cr->property_y1() = 1;
|
||||
cr->property_y2() = _height - 2;
|
||||
cr->property_outline_pixels() = 0;
|
||||
cr->property_fill_color_rgba () = color;
|
||||
|
||||
last_end = (*i).second;
|
||||
|
||||
cr->property_x2() = trackview.editor().frame_to_pixel ((*i).second - _region->start());
|
||||
|
||||
if (((*i).second - (*i).first) < shortest) {
|
||||
shortest= (*i).second;
|
||||
}
|
||||
}
|
||||
|
||||
if (last_end != _region->length()) {
|
||||
shortest_audible = min (shortest_audible, _region->last_frame() - last_end);
|
||||
seen_audible = true;
|
||||
}
|
||||
|
||||
_silence_text = new ArdourCanvas::NoEventText (*group);
|
||||
_silence_text->property_font_desc() = *(get_font_for_style (N_("VerboseCanvasCusor")));
|
||||
_silence_text->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SilenceText.get();
|
||||
_silence_text->property_anchor() = ANCHOR_NW;
|
||||
|
||||
/* both positions are relative to the region start offset in source */
|
||||
|
||||
_silence_text->property_x() = trackview.editor().frame_to_pixel (silences.front().first - _region->start()) + 10.0;
|
||||
_silence_text->property_y() = 20.0;
|
||||
|
||||
double ms;
|
||||
char const * sunits;
|
||||
char const * noun;
|
||||
|
||||
if (silences.size() > 1) {
|
||||
noun = _("silent segments");
|
||||
} else {
|
||||
noun = _("silent segment");
|
||||
}
|
||||
|
||||
ms = (float) shortest/_region->session().frame_rate();
|
||||
|
||||
/* ms are now in seconds */
|
||||
|
||||
if (ms >= 60.0) {
|
||||
sunits = _("minutes");
|
||||
ms /= 60.0;
|
||||
} else if (ms < 1.0) {
|
||||
sunits = _("msecs");
|
||||
ms *= 1000.0;
|
||||
} else {
|
||||
sunits = _("secs");
|
||||
}
|
||||
|
||||
if (seen_audible) {
|
||||
/* ms are now in seconds */
|
||||
double ma = shortest_audible / _region->session().frame_rate();
|
||||
char const * aunits;
|
||||
|
||||
if (ma >= 60.0) {
|
||||
aunits = _("minutes");
|
||||
ma /= 60.0;
|
||||
} else if (ma < 1.0) {
|
||||
aunits = _("msecs");
|
||||
ma *= 1000.0;
|
||||
if (s == silences.end()) {
|
||||
end = _region->start() + _region->length();
|
||||
} else {
|
||||
aunits = _("secs");
|
||||
end = s->first;
|
||||
}
|
||||
|
||||
_silence_text->property_text() = string_compose (_("%1 %2, shortest = %3 %4\n (shortest audible segment = %5 %6)"),
|
||||
silences.size(), noun,
|
||||
ms, sunits, ma, aunits).c_str();
|
||||
} else {
|
||||
_silence_text->property_text() = string_compose (_("%1 %2, shortest = %3 %4"),
|
||||
silences.size(), noun, ms, sunits).c_str();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_silence_text = new ArdourCanvas::NoEventText (*group);
|
||||
_silence_text->property_font_desc() = *(get_font_for_style (N_("SilenceText")));
|
||||
_silence_text->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SilenceText.get();
|
||||
_silence_text->property_anchor() = ANCHOR_NW;
|
||||
|
||||
/* both positions are relative to the region start offset in source */
|
||||
|
||||
_silence_text->property_x() = trackview.editor().frame_to_pixel (silences.front().first - _region->start()) + 10.0;
|
||||
_silence_text->property_y() = 20.0;
|
||||
|
||||
double ms;
|
||||
char const * sunits;
|
||||
char const * noun;
|
||||
|
||||
if (silences.size() > 1) {
|
||||
noun = _("silent segments");
|
||||
} else {
|
||||
noun = _("silent segment");
|
||||
}
|
||||
|
||||
ms = (float) shortest/_region->session().frame_rate();
|
||||
|
||||
/* ms are now in seconds */
|
||||
|
||||
if (ms >= 60.0) {
|
||||
sunits = _("minutes");
|
||||
ms /= 60.0;
|
||||
} else if (ms < 1.0) {
|
||||
sunits = _("msecs");
|
||||
ms *= 1000.0;
|
||||
} else {
|
||||
sunits = _("secs");
|
||||
}
|
||||
|
||||
if (seen_audible) {
|
||||
/* ms are now in seconds */
|
||||
double ma = shortest_audible / _region->session().frame_rate();
|
||||
char const * aunits;
|
||||
|
||||
if (ma >= 60.0) {
|
||||
aunits = _("minutes");
|
||||
ma /= 60.0;
|
||||
} else if (ma < 1.0) {
|
||||
aunits = _("msecs");
|
||||
ma *= 1000.0;
|
||||
} else {
|
||||
aunits = _("secs");
|
||||
}
|
||||
|
||||
_silence_text->property_text() = string_compose (_("%1 %2, shortest = %3 %4\n (shortest audible segment = %5 %6)"),
|
||||
silences.size(), noun,
|
||||
ms, sunits, ma, aunits).c_str();
|
||||
} else {
|
||||
_silence_text->property_text() = string_compose (_("%1 %2, shortest = %3 %4"),
|
||||
silences.size(), noun, ms, sunits).c_str();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -354,15 +374,6 @@ RegionView::drop_silent_frames ()
|
|||
_silence_text = 0;
|
||||
}
|
||||
|
||||
void
|
||||
RegionView::show_silent_frames ()
|
||||
{
|
||||
for (list<ArdourCanvas::SimpleRect*>::iterator i = _silent_frames.begin (); i != _silent_frames.end (); ++i) {
|
||||
(*i)->show ();
|
||||
}
|
||||
_silence_text->show ();
|
||||
}
|
||||
|
||||
gint
|
||||
RegionView::_lock_toggle (ArdourCanvas::Item*, GdkEvent* ev, void* arg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -112,10 +112,9 @@ class RegionView : public TimeAxisViewItem
|
|||
void trim_contents (framepos_t, bool, bool);
|
||||
virtual void thaw_after_trim ();
|
||||
|
||||
void set_silent_frames (const ARDOUR::AudioIntervalResult&);
|
||||
void set_silent_frames (const ARDOUR::AudioIntervalResult&, double threshold);
|
||||
void drop_silent_frames ();
|
||||
void hide_silent_frames ();
|
||||
void show_silent_frames ();
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -173,11 +172,12 @@ class RegionView : public TimeAxisViewItem
|
|||
*/
|
||||
std::list<ArdourCanvas::SimpleRect*> _coverage_frames;
|
||||
|
||||
/** a list of rectangles which are used in stacked display mode to colour
|
||||
different bits of regions according to whether or not they are the one
|
||||
that will be played at any given time.
|
||||
/** a list of rectangles used to show silent segments
|
||||
*/
|
||||
std::list<ArdourCanvas::SimpleRect*> _silent_frames;
|
||||
/** a list of rectangles used to show the current silence threshold
|
||||
*/
|
||||
std::list<ArdourCanvas::SimpleRect*> _silent_threshold_frames;
|
||||
/** a text item to display strip silence statistics
|
||||
*/
|
||||
ArdourCanvas::NoEventText* _silence_text;
|
||||
|
|
|
|||
|
|
@ -84,9 +84,12 @@ StripSilenceDialog::StripSilenceDialog (Session* s, list<RegionView*> const & v)
|
|||
_minimum_length.set_mode (AudioClock::Frames);
|
||||
_minimum_length.set (1000, true);
|
||||
|
||||
/* Add this back when we finally do something with it */
|
||||
/*
|
||||
table->attach (*Gtk::manage (new Gtk::Label (_("Fade length"), 1, 0.5)), 0, 1, n, n + 1, Gtk::FILL);
|
||||
table->attach (_fade_length, 1, 2, n, n + 1, Gtk::FILL);
|
||||
++n;
|
||||
*/
|
||||
|
||||
_fade_length.set_session (s);
|
||||
_fade_length.set_mode (AudioClock::Frames);
|
||||
|
|
@ -133,17 +136,13 @@ StripSilenceDialog::~StripSilenceDialog ()
|
|||
delete _peaks_ready_connection;
|
||||
}
|
||||
|
||||
AudioIntervalMap
|
||||
StripSilenceDialog::silences ()
|
||||
void
|
||||
StripSilenceDialog::silences (AudioIntervalMap& m)
|
||||
{
|
||||
AudioIntervalMap m;
|
||||
|
||||
for (list<ViewInterval>::iterator v = views.begin(); v != views.end(); ++v) {
|
||||
pair<boost::shared_ptr<Region>,AudioIntervalResult> newpair ((*v).view->region(), (*v).intervals);
|
||||
m.insert (newpair);
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -188,8 +187,10 @@ StripSilenceDialog::update_silence_rects ()
|
|||
{
|
||||
/* Lock so that we don't contend with the detection thread for access to the silence regions */
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
double const y = _threshold.get_value();
|
||||
|
||||
for (list<ViewInterval>::iterator v = views.begin(); v != views.end(); ++v) {
|
||||
(*v).view->set_silent_frames ((*v).intervals);
|
||||
(*v).view->set_silent_frames ((*v).intervals, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public:
|
|||
|
||||
void drop_rects ();
|
||||
|
||||
ARDOUR::AudioIntervalMap silences ();
|
||||
void silences (ARDOUR::AudioIntervalMap&);
|
||||
|
||||
ARDOUR::framecnt_t minimum_length () const;
|
||||
ARDOUR::framecnt_t fade_length () const;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class StripSilence : public Filter
|
|||
int run (boost::shared_ptr<ARDOUR::Region>, Progress* progress = 0);
|
||||
|
||||
private:
|
||||
AudioIntervalMap _smap;
|
||||
const AudioIntervalMap& _smap;
|
||||
framecnt_t _fade_length; ///< fade in/out to use on trimmed regions, in samples
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue