2013-12-15 21:51:00 +09:00
|
|
|
//
|
|
|
|
// YsrDevice.h
|
|
|
|
// OpenSpades
|
|
|
|
//
|
|
|
|
// Created by Tomoaki Kawada on 12/15/13.
|
|
|
|
// Copyright (c) 2013 yvt.jp. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Client/IAudioDevice.h>
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
#include <array>
|
|
|
|
|
|
|
|
namespace spades {
|
|
|
|
namespace audio {
|
|
|
|
|
|
|
|
class YsrDriver;
|
|
|
|
class YsrAudioChunk;
|
2013-12-15 23:01:29 +09:00
|
|
|
struct SdlAudioDevice;
|
2013-12-15 21:51:00 +09:00
|
|
|
|
|
|
|
class YsrDevice: public client::IAudioDevice {
|
|
|
|
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;
|
|
|
|
|
|
|
|
std::map<std::string, YsrAudioChunk *> chunks;
|
|
|
|
YsrAudioChunk *CreateChunk(const char *name);
|
2013-12-15 23:01:29 +09:00
|
|
|
|
|
|
|
static void SpatializeCallback(const void *,
|
|
|
|
void *, YsrDevice *);
|
|
|
|
static void RenderCallback(YsrDevice *, float *, int);
|
|
|
|
void Render(float *stream, int numBytes);
|
|
|
|
void Spatialize(const void *, void *);
|
|
|
|
protected:
|
|
|
|
virtual ~YsrDevice();
|
2013-12-15 21:51:00 +09:00
|
|
|
public:
|
|
|
|
YsrDevice();
|
|
|
|
|
|
|
|
virtual client::IAudioChunk *RegisterSound(const char *name);
|
|
|
|
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|