diff options
author | Wohlstand <admin@wohlnet.ru> | 2017-10-25 03:01:50 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2017-10-25 03:01:50 +0300 |
commit | 0401ee9f58ea842cb4aef687e8e107380d46445c (patch) | |
tree | 900ba7dad4b6bb70bad88c401cff1494884de2bb /src/adlmidi_private.hpp | |
parent | 6783770a8533dd099b39c51a5c3f7f5f4000b4bc (diff) | |
download | libADLMIDI-0401ee9f58ea842cb4aef687e8e107380d46445c.tar.gz libADLMIDI-0401ee9f58ea842cb4aef687e8e107380d46445c.tar.bz2 libADLMIDI-0401ee9f58ea842cb4aef687e8e107380d46445c.zip |
Clean-up
- Move all private variables into MIDIplay class away from public ADL_MIDIPlayer structure
- Comment out most of legacy code
- Implement new-style ReadVarLenEx for error-checked var-len value reading process
TODO: Stabilize this and implement missing fields and API calls (meta-data retreiving)
Diffstat (limited to 'src/adlmidi_private.hpp')
-rw-r--r-- | src/adlmidi_private.hpp | 91 |
1 files changed, 66 insertions, 25 deletions
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 451a8e6..d964e1e 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -156,7 +156,7 @@ public: VOLUME_CMF, VOLUME_DMX, VOLUME_APOGEE, - VOLUME_9X, + VOLUME_9X } m_volumeScale; OPL3(); @@ -181,30 +181,30 @@ public: void Silence(); void updateFlags(); void ChangeVolumeRangesModel(ADLMIDI_VolumeModels volumeModel); - void Reset(); + void Reset(unsigned long PCM_RATE); }; class MIDIplay { // Information about each track - struct Position - { - bool began; - char padding[7]; - double wait; - struct TrackInfo - { - size_t ptr; - uint64_t delay; - int status; - char padding2[4]; - TrackInfo(): ptr(0), delay(0), status(0) {} - }; - std::vector<TrackInfo> track; - - Position(): began(false), wait(0.0l), track() { } - } CurrentPosition, LoopBeginPosition, trackBeginPosition; + //struct Position + //{ + // bool began; + // char padding[7]; + // double wait; + // struct TrackInfo + // { + // size_t ptr; + // uint64_t delay; + // int status; + // char padding2[4]; + // TrackInfo(): ptr(0), delay(0), status(0) {} + // }; + // std::vector<TrackInfo> track; + + // Position(): began(false), wait(0.0l), track() { } + //} CurrentPosition, LoopBeginPosition, trackBeginPosition; std::map<std::string, uint64_t> devices; std::map<uint64_t /*track*/, uint64_t /*channel begin index*/> current_device; @@ -323,7 +323,7 @@ private: T_SYSCOMSPOSPTR = 0xF2,//size == 2 T_SYSCOMSNGSEL = 0xF3,//size == 1 T_SYSEX2 = 0xF7,//size == len - T_SPECIAL = 0xFF, + T_SPECIAL = 0xFF }; enum SubTypes { @@ -348,7 +348,7 @@ private: /* Non-standard, internal ADLMIDI usage only */ ST_LOOPSTART = 0xE1,//size == 0 <CUSTOM> ST_LOOPEND = 0xE2,//size == 0 <CUSTOM> - ST_RAWOPL = 0xE3,//size == 0 <CUSTOM> + ST_RAWOPL = 0xE3//size == 0 <CUSTOM> }; //! Main type of event uint8_t type; @@ -390,6 +390,15 @@ private: void sortEvents(); }; + /** + * @brief Tempo maker entry. Used in the MIDI data building function only. + */ + struct TempoMarker + { + uint64_t absPos; + fraction<uint64_t> tempo; + }; + typedef std::list<MidiTrackPos> MidiTrackQueue; // Information about each track @@ -420,7 +429,7 @@ private: std::vector<MidiTrackQueue > trackDataNew; std::vector<int> trackDataNewStatus; - void buildTrackData(); + bool buildTrackData(); MidiEvent parseEvent(uint8_t **ptr, int &status); public: @@ -428,7 +437,6 @@ public: ~MIDIplay() {} - ADL_MIDIPlayer *config; std::string musTitle; fraction<uint64_t> InvDeltaTicks, Tempo; bool trackStart, @@ -440,13 +448,46 @@ public: loopStart_hit /*loopStart entry was hited in previous tick*/; char ____padding2[2]; OPL3 opl; + + struct Setup + { + unsigned int AdlBank; + unsigned int NumFourOps; + unsigned int NumCards; + bool HighTremoloMode; + bool HighVibratoMode; + bool AdlPercussionMode; + bool LogarithmicVolumes; + int VolumeModel; + unsigned int SkipForward; + bool loopingIsEnabled; + bool ScaleModulators; + + double delay; + double carry; + + /* The lag between visual content and audio content equals */ + /* the sum of these two buffers. */ + double mindelay; + double maxdelay; + + /* For internal usage */ + ssize_t stored_samples; /* num of collected samples */ + short backup_samples[1024]; /* Backup sample storage. */ + ssize_t backup_samples_size; /* Backup sample storage. */ + /* For internal usage */ + + unsigned long PCM_RATE; + } m_setup; + public: static uint64_t ReadBEint(const void *buffer, size_t nbytes); static uint64_t ReadLEint(const void *buffer, size_t nbytes); uint64_t ReadVarLen(uint8_t **ptr); - uint64_t ReadVarLen(size_t tk); - uint64_t ReadVarLenEx(size_t tk, bool &ok); + //uint64_t ReadVarLen(size_t tk); + //uint64_t ReadVarLenEx(size_t tk, bool &ok); + uint64_t ReadVarLenEx(uint8_t **ptr, uint8_t *end, bool &ok); /* * A little class gives able to read filedata from disk and also from a memory segment |