openspades/Sources/Audio/YsrDevice.h

77 lines
2.2 KiB
C
Raw Normal View History

2014-02-13 12:25:34 +09:00
/*
Copyright (c) 2013 yvt
2014-02-13 12:25:34 +09:00
This file is part of OpenSpades.
2014-02-13 12:25:34 +09:00
OpenSpades is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2014-02-13 12:25:34 +09:00
OpenSpades is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2014-02-13 12:25:34 +09:00
You should have received a copy of the GNU General Public License
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
2014-02-13 12:25:34 +09:00
*/
2013-12-15 21:51:00 +09:00
#pragma once
#include <array>
2013-12-15 21:51:00 +09:00
#include <map>
#include <memory>
#include <Client/IAudioDevice.h>
2013-12-15 21:51:00 +09:00
namespace spades {
namespace audio {
2013-12-15 21:51:00 +09:00
class YsrDriver;
class YsrAudioChunk;
2013-12-15 23:01:29 +09:00
struct SdlAudioDevice;
class YsrDevice : public client::IAudioDevice {
2013-12-15 21:51:00 +09:00
std::shared_ptr<YsrDriver> driver;
client::GameMap *gameMap;
2013-12-15 23:01:29 +09:00
std::unique_ptr<SdlAudioDevice> sdlAudioDevice;
Vector3 listenerPosition;
2013-12-15 21:51:00 +09:00
int roomHistoryPos;
enum { RoomHistorySize = 128 };
std::array<float, RoomHistorySize> roomHistory;
std::array<float, RoomHistorySize> roomFeedbackHistory;
2013-12-15 21:51:00 +09:00
std::map<std::string, YsrAudioChunk *> chunks;
YsrAudioChunk *CreateChunk(const char *name);
static void SpatializeCallback(const void *, void *, YsrDevice *);
2013-12-15 23:01:29 +09:00
static void RenderCallback(YsrDevice *, float *, int);
void Render(float *stream, int numBytes);
void Spatialize(const void *, void *);
2013-12-15 23:01:29 +09:00
protected:
virtual ~YsrDevice();
2013-12-15 21:51:00 +09:00
public:
YsrDevice();
static bool TryLoadYsr();
2013-12-15 21:51:00 +09:00
virtual client::IAudioChunk *RegisterSound(const char *name);
2013-12-15 21:51:00 +09:00
virtual void SetGameMap(client::GameMap *);
virtual void Play(client::IAudioChunk *, const Vector3 &origin,
const client::AudioParam &);
virtual void PlayLocal(client::IAudioChunk *, const Vector3 &origin,
const client::AudioParam &);
virtual void PlayLocal(client::IAudioChunk *, const client::AudioParam &);
virtual void Respatialize(const Vector3 &eye, const Vector3 &front, const Vector3 &up);
2013-12-15 21:51:00 +09:00
};
}
}