]>
Commit | Line | Data |
---|---|---|
1 | // -------------------------------------------------------------------------- | |
2 | // Name: sndfile.h | |
3 | // Purpose: | |
4 | // Date: 08/11/1999 | |
5 | // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999 | |
6 | // CVSID: $Id$ | |
7 | // -------------------------------------------------------------------------- | |
8 | #ifndef _WX_SNDFILE_H | |
9 | #define _WX_SNDFILE_H | |
10 | ||
11 | #include <wx/defs.h> | |
12 | #include <wx/stream.h> | |
13 | #include <stdlib.h> | |
14 | #include "sndbase.h" | |
15 | #include "sndcodec.h" | |
16 | ||
17 | #define wxSOUND_INFINITE_TIME ((unsigned long)-1) | |
18 | ||
19 | // | |
20 | // Codec router class | |
21 | // | |
22 | ||
23 | class WXDLLEXPORT wxSoundRouterStream: public wxSoundStreamCodec { | |
24 | public: | |
25 | wxSoundRouterStream(wxSoundStream& sndio); | |
26 | ~wxSoundRouterStream(); | |
27 | ||
28 | wxSoundStream& Read(void *buffer, wxUint32 len); | |
29 | wxSoundStream& Write(const void *buffer, wxUint32 len); | |
30 | ||
31 | bool SetSoundFormat(const wxSoundFormatBase& format); | |
32 | ||
33 | bool StartProduction(int evt); | |
34 | bool StopProduction(); | |
35 | ||
36 | wxUint32 GetBestSize() const; | |
37 | ||
38 | protected: | |
39 | wxSoundStream *m_router; | |
40 | }; | |
41 | ||
42 | typedef enum { | |
43 | wxSOUND_FILE_STOPPED, | |
44 | wxSOUND_FILE_PAUSED, | |
45 | wxSOUND_FILE_PLAYING, | |
46 | wxSOUND_FILE_RECORDING | |
47 | } wxSoundFileState; | |
48 | ||
49 | // | |
50 | // Base class for file coders/decoders | |
51 | // | |
52 | ||
53 | class wxSoundFileStream: public wxSoundStream { | |
54 | public: | |
55 | wxSoundFileStream(wxInputStream& stream, wxSoundStream& io_sound); | |
56 | wxSoundFileStream(wxOutputStream& stream, wxSoundStream& io_sound); | |
57 | ~wxSoundFileStream(); | |
58 | ||
59 | bool Play(); | |
60 | bool Record(unsigned long time); | |
61 | bool Stop(); | |
62 | bool Pause(); | |
63 | bool Resume(); | |
64 | ||
65 | bool IsStopped() const { return m_state == wxSOUND_FILE_STOPPED; } | |
66 | ||
67 | bool StartProduction(int evt); | |
68 | bool StopProduction(); | |
69 | ||
70 | unsigned long GetLength() const; | |
71 | ||
72 | wxSoundStream& Read(void *buffer, wxUint32 len); | |
73 | wxSoundStream& Write(const void *buffer, wxUint32 len); | |
74 | ||
75 | void SetDuplexMode(bool duplex); | |
76 | ||
77 | bool SetSoundFormat(const wxSoundFormatBase& format); | |
78 | ||
79 | virtual bool CanRead() { return FALSE; } | |
80 | ||
81 | protected: | |
82 | wxSoundRouterStream m_codec; | |
83 | wxSoundStream *m_sndio; | |
84 | wxInputStream *m_input; | |
85 | wxOutputStream *m_output; | |
86 | ||
87 | wxSoundFileState m_state, m_oldstate; | |
88 | wxUint32 m_len; | |
89 | ||
90 | protected: | |
91 | virtual bool PrepareToPlay() = 0; | |
92 | virtual bool PrepareToRecord(unsigned long time) = 0; | |
93 | virtual bool FinishRecording() = 0; | |
94 | ||
95 | virtual wxUint32 GetData(void *buffer, wxUint32 len) = 0; | |
96 | virtual wxUint32 PutData(const void *buffer, wxUint32 len) = 0; | |
97 | ||
98 | void OnSoundEvent(int evt); | |
99 | }; | |
100 | ||
101 | #endif |