#ifndef SONA_H_
#define SONA_H_
#include "stream.h"
// SonaStream event numbers
// Some of these are OR'd with the channel number
#define SONAEVENT_LOAD 0x00 // Load instrument
#define SONAEVENT_KEYON 0x10 // Key-on
#define SONAEVENT_KEYOFF 0x20 // Key-off
#define SONAEVENT_PITCH 0x30 // Set pitch
#define SONAEVENT_VOLUME 0x40 // Set volume
#define SONAEVENT_PAN 0x50 // Set panning
#define SONAEVENT_VMMOVE 0xC0 // var = value
#define SONAEVENT_VMADD 0xC2 // var = var + value
#define SONAEVENT_VMSUB 0xC4 // var = var - value
#define SONAEVENT_VMAND 0xC6 // var = var AND value
#define SONAEVENT_VMOR 0xC8 // var = var OR value
#define SONAEVENT_VMXOR 0xCA // var = var XOR value
#define SONAEVENT_QDELAY 0xD0 // Delay (short form)
#define SONAEVENT_LOCK 0xE0 // Lock channel
#define SONAEVENT_FMREG 0xF8 // FM register write
#define SONAEVENT_TEMPO 0xFA // Set BGM tempo
#define SONAEVENT_SETLOOP 0xFC // Set loop point
#define SONAEVENT_GOTOLOOP 0xFD // Go to loop point
#define SONAEVENT_DELAY 0xFE // Delay (long form)
#define SONAEVENT_END 0xFF // End of stream
// SonaStream channel numbers
#define SONACHAN_FM1 0x00 // 1st FM channel
#define SONACHAN_FM2 0x01 // 2nd FM channel
#define SONACHAN_FM3 0x02 // 3rd FM channel (normal mode)
#define SONACHAN_FM3SP 0x03 // 3rd FM channel (special mode)
#define SONACHAN_FM4 0x04 // 4th FM channel
#define SONACHAN_FM5 0x05 // 5th FM channel
#define SONACHAN_FM6 0x06 // 6th FM channel
#define SONACHAN_FMX 0x07 // Allocated FM channel
#define SONACHAN_PSG1 0x08 // 1st square channel
#define SONACHAN_PSG2 0x09 // 2nd square channel
#define SONACHAN_PSG3 0x0A // 3rd square channel
#define SONACHAN_PSG4 0x0B // Noise channel
#define SONACHAN_PSGX 0x0C // Allocated square channel
#define SONACHAN_PCMX 0x0D // Allocated PCM channel
#define SONACHAN_PCM1 0x0E // 1st PCM channel
#define SONACHAN_PCM2 0x0F // 2nd PCM channel
int save_sona(const char *filename, const Stream *stream);
#endif