-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoggdeep
More file actions
executable file
·77 lines (65 loc) · 1.73 KB
/
oggdeep
File metadata and controls
executable file
·77 lines (65 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl -w
# Recursively, randomly play oggs under current dir with ogg123
@default_options = ('-z');
#$mutex_options{'-Z'} = '-z'; # What kind of random
#$mutex_options{'-0'} = '-1'; # Channel selector
#$mutex_options{'-2'} = '-4'; # Downsampling options
@options_disallow = ('-w','-@','-u','-p','-h','-d','-o','-a','-g','-r','-f','-n','-k','-b', '--audio-buffer'); # These all take arguments after them, and make it harder to
# do magic spiffy mutex checking.
cleanup_predef();
main(@ARGV);
sub main
{
my @program_args = @_;
my @args = figure_args(@program_args);
print "Figured args [" . join(', ',@args) . "]\n";
my @ogg_list = recurse_get_ogglist(".");
do_ogg123(\@args, @ogg_list);
}
sub recurse_get_ogglist
{
my $cwd = shift;
opendir(THISDIR, $cwd);
my @oggfiles;
my @direntries = map {$cwd . '/' . $_;} grep !/^\./, readdir(THISDIR);
closedir(THISDIR);
foreach my $entry (@direntries)
{
if( -d $entry)
{
push(@oggfiles, recurse_get_ogglist($entry));
next;
}
if( ( -f $entry) && ($entry =~ /\.ogg$/i))
{
push(@oggfiles, $entry);
next;
}
}
return @oggfiles;
}
sub do_ogg123
{
my $argsref = shift;
my @oggs = @_;
exec 'ogg123', @$argsref, @oggs;
}
sub figure_args
{ # Coalesce @argv and @default_options into a coherent
# set of args, using %mutex_args
my @argv = @_;
my %h_returner;
foreach $arg (@argv, @default_options)
{
if($disallow{$arg})
{die "Disallowed argument [$arg] found\n";}
if(! (($mutex_options{$arg}) && ($h_returner{$mutex_options{$arg}})))
{$h_returner{$arg} = 1;}
}
return (keys %h_returner);
}
sub cleanup_predef
{ # It'd suck to need to specify mutually exclusive flags both ways
map{$mutex_options{$mutex_options{$_}} = $_;} keys %mutex_options;
map{$disallow{$_}=1;} @options_disallow;
}