AudioGroupProject loader and initial driver

This commit is contained in:
Jack Andersen
2016-05-09 19:32:31 -10:00
parent a62fa64fb5
commit 04382030a1
4 changed files with 245 additions and 0 deletions

View File

@@ -1,13 +1,74 @@
#ifndef __AMUSE_AUDIOGROUPPROJECT_HPP__
#define __AMUSE_AUDIOGROUPPROJECT_HPP__
#include "Entity.hpp"
#include <vector>
#include <array>
#include <unordered_map>
namespace amuse
{
struct AudioGroupIndex {};
/** Root index of SongGroup */
struct SongGroupIndex : AudioGroupIndex
{
/** Maps GM program numbers to sound entities */
struct PageEntry
{
ObjectId objId;
uint8_t priority;
uint8_t maxVoices;
uint8_t programNo;
uint8_t pad;
};
std::unordered_map<uint8_t, const PageEntry*> m_normPages;
std::unordered_map<uint8_t, const PageEntry*> m_drumPages;
/** Maps SongID to 16 MIDI channel numbers to GM program numbers and settings */
struct MIDISetup
{
uint8_t programNo;
uint8_t volume;
uint8_t panning;
uint8_t reverb;
uint8_t chorus;
};
std::unordered_map<int, std::array<const MIDISetup*, 16>> m_midiSetups;
};
/** Root index of SFXGroup */
struct SFXGroupIndex : AudioGroupIndex
{
/** Maps game-side SFX define IDs to sound entities */
struct SFXEntry
{
uint16_t defineId;
ObjectId objId;
uint8_t priority;
uint8_t maxVoices;
uint8_t defVel;
uint8_t panning;
uint8_t defKey;
uint8_t pad;
};
std::unordered_map<uint16_t, const SFXEntry*> m_sfxEntries;
};
/** Collection of SongGroup and SFXGroup indexes */
class AudioGroupProject
{
std::unordered_map<int, SongGroupIndex> m_songGroups;
std::unordered_map<int, SFXGroupIndex> m_sfxGroups;
public:
AudioGroupProject(const unsigned char* data);
const SongGroupIndex* getSongGroupIndex(int groupId) const;
const SFXGroupIndex* getSFXGroupIndex(int groupId) const;
const std::unordered_map<int, SongGroupIndex>& songGroups() const {return m_songGroups;}
const std::unordered_map<int, SFXGroupIndex>& sfxGroups() const {return m_sfxGroups;}
};
}

View File

@@ -7,6 +7,14 @@
namespace amuse
{
#ifndef PRISize
#ifdef _MSC_VER
#define PRISize "Iu"
#else
#define PRISize "zu"
#endif
#endif
template <typename T>
static inline T clamp(T a, T val, T b) {return std::max<T>(a, std::min<T>(b, val));}