# Amuse: include/amuse/SongState.hpp Source File

SongState.hpp
#ifndef __AMUSE_SONGSTATE_HPP__
#define __AMUSE_SONGSTATE_HPP__
#include <stdint.h>
#include <vector>
#include <list>
#include "optional.hpp"
#include "Entity.hpp"
namespace amuse
{
class Sequencer;
enum class SongPlayState
{
Stopped,
Playing
};
class SongState
{
friend class Voice;
struct Header
{
uint32_t m_version;
uint32_t m_chanIdxOff;
uint32_t m_chanMapOff;
uint32_t m_tempoTableOff;
uint32_t m_initialTempo;
uint32_t m_unkOff;
uint32_t m_chanOffs[64];
void swapBig();
} m_header;
struct ChanHeader
{
uint32_t m_startTick;
uint16_t m_unk1;
uint16_t m_unk2;
uint16_t m_dataIndex;
uint16_t m_unk3;
uint32_t m_startTick2;
uint16_t m_unk4;
uint16_t m_unk5;
uint16_t m_unk6;
uint16_t m_unk7;
void swapBig();
};
struct TempoChange
{
uint32_t m_tick;
uint32_t m_tempo;
void swapBig();
};
struct Channel
{
struct Header
{
uint32_t m_type;
uint32_t m_pitchOff;
uint32_t m_modOff;
void swapBig();
};
SongState& m_parent;
uint8_t m_midiChan;
uint32_t m_startTick;
const unsigned char* m_dataBase;
const unsigned char* m_data;
const unsigned char* m_pitchWheelData = nullptr;
const unsigned char* m_modWheelData = nullptr;
uint32_t m_lastPitchTick = 0;
int32_t m_lastPitchVal = 0;
uint32_t m_lastModTick = 0;
int32_t m_lastModVal = 0;
std::array<uint16_t, 128> m_remNoteLengths = {};
int32_t m_waitCountdown = 0;
Channel(SongState& parent, uint8_t midiChan, uint32_t startTick,
const unsigned char* song, const unsigned char* chan);
bool advance(Sequencer& seq, int32_t ticks);
};
std::array<std::experimental::optional<Channel>, 64> m_channels;
const TempoChange* m_tempoPtr = nullptr;
uint32_t m_tempo = 120;
uint32_t m_curTick = 0;
SongPlayState m_songState = SongPlayState::Playing;
double m_curDt = 0.f;
public:
void initialize(const unsigned char* ptr);
bool advance(Sequencer& seq, double dt);
};
}
#endif // __AMUSE_SONGSTATE_HPP__
amuse::SongState
Definition: SongState.hpp:21
amuse
Definition: AudioGroup.hpp:8
amuse::SongState::Channel::Header
Definition: SongState.hpp:65
amuse::Voice
Definition: Voice.hpp:30
amuse::Sequencer
Definition: Sequencer.hpp:27