File: sound.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (130 lines) | stat: -rw-r--r-- 3,947 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/////////////////////////////////////////////////////////////////////////////
// Name:        sound.h
// Purpose:     interface of wxSound
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////


#define wxSOUND_SYNC  0
#define wxSOUND_ASYNC 1
#define wxSOUND_LOOP  2


/**
    @class wxSound

    This class represents a short sound (loaded from Windows WAV file), that
    can be stored in memory and played.

    Currently this class is implemented on Windows and Unix (and uses either
    Open Sound System or Simple DirectMedia Layer).

    @library{wxadv}
    @category{media}
*/
class wxSound : public wxObject
{
public:
    /**
        Default ctor.
    */
    wxSound();

    /**
        Constructs a wave object from a file or, under Windows, from a Windows
        resource. Call IsOk() to determine whether this succeeded.

        @param fileName
            The filename or Windows resource.
        @param isResource
            @true if fileName is a resource, @false if it is a filename.
    */
    wxSound(const wxString& fileName, bool isResource = false);

    /**
        Constructs a wave object from in-memory data.

        @param size
            Size of the buffer pointer to by @a data.
        @param data
            The buffer containing the sound data in WAV format.
     */
    wxSound(size_t size, const void* data);

    /**
        Destroys the wxSound object.
    */
    virtual ~wxSound();

    /**
        Constructs a wave object from a file or resource.

        @param fileName
            The filename or Windows resource.
        @param isResource
            @true if fileName is a resource, @false if it is a filename.

        @return @true if the call was successful, @false otherwise.
    */
    bool Create(const wxString& fileName, bool isResource = false);

    /**
        Constructs a wave object from in-memory data.

        @param size
            Size of the buffer pointer to by @a data.
        @param data
            The buffer containing the sound data in WAV format.
     */
    bool Create(size_t size, const void* data);

    /**
        Returns @true if the object contains a successfully loaded file or resource,
        @false otherwise.
    */
    bool IsOk() const;

    /**
        Returns @true if a sound is played at the moment.

        This method is currently not available under Windows and may not be
        always implemented in Unix ports depending on the compilation options
        used (in this case it just always returns @false).

        @onlyfor{wxgtk,wxosx}
    */
    static bool IsPlaying();

    //@{
    /**
        Plays the sound file. If another sound is playing, it will be interrupted.

        Returns @true on success, @false otherwise. Note that in general it is
        possible to delete the object which is being asynchronously played any time
        after calling this function and the sound would continue playing, however this
        currently doesn't work under Windows for sound objects loaded from memory data.

        The possible values for @a flags are:
        - wxSOUND_SYNC: @c Play will block and wait until the sound is replayed.
        - wxSOUND_ASYNC: Sound is played asynchronously, @c Play returns immediately.
        - wxSOUND_ASYNC|wxSOUND_LOOP: Sound is played asynchronously and loops
                                      until another sound is played, Stop() is
                                      called or the program terminates.

        The static form is shorthand for this code:
        @code
        wxSound(filename).Play(flags);
        @endcode
    */
    bool Play(unsigned flags = wxSOUND_ASYNC) const;
    static bool Play(const wxString& filename,
                     unsigned flags = wxSOUND_ASYNC);
    //@}

    /**
        If a sound is played, this function stops it.
    */
    static void Stop();
};