Hydrogen - Linux Drum Machine
Main Page | Class Hierarchy | Compound List | File List | Compound Members

OssDriver.h

00001 /*
00002  * Hydrogen
00003  * Copyright(c) 2002-2003 by Alex >Comix< Cominu [comix@users.sourceforge.net]
00004  *
00005  * http://hydrogen.sourceforge.net
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY, without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * $Id: OssDriver.h,v 1.13 2003/05/03 16:55:28 comix Exp $
00022  *
00023  */
00024 
00025 
00026 #ifndef OSS_AUDIO_DRIVER_H
00027 #define OSS_AUDIO_DRIVER_H
00028 
00029 #include "config.h"
00030 
00031 // check if OSS support is enabled
00032 #ifdef OSS_SUPPORT
00033 
00034 
00035 #ifdef __NetBSD__
00036     #include <soundcard.h>
00037 #else
00038     #include <sys/soundcard.h>
00039 #endif
00040 #include <sys/ioctl.h>
00041 #include <stdio.h>
00042 #include <sys/types.h>
00043 #include <sys/stat.h>
00044 #include <fcntl.h>
00045 #include <iostream>
00046 #include <unistd.h>
00047 
00048 using std::cout;
00049 using std::endl;
00050 
00051 #include "GenericDriver.h"
00052 #include "PreferencesMng.h"
00053 
00054 #ifdef __NetBSD__
00055     #define AUDIO_DEVICE "/dev/audio"
00056 #else
00057     #define AUDIO_DEVICE "/dev/dsp"
00058 #endif
00059 
00060 typedef int  (*audioProcessCallback)(unsigned long, void *);
00061 
00062 //----------------------------------------------------------------------------
00066 class OssDriver : public GenericDriver {
00067     private:
00069         int fd;
00070 
00071         short* audioBuffer;
00072 
00073         audioProcessCallback processCallback;
00074         int log2(int n);
00075 
00076     public:
00077         virtual string getClassName() { return "OssDriver"; }
00078 
00080         OssDriver(audioProcessCallback processCallback);
00081 
00083         ~OssDriver();
00084 
00085         int connect();
00086 
00087         void disconnect();
00088 
00089         void write(float* buffer_L, float* buffer_R, unsigned int bufferSize);
00090         void setBufferSize(uint bufferSize);
00091         uint getBufferSize();
00092         uint getSampleRate();
00093 };
00094 
00095 
00096 #endif // OSS support
00097 
00098 #endif

 
 
Hydrogen (c) 2002..2003 Comix