#ifndef _SYNTH_FILE_H
#define _SYNTH_FILE_H
#include "SynthFileReader.h"
#include <ObjectList.h>
class SSound {
uint32 fOffset;
uint16 fId;
BString fName;
void* fSamples;
int32 fFrameCount;
int16 fSampleSize;
int16 fChannelCount;
SSound() { }
public:
SSound(uint16 id);
uint16 Id() const { return fId; }
void SetName(const char* name) { fName = name; }
const char* Name() const { return fName.String(); }
void SetSample(void* samples, int32 frameCount, int16 sampleSize, int16 channelCount);
void* Samples() const { return fSamples; }
int32 FrameCount() const { return fFrameCount; }
int16 SampleSize() const { return fSampleSize; }
int16 ChannelCount() const { return fChannelCount; }
bool HasSamples() const { return fSamples != NULL; }
void SetOffset(uint32 offset) { fOffset = offset; }
uint32 Offset() const { return fOffset; }
};
class SSoundInRange {
uint8 fNoteStart;
uint8 fNoteEnd;
SSound* fSound;
SSoundInRange() { }
public:
SSoundInRange(uint8 start, uint8 end, SSound* sound);
uint8 Start() const { return fNoteStart; }
uint8 End() const { return fNoteEnd; }
SSound* Sound() const { return fSound; }
};
class SInstrument {
uint32 fOffset;
uint8 fId;
BString fName;
SSound* fDefaultSound;
BObjectList<SSoundInRange> fSounds;
public:
SInstrument(uint8 instrument);
void SetOffset(uint32 offset) { fOffset = offset; }
uint32 Offset() const { return fOffset; }
uint8 Id() const { return fId; }
void SetName(const char* name) { fName = name; }
const char* Name() const { return fName.String(); }
void SetDefaultSound(SSound* sound) { fDefaultSound = sound; }
SSound* DefaultSound() const { return fDefaultSound; }
BObjectList<SSoundInRange>* Sounds() { return &fSounds; }
};
class SSynthFile;
class SSynthFile {
BObjectList<SInstrument> fInstruments;
BObjectList<SSound> fSounds;
SSynthFileReader fReader;
status_t fStatus;
void InstrumentAtPut(int i, SInstrument* instr);
SSound* FindSound(uint16 sound);
public:
SSynthFile(const char* fileName);
status_t InitCheck() const { return fReader.InitCheck(); }
SSound* GetSound(uint16 sound);
bool HasInstrument(uint8 instrument) const;
SInstrument* GetInstrument(uint8 instrument);
void Dump();
};
#endif