Changeset 1860

Show
Ignore:
Timestamp:
06/15/06 10:56:01
Author:
miyagawa
Message:

more sounds support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • thinkpad-saber/trunk/Changes

    r1856 r1860  
    11Changelog for ThinkPad Saber 
     2 
     3== 0.22 (2006/06/15 10:54 JST) == 
     4 
     5  * Behaves more like Lightsaber with idle sounds 
     6  * No volume control 
    27 
    38== 0.21 (2006/06/14 15:17 JST) == 
  • thinkpad-saber/trunk/thinkpad-saber.pl

    r1855 r1860  
    1212use List::Util qw(max min); 
    1313use Getopt::Long; 
     14 
     15our $VERSION = "0.22"; 
    1416 
    1517GetOptions('--debug', \my $debug, '--threshold=s' => \my $threshold, "--help" => \my $help); 
     
    7678} 
    7779 
     80# main program 
     81Win32::Sound::Volume(65535, 65535); 
     82Win32::Sound::Play('sound/start0.wav'); 
     83 
     84Win32::Sound::Play('sound/idle1.wav', SND_LOOP|SND_ASYNC); 
     85 
    7886my $depth = 8; 
    7987 
     
    117125    warn "$mode $dev" if $debug; 
    118126    Win32::GUI::DoEvents(); 
     127     
     128    my $idle = int(rand 100) % 2 ? 1 :0; 
     129    Win32::Sound::Play("sound/idle$idle.wav", SND_NOSTOP|SND_LOOP|SND_ASYNC); 
    119130    sleep 0.05; 
    120131} 
     
    124135sub play_sound { 
    125136    my $volume = shift; 
    126     my $num = int rand 5; 
    127     my $filename = "hit$num.wav"; 
    128     $volume = int(65535 * min($volume / 15, 1)); 
     137     
     138    my $hit = $volume > 10 ? "hit" : "swing"; 
     139    my $num = int rand ($hit ? 5 : 8); 
     140    my $filename = "$hit$num.wav"; 
     141#    $volume = int(65535 * min($volume / 15, 1)); 
    129142    warn "playing $filename in $volume" if $debug; 
    130     Win32::Sound::Volume($volume); 
     143#    Win32::Sound::Volume($volume); 
    131144    Win32::Sound::Play(File::Spec->catfile($cwd, "sound", $filename), SND_ASYNC); 
    132145}