| 1 | /* |
|---|
| 2 | * Hydrogen |
|---|
| 3 | * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] |
|---|
| 4 | * |
|---|
| 5 | * http://www.hydrogen-music.org |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | * (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY, without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | * |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | #ifndef PORT_AUDIO_DRIVER_H |
|---|
| 24 | #define PORT_AUDIO_DRIVER_H |
|---|
| 25 | |
|---|
| 26 | #include <hydrogen/IO/AudioOutput.h> |
|---|
| 27 | #include <hydrogen/IO/NullDriver.h> |
|---|
| 28 | |
|---|
| 29 | #ifdef PORTAUDIO_SUPPORT |
|---|
| 30 | |
|---|
| 31 | #include <inttypes.h> |
|---|
| 32 | #include <portaudio.h> |
|---|
| 33 | |
|---|
| 34 | namespace H2Core |
|---|
| 35 | { |
|---|
| 36 | |
|---|
| 37 | typedef int ( *audioProcessCallback )( uint32_t, void * ); |
|---|
| 38 | |
|---|
| 39 | class PortAudioDriver : public AudioOutput |
|---|
| 40 | { |
|---|
| 41 | public: |
|---|
| 42 | audioProcessCallback m_processCallback; |
|---|
| 43 | float* m_pOut_L; |
|---|
| 44 | float* m_pOut_R; |
|---|
| 45 | unsigned m_nBufferSize; |
|---|
| 46 | |
|---|
| 47 | PortAudioDriver( audioProcessCallback processCallback ); |
|---|
| 48 | virtual ~PortAudioDriver(); |
|---|
| 49 | |
|---|
| 50 | virtual int init( unsigned nBufferSize ); |
|---|
| 51 | virtual int connect(); |
|---|
| 52 | virtual void disconnect(); |
|---|
| 53 | virtual unsigned getBufferSize(); |
|---|
| 54 | virtual unsigned getSampleRate(); |
|---|
| 55 | virtual float* getOut_L(); |
|---|
| 56 | virtual float* getOut_R(); |
|---|
| 57 | |
|---|
| 58 | private: |
|---|
| 59 | PortAudioStream *m_pStream; |
|---|
| 60 | unsigned m_nSampleRate; |
|---|
| 61 | |
|---|
| 62 | }; |
|---|
| 63 | |
|---|
| 64 | }; |
|---|
| 65 | |
|---|
| 66 | #else |
|---|
| 67 | |
|---|
| 68 | namespace H2Core |
|---|
| 69 | { |
|---|
| 70 | |
|---|
| 71 | class PortAudioDriver : public NullDriver |
|---|
| 72 | { |
|---|
| 73 | public: |
|---|
| 74 | PortAudioDriver( audioProcessCallback processCallback ) : NullDriver( processCallback ) {} |
|---|
| 75 | |
|---|
| 76 | }; |
|---|
| 77 | |
|---|
| 78 | }; |
|---|
| 79 | |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | #endif |
|---|
| 84 | |
|---|