#!/usr/bin/perl -w package SCX::Sound; use strict; sub new { my ($class, $args) = @_; my $self = { data_dir => $args->{data_dir} || './sounds/', muted => 1, }; bless $self, $class; return $self; } sub _play { my ($self, @names) = @_; return if $self->{muted}; system 'aplay', $self->{data_dir} . '/' . join('-', @names) . '.wav'; } sub mute { shift->{muted} = 1; } sub unmute { shift->{muted} = 0; } sub start { shift->_play('start'); } sub filled { shift->_play('filled'); } sub winner { my ($self, $car_id) = @_; $self->_play('winner', $car_id); } sub box { my ($self, $car_id) = @_; $self->_play('box', $car_id); } sub best_lap { my ($self, $car_id) = @_; $self->_play('bestlap', $car_id); } 1;