diff options
author | JP Cimalando <jpcima@users.noreply.github.com> | 2018-05-16 01:31:18 +0200 |
---|---|---|
committer | JP Cimalando <jpcima@users.noreply.github.com> | 2018-05-16 19:35:30 +0200 |
commit | 9b478615e7f0cd73c360fd289b05db52b5f730f1 (patch) | |
tree | 718629304c857bfe69d930c428bddd12ec02ee04 /src/adldata.hh | |
parent | 8cce88f8706ca6fb52592458aa12641c43469a6e (diff) | |
download | libADLMIDI-9b478615e7f0cd73c360fd289b05db52b5f730f1.tar.gz libADLMIDI-9b478615e7f0cd73c360fd289b05db52b5f730f1.tar.bz2 libADLMIDI-9b478615e7f0cd73c360fd289b05db52b5f730f1.zip |
storing adldata and adlinsdata in unified structures
Diffstat (limited to 'src/adldata.hh')
-rw-r--r-- | src/adldata.hh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/adldata.hh b/src/adldata.hh index e9ff00b..20cbd21 100644 --- a/src/adldata.hh +++ b/src/adldata.hh @@ -24,8 +24,16 @@ #ifndef ADLDATA_H #define ADLDATA_H +#include <string.h> #include <stdint.h> +#pragma pack(push, 1) +#define ADLDATA_BYTE_COMPARABLE(T) \ + inline bool operator==(const T &a, const T &b) \ + { return !memcmp(&a, &b, sizeof(T)); } \ + inline bool operator!=(const T &a, const T &b) \ + { return !operator==(a, b); } + extern const struct adldata { uint32_t modulator_E862, carrier_E862; // See below @@ -34,6 +42,8 @@ extern const struct adldata int8_t finetune; } adl[]; +ADLDATA_BYTE_COMPARABLE(struct adldata); +enum { adlDefaultNumber = 189 }; extern const struct adlinsdata { @@ -46,11 +56,31 @@ extern const struct adlinsdata uint16_t ms_sound_koff; double voice2_fine_tune; } adlins[]; +ADLDATA_BYTE_COMPARABLE(struct adlinsdata); int maxAdlBanks(); extern const unsigned short banks[][256]; extern const char* const banknames[]; /** + * @brief Instrument data with operators included + */ +struct adlinsdata2 +{ + adldata adl[2]; + uint8_t tone; + uint8_t flags; + uint16_t ms_sound_kon; // Number of milliseconds it produces sound; + uint16_t ms_sound_koff; + double voice2_fine_tune; + adlinsdata2() {} + explicit adlinsdata2(const adlinsdata &d); +}; +ADLDATA_BYTE_COMPARABLE(struct adlinsdata2); + +#undef ADLDATA_BYTE_COMPARABLE +#pragma pack(pop) + +/** * @brief Bank global setup */ extern const struct AdlBankSetup @@ -62,4 +92,16 @@ extern const struct AdlBankSetup bool scaleModulators; } adlbanksetup[]; +/** + * @brief Conversion of storage formats + */ +inline adlinsdata2::adlinsdata2(const adlinsdata &d) + : tone(d.tone), flags(d.flags), + ms_sound_kon(d.ms_sound_kon), ms_sound_koff(d.ms_sound_koff), + voice2_fine_tune(d.voice2_fine_tune) +{ + adl[0] = ::adl[d.adlno1]; + adl[1] = ::adl[d.adlno2]; +} + #endif //ADLDATA_H |