Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

audiodevice.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 // L.J.Potter added changes Fri 02-15-2002
00021 
00022 #ifndef AUDIODEVICE_H
00023 #define AUDIODEVICE_H
00024 
00025 
00026 #include <qobject.h>
00027 #include <sys/soundcard.h>
00028 
00029 
00030 class AudioDevicePrivate;
00031 
00032 
00033 class AudioDevice : public QObject {
00034     Q_OBJECT
00035 public:
00036     AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = AFMT_S16_LE );
00037     ~AudioDevice();
00038 
00039     unsigned int canWrite() const;
00040     void write( char *buffer, unsigned int length );
00041     int bytesWritten();
00042 
00043     unsigned int channels() const;
00044     unsigned int frequency() const;
00045     unsigned int bytesPerSample() const;
00046     unsigned int bufferSize() const;
00047 
00048     // Each volume level is from 0 to 0xFFFF
00049     static void getVolume( unsigned int& left, unsigned int& right, bool& muted );
00050     static void setVolume( unsigned int  left, unsigned int  right, bool  muted );
00051 
00052     static unsigned int leftVolume()  { bool muted; unsigned int l, r; getVolume( l, r, muted ); return l;     }
00053     static unsigned int rightVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return r;     }
00054     static bool         isMuted()     { bool muted; unsigned int l, r; getVolume( l, r, muted ); return muted; }
00055 
00056     static void increaseVolume() { setVolume( leftVolume() + 1968, rightVolume() + 1968, isMuted() ); }
00057     static void decreaseVolume() { setVolume( leftVolume() - 1966, rightVolume() - 1966, isMuted() ); }
00058 
00059 public slots:
00060     // Convinence functions derived from above functions
00061     void setVolume( unsigned int level ) { setVolume( level, level, isMuted() ); }
00062     void mute() { setVolume( leftVolume(), rightVolume(), TRUE ); }
00063     void volumeChanged( bool muted );
00064 
00065 signals:
00066     void completedIO();
00067 
00068 private:
00069     AudioDevicePrivate *d;
00070 };
00071 
00072 
00073 #endif // AUDIODEVICE_H
00074 

Generated on Sat Nov 5 16:15:34 2005 for OPIE by  doxygen 1.4.2