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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
/*
** ClanLib SDK
** Copyright (c) 1997-2005 The ClanLib Team
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
** Note: Some of the libraries ClanLib may link to may have additional
** requirements or restrictions.
**
** File Author(s):
**
** Magnus Norddahl
** (if your name is missing here, please add it)
*/
//! clanSound="Audio Mixing"
//! header=sound.h
#ifndef header_soundbuffer_session
#define header_soundbuffer_session
#ifdef CL_API_DLL
#ifdef CL_SOUND_EXPORT
#define CL_API_SOUND __declspec(dllexport)
#else
#define CL_API_SOUND __declspec(dllimport)
#endif
#else
#define CL_API_SOUND
#endif
#if _MSC_VER > 1000
#pragma once
#endif
#include "../Core/System/mutexsharedptr.h"
class CL_SoundCard;
class CL_SoundFilter;
class CL_SoundBuffer;
class CL_SoundBuffer_Session_Generic;
class CL_API_SOUND CL_SoundBuffer_Session
//: CL_SoundBuffer_Session provides control over a playing soundeffect.
//- !group=Sound/Audio Mixing!
//- !header=sound.h!
//- <p>Whenever a soundbuffer is played, it returns a CL_SoundBuffer_Session
//- class, which can be used to control the sound (its volume, pitch,
//- pan, position). It can also be used to retrigger the sound
//- or to stop it.</p>
{
//! Construction:
public:
//: Creates a soundbuffer session.
CL_SoundBuffer_Session();
CL_SoundBuffer_Session(const CL_SoundBuffer_Session ©);
virtual ~CL_SoundBuffer_Session();
//! Attributes:
public:
//: Returns the current sample position of the playback.
int get_position() const;
//: Returns the sample position relative to the full length.
//- <p>The value returned will be between 0 and 1, where 0
//- means the session is at the beginning, and 1
//- means that the soundeffect has reached the end.</p>
float get_position_relative() const;
//: Returns the total length (in samples) of the sound buffer played.
//- <p>Value returned will be -1 if the length is unknown (in
//- case of non-static soundeffects like streamed sound)</p>
int get_length() const;
//: Returns the frequency of the session.
int get_frequency() const;
//: Returns the linear relative volume of the soundeffect.
//- <p>0 means the soundeffect is muted, 1 means the soundeffect
//- is playing at "max" volume.</p>
float get_volume() const;
//: Returns the current pan (in a measure from -1 -> 1).
//- <p>-1 means the soundeffect is only playing in the left speaker,
//- and 1 means the soundeffect is only playing in the right speaker.</p>
float get_pan() const;
//: Returns the current speedfactor.
float get_speedfactor() const;
//: Returns true if the session is playing
bool is_playing();
//! Operations:
public:
//: Sets the session position to 'new_pos'.
//- <p>The new position of the session.</p>
//return: Returns true if operation completed succesfully.
bool set_position(int new_pos);
//: Sets the relative position of the session.
//- <p>Value must be between 0 and 1, where 0 sets the
//- session to the beginning, and 1 sets it
//- to the end of the sound buffer.</p>
//param new_pos: New relative position.
//return: Returns true if operation completed succesfully.
bool set_position_relative(float new_pos);
//: Sets the frequency of the session.
//param new_freq: New frequency of session.
//return: Returns true, if the operation completed succesfully.
bool set_frequency(int new_freq);
//: Sets the volume of the session in a relative measure (0->1)
//- <p>A value of 0 will effectively mute the sound (although it will
//- still be sampled), and a value of 1 will set the volume to "max".</p>
//param new_volume: New volume of session.
//return: Returns true if the operation completed succesfully.
void set_volume(float new_volume);
//: Sets the panning of the session played in measures from -1 -> 1
//- <p>Setting the pan with a value of -1 will pan the session to the
//- extreme left (left speaker only), 1 will pan the session to the
//- extreme right (right speaker only).</p>
//param new_pan: New pan of the session played.
//return: Returns true if the operation completed sucecsfully.
void set_pan(float new_pan);
//: Sets the speedfactor of the session.
//param new_speedfactor: New speedfactor of session.
void set_speedfactor(float new_speedfactor);
//: Starts playback of the session.
void play();
//: Stops playback of the session.
void stop();
//: Rewinds the session so playback will start from the beginning.
void rewind() { set_position(0); }
//: Determines whether this session should loop
//param loop: true if session should loop, false otherwise
void set_looping(bool loop);
//: Adds the sound filter to the session. See CL_SoundFilter for details.
//param filter: Sound filter to pass sound through.
//param delete_filter: If true, the filter will be deleted when removed or the session is destroyed
void add_filter(CL_SoundFilter *filter, bool delete_filter = false);
//: Remove the sound filter from the session. See CL_SoundFilter for details.
void remove_filter(CL_SoundFilter *filter);
//: Removes all filters from the session.
void remove_all_filters();
//! Implementation:
private:
CL_SoundBuffer_Session(const CL_MutexSharedPtr<CL_SoundBuffer_Session_Generic> &impl);
CL_MutexSharedPtr<CL_SoundBuffer_Session_Generic> impl;
friend class CL_SoundBuffer;
};
#endif
|