aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/audio/source.h
blob: f3b749df0d818da4bd0253d169dd0a84043174cc (plain)
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
#ifndef __JE_AUDIO_SOURCE_H__
#define __JE_AUDIO_SOURCE_H__
#include "../core/configuration.h"
#if defined(jin_audio) 

#include "../common/object.h"

#include "SDL2/SDL.h"

namespace JinEngine
{
    namespace Audio
    {

        ///
        /// Audio source encoding type.
        ///
        enum SourceType
        {
            INVALID = 0,
            WAV,
            OGG,
        };

        ///
        /// Audio source.
        ///
        class Source : public Object
        {
        public:
            ///
            /// Source constructor.
            ///
            Source() {};

            ///
            /// Source destructor.
            ///
            virtual ~Source() {};

            ///
            /// Start playing source.
            ///
            virtual void play() = 0;

            ///
            /// Stop playing source.
            ///
            virtual void stop() = 0;

            ///
            /// Pause source.
            ///
            virtual void pause() = 0;

            ///
            /// Resume source.
            ///
            virtual void resume() = 0;

            ///
            /// Rewind source.
            ///
            virtual void rewind() = 0;

            ///
            /// Whether the source is playing or not.
            ///
            virtual bool isStopped() const = 0;

            ///
            /// Whether the source is paused or not.
            ///
            virtual bool isPaused() const = 0;

            ///
            /// Set source pitch.
            ///
            /// @param pitch Pitch of source.
            /// 
            virtual void setPitch(float pitch) = 0;

            ///
            /// Set volume of source.
            /// 
            /// @param volume Volume of source.
            ///
            virtual void setVolume(float volume) = 0;

            ///
            /// Set source loop.
            /// 
            /// @param loop Looping or not.
            ///
            virtual void setLoop(bool loop) = 0;

            ///
            /// Set source rate.
            /// 
            /// @param rate Rate of source.
            ///
            virtual void setRate(float rate) = 0;

        protected:

            /// 
            /// Get type of source data.
            /// 
            static SourceType getType(const void* mem, int size);

        };

    } // namespace Audio
} // namespace JinEngine

#endif // jin_audio

#endif // __JE_AUDIO_SOURCE_H__