X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=tools%2Fsynthesize_sources.pl;h=37e4ec0730650138d2e1dcd0b9b38f6559394476;hb=213cc1d320559c090fd2bc1748e6365382672888;hp=ebb903cf37023c1d084535b597e69d1a6d78c888;hpb=76c25a4a4459b8e550c3c687458d04db0beaee77;p=ardour.git diff --git a/tools/synthesize_sources.pl b/tools/synthesize_sources.pl index ebb903cf37..37e4ec0730 100755 --- a/tools/synthesize_sources.pl +++ b/tools/synthesize_sources.pl @@ -1,26 +1,45 @@ #!/usr/bin/env perl # Ardour session synthesizer -# (c)Sampo Savolainen 2007 +# (c)Sampo Savolainen 2007-2008 # # 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 FindBin '$Bin'; +use lib "$Bin"; use XML::Parser::PerlSAX; use XML::Handler::XMLWriter; use IO::Handle; use ARDOUR::SourceInfoLoader; +my $usage = "usage: synthesize_sources.pl samplerate [session name, the name must match the directory and the .ardour file in it] [options: -sine for 440hz sine waves in wave files]\n"; -my ($samplerate, $sessionName) = @ARGV; +my ($samplerate, $sessionName, @options) = @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"; + print $usage; exit; } +my $waveType = "silent"; + +foreach my $o (@options) { + if ($o eq "-sine") { + $waveType = "sine"; + } elsif ($o eq "-silent") { + $waveType = "silent"; + } else { + print "unknown parameter ".$o."\n"; + print $usage; + exit; + + } + +} + my $sessionFile = $sessionName."/".$sessionName.".ardour"; @@ -52,23 +71,28 @@ my %sources = %{$handler->{Sources}}; foreach my $tmp (keys %sources) { - print "Generating ".$audioFileDirectory."/".$sources{$tmp}->{name}.".wav\n"; + print "Generating ".$audioFileDirectory."/".$sources{$tmp}->{name}."\n"; - system("sox", + my @cmd = + ("sox", "-t", "raw", # /dev/zero is raw :) "-r", $samplerate, # set sample rate "-c", "1", # 1 channel - "-b", # input in bytes + "-b", "8", # input in 8 bit chunks "-s", # signed "/dev/zero", # input signal - "-w", # output 16 bit + "-b", "16", # input in 16 bit chunks "-t", "wav", # format wav $audioFileDirectory."/".$sources{$tmp}->{name}, # filename "trim", "0", $sources{$tmp}->{calculated_length}."s" # trim silence to wanted sample amount ); + if ($waveType eq "sine") { + @cmd = (@cmd, "synth","sin","%0", "vol", "0.2", "fade","q","0.01s", $sources{$tmp}->{calculated_length}."s" , "0.01s"); + } + system(@cmd); }