add sampo's synthesize_sources perl script to tools; add scroll-playhead-{forward,backward} with ctrl-<arrow> default bindings (for mr beasley)

git-svn-id: svn://localhost/ardour2/trunk@1336 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-01-17 13:13:58 +00:00
parent 9fc6895565
commit 76c25a4a44
7 changed files with 193 additions and 2 deletions

View File

@ -110,6 +110,8 @@
; (gtk_accel_path "<Actions>/Editor/toggle-xfades-visible" "")
(gtk_accel_path "<Actions>/Editor/extend-range-to-end-of-region" "rightanglebracket")
(gtk_accel_path "<Actions>/Editor/scroll-backward" "leftarrow")
(gtk_accel_path "<Actions>/Editor/scroll-playhead-backward" "<Control>leftarrow")
(gtk_accel_path "<Actions>/Editor/scroll-playhead-forward" "<Control>rightarrow")
(gtk_accel_path "<Actions>/Editor/start-range" "<Control>KP_Down")
; (gtk_accel_path "<Actions>/ShuttleActions/SetShuttleUnitsSemitones" "")
; (gtk_accel_path "<Actions>/JACK/JACKLatency128" "")

View File

@ -203,6 +203,9 @@
<menuitem action='scroll-forward'/>
<menuitem action='scroll-backward'/>
<separator/>
<menuitem action='scroll-playhead-forward'/>
<menuitem action='scroll-playhead-backward'/>
<separator/>
<menuitem action='ToggleWaveformVisibility'/>
<menuitem action='ToggleWaveformsWhileRecording'/>
<menuitem action='ToggleMeasureVisibility'/>

View File

@ -994,6 +994,7 @@ class Editor : public PublicEditor
void edit_cursor_forward ();
void playhead_backward ();
void playhead_forward ();
void scroll_playhead (bool forward);
void scroll_backward (float pages=0.8f);
void scroll_forward (float pages=0.8f);
void scroll_tracks_down ();

View File

@ -164,10 +164,12 @@ Editor::register_actions ()
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "center-edit-cursor", _("Center Edit Cursor"), mem_fun(*this, &Editor::center_edit_cursor));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "playhead-forward", _("Playhead Forward"), mem_fun(*this, &Editor::playhead_forward));
act = ActionManager::register_action (editor_actions, "scroll-playhead-forward", _("Playhead forward"), bind (mem_fun(*this, &Editor::scroll_playhead), true));;
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "playhead-backward", _("Playhead Backward"), mem_fun(*this, &Editor::playhead_backward));
act = ActionManager::register_action (editor_actions, "scroll-playhead-backward", _("Playhead Backward"), bind (mem_fun(*this, &Editor::scroll_playhead), false));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "playhead-to-edit", _("Playhead to Edit"), bind (mem_fun(*this, &Editor::cursor_align), true));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "edit-to-playhead", _("Edit to Playhead"), bind (mem_fun(*this, &Editor::cursor_align), false));

View File

@ -756,6 +756,39 @@ Editor::cursor_to_selection_end (Cursor *cursor)
}
}
void
Editor::scroll_playhead (bool forward)
{
nframes_t pos = playhead_cursor->current_frame;
nframes_t delta = (nframes_t) floor (current_page_frames() / 0.8);
if (forward) {
if (pos == max_frames) {
return;
}
if (pos < max_frames - delta) {
pos += delta ;
} else {
pos = max_frames;
}
} else {
if (pos == 0) {
return;
}
if (pos > delta) {
pos -= delta;
} else {
pos = 0;
}
}
session->request_locate (pos);
}
void
Editor::playhead_backward ()
{

View File

@ -0,0 +1,75 @@
package ARDOUR::SourceInfoLoader;
use XML::Handler::Subs;
@ISA = qw( XML::Handler::Subs );
$VERSION = 1.0;
sub new {
my ($type, $sessionName) = @_;
my $self = $type->SUPER::new();
$self->{SessionName} = $sessionName;
$self->{InRegions} = 0;
%self->{Sources} = {};
return $self;
}
sub start_element {
my $self = shift;
my $element = shift;
my $atts = $element->{Attributes};
if ( $element->{Name} eq "Source") {
if ( ! -f "interchange/".$sessionName."/audiofiles/".$atts->{name}) {
$atts->{calculated_length} = 1;
$self->{Sources}->{$atts->{id}} = $atts;
}
}
if ( $self->{InRegions} eq 1 && $element->{Name} eq "Region") {
#print "Looking at region ".$atts->{id}."\n";
my $num = 0;
my $region_length = $atts->{length};
while ( $atts->{"source-".$num} ne "" ) {
if ($region_length > $self->{Sources}->{$atts->{"source-".$num}}->{calculated_length} ) {
$self->{Sources}->{$atts->{"source-".$num}}->{calculated_length} = $region_length;
}
$num++;
}
}
if ( $element->{Name} eq "Regions") {
$self->{InRegions} = 1;
#print "In regions\n";
}
}
sub end_element {
my $self = shift;
my $element = shift;
if ( $element->{Name} eq "Regions") {
$self->{InRegions} = 0;
#print "Out of regions\n";
}
}
1;

75
tools/synthesize_sources.pl Executable file
View File

@ -0,0 +1,75 @@
#!/usr/bin/env perl
# Ardour session synthesizer
# (c)Sampo Savolainen 2007
#
# GPL
# This reads an Ardour session file and creates zero-signal source files
# for each missing source file. The length of each file is determined
# by how far regions using that source file go into the sample data.
use XML::Parser::PerlSAX;
use XML::Handler::XMLWriter;
use IO::Handle;
use ARDOUR::SourceInfoLoader;
my ($samplerate, $sessionName) = @ARGV;
if ( ! -d $sessionName || ! -f $sessionName."/".$sessionName.".ardour" ) {
print "usage: synthesize_sources.pl samplerate [session name, the name must match the directory and the .ardour file in it]\n";
exit;
}
my $sessionFile = $sessionName."/".$sessionName.".ardour";
my $handler = new ARDOUR::SourceInfoLoader($sessionName);
my $parser = XML::Parser::PerlSAX->new( Handler => $handler );
$parser->parse(Source => { SystemId => $sessionFile });
if ( ! -d $sessionName."/interchange" ) {
mkdir $sessionName."/interchange/" || die "couldn't create ".$sessionName."/interchange";
}
if ( ! -d $sessionName."/interchange/".$sessionName ) {
mkdir $sessionName."/interchange/".$sessionName || die "couldn't create ".$sessionName."/interchange/".$sessionName;
}
if ( ! -d $sessionName."/interchange/".$sessionName."/audiofiles" ) {
mkdir $sessionName."/interchange/".$sessionName."/audiofiles" || die "couldn't create ".$sessionName."/interchange/".$sessionName."/audiofiles";
}
if ( ! -d $sessionName."/peaks") {
mkdir $sessionName."/peaks/" || die "couldn't create ".$sessionName."/peaks";
}
my $audioFileDirectory = $sessionName."/interchange/".$sessionName."/audiofiles";
my %sources = %{$handler->{Sources}};
foreach my $tmp (keys %sources) {
print "Generating ".$audioFileDirectory."/".$sources{$tmp}->{name}.".wav\n";
system("sox",
"-t", "raw", # /dev/zero is raw :)
"-r", $samplerate, # set sample rate
"-c", "1", # 1 channel
"-b", # input in bytes
"-s", # signed
"/dev/zero", # input signal
"-w", # output 16 bit
"-t", "wav", # format wav
$audioFileDirectory."/".$sources{$tmp}->{name}, # filename
"trim", "0", $sources{$tmp}->{calculated_length}."s" # trim silence to wanted sample amount
);
}