00001 00012 #ifndef AUDIODRV_ER6_H 00013 #define AUDIODRV_ER6_H 00014 00015 #include <e32def.h> 00016 #include <e32std.h> 00017 #include <mdaaudiooutputstream.h> 00018 #include <mda/common/audio.h> 00019 #include "mytypes.h" 00020 #include "emucfg.h" 00021 #include <f32file.h> 00022 00032 const TInt KDefaultBufSize = 0x2000; 00033 //#define SAMPLE_FREQ 44100 ///< in Hertz 00034 #define SAMPLE_FREQ 8000 00035 const TInt KVolumeSteps = 16; 00036 00037 00044 class audioDriver : public MMdaAudioOutputStreamCallback, public CBase 00045 { 00046 public: 00047 audioDriver(); 00048 void ConstructL(); 00049 ~audioDriver(); 00050 bool IsThere(); 00051 bool Open(udword freq, int precision, int channels, int fragments, int fragBase); 00052 void Close(); 00053 void Play(ubyte* buffer, int bufferSize); 00054 void StopStream(); 00055 TInt VolumeDelta(TInt aDelta); 00056 00057 // from MMdaAudioOutputStreamCallback 00058 virtual void MaoscOpenComplete(TInt aError); 00059 virtual void MaoscBufferCopied(TInt aError, const TDesC8& aBuffer); 00060 virtual void MaoscPlayComplete(TInt aError); 00061 00062 // methods for dumping to WAV file 00063 public: 00064 TInt StartWavDump(const TDesC& aSidTune); 00065 TInt StopWavDump(); 00066 TBool IsWavDumping(); 00067 private: 00068 void DoWavDump(const TDesC8& aBuffer); 00069 00070 public: 00071 bool Reset() {return 0;} 00072 int GetAudioHandle(){return audioHd;} 00073 udword GetFrequency(){return frequency;} 00074 int GetChannels(){return channels;} 00075 int GetSamplePrecision(){return precision;} 00076 int GetSampleEncoding(){return encoding;} 00077 int GetBlockSize(){return blockSize;} 00078 int GetFragments(){return fragments;} 00079 int GetFragSizeBase(){return fragSizeBase;} 00080 const char* GetErrorString(){return errorString;} 00081 private: 00082 void ResetStream(); 00083 00084 private: // ------------------------------------------------------- private 00085 int audioHd; 00086 const char* errorString; 00087 int blockSize; 00088 int fragments; 00089 int fragSizeBase; 00090 udword frequency; 00091 00092 // These are constants/enums from ``libsidplay/include/emucfg.h''. 00093 int encoding; 00094 int precision; 00095 int channels; 00096 00097 TInt iVolume; 00098 CMdaAudioOutputStream* iMdaAudio; 00099 TMdaAudioDataSettings iSettings; 00100 TBuf8<KDefaultBufSize*2> iExtraBuf; 00101 public: 00102 TBool iIsReady; 00103 TInt iBlocksInQueue; 00104 TBool iPrefilled; 00105 private: 00106 RFs iFs; 00107 TFileName iWavDump; 00108 TBool iIsWavDumping; 00109 }; 00110 00111 00112 #endif // AUDIODRV_ER6_H