~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmix/volume.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*-C++-*-
 
2
#ifndef VOLUME_H
 
3
#define VOLUME_H
 
4
 
 
5
#include <qarray.h>
 
6
 
 
7
class Volume
 
8
{
 
9
 public:
 
10
  enum ChannelID { LEFT = 0, RIGHT, CENTER,
 
11
                   REARLEFT, REARRIGHT, WOOFER, MAXCHANNELS };
 
12
 
 
13
  Volume( int channels = 2, int maxVolume = 100 );
 
14
 
 
15
  void setAllVolumes( int value )
 
16
    { v_volumes.fill( volrange(value) ); };
 
17
  void setVolume( unsigned channel, int value )
 
18
    { if( channel<v_volumes.size() ) v_volumes[ channel ] = volrange(value); };
 
19
  int  operator[]( unsigned channel ) const
 
20
    { return (channel<v_volumes.size()) ? v_volumes[channel] : 0; };
 
21
  int  getVolume( unsigned channel ) const
 
22
    { return (channel<v_volumes.size()) ? v_volumes[channel] : 0; };
 
23
  int  maxVolume() const { return v_maxVolume; };
 
24
  int  channels() const { return v_volumes.size(); };
 
25
 
 
26
  void setMuted( bool val ) { v_muted = val; };
 
27
  bool isMuted() const      { return v_muted; };
 
28
private:
 
29
  int volrange( int vol ) { return vol > v_maxVolume ? v_maxVolume : vol; };
 
30
  int           v_maxVolume;
 
31
 
 
32
  bool          v_muted;
 
33
  QArray<int>   v_volumes;
 
34
};
 
35
 
 
36
class MonoVolume : public Volume
 
37
{
 
38
  MonoVolume( int maxVolume = 100 ) : Volume( 1, maxVolume ) {};
 
39
};
 
40
 
 
41
class StereoVolume : public Volume
 
42
{
 
43
  StereoVolume( int maxVolume = 100 ) : Volume( 2, maxVolume ) {};
 
44
};
 
45
 
 
46
#endif // VOLUME