File: streamed_mikmod_sample.h

package info (click to toggle)
clanlib 0.5.4-1-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,320 kB
  • ctags: 10,893
  • sloc: cpp: 76,056; xml: 3,281; sh: 2,961; perl: 1,204; asm: 837; makefile: 775
file content (154 lines) | stat: -rw-r--r-- 3,393 bytes parent folder | download
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
	$Id: streamed_mikmod_sample.h,v 1.15 2001/12/11 20:44:20 mbn Exp $

	------------------------------------------------------------------------
	ClanLib, the platform independent game SDK.

	This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
	version 2. See COPYING for details.

	For a total list of contributers see CREDITS.

	See http://www.clanlib.org
	------------------------------------------------------------------------

	File purpose:
		Streamed sample header file
*/

//! clanMikMod="Sound Providers"
//! header=mikmod.h

#ifndef header_streamed_mikmod_sample
#define header_streamed_mikmod_sample

#include <stdlib.h>
#include "../core.h"
#include "../Sound/stream_soundprovider.h"
#include "../Sound/soundbuffer.h"

#include <mikmod.h>

//: CL_Streamed_MikModSample is used to store MikMod modules in memory.
//: <p>This class stores the ClanLib sample the way the MikMod MODULE struct
//: does. It's only intended to store the module in memory, not to play
//: it directly. To play the module, use CL_Streamed_MikModSample_Session
//: instead.</p>
class CL_Streamed_MikModSample : public CL_StreamSoundProvider
{
protected:
	std::string filename;
	bool looped;
	bool loaded_from_resource;
	CL_ResourceManager *manager;

	MODULE *module;
public:
//! Construction:
	//: Use this function to create a module from a file for instance
	static CL_SoundBuffer *create(
		const std::string &filename, 
		CL_InputSourceProvider *inputprovider = NULL, 
		bool looped = false);

	//: Loads a module from a resource file (.scr or .dat)
	static CL_SoundBuffer *load(
		const std::string &res_id, 
		CL_ResourceManager *manager, 
		bool looped = false);

	//: Use this function to create a module from a file for instance
	CL_Streamed_MikModSample(
		const std::string &filename, 
		CL_InputSourceProvider *inputprovider = NULL, 
		bool looped = false);

	//: Loads a module from a resource file (.scr or .dat)
	CL_Streamed_MikModSample(
		const std::string &res_id, 
		CL_ResourceManager *manager, 
		bool looped = false);

	//: Streamed MikModSample Destructor
	virtual ~CL_Streamed_MikModSample();

//! Operations:
	//: Starts playing the module
	virtual CL_StreamSoundProvider_Session *begin_session();

	//: Ends the session
	virtual void end_session(CL_StreamSoundProvider_Session *session);

};

//: CL_Streamed_MikModSample_Session is used to play and control a module.
class CL_Streamed_MikModSample_Session : public CL_StreamSoundProvider_Session
{
protected:
	friend class CL_Streamed_MikModSample;

	CL_Streamed_MikModSample_Session(MODULE *_module, bool _looped);

	MODULE *module;
	bool looped;

	SoundFormat sample_format;
	int sample_size;
	int sample_freq;
	int sample_left;

public:
//! Construction:
	//: ~CL Streamed MikModSample Session
	virtual ~CL_Streamed_MikModSample_Session();

//! Operations:
	//: Stop
	virtual void stop();

	//: Play
	virtual bool play();

	//: Set position
	virtual bool set_position(int pos);

	//: ClanMikMod Update
	static void clanMikMod_Update() { /* do nothing */ }

//! Attributes:
	//: Eof
	virtual bool eof() const;

	//: Get data
	virtual int get_data(void *data_ptr, int data_requested);

	//: Get frequency
	virtual int get_frequency() const;

	//: Get format
	virtual SoundFormat get_format() const;

	//: ClanMikMod IsPresent
	static BOOL clanMikMod_IsPresent() { return 1; }


};

#endif