Magic_Game/src/kiwano-audio/Sound.h

97 lines
2.2 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-08-13 21:16:38 +08:00
#include <kiwano/core/intrusive_ptr.hpp>
2019-08-18 10:23:54 +08:00
#include <kiwano/base/ObjectBase.h>
#include <kiwano/base/Resource.h>
2019-10-11 21:55:29 +08:00
#include <kiwano-audio/Transcoder.h>
#include <xaudio2.h>
2019-04-11 14:40:54 +08:00
namespace kiwano
{
2019-07-30 10:46:01 +08:00
namespace audio
{
2019-07-30 10:46:01 +08:00
KGE_DECLARE_SMART_PTR(Sound);
class KGE_API Sound
2019-08-18 10:23:54 +08:00
: public ObjectBase
{
2019-07-30 10:46:01 +08:00
public:
Sound();
2019-08-18 17:49:13 +08:00
Sound(
String const& file_path /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>ļ<EFBFBD> */
);
2019-07-30 10:46:01 +08:00
Sound(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
2019-07-30 10:46:01 +08:00
virtual ~Sound();
2019-08-18 17:49:13 +08:00
// <20>򿪱<EFBFBD><F2BFAAB1><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>ļ<EFBFBD>
bool Load(
String const& file_path
);
2019-07-30 10:46:01 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
bool Load(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
// <20><><EFBFBD><EFBFBD>
void Play(
2019-09-29 22:23:13 +08:00
int loop_count = 0 /* <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (-1 Ϊѭ<CEAA><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) */
2019-07-30 10:46:01 +08:00
);
// <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>
2019-09-29 22:23:13 +08:00
float GetVolume() const;
2019-07-30 10:46:01 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void SetVolume(
2019-09-29 22:23:13 +08:00
float volume /* 1 Ϊԭʼ<D4AD><CABC><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> 1 Ϊ<>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>, 0 Ϊ<><CEAA>С<EFBFBD><D0A1><EFBFBD><EFBFBD> */
2019-07-30 10:46:01 +08:00
);
protected:
2019-09-10 11:50:19 +08:00
bool opened_;
bool playing_;
Transcoder transcoder_;
2019-08-19 09:28:59 +08:00
IXAudio2SourceVoice* voice_;
};
}
}