Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

AudioIO.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 
00003   Audacity: A Digital Audio Editor
00004 
00005   AudioIO.h
00006 
00007   Dominic Mazzoni
00008 
00009   Use the PortAudio library to play and record sound
00010 
00011 **********************************************************************/
00012 
00013 #ifndef __AUDACITY_AUDIO_IO__
00014 #define __AUDACITY_AUDIO_IO__
00015 
00016 #include "portaudio.h"
00017 
00018 #include <wx/string.h>
00019 #include <wx/timer.h>
00020 
00021 #include "SampleFormat.h"
00022 #include "WaveTrack.h"
00023 
00024 class AudioIO;
00025 class AudacityProject;
00026 
00027 extern AudioIO *gAudioIO;
00028 
00029 void InitAudioIO();
00030 
00031 class AudioIOTimer:public wxTimer {
00032  public:
00033    virtual void Notify();
00034 };
00035 
00036 struct AudioIOBuffer {
00037    int          ID;
00038    int          len;
00039    samplePtr    data;
00040 };
00041 
00042 class AudioIO {
00043 
00044  public:
00045    AudioIO();
00046    ~AudioIO();
00047 
00048    bool StartPlay(AudacityProject * project,
00049                   TrackList * tracks, double t0, double t1);
00050 
00051    bool StartRecord(AudacityProject * project,
00052                     TrackList * tracks, double t0, double t1);
00053 
00054    void Stop();
00055    void HardStop();
00056    bool IsBusy();
00057    bool IsPlaying();
00058    bool IsRecording(Track *t = NULL);
00059 
00060    // AS: This would be more properly named GetCurrentTime or
00061    //  something like that.  The indicator is the little graphic
00062    //  displayed in TrackPanel showing the current position while
00063    //  you're playing or recording.
00064    double GetIndicator();
00065 
00066    AudacityProject *GetProject();
00067 
00068    void OnTimer();
00069 
00070    sampleFormat GetFormat();
00071 
00072    void AddDroppedSamples(sampleCount nSamples);
00073 
00074    double GetPauseIndicator();
00075 
00076    void SetPaused(bool state);
00077    bool GetPaused();
00078 
00079  private:
00080 
00081    bool Start();
00082 
00083    bool OpenDevice();
00084    void FillBuffers();   
00085 
00086    AudacityProject     *mProject;
00087    TrackList           *mTracks;
00088    double              mRate;
00089    double              mT;
00090    double              mRecT;
00091    double              mT0;
00092    double              mT1;
00093    bool                mHardStop;
00094    bool                mPaused;
00095 
00096    sampleCount         mDroppedSamples;
00097    double              mPausePosition;
00098 
00099    PortAudioStream    *mPortStream;
00100 
00101    unsigned int        mNumInChannels;
00102    unsigned int        mNumOutChannels;
00103 
00104    sampleFormat        mFormat;
00105    
00106    WaveTrack         **mInTracks;
00107 
00108    AudioIOTimer        mTimer;
00109    
00110    sampleCount         mBufferSize;
00111    int                 mInID;
00112    int                 mOutID;
00113    unsigned int        mMaxBuffers;
00114    unsigned int        mInitialNumOutBuffers;
00115    unsigned int        mNumOutBuffers;
00116    unsigned int        mNumInBuffers;
00117    AudioIOBuffer      *mOutBuffer;
00118    AudioIOBuffer      *mInBuffer;
00119    
00120    int                 mInUnderruns;
00121    int                 mRepeats;
00122    int                 mLastChecksum;
00123    double              mRepeatPoint;
00124    
00125    friend int audacityAudioCallback(
00126                 void *inputBuffer, void *outputBuffer,
00127                 unsigned long framesPerBuffer,
00128                 PaTimestamp outTime, void *userData );
00129 };
00130 
00131 #endif

Generated on Wed Nov 6 20:20:52 2002 for Audacity by doxygen1.2.18