diff options
author | psyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet> | 2016-08-10 15:28:25 +0000 |
---|---|---|
committer | psyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet> | 2016-08-10 15:28:25 +0000 |
commit | 2d085647724720dfe053bfd6cbb9882fedbd3f8a (patch) | |
tree | 154cc6ca767014534075df0bf3720feb1f78bcf3 /bin/psycamp | |
parent | 05fe7fac98625d35055744d6e43178e8c4b60d33 (diff) | |
download | perlpsyc-2d085647724720dfe053bfd6cbb9882fedbd3f8a.tar.gz perlpsyc-2d085647724720dfe053bfd6cbb9882fedbd3f8a.zip |
fade volume before skipping to next track
Diffstat (limited to 'bin/psycamp')
-rwxr-xr-x | bin/psycamp | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/bin/psycamp b/bin/psycamp index 06130d3..7e52a16 100755 --- a/bin/psycamp +++ b/bin/psycamp | |||
@@ -208,6 +208,8 @@ $playlist="$tmpdir/playlist-$ENV{USER}.m3u"; | |||
208 | use Date::Format qw( time2str ); ## T | 208 | use Date::Format qw( time2str ); ## T |
209 | use IPC::Open3 qw( open3 ); | 209 | use IPC::Open3 qw( open3 ); |
210 | use Net::PSYC qw( :event ); | 210 | use Net::PSYC qw( :event ); |
211 | # would need to extend this to actually use it: | ||
212 | #use Audio::Play::MPlayer; | ||
211 | 213 | ||
212 | *name = *File::Find::name; # ugly style works | 214 | *name = *File::Find::name; # ugly style works |
213 | $scan = 0; | 215 | $scan = 0; |
@@ -226,7 +228,7 @@ MAIN: { | |||
226 | 228 | ||
227 | print "Using playlist: $playlist\n" if $opt_v; | 229 | print "Using playlist: $playlist\n" if $opt_v; |
228 | if ($opt_h) { | 230 | if ($opt_h) { |
229 | print BOLD, BLACK, &head, YELLOW, <<X, BOLD, BLUE, &sorthelp, RESET; | 231 | print BOLD, BLACK, &head, RESET, <<X, &sorthelp; |
230 | 232 | ||
231 | usage: $0 [<flags>] [-b <uniform>] [-n <nick>] [-s <mode>] | 233 | usage: $0 [<flags>] [-b <uniform>] [-n <nick>] [-s <mode>] |
232 | [-M <UNI>] [-S <screen>] [<files|dirs>] | 234 | [-M <UNI>] [-S <screen>] [<files|dirs>] |
@@ -332,8 +334,7 @@ X | |||
332 | &load unless $opt_x; | 334 | &load unless $opt_x; |
333 | system "$ENV{EDITOR} $playlist;clear" if $opt_e; | 335 | system "$ENV{EDITOR} $playlist;clear" if $opt_e; |
334 | } | 336 | } |
335 | #exec "xaudio `cat $playlist`" if $opt_x; | 337 | exec '$has_mplayer "`cat $playlist`"' if $opt_x; |
336 | exec 'mplayer "`cat $playlist`"' if $opt_x; | ||
337 | #exec "mpg123 --remain --aggressive -@ $playlist" if $opt_x; | 338 | #exec "mpg123 --remain --aggressive -@ $playlist" if $opt_x; |
338 | 339 | ||
339 | print STDERR BOLD, YELLOW, "binding to $opt_b ...\n", RESET if DEBUG & 16 && $opt_b; | 340 | print STDERR BOLD, YELLOW, "binding to $opt_b ...\n", RESET if DEBUG & 16 && $opt_b; |
@@ -372,7 +373,14 @@ X | |||
372 | $CS = -1; # global var for current song | 373 | $CS = -1; # global var for current song |
373 | 374 | ||
374 | &next(0); | 375 | &next(0); |
375 | # &vol(100); | 376 | # ah wait, selecting PCM by command doesn't even work. |
377 | # rgrep USEMASTER in source shows that 'use_master' | ||
378 | # to toggle PCM doesn't even exist. great docs! :D | ||
379 | #&gin('use_master'); | ||
380 | # if we don't want to raise volume to 100% at start then | ||
381 | # we have to disable the fade-on-next logic as well. | ||
382 | # let's try to make mplayer use PCM instead of Master. | ||
383 | &vol( $Volume = $VOL ); | ||
376 | $|=1; | 384 | $|=1; |
377 | 385 | ||
378 | # Net::PSYC::Event doesn't support idle events yet.. TODO | 386 | # Net::PSYC::Event doesn't support idle events yet.. TODO |
@@ -775,7 +783,8 @@ sub gin { | |||
775 | sub fade { | 783 | sub fade { |
776 | my $s = shift; | 784 | my $s = shift; |
777 | #% $s = 33 unless $s; #? X | 785 | #% $s = 33 unless $s; #? X |
778 | $s = 12 unless $s; #? !X | 786 | # 12 when using Master |
787 | $s = 3 unless $s; #? !X | ||
779 | my $p = shift; | 788 | my $p = shift; |
780 | $p = 0.4 unless $p; | 789 | $p = 0.4 unless $p; |
781 | foreach $i ( reverse @VV ) { | 790 | foreach $i ( reverse @VV ) { |
@@ -841,6 +850,7 @@ sub seek { | |||
841 | return 1; | 850 | return 1; |
842 | } | 851 | } |
843 | 852 | ||
853 | # FIXME: duration isn't essential, but annoying not to have | ||
844 | sub duration { | 854 | sub duration { |
845 | my $t = shift; | 855 | my $t = shift; |
846 | 856 | ||
@@ -877,8 +887,9 @@ sub which { | |||
877 | sub sortsongs { | 887 | sub sortsongs { |
878 | my $style = shift; | 888 | my $style = shift; |
879 | return (1 .. $NS) unless $style; | 889 | return (1 .. $NS) unless $style; |
880 | lc $style; | 890 | # lc $style; -- eh? this breaks half of the algorithms |
881 | my @order; | 891 | my @order; |
892 | print STDERR "sorting by_$style 1 .. $NS\n" if DEBUG & 8; | ||
882 | eval "\@order = sort by_$style 1 .. $NS"; | 893 | eval "\@order = sort by_$style 1 .. $NS"; |
883 | croak <<X, &sorthelp if $@; | 894 | croak <<X, &sorthelp if $@; |
884 | invalid sort option '$style' | 895 | invalid sort option '$style' |
@@ -890,23 +901,32 @@ sub sorthelp { return <<X; } | |||
890 | available sort algorithms: | 901 | available sort algorithms: |
891 | n(ame) # sorts by file path (directory first) | 902 | n(ame) # sorts by file path (directory first) |
892 | N(ame) # sorts by file ending (reverse of -n) | 903 | N(ame) # sorts by file ending (reverse of -n) |
893 | nr # gives an order by name a slight shuffle | ||
894 | cr # gives the order given on commandline a slight shuffle | ||
895 | s(ize) # hear silly small sound snippets first | 904 | s(ize) # hear silly small sound snippets first |
896 | S(ize) # hear big epic pieces first | 905 | S(ize) # hear big epic pieces first |
897 | m(odification) # hear newest tracks first | 906 | m(odification) # hear newest tracks first |
898 | M(odification) # hear oldest tracks first | 907 | M(odification) # hear oldest tracks first |
899 | a(ccessTime) # hear tracks you haven't heard in a long time first | 908 | a(ccessTime) # hear tracks you haven't heard in a long time first |
900 | A(ccessTime) # hear tracks you recently accessed first | 909 | A(ccessTime) # hear tracks you recently accessed first |
910 | cr # gives the order given on commandline a slight shuffle | ||
911 | |||
912 | you can append 'r' to each algorithm (as in 'nr' or 'Ar') to apply a slight | ||
913 | random shuffle of the items while roughly following the sorting principle. | ||
901 | X | 914 | X |
902 | # r(andom) # bad randomizer algorithm (use -r instead) | 915 | # r(andom) # bad randomizer algorithm (use -r instead) |
903 | sub by_n { $file[$a] cmp $file[$b]; } | ||
904 | sub by_N { reverse($file[$a]) cmp reverse($file[$b]); } | ||
905 | # this actually produces VERY pseudo random results, says randal | 916 | # this actually produces VERY pseudo random results, says randal |
906 | # see http://www.perlmonks.org/?node_id=199901 | 917 | # see http://www.perlmonks.org/?node_id=199901 |
907 | sub by_r { rand(10) < 5; } | 918 | sub by_r { rand(10) < 5; } |
908 | sub by_nr { rand(9) > 3 ? &by_n : &by_r; } | 919 | sub by_nr { rand(9) > 3 ? &by_n : &by_r; } |
920 | sub by_Nr { rand(9) > 3 ? &by_N : &by_r; } | ||
909 | sub by_cr { rand(9) > 3 ? $a <=> $b : &by_r; } | 921 | sub by_cr { rand(9) > 3 ? $a <=> $b : &by_r; } |
922 | sub by_sr { rand(9) > 3 ? &by_s : &by_r; } | ||
923 | sub by_Sr { rand(9) > 3 ? &by_S : &by_r; } | ||
924 | sub by_mr { rand(9) > 3 ? &by_m : &by_r; } | ||
925 | sub by_Mr { rand(9) > 3 ? &by_M : &by_r; } | ||
926 | sub by_ar { rand(9) > 3 ? &by_a : &by_r; } | ||
927 | sub by_Ar { rand(9) > 3 ? &by_A : &by_r; } | ||
928 | sub by_n { $file[$a] cmp $file[$b]; } | ||
929 | sub by_N { reverse($file[$a]) cmp reverse($file[$b]); } | ||
910 | sub by_m { $date[$a] <=> $date[$b]; } | 930 | sub by_m { $date[$a] <=> $date[$b]; } |
911 | sub by_M { $date[$b] <=> $date[$a]; } | 931 | sub by_M { $date[$b] <=> $date[$a]; } |
912 | sub by_a { $adate[$a] <=> $adate[$b]; } | 932 | sub by_a { $adate[$a] <=> $adate[$b]; } |
@@ -1037,7 +1057,7 @@ sub progress { | |||
1037 | my $tx = join('', @_); | 1057 | my $tx = join('', @_); |
1038 | my $len = length $tx; | 1058 | my $len = length $tx; |
1039 | print "\r", GREEN, $tx, RESET, ' '; | 1059 | print "\r", GREEN, $tx, RESET, ' '; |
1040 | print '_' x (74-$len), ' ' if $len < 74; | 1060 | print '_' x (76-$len), ' ' if $len < 76; |
1041 | print "\n" if DEBUG & 1; | 1061 | print "\n" if DEBUG & 1; |
1042 | } | 1062 | } |
1043 | 1063 | ||
@@ -1067,7 +1087,13 @@ sub ginparse { | |||
1067 | } | 1087 | } |
1068 | return 0; | 1088 | return 0; |
1069 | } | 1089 | } |
1070 | print STDERR BOLD, BLUE, $_, RESET if $opt_V or DEBUG & 512; | 1090 | if ($opt_V or DEBUG & 512) { |
1091 | #{ !X | ||
1092 | return if / supported but disabled$/; | ||
1093 | return if /^(Configuration: --|CommandLine:|get_path)/; | ||
1094 | #} !X | ||
1095 | print STDERR BOLD, BLUE, $_, RESET; | ||
1096 | } | ||
1071 | #{ X | 1097 | #{ X |
1072 | #% if (/^MSG notify duration \[(\d+)\]/) { | 1098 | #% if (/^MSG notify duration \[(\d+)\]/) { |
1073 | #% # kludge to get around a bug in xaudio (duration output twice) | 1099 | #% # kludge to get around a bug in xaudio (duration output twice) |
@@ -1175,8 +1201,6 @@ sub ginparse { | |||
1175 | print GREEN, $txt, RESET, "\n" if $opt_v; | 1201 | print GREEN, $txt, RESET, "\n" if $opt_v; |
1176 | return 0; | 1202 | return 0; |
1177 | } | 1203 | } |
1178 | return if / supported but disabled$/; # unimportant | ||
1179 | return if /^Configuration: --prefix/; # useless ffmpeg compilation infos | ||
1180 | #} X | 1204 | #} X |
1181 | return $_; | 1205 | return $_; |
1182 | } | 1206 | } |
@@ -1197,11 +1221,12 @@ sub ginstart { | |||
1197 | #: X | 1221 | #: X |
1198 | # -v is needed to receive the EOF! | 1222 | # -v is needed to receive the EOF! |
1199 | # '-osdlevel', '3' can be useful | 1223 | # '-osdlevel', '3' can be useful |
1200 | $pid = open3( \*W, \*R, \*R, $has_mplayer, '-slave', '-idle', '-v', '-fs', '-zoom', '-screen', $opt_S || $screen ); | 1224 | # to allow for fading we want to have the PCM channel, |
1225 | # this works for ALSA - does it fail otherwise? | ||
1226 | $pid = open3( \*W, \*R, \*R, $has_mplayer, '-slave', '-idle', '-v', '-fs', '-zoom', '-screen', $opt_S || $screen, '-mixer-channel', 'PCM' ); | ||
1201 | R->blocking(0); | 1227 | R->blocking(0); |
1202 | $pid || die "$has_mplayer: $!"; | 1228 | $pid || die "$has_mplayer: $!"; |
1203 | &ginxpect('^MPlayer'); | 1229 | &ginxpect('^MPlayer'); |
1204 | &gin('use_master'); | ||
1205 | #} X | 1230 | #} X |
1206 | print STDERR <<X if DEBUG & 64; | 1231 | print STDERR <<X if DEBUG & 64; |
1207 | audio engine running as $pid | 1232 | audio engine running as $pid |