File: sound.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 (126 lines) | stat: -rw-r--r-- 4,063 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
/*
	$Id: sound.h,v 1.6 2001/10/10 12:51:05 sphair 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
	------------------------------------------------------------------------
*/

//! clanSound="Audio Mixing"
//! header=sound.h

#ifndef header_sound
#define header_sound

#include <vector>
#include <stdlib.h>
#include "soundbuffer.h"

//: Soundcard interface in ClanLib.
//- <p>CL_SoundCard is the interface to a soundcard. It is used to control the
//- main mixer volume and other global settings. It also provides access to
//- the microphone and line in as streamed soundproviders.</p>
class CL_SoundCard
{
public:
//! Variables:
	//: Name of the soundcard.
	std::string name;

	//: Card number.
	int card_no;

//! Construction:
	//: Sound Card destructor
	virtual ~CL_SoundCard() { ; }

//! Attributes:
	//: Returns the streamed soundprovider representing the microphone.
	virtual CL_StreamSoundProvider *get_microphone()=0;

	//: Returns the streamed soundprovider representing the line in.
	virtual CL_StreamSoundProvider *get_line_in()=0;

//! Operations:
	//: Stops all sample playbacks on the soundcard.
	virtual void stop_all()=0;
	
	//: Sets the main/mixer volume on the soundcard.
	virtual void set_global_volume(int volume)=0;

	//: Sets the main panning position on the soundcard.
	virtual void set_global_pan(int pan)=0;
};

class CL_Sound
//: Sound interface in ClanLib.
//- <p>This class provides a list of all soundcards available on the system. It
//- is also a wrapper class for the CL_SoundCard class, providing an easier
//- access to a single selected soundcard.</p>
//- 
//- <p>All the functions that share name with those in CL_SoundCard have the
//- same functionality. The only difference is, that the ones CL_Sound
//- operate on a selected soundcard. This saves the trouble of passing around
//- a pointer to the soundcard, when only a single one is used anyway.</p>
//- See also - CL_SoundCard - Soundcard interface class.
//- See also - CL_SoundBuffer - Sample class in ClanLib.
{
public:
//! Construction:
	//: Sound Destructor
	virtual ~CL_Sound() { ; }

//! Variables:
	//: The list of soundcards available on this system.
	static std::vector<CL_SoundCard*> cards;
	
	//: List of all cards where soundbuffers are automatically preloaded.
	static std::list<CL_SoundCard*> preload_cards;

//! Attributes:
	//: Returns the streamed soundprovider representing the microphone.
	//- Returns - The microphone.
	static CL_StreamSoundProvider *get_microphone();

	//: Returns the streamed soundprovider representing the line in.
	//- Returns - The line in.
	static CL_StreamSoundProvider *get_line_in();

	//: Returns the current selected soundcard.
	//- Returns - Current soundcard.
	static CL_SoundCard *get_current_card();

//! Operations:
	//: Clears the list of preloaded soundcards.
	static void clear_card_preload();

	//: <p>Adds 'card' to the preloaded soundcards list. This means all soundbuffers 
	//: will be automatically preloaded onto the card. By default the first card 
	//: is always on the preload list.</p>
	//:
	//: <p>If a card isn't on the list, the soundbuffer's data will first be loaded when 
	//: the sample is actually played for the first time.</p>
	//- card - The card to be added to the preload list.
	static void add_card_preload(CL_SoundCard *card);

	//: Removes the specified card from the preload list.
	//- card - The card to be removed from the list.
	static void remove_card_preload(CL_SoundCard *card);

	//: Change the current selected soundcard to 'card'.
	//- card - The new current selected soundcard.
	static void select_card(CL_SoundCard *card);
	
	//: Change the current selected soundcard to soundcard number 'card_no'.
	//- card_no - Card number in the CL_Sound::cards list.
	static void select_card(int card_no);
};

#endif