Magic_Game/Kiwano/audio/Sound.h

82 lines
1.9 KiB
C
Raw Normal View History

2019-04-11 14:40:54 +08:00
// Copyright (c) 2016-2018 Kiwano - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
2019-04-11 16:00:57 +08:00
#include <xaudio2.h>
2019-04-11 14:40:54 +08:00
namespace kiwano
{
2019-04-11 16:00:57 +08:00
KGE_DECLARE_SMART_PTR(Sound);
// <20><><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>
2019-04-11 16:00:57 +08:00
class KGE_API Sound
: public virtual Object
{
public:
2019-04-11 16:00:57 +08:00
Sound();
2019-04-11 16:00:57 +08:00
Sound(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
2019-04-11 16:00:57 +08:00
virtual ~Sound();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
bool Load(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
// <20><><EFBFBD><EFBFBD>
2019-04-11 16:00:57 +08:00
void Play(
int loop_count = 0 /* <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (-1 Ϊѭ<CEAA><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) */
);
// <20><>ͣ
void Pause();
// <20><><EFBFBD><EFBFBD>
void Resume();
// ֹͣ
void Stop();
// <20>رղ<D8B1><D5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
void Close();
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>
bool IsPlaying() const;
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
float GetVolume() const;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-04-11 16:00:57 +08:00
void SetVolume(
float volume /* 1 Ϊԭʼ<D4AD><CABC><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> 1 Ϊ<>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>, 0 Ϊ<><CEAA>С<EFBFBD><D0A1><EFBFBD><EFBFBD> */
);
protected:
bool opened_;
bool playing_;
UINT32 size_;
BYTE* wave_data_;
2019-04-11 16:00:57 +08:00
IXAudio2SourceVoice* voice_;
};
}