]> git.saurik.com Git - wxWidgets.git/blame_incremental - contrib/include/wx/mmedia/sndfile.h
added i18n support to the compiler
[wxWidgets.git] / contrib / include / wx / mmedia / sndfile.h
... / ...
CommitLineData
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 "wx/mmedia/sndbase.h"
14#include "wx/mmedia/sndcodec.h"
15
16#define wxSOUND_INFINITE_TIME ((wxUint32)-1)
17
18//
19// Codec router class
20//
21
22class WXDLLEXPORT wxSoundRouterStream: public wxSoundStreamCodec {
23 public:
24 wxSoundRouterStream(wxSoundStream& sndio);
25 ~wxSoundRouterStream();
26
27 wxSoundStream& Read(void *buffer, wxUint32 len);
28 wxSoundStream& Write(const void *buffer, wxUint32 len);
29
30 bool SetSoundFormat(const wxSoundFormatBase& format);
31
32 bool StartProduction(int evt);
33 bool StopProduction();
34
35 wxUint32 GetBestSize() const;
36
37 protected:
38 wxSoundStream *m_router;
39};
40
41typedef enum {
42 wxSOUND_FILE_STOPPED,
43 wxSOUND_FILE_PAUSED,
44 wxSOUND_FILE_PLAYING,
45 wxSOUND_FILE_RECORDING
46} wxSoundFileState;
47
48//
49// Base class for file coders/decoders
50//
51
52class wxSoundFileStream: public wxSoundStream {
53public:
54 wxSoundFileStream(wxInputStream& stream, wxSoundStream& io_sound);
55 wxSoundFileStream(wxOutputStream& stream, wxSoundStream& io_sound);
56 ~wxSoundFileStream();
57
58 // Usual sound file calls (Play, Stop, ...)
59 bool Play();
60 bool Record(wxUint32 time);
61 bool Stop();
62 bool Pause();
63 bool Resume();
64
65 // Functions which return the current state
66 bool IsStopped() const { return m_state == wxSOUND_FILE_STOPPED; }
67 bool IsPaused() const { return m_state == wxSOUND_FILE_PAUSED; }
68
69 // A user should not call these two functions.
70 // Several things must be done before calling them.
71 // Users should use Play(), ...
72 bool StartProduction(int evt);
73 bool StopProduction();
74
75 // These three functions deals with the length, the position in the sound file.
76 // All the values are expressed in bytes. If you need the values expressed
77 // in terms of time, you have to use GetSoundFormat().GetTimeFromBytes(...)
78 wxUint32 GetLength();
79 wxUint32 GetPosition();
80 wxUint32 SetPosition(wxUint32 new_position);
81
82 // These two functions use the sound format specified by GetSoundFormat().
83 // All samples must be encoded in that format.
84 wxSoundStream& Read(void *buffer, wxUint32 len);
85 wxSoundStream& Write(const void *buffer, wxUint32 len);
86
87 // This function set the sound format of the file. !! It must be used only
88 // when you are in output mode (concerning the file) !! If you are in
89 // input mode (concerning the file) you can't use this function to modify
90 // the format of the samples returned by Read() !
91 // For this action, you must use wxSoundRouterStream applied to wxSoundFileStream.
92 bool SetSoundFormat(const wxSoundFormatBase& format);
93
94 // This function returns the Codec name. This is useful for those who want to build
95 // a player (But also in some other case).
96 virtual wxString GetCodecName() const;
97
98 // You should use this function to test whether this file codec can read
99 // the stream you passed to it.
100 virtual bool CanRead() { return FALSE; }
101
102protected:
103 wxSoundRouterStream m_codec;
104 wxSoundStream *m_sndio;
105 wxInputStream *m_input;
106 wxOutputStream *m_output;
107
108 wxSoundFileState m_state, m_oldstate;
109 wxUint32 m_length, m_bytes_left;
110 bool m_prepared;
111
112protected:
113 virtual bool PrepareToPlay() = 0;
114 virtual bool PrepareToRecord(wxUint32 time) = 0;
115 virtual bool FinishRecording() = 0;
116 virtual bool RepositionStream(wxUint32 position) = 0;
117 void FinishPreparation(wxUint32 len);
118
119 virtual wxUint32 GetData(void *buffer, wxUint32 len) = 0;
120 virtual wxUint32 PutData(const void *buffer, wxUint32 len) = 0;
121
122 void OnSoundEvent(int evt);
123};
124
125#endif