]>
Commit | Line | Data |
---|---|---|
526ddb13 GL |
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, size_t len); | |
29 | wxSoundStream& Write(const void *buffer, size_t len); | |
30 | ||
31 | bool SetSoundFormat(const wxSoundFormatBase& format); | |
32 | ||
33 | bool StartProduction(int evt); | |
34 | bool StopProduction(); | |
35 | ||
36 | protected: | |
37 | wxSoundStream *m_router; | |
38 | }; | |
39 | ||
40 | typedef enum { | |
41 | wxSOUND_FILE_STOPPED, | |
42 | wxSOUND_FILE_PAUSED, | |
43 | wxSOUND_FILE_PLAYING, | |
44 | wxSOUND_FILE_RECORDING | |
45 | } wxSoundFileState; | |
46 | ||
47 | // | |
48 | // Base class for file coders/decoders | |
49 | // | |
50 | ||
51 | class wxSoundFileStream: public wxSoundStream { | |
52 | public: | |
53 | wxSoundFileStream(wxInputStream& stream, wxSoundStream& io_sound); | |
54 | wxSoundFileStream(wxOutputStream& stream, wxSoundStream& io_sound); | |
55 | ~wxSoundFileStream(); | |
56 | ||
57 | bool Play(); | |
58 | bool Record(unsigned long time); | |
59 | bool Stop(); | |
60 | bool Pause(); | |
61 | bool Resume(); | |
62 | ||
63 | bool IsStopped() const { return m_state == wxSOUND_FILE_STOPPED; } | |
64 | ||
65 | bool StartProduction(int evt); | |
66 | bool StopProduction(); | |
67 | ||
68 | unsigned long GetLength() const; | |
69 | ||
70 | wxSoundStream& Read(void *buffer, size_t len); | |
71 | wxSoundStream& Write(const void *buffer, size_t len); | |
72 | ||
73 | void SetDuplexMode(bool duplex); | |
74 | ||
75 | bool SetSoundFormat(const wxSoundFormatBase& format); | |
76 | ||
77 | virtual bool CanRead() { return TRUE; } | |
78 | ||
79 | protected: | |
80 | wxSoundRouterStream m_codec; | |
81 | wxSoundStream *m_sndio; | |
82 | wxInputStream *m_input; | |
83 | wxOutputStream *m_output; | |
84 | ||
85 | wxSoundFileState m_state, m_oldstate; | |
86 | wxUint32 m_len; | |
87 | ||
88 | protected: | |
89 | virtual bool PrepareToPlay() = 0; | |
90 | virtual bool PrepareToRecord(unsigned long time) = 0; | |
91 | virtual bool FinishRecording() = 0; | |
92 | ||
93 | virtual size_t GetData(void *buffer, size_t len) = 0; | |
94 | virtual size_t PutData(const void *buffer, size_t len) = 0; | |
95 | ||
96 | void OnSoundEvent(int evt); | |
97 | }; | |
98 | ||
99 | #endif |