12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295 |
- #pragma once
- #include "openmpt/all/BuildSettings.hpp"
- #include "SoundFilePlayConfig.h"
- #include "MixerSettings.h"
- #include "../common/misc_util.h"
- #include "../common/mptRandom.h"
- #include "../common/version.h"
- #include <vector>
- #include <bitset>
- #include <set>
- #include "Snd_defs.h"
- #include "tuningbase.h"
- #include "MIDIMacros.h"
- #ifdef MODPLUG_TRACKER
- #include "../mptrack/MIDIMapping.h"
- #endif
- #include "Mixer.h"
- #include "Resampler.h"
- #ifndef NO_REVERB
- #include "../sounddsp/Reverb.h"
- #endif
- #ifndef NO_AGC
- #include "../sounddsp/AGC.h"
- #endif
- #ifndef NO_DSP
- #include "../sounddsp/DSP.h"
- #endif
- #ifndef NO_EQ
- #include "../sounddsp/EQ.h"
- #endif
- #include "modcommand.h"
- #include "ModSample.h"
- #include "ModInstrument.h"
- #include "ModChannel.h"
- #include "plugins/PluginStructs.h"
- #include "RowVisitor.h"
- #include "Message.h"
- #include "pattern.h"
- #include "patternContainer.h"
- #include "ModSequence.h"
- #include "mpt/audio/span.hpp"
- #include "../common/FileReaderFwd.h"
- OPENMPT_NAMESPACE_BEGIN
- bool SettingCacheCompleteFileBeforeLoading();
- #ifndef MODPLUG_NO_FILESAVE
- void WriteInstrumentHeaderStructOrField(ModInstrument * input, std::ostream &file, uint32 only_this_code = -1 , uint16 fixedsize = 0);
- #endif
- bool ReadInstrumentHeaderField(ModInstrument * input, uint32 fcode, uint16 fsize, FileReader &file);
- void AMSUnpack(const int8 * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter);
- uintptr_t DMFUnpack(FileReader &file, uint8 *psample, uint32 maxlen);
- #ifdef LIBOPENMPT_BUILD
- #ifndef NO_PLUGINS
- class CVstPluginManager;
- #endif
- #endif
- using PlayBehaviourSet = std::bitset<kMaxPlayBehaviours>;
- #ifdef MODPLUG_TRACKER
- struct PatternCuePoint
- {
- uint64 offset;
- ORDERINDEX order;
- bool processed;
- };
- #endif
- struct GetLengthType
- {
- double duration = 0.0;
- ROWINDEX lastRow = ROWINDEX_INVALID;
- ROWINDEX endRow = ROWINDEX_INVALID;
- ROWINDEX startRow = 0;
- ORDERINDEX lastOrder = ORDERINDEX_INVALID;
- ORDERINDEX endOrder = ORDERINDEX_INVALID;
- ORDERINDEX startOrder = 0;
- bool targetReached = false;
- };
- struct SubSong
- {
- double duration;
- ROWINDEX startRow, endRow, loopStartRow;
- ORDERINDEX startOrder, endOrder, loopStartOrder;
- SEQUENCEINDEX sequence;
- };
- struct GetLengthTarget
- {
- ROWINDEX startRow;
- ORDERINDEX startOrder;
- SEQUENCEINDEX sequence;
-
- struct pos_type
- {
- ROWINDEX row;
- ORDERINDEX order;
- };
- union
- {
- double time;
- pos_type pos;
- };
- enum Mode
- {
- NoTarget,
- GetAllSubsongs,
- SeekPosition,
- SeekSeconds,
- } mode;
-
- GetLengthTarget(bool allSongs = false)
- {
- mode = allSongs ? GetAllSubsongs : NoTarget;
- sequence = SEQUENCEINDEX_INVALID;
- startOrder = 0;
- startRow = 0;
- }
-
- GetLengthTarget(ORDERINDEX order, ROWINDEX row)
- {
- mode = NoTarget;
- sequence = SEQUENCEINDEX_INVALID;
- startOrder = 0;
- startRow = 0;
- if(order != ORDERINDEX_INVALID && row != ROWINDEX_INVALID)
- {
- mode = SeekPosition;
- pos.row = row;
- pos.order = order;
- }
- }
-
- GetLengthTarget(double t)
- {
- mode = NoTarget;
- sequence = SEQUENCEINDEX_INVALID;
- startOrder = 0;
- startRow = 0;
- if(t >= 0.0)
- {
- mode = SeekSeconds;
- time = t;
- }
- }
-
- GetLengthTarget &StartPos(SEQUENCEINDEX seq, ORDERINDEX order, ROWINDEX row)
- {
- sequence = seq;
- startOrder = order;
- startRow = row;
- return *this;
- }
- };
- enum enmGetLengthResetMode
- {
-
- eNoAdjust = 0x00,
-
- eAdjust = 0x01,
-
- eAdjustOnSuccess = 0x02 | eAdjust,
-
- eAdjustSamplePositions = 0x04 | eAdjustOnSuccess,
-
- eAdjustOnlyVisitedRows = 0x08,
- };
- enum deleteInstrumentSamples
- {
- deleteAssociatedSamples,
- doNoDeleteAssociatedSamples,
- };
- namespace Tuning {
- class CTuningCollection;
- }
- using CTuningCollection = Tuning::CTuningCollection;
- struct CModSpecifications;
- class OPL;
- class CModDoc;
- #define HISTORY_TIMER_PRECISION 18.2
- struct FileHistory
- {
-
- tm loadDate = {};
-
- uint32 openTime = 0;
-
- mpt::ustring AsISO8601() const;
-
- bool HasValidDate() const { return loadDate.tm_mday != 0; }
- };
- struct TimingInfo
- {
- double InputLatency = 0.0;
- double OutputLatency = 0.0;
- int64 StreamFrames = 0;
- uint64 SystemTimestamp = 0;
- double Speed = 1.0;
- };
- enum class ModMessageHeuristicOrder
- {
- Instruments,
- Samples,
- InstrumentsSamples,
- SamplesInstruments,
- BothInstrumentsSamples,
- BothSamplesInstruments,
- Default = InstrumentsSamples,
- };
- struct ModFormatDetails
- {
- mpt::ustring formatName;
- mpt::ustring type;
- mpt::ustring madeWithTracker;
- mpt::ustring originalFormatName;
- mpt::ustring originalType;
- mpt::Charset charset = mpt::Charset::UTF8;
- };
- class IAudioTarget
- {
- protected:
- virtual ~IAudioTarget() = default;
- public:
- virtual void Process(mpt::audio_span_interleaved<MixSampleInt> buffer) = 0;
- virtual void Process(mpt::audio_span_interleaved<MixSampleFloat> buffer) = 0;
- };
- class IAudioSource
- {
- public:
- virtual ~IAudioSource() = default;
- public:
- virtual void Process(mpt::audio_span_planar<MixSampleInt> buffer) = 0;
- virtual void Process(mpt::audio_span_planar<MixSampleFloat> buffer) = 0;
- };
- class IMonitorInput
- {
- public:
- virtual ~IMonitorInput() = default;
- public:
- virtual void Process(mpt::audio_span_planar<const MixSampleInt> buffer) = 0;
- virtual void Process(mpt::audio_span_planar<const MixSampleFloat> buffer) = 0;
- };
- class IMonitorOutput
- {
- public:
- virtual ~IMonitorOutput() = default;
- public:
- virtual void Process(mpt::audio_span_interleaved<const MixSampleInt> buffer) = 0;
- virtual void Process(mpt::audio_span_interleaved<const MixSampleFloat> buffer) = 0;
- };
- class AudioSourceNone
- : public IAudioSource
- {
- public:
- void Process(mpt::audio_span_planar<MixSampleInt> buffer) override
- {
- for(std::size_t channel = 0; channel < buffer.size_channels(); ++channel)
- {
- for(std::size_t frame = 0; frame < buffer.size_frames(); ++frame)
- {
- buffer(channel, frame) = 0;
- }
- }
- }
- void Process(mpt::audio_span_planar<MixSampleFloat> buffer) override
- {
- for(std::size_t channel = 0; channel < buffer.size_channels(); ++channel)
- {
- for(std::size_t frame = 0; frame < buffer.size_frames(); ++frame)
- {
- buffer(channel, frame) = MixSampleFloat(0.0);
- }
- }
- }
- };
- using NoteName = mpt::uchar[4];
- class CSoundFile
- {
- friend class GetLengthMemory;
- public:
- #ifdef MODPLUG_TRACKER
- void ChangeModTypeTo(const MODTYPE newType, bool adjust = true);
- #endif
-
-
-
- double GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row, bool updateVars, bool updateSamplePos);
- std::vector<SubSong> GetAllSubSongs();
-
- public:
- static std::unique_ptr<CTuning> CreateTuning12TET(const mpt::ustring &name);
- static CTuning *GetDefaultTuning() {return nullptr;}
- CTuningCollection& GetTuneSpecificTunings() {return *m_pTuningsTuneSpecific;}
- mpt::ustring GetNoteName(const ModCommand::NOTE note, const INSTRUMENTINDEX inst) const;
- mpt::ustring GetNoteName(const ModCommand::NOTE note) const;
- static mpt::ustring GetNoteName(const ModCommand::NOTE note, const NoteName *noteNames);
- #ifdef MODPLUG_TRACKER
- public:
- static void SetDefaultNoteNames();
- static const NoteName *GetDefaultNoteNames();
- static mpt::ustring GetDefaultNoteName(int note)
- {
- return m_NoteNames[note];
- }
- private:
- static const NoteName *m_NoteNames;
- #else
- private:
- const NoteName *m_NoteNames;
- #endif
- private:
- CTuningCollection* m_pTuningsTuneSpecific = nullptr;
- #ifdef MODPLUG_TRACKER
- public:
- CMIDIMapper& GetMIDIMapper() {return m_MIDIMapper;}
- const CMIDIMapper& GetMIDIMapper() const {return m_MIDIMapper;}
- private:
- CMIDIMapper m_MIDIMapper;
- #endif
- private:
- static void SetModSpecsPointer(const CModSpecifications* &pModSpecs, const MODTYPE type);
- private:
- const CModSpecifications *m_pModSpecs;
- private:
-
- mixsample_t MixSoundBuffer[MIXBUFFERSIZE * 4];
- mixsample_t MixRearBuffer[MIXBUFFERSIZE * 2];
-
- float MixFloatBuffer[2][MIXBUFFERSIZE];
- mixsample_t MixInputBuffer[NUMMIXINPUTBUFFERS][MIXBUFFERSIZE];
-
- mixsample_t m_dryLOfsVol = 0, m_dryROfsVol = 0;
- mixsample_t m_surroundLOfsVol = 0, m_surroundROfsVol = 0;
- public:
- MixerSettings m_MixerSettings;
- CResampler m_Resampler;
- #ifndef NO_REVERB
- mixsample_t ReverbSendBuffer[MIXBUFFERSIZE * 2];
- mixsample_t m_RvbROfsVol = 0, m_RvbLOfsVol = 0;
- CReverb m_Reverb;
- #endif
- #ifndef NO_DSP
- CSurround m_Surround;
- CMegaBass m_MegaBass;
- #endif
- #ifndef NO_EQ
- CEQ m_EQ;
- #endif
- #ifndef NO_AGC
- CAGC m_AGC;
- #endif
- #ifndef NO_DSP
- BitCrush m_BitCrush;
- #endif
- using samplecount_t = uint32;
- static constexpr uint32 TICKS_ROW_FINISHED = uint32_max - 1u;
- public:
- #ifdef MODPLUG_TRACKER
- CModDoc *m_pModDoc = nullptr;
- #endif
- Enum<MODTYPE> m_nType;
- private:
- MODCONTAINERTYPE m_ContainerType = MOD_CONTAINERTYPE_NONE;
- public:
- CHANNELINDEX m_nChannels = 0;
- SAMPLEINDEX m_nSamples = 0;
- INSTRUMENTINDEX m_nInstruments = 0;
- uint32 m_nDefaultSpeed, m_nDefaultGlobalVolume;
- TEMPO m_nDefaultTempo;
- FlagSet<SongFlags> m_SongFlags;
- CHANNELINDEX m_nMixChannels = 0;
- private:
- CHANNELINDEX m_nMixStat;
- public:
- ROWINDEX m_nDefaultRowsPerBeat, m_nDefaultRowsPerMeasure;
- TempoMode m_nTempoMode = TempoMode::Classic;
- #ifdef MODPLUG_TRACKER
-
- ROWINDEX m_lockRowStart = ROWINDEX_INVALID, m_lockRowEnd = ROWINDEX_INVALID;
-
- ORDERINDEX m_lockOrderStart = ORDERINDEX_INVALID, m_lockOrderEnd = ORDERINDEX_INVALID;
- #endif
- uint32 m_nSamplePreAmp, m_nVSTiVolume;
- uint32 m_OPLVolumeFactor;
- static constexpr uint32 m_OPLVolumeFactorScale = 1 << 16;
- constexpr bool IsGlobalVolumeUnset() const noexcept { return IsFirstTick(); }
- #ifndef MODPLUG_TRACKER
- uint32 m_nFreqFactor = 65536;
- uint32 m_nTempoFactor = 65536;
- #endif
-
- TempoSwing m_tempoSwing;
-
-
-
- int32 m_nMinPeriod, m_nMaxPeriod;
- ResamplingMode m_nResampling;
- int32 m_nRepeatCount = 0;
- ORDERINDEX m_nMaxOrderPosition;
- ModChannelSettings ChnSettings[MAX_BASECHANNELS];
- CPatternContainer Patterns;
- ModSequenceSet Order;
- protected:
- ModSample Samples[MAX_SAMPLES];
- public:
- ModInstrument *Instruments[MAX_INSTRUMENTS];
- MIDIMacroConfig m_MidiCfg;
- #ifndef NO_PLUGINS
- SNDMIXPLUGIN m_MixPlugins[MAX_MIXPLUGINS];
- uint32 m_loadedPlugins = 0;
- #endif
- mpt::charbuf<MAX_SAMPLENAME> m_szNames[MAX_SAMPLES];
- Version m_dwCreatedWithVersion;
- Version m_dwLastSavedWithVersion;
- PlayBehaviourSet m_playBehaviour;
- protected:
- mpt::fast_prng m_PRNG;
- inline mpt::fast_prng & AccessPRNG() const { return const_cast<CSoundFile*>(this)->m_PRNG; }
- inline mpt::fast_prng & AccessPRNG() { return m_PRNG; }
- protected:
-
- CSoundFilePlayConfig m_PlayConfig;
- MixLevels m_nMixLevels;
- public:
- struct PlayState
- {
- friend class CSoundFile;
- public:
- samplecount_t m_lTotalSampleCount = 0;
- protected:
- samplecount_t m_nBufferCount = 0;
- double m_dBufferDiff = 0.0;
- public:
- uint32 m_nTickCount = 0;
- protected:
- uint32 m_nPatternDelay = 0;
- uint32 m_nFrameDelay = 0;
- public:
- uint32 m_nSamplesPerTick = 0;
- ROWINDEX m_nCurrentRowsPerBeat = 0;
- ROWINDEX m_nCurrentRowsPerMeasure = 0;
- uint32 m_nMusicSpeed = 0;
- TEMPO m_nMusicTempo;
-
- ROWINDEX m_nRow = 0;
- ROWINDEX m_nNextRow = 0;
- protected:
- ROWINDEX m_nextPatStartRow = 0;
- ROWINDEX m_breakRow = 0;
- ROWINDEX m_patLoopRow = 0;
- ORDERINDEX m_posJump = 0;
- public:
- PATTERNINDEX m_nPattern = 0;
- ORDERINDEX m_nCurrentOrder = 0;
- ORDERINDEX m_nNextOrder = 0;
- ORDERINDEX m_nSeqOverride = ORDERINDEX_INVALID;
-
- public:
- int32 m_nGlobalVolume = MAX_GLOBAL_VOLUME;
- protected:
- int32 m_nSamplesToGlobalVolRampDest = 0, m_nGlobalVolumeRampAmount = 0,
- m_nGlobalVolumeDestination = 0;
- int32 m_lHighResRampingGlobalVolume = 0;
- public:
- bool m_bPositionChanged = true;
- public:
- CHANNELINDEX ChnMix[MAX_CHANNELS];
- ModChannel Chn[MAX_CHANNELS];
- struct MIDIMacroEvaluationResults
- {
- std::map<PLUGINDEX, float> pluginDryWetRatio;
- std::map<std::pair<PLUGINDEX, PlugParamIndex>, PlugParamValue> pluginParameter;
- };
- std::vector<uint8> m_midiMacroScratchSpace;
- std::optional<MIDIMacroEvaluationResults> m_midiMacroEvaluationResults;
- public:
- PlayState();
- void ResetGlobalVolumeRamping()
- {
- m_lHighResRampingGlobalVolume = m_nGlobalVolume << VOLUMERAMPPRECISION;
- m_nGlobalVolumeDestination = m_nGlobalVolume;
- m_nSamplesToGlobalVolRampDest = 0;
- m_nGlobalVolumeRampAmount = 0;
- }
- constexpr uint32 TicksOnRow() const noexcept
- {
- return (m_nMusicSpeed + m_nFrameDelay) * std::max(m_nPatternDelay, uint32(1));
- }
- };
- PlayState m_PlayState;
- protected:
-
- RowVisitor m_visitedRows;
- public:
- #ifdef MODPLUG_TRACKER
- std::bitset<MAX_BASECHANNELS> m_bChannelMuteTogglePending;
- std::bitset<MAX_MIXPLUGINS> m_pluginDryWetRatioChanged;
- std::vector<PatternCuePoint> *m_PatternCuePoints = nullptr;
- std::vector<SmpLength> *m_SamplePlayLengths = nullptr;
- #endif
- std::unique_ptr<OPL> m_opl;
- public:
- #ifdef LIBOPENMPT_BUILD
- #ifndef NO_PLUGINS
- std::unique_ptr<CVstPluginManager> m_PluginManager;
- #endif
- #endif
- public:
- std::string m_songName;
- mpt::ustring m_songArtist;
- SongMessage m_songMessage;
- ModFormatDetails m_modFormat;
- protected:
- std::vector<FileHistory> m_FileHistory;
- public:
- std::vector<FileHistory> &GetFileHistory() { return m_FileHistory; }
- const std::vector<FileHistory> &GetFileHistory() const { return m_FileHistory; }
- #ifdef MPT_EXTERNAL_SAMPLES
-
- protected:
- std::vector<mpt::PathString> m_samplePaths;
- public:
- void SetSamplePath(SAMPLEINDEX smp, mpt::PathString filename) { if(m_samplePaths.size() < smp) m_samplePaths.resize(smp); m_samplePaths[smp - 1] = std::move(filename); }
- void ResetSamplePath(SAMPLEINDEX smp) { if(m_samplePaths.size() >= smp) m_samplePaths[smp - 1] = mpt::PathString(); Samples[smp].uFlags.reset(SMP_KEEPONDISK | SMP_MODIFIED);}
- mpt::PathString GetSamplePath(SAMPLEINDEX smp) const { if(m_samplePaths.size() >= smp) return m_samplePaths[smp - 1]; else return mpt::PathString(); }
- bool SampleHasPath(SAMPLEINDEX smp) const { if(m_samplePaths.size() >= smp) return !m_samplePaths[smp - 1].empty(); else return false; }
- bool IsExternalSampleMissing(SAMPLEINDEX smp) const { return Samples[smp].uFlags[SMP_KEEPONDISK] && !Samples[smp].HasSampleData(); }
- bool LoadExternalSample(SAMPLEINDEX smp, const mpt::PathString &filename);
- #endif
- bool m_bIsRendering = false;
- TimingInfo m_TimingInfo;
- private:
-
- ILog *m_pCustomLog = nullptr;
- public:
- CSoundFile();
- CSoundFile(const CSoundFile &) = delete;
- CSoundFile & operator=(const CSoundFile &) = delete;
- ~CSoundFile();
- public:
-
- void SetCustomLog(ILog *pLog) { m_pCustomLog = pLog; }
- void AddToLog(LogLevel level, const mpt::ustring &text) const;
- public:
- enum ModLoadingFlags
- {
- onlyVerifyHeader = 0x00,
- loadPatternData = 0x01,
- loadSampleData = 0x02,
- loadPluginData = 0x04,
- loadPluginInstance = 0x08,
- skipContainer = 0x10,
- skipModules = 0x20,
-
- loadCompleteModule = loadSampleData | loadPatternData | loadPluginData | loadPluginInstance,
- loadNoPatternOrPluginData = loadSampleData,
- loadNoPluginInstance = loadSampleData | loadPatternData | loadPluginData,
- };
- #define PROBE_RECOMMENDED_SIZE 2048u
- static constexpr std::size_t ProbeRecommendedSize = PROBE_RECOMMENDED_SIZE;
- enum ProbeFlags
- {
- ProbeModules = 0x1,
- ProbeContainers = 0x2,
- ProbeFlagsDefault = ProbeModules | ProbeContainers,
- ProbeFlagsNone = 0
- };
- enum ProbeResult
- {
- ProbeSuccess = 1,
- ProbeFailure = 0,
- ProbeWantMoreData = -1
- };
- static ProbeResult ProbeAdditionalSize(MemoryFileReader &file, const uint64 *pfilesize, uint64 minimumAdditionalSize);
- static ProbeResult Probe(ProbeFlags flags, mpt::span<const std::byte> data, const uint64 *pfilesize);
- public:
- #ifdef MODPLUG_TRACKER
-
- CModDoc *GetpModDoc() const noexcept { return m_pModDoc; }
- #endif
- bool Create(FileReader file, ModLoadingFlags loadFlags = loadCompleteModule, CModDoc *pModDoc = nullptr);
- private:
- bool CreateInternal(FileReader file, ModLoadingFlags loadFlags);
- public:
- bool Destroy();
- Enum<MODTYPE> GetType() const noexcept { return m_nType; }
- MODCONTAINERTYPE GetContainerType() const noexcept { return m_ContainerType; }
-
- mpt::Charset GetCharsetFile() const
- {
- return m_modFormat.charset;
- }
- mpt::Charset GetCharsetInternal() const
- {
- #if defined(MODPLUG_TRACKER)
- return mpt::Charset::Locale;
- #else
- return GetCharsetFile();
- #endif
- }
- ModMessageHeuristicOrder GetMessageHeuristic() const;
- void SetPreAmp(uint32 vol);
- uint32 GetPreAmp() const noexcept { return m_MixerSettings.m_nPreAmp; }
- void SetMixLevels(MixLevels levels);
- MixLevels GetMixLevels() const noexcept { return m_nMixLevels; }
- const CSoundFilePlayConfig &GetPlayConfig() const noexcept { return m_PlayConfig; }
- constexpr INSTRUMENTINDEX GetNumInstruments() const noexcept { return m_nInstruments; }
- constexpr SAMPLEINDEX GetNumSamples() const noexcept { return m_nSamples; }
- constexpr PATTERNINDEX GetCurrentPattern() const noexcept { return m_PlayState.m_nPattern; }
- constexpr ORDERINDEX GetCurrentOrder() const noexcept { return m_PlayState.m_nCurrentOrder; }
- constexpr CHANNELINDEX GetNumChannels() const noexcept { return m_nChannels; }
- constexpr bool CanAddMoreSamples(SAMPLEINDEX amount = 1) const noexcept { return (amount < MAX_SAMPLES) && m_nSamples < (MAX_SAMPLES - amount); }
- constexpr bool CanAddMoreInstruments(INSTRUMENTINDEX amount = 1) const noexcept { return (amount < MAX_INSTRUMENTS) && m_nInstruments < (MAX_INSTRUMENTS - amount); }
- #ifndef NO_PLUGINS
- IMixPlugin* GetInstrumentPlugin(INSTRUMENTINDEX instr) const noexcept;
- #endif
- const CModSpecifications& GetModSpecifications() const {return *m_pModSpecs;}
- static const CModSpecifications& GetModSpecifications(const MODTYPE type);
- static ChannelFlags GetChannelMuteFlag();
- #ifdef MODPLUG_TRACKER
- void PatternTranstionChnSolo(const CHANNELINDEX chnIndex);
- void PatternTransitionChnUnmuteAll();
- protected:
- void HandlePatternTransitionEvents();
- #endif
- public:
- double GetCurrentBPM() const;
- void DontLoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0);
- CHANNELINDEX GetMixStat() const { return m_nMixStat; }
- void ResetMixStat() { m_nMixStat = 0; }
- void ResetPlayPos();
- void SetCurrentOrder(ORDERINDEX nOrder);
- std::string GetTitle() const { return m_songName; }
- bool SetTitle(const std::string &newTitle);
- const char *GetSampleName(SAMPLEINDEX nSample) const;
- const char *GetInstrumentName(INSTRUMENTINDEX nInstr) const;
- uint32 GetMusicSpeed() const { return m_PlayState.m_nMusicSpeed; }
- TEMPO GetMusicTempo() const { return m_PlayState.m_nMusicTempo; }
- constexpr bool IsFirstTick() const noexcept { return (m_PlayState.m_lTotalSampleCount == 0); }
-
- std::vector<GetLengthType> GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target = GetLengthTarget());
- public:
- void RecalculateSamplesPerTick();
- double GetRowDuration(TEMPO tempo, uint32 speed) const;
- uint32 GetTickDuration(PlayState &playState) const;
-
- void SetRepeatCount(int n) { m_nRepeatCount = n; }
- int GetRepeatCount() const { return m_nRepeatCount; }
- bool IsPaused() const { return m_SongFlags[SONG_PAUSED | SONG_STEP]; }
- void LoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0);
- bool InitChannel(CHANNELINDEX nChn);
- void InitAmigaResampler();
- void InitOPL();
- static constexpr bool SupportsOPL(MODTYPE type) noexcept { return type & (MOD_TYPE_S3M | MOD_TYPE_MPT); }
- bool SupportsOPL() const noexcept { return SupportsOPL(m_nType); }
- #if !defined(MPT_WITH_ANCIENT)
- static ProbeResult ProbeFileHeaderMMCMP(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderPP20(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderXPK(MemoryFileReader file, const uint64 *pfilesize);
- #endif
- static ProbeResult ProbeFileHeaderUMX(MemoryFileReader file, const uint64* pfilesize);
- static ProbeResult ProbeFileHeader669(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderAM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderAMF_Asylum(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderAMF_DSMI(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderAMS(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderAMS2(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderC67(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderDBM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderDTM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderDIGI(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderDMF(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderDSM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderDSym(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderFAR(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderFMT(MemoryFileReader file, const uint64* pfilesize);
- static ProbeResult ProbeFileHeaderGDM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderICE(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderIMF(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderIT(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderITP(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderJ2B(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderMUS_KM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderM15(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderMDL(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderMED(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderMO3(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderMOD(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderMT2(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderMTM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderOKT(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderPLM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderPSM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderPSM16(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderPT36(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderPTM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderS3M(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderSFX(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderSTM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderSTP(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderSTX(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderSymMOD(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderULT(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderXM(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderMID(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderUAX(MemoryFileReader file, const uint64 *pfilesize);
- static ProbeResult ProbeFileHeaderWAV(MemoryFileReader file, const uint64 *pfilesize);
-
- bool Read669(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadAM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadAMF_Asylum(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadAMF_DSMI(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadAMS(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadAMS2(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadC67(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadDBM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadDTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadDIGI(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadDMF(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadDSM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadDSym(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadFAR(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadFMT(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadGDM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadICE(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadIMF(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadIT(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadITP(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadJ2B(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMUS_KM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadM15(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMDL(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMED(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMO3(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMOD(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMT2(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadOKT(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadPLM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadPSM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadPSM16(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadPT36(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadPTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadS3M(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadSFX(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadSTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadSTP(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadSTX(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadSymMOD(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadULT(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadXM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMID(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadUAX(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadWAV(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- static std::vector<const char *> GetSupportedExtensions(bool otherFormats);
- static bool IsExtensionSupported(std::string_view ext);
- static mpt::ustring ModContainerTypeToString(MODCONTAINERTYPE containertype);
- static mpt::ustring ModContainerTypeToTracker(MODCONTAINERTYPE containertype);
-
-
-
-
-
-
-
- static std::string ExtensionToTracker(std::string extension);
-
- void UpgradeModule();
-
- #ifndef MODPLUG_NO_FILESAVE
- bool SaveXM(std::ostream &f, bool compatibilityExport = false);
- bool SaveS3M(std::ostream &f) const;
- bool SaveMod(std::ostream &f) const;
- bool SaveIT(std::ostream &f, const mpt::PathString &filename, bool compatibilityExport = false);
- uint32 SaveMixPlugins(std::ostream *file=nullptr, bool bUpdate=true);
- void WriteInstrumentPropertyForAllInstruments(uint32 code, uint16 size, std::ostream &f, INSTRUMENTINDEX nInstruments) const;
- void SaveExtendedInstrumentProperties(INSTRUMENTINDEX nInstruments, std::ostream &f) const;
- void SaveExtendedSongProperties(std::ostream &f) const;
- #endif
- void LoadExtendedSongProperties(FileReader &file, bool ignoreChannelCount, bool* pInterpretMptMade = nullptr);
- void LoadMPTMProperties(FileReader &file, uint16 cwtv);
- static mpt::ustring GetSchismTrackerVersion(uint16 cwtv, uint32 reserved);
-
-
- bool LoadExtendedInstrumentProperties(FileReader &file);
- void SetDefaultPlaybackBehaviour(MODTYPE type);
- static PlayBehaviourSet GetSupportedPlaybackBehaviour(MODTYPE type);
- static PlayBehaviourSet GetDefaultPlaybackBehaviour(MODTYPE type);
-
- MODTYPE GetBestSaveFormat() const;
- static void ConvertModCommand(ModCommand &m);
- static void S3MConvert(ModCommand &m, bool fromIT);
- void S3MSaveConvert(uint8 &command, uint8 ¶m, bool toIT, bool compatibilityExport = false) const;
- void ModSaveCommand(uint8 &command, uint8 ¶m, const bool toXM, const bool compatibilityExport = false) const;
- static void ReadMODPatternEntry(FileReader &file, ModCommand &m);
- static void ReadMODPatternEntry(const std::array<uint8, 4> data, ModCommand &m);
- void SetupMODPanning(bool bForceSetup = false);
- public:
-
- void SuspendPlugins();
- void ResumePlugins();
- void StopAllVsti();
- void RecalculateGainForAllPlugs();
- void ResetChannels();
- samplecount_t Read(samplecount_t count, IAudioTarget &target) { AudioSourceNone source; return Read(count, target, source); }
- samplecount_t Read(
- samplecount_t count,
- IAudioTarget &target,
- IAudioSource &source,
- std::optional<std::reference_wrapper<IMonitorOutput>> outputMonitor = std::nullopt,
- std::optional<std::reference_wrapper<IMonitorInput>> inputMonitor = std::nullopt
- );
- samplecount_t ReadOneTick();
- private:
- void CreateStereoMix(int count);
- public:
- bool FadeSong(uint32 msec);
- private:
- void ProcessDSP(uint32 countChunk);
- void ProcessPlugins(uint32 nCount);
- void ProcessInputChannels(IAudioSource &source, std::size_t countChunk);
- public:
- samplecount_t GetTotalSampleCount() const { return m_PlayState.m_lTotalSampleCount; }
- bool HasPositionChanged() { bool b = m_PlayState.m_bPositionChanged; m_PlayState.m_bPositionChanged = false; return b; }
- bool IsRenderingToDisc() const { return m_bIsRendering; }
- void PrecomputeSampleLoops(bool updateChannels = false);
- public:
-
- void SetMixerSettings(const MixerSettings &mixersettings);
- void SetResamplerSettings(const CResamplerSettings &resamplersettings);
- void InitPlayer(bool bReset=false);
- void SetDspEffects(uint32 DSPMask);
- uint32 GetSampleRate() const { return m_MixerSettings.gdwMixingFreq; }
- #ifndef NO_EQ
- void SetEQGains(const uint32 *pGains, const uint32 *pFreqs, bool bReset = false) { m_EQ.SetEQGains(pGains, pFreqs, bReset, m_MixerSettings.gdwMixingFreq); }
- #endif
- public:
- bool ReadNote();
- bool ProcessRow();
- bool ProcessEffects();
- std::pair<bool, bool> NextRow(PlayState &playState, const bool breakRow) const;
- void SetupNextRow(PlayState &playState, const bool patternLoop) const;
- CHANNELINDEX GetNNAChannel(CHANNELINDEX nChn) const;
- CHANNELINDEX CheckNNA(CHANNELINDEX nChn, uint32 instr, int note, bool forceCut);
- void NoteChange(ModChannel &chn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false, CHANNELINDEX channelHint = CHANNELINDEX_INVALID) const;
- void InstrumentChange(ModChannel &chn, uint32 instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true) const;
- void ApplyInstrumentPanning(ModChannel &chn, const ModInstrument *instr, const ModSample *smp) const;
- uint32 CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn, uint32 *extendedRows = nullptr) const;
-
- void KeyOff(ModChannel &chn) const;
-
- void SetTempo(TEMPO param, bool setAsNonModcommand = false);
- void SetSpeed(PlayState &playState, uint32 param) const;
- static TEMPO ConvertST2Tempo(uint8 tempo);
- void ProcessRamping(ModChannel &chn) const;
- protected:
-
- void SetType(MODTYPE type);
- void InitializeGlobals(MODTYPE type = MOD_TYPE_NONE);
- void InitializeChannels();
-
- int GetVibratoDelta(int type, int position) const;
- void ProcessVolumeSwing(ModChannel &chn, int &vol) const;
- void ProcessPanningSwing(ModChannel &chn) const;
- void ProcessTremolo(ModChannel &chn, int &vol) const;
- void ProcessTremor(CHANNELINDEX nChn, int &vol);
- bool IsEnvelopeProcessed(const ModChannel &chn, EnvelopeType env) const;
- void ProcessVolumeEnvelope(ModChannel &chn, int &vol) const;
- void ProcessPanningEnvelope(ModChannel &chn) const;
- int ProcessPitchFilterEnvelope(ModChannel &chn, int32 &period) const;
- void IncrementEnvelopePosition(ModChannel &chn, EnvelopeType envType) const;
- void IncrementEnvelopePositions(ModChannel &chn) const;
- void ProcessInstrumentFade(ModChannel &chn, int &vol) const;
- static void ProcessPitchPanSeparation(int32 &pan, int note, const ModInstrument &instr);
- void ProcessPanbrello(ModChannel &chn) const;
- void ProcessArpeggio(CHANNELINDEX nChn, int32 &period, Tuning::NOTEINDEXTYPE &arpeggioSteps);
- void ProcessVibrato(CHANNELINDEX nChn, int32 &period, Tuning::RATIOTYPE &vibratoFactor);
- void ProcessSampleAutoVibrato(ModChannel &chn, int32 &period, Tuning::RATIOTYPE &vibratoFactor, int &nPeriodFrac) const;
- std::pair<SamplePosition, uint32> GetChannelIncrement(const ModChannel &chn, uint32 period, int periodFrac) const;
- protected:
-
- enum PanningType
- {
- Pan4bit = 4,
- Pan6bit = 6,
- Pan8bit = 8,
- };
-
- void UpdateS3MEffectMemory(ModChannel &chn, ModCommand::PARAM param) const;
- void PortamentoUp(CHANNELINDEX nChn, ModCommand::PARAM param, const bool doFinePortamentoAsRegular = false);
- void PortamentoDown(CHANNELINDEX nChn, ModCommand::PARAM param, const bool doFinePortamentoAsRegular = false);
- void MidiPortamento(CHANNELINDEX nChn, int param, bool doFineSlides);
- void FinePortamentoUp(ModChannel &chn, ModCommand::PARAM param) const;
- void FinePortamentoDown(ModChannel &chn, ModCommand::PARAM param) const;
- void ExtraFinePortamentoUp(ModChannel &chn, ModCommand::PARAM param) const;
- void ExtraFinePortamentoDown(ModChannel &chn, ModCommand::PARAM param) const;
- void PortamentoMPT(ModChannel &chn, int);
- void PortamentoFineMPT(ModChannel &chn, int);
- void PortamentoExtraFineMPT(ModChannel &chn, int);
- void SetFinetune(CHANNELINDEX channel, PlayState &playState, bool isSmooth) const;
- void NoteSlide(ModChannel &chn, uint32 param, bool slideUp, bool retrig) const;
- std::pair<uint16, bool> GetVolCmdTonePorta(const ModCommand &m, uint32 startTick) const;
- void TonePortamento(ModChannel &chn, uint16 param) const;
- void Vibrato(ModChannel &chn, uint32 param) const;
- void FineVibrato(ModChannel &chn, uint32 param) const;
- void VolumeSlide(ModChannel &chn, ModCommand::PARAM param) const;
- void PanningSlide(ModChannel &chn, ModCommand::PARAM param, bool memory = true) const;
- void ChannelVolSlide(ModChannel &chn, ModCommand::PARAM param) const;
- void FineVolumeUp(ModChannel &chn, ModCommand::PARAM param, bool volCol) const;
- void FineVolumeDown(ModChannel &chn, ModCommand::PARAM param, bool volCol) const;
- void Tremolo(ModChannel &chn, uint32 param) const;
- void Panbrello(ModChannel &chn, uint32 param) const;
- void Panning(ModChannel &chn, uint32 param, PanningType panBits) const;
- void RetrigNote(CHANNELINDEX nChn, int param, int offset = 0);
- void ProcessSampleOffset(ModChannel &chn, CHANNELINDEX nChn, const PlayState &playState) const;
- void SampleOffset(ModChannel &chn, SmpLength param) const;
- void ReverseSampleOffset(ModChannel &chn, ModCommand::PARAM param) const;
- void DigiBoosterSampleReverse(ModChannel &chn, ModCommand::PARAM param) const;
- void HandleDigiSamplePlayDirection(PlayState &state, CHANNELINDEX chn) const;
- void NoteCut(CHANNELINDEX nChn, uint32 nTick, bool cutSample);
- void PatternLoop(PlayState &state, ModChannel &chn, ModCommand::PARAM param) const;
- bool HandleNextRow(PlayState &state, const ModSequence &order, bool honorPatternLoop) const;
- void ExtendedMODCommands(CHANNELINDEX nChn, ModCommand::PARAM param);
- void ExtendedS3MCommands(CHANNELINDEX nChn, ModCommand::PARAM param);
- void ExtendedChannelEffect(ModChannel &chn, uint32 param);
- void InvertLoop(ModChannel &chn);
- void PositionJump(PlayState &state, CHANNELINDEX chn) const;
- ROWINDEX PatternBreak(PlayState &state, CHANNELINDEX chn, uint8 param) const;
- void GlobalVolSlide(ModCommand::PARAM param, uint8 &nOldGlobalVolSlide);
- void ProcessMacroOnChannel(CHANNELINDEX nChn);
- void ProcessMIDIMacro(PlayState &playState, CHANNELINDEX nChn, bool isSmooth, const MIDIMacroConfigData::Macro ¯o, uint8 param = 0, PLUGINDEX plugin = 0);
- void ParseMIDIMacro(PlayState &playState, CHANNELINDEX nChn, bool isSmooth, const mpt::span<const char> macro, mpt::span<uint8> &out, uint8 param = 0, PLUGINDEX plugin = 0) const;
- static float CalculateSmoothParamChange(const PlayState &playState, float currentValue, float param);
- void SendMIDIData(PlayState &playState, CHANNELINDEX nChn, bool isSmooth, const mpt::span<const uint8> macro, PLUGINDEX plugin);
- void SendMIDINote(CHANNELINDEX chn, uint16 note, uint16 volume);
- int SetupChannelFilter(ModChannel &chn, bool bReset, int envModifier = 256) const;
-
- void DoFreqSlide(ModChannel &chn, int32 &period, int32 amount, bool isTonePorta = false) const;
- void UpdateTimeSignature();
- public:
-
- uint8 FrequencyToCutOff(double frequency) const;
-
- uint32 CutOffToFrequency(uint32 nCutOff, int envModifier = 256) const;
-
- bool PeriodsAreFrequencies() const noexcept
- {
- return m_playBehaviour[kPeriodsAreHertz] && !UseFinetuneAndTranspose();
- }
-
-
- static constexpr bool UseFinetuneAndTranspose(MODTYPE type) noexcept
- {
- return (type & (MOD_TYPE_AMF0 | MOD_TYPE_DIGI | MOD_TYPE_MED | MOD_TYPE_MOD | MOD_TYPE_MTM | MOD_TYPE_OKT | MOD_TYPE_SFX | MOD_TYPE_STP | MOD_TYPE_XM));
- }
- bool UseFinetuneAndTranspose() const noexcept
- {
- return UseFinetuneAndTranspose(GetType());
- }
- bool DestroySample(SAMPLEINDEX nSample);
- bool DestroySampleThreadsafe(SAMPLEINDEX nSample);
-
-
- SAMPLEINDEX GetNextFreeSample(INSTRUMENTINDEX targetInstrument = INSTRUMENTINDEX_INVALID, SAMPLEINDEX start = 1) const;
-
-
- INSTRUMENTINDEX GetNextFreeInstrument(INSTRUMENTINDEX start = 1) const;
-
- bool IsSampleReferencedByInstrument(SAMPLEINDEX sample, INSTRUMENTINDEX instr) const;
- ModInstrument *AllocateInstrument(INSTRUMENTINDEX instr, SAMPLEINDEX assignedSample = 0);
- bool DestroyInstrument(INSTRUMENTINDEX nInstr, deleteInstrumentSamples removeSamples);
- bool RemoveInstrumentSamples(INSTRUMENTINDEX nInstr, SAMPLEINDEX keepSample = SAMPLEINDEX_INVALID);
- SAMPLEINDEX DetectUnusedSamples(std::vector<bool> &sampleUsed) const;
- SAMPLEINDEX RemoveSelectedSamples(const std::vector<bool> &keepSamples);
-
- void PropagateXMAutoVibrato(INSTRUMENTINDEX ins, VibratoType type, uint8 sweep, uint8 depth, uint8 rate);
-
- bool ReadSampleFromFile(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize = false, bool includeInstrumentFormats = true);
- bool ReadWAVSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize = false, FileReader *wsmpChunk = nullptr);
- protected:
- bool ReadW64Sample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize = false);
- bool ReadPATSample(SAMPLEINDEX nSample, FileReader &file);
- bool ReadS3ISample(SAMPLEINDEX nSample, FileReader &file);
- bool ReadSBISample(SAMPLEINDEX sample, FileReader &file);
- bool ReadCAFSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize = false);
- bool ReadAIFFSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize = false);
- bool ReadAUSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize = false);
- bool ReadXISample(SAMPLEINDEX nSample, FileReader &file);
- bool ReadITSSample(SAMPLEINDEX nSample, FileReader &file, bool rewind = true);
- bool ReadITISample(SAMPLEINDEX nSample, FileReader &file);
- bool ReadIFFSample(SAMPLEINDEX sample, FileReader &file);
- bool ReadBRRSample(SAMPLEINDEX sample, FileReader &file);
- bool ReadFLACSample(SAMPLEINDEX sample, FileReader &file);
- bool ReadOpusSample(SAMPLEINDEX sample, FileReader &file);
- bool ReadVorbisSample(SAMPLEINDEX sample, FileReader &file);
- bool ReadMP3Sample(SAMPLEINDEX sample, FileReader &file, bool raw = false, bool mo3Decode = false);
- bool ReadMediaFoundationSample(SAMPLEINDEX sample, FileReader &file, bool mo3Decode = false);
- public:
- #ifdef MODPLUG_TRACKER
- static std::vector<FileType> GetMediaFoundationFileTypes();
- #endif
- #ifndef MODPLUG_NO_FILESAVE
- bool SaveWAVSample(SAMPLEINDEX nSample, std::ostream &f) const;
- bool SaveRAWSample(SAMPLEINDEX nSample, std::ostream &f) const;
- bool SaveFLACSample(SAMPLEINDEX nSample, std::ostream &f) const;
- bool SaveS3ISample(SAMPLEINDEX smp, std::ostream &f) const;
- #endif
-
- bool ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize = false);
- bool ReadSampleAsInstrument(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize = false);
- protected:
- bool ReadXIInstrument(INSTRUMENTINDEX nInstr, FileReader &file);
- bool ReadITIInstrument(INSTRUMENTINDEX nInstr, FileReader &file);
- bool ReadPATInstrument(INSTRUMENTINDEX nInstr, FileReader &file);
- bool ReadSFZInstrument(INSTRUMENTINDEX nInstr, FileReader &file);
- public:
- #ifndef MODPLUG_NO_FILESAVE
- bool SaveXIInstrument(INSTRUMENTINDEX nInstr, std::ostream &f) const;
- bool SaveITIInstrument(INSTRUMENTINDEX nInstr, std::ostream &f, const mpt::PathString &filename, bool compress, bool allowExternal) const;
- bool SaveSFZInstrument(INSTRUMENTINDEX nInstr, std::ostream &f, const mpt::PathString &filename, bool useFLACsamples) const;
- #endif
-
- bool ReadInstrumentFromSong(INSTRUMENTINDEX targetInstr, const CSoundFile &srcSong, INSTRUMENTINDEX sourceInstr);
- bool ReadSampleFromSong(SAMPLEINDEX targetSample, const CSoundFile &srcSong, SAMPLEINDEX sourceSample);
-
- uint32 GetNoteFromPeriod(uint32 period, int32 nFineTune = 0, uint32 nC5Speed = 0) const;
- uint32 GetPeriodFromNote(uint32 note, int32 nFineTune, uint32 nC5Speed) const;
- uint32 GetFreqFromPeriod(uint32 period, uint32 c5speed, int32 nPeriodFrac = 0) const;
-
- ModSample &GetSample(SAMPLEINDEX sample) { MPT_ASSERT(sample <= m_nSamples && sample < std::size(Samples)); return Samples[sample]; }
- const ModSample &GetSample(SAMPLEINDEX sample) const { MPT_ASSERT(sample <= m_nSamples && sample < std::size(Samples)); return Samples[sample]; }
-
- SAMPLEINDEX GetSampleIndex(ModCommand::NOTE note, uint32 instr) const noexcept;
- uint32 MapMidiInstrument(uint8 program, uint16 bank, uint8 midiChannel, uint8 note, bool isXG, std::bitset<16> drumChns);
- size_t ITInstrToMPT(FileReader &file, ModInstrument &ins, uint16 trkvers);
- bool LoadMixPlugins(FileReader &file);
- #ifndef NO_PLUGINS
- static void ReadMixPluginChunk(FileReader &file, SNDMIXPLUGIN &plugin);
- void ProcessMidiOut(CHANNELINDEX nChn);
- #endif
- void ProcessGlobalVolume(long countChunk);
- void ProcessStereoSeparation(long countChunk);
- private:
- PLUGINDEX GetChannelPlugin(const PlayState &playState, CHANNELINDEX nChn, PluginMutePriority respectMutes) const;
- static PLUGINDEX GetActiveInstrumentPlugin(const ModChannel &chn, PluginMutePriority respectMutes);
- IMixPlugin *GetChannelInstrumentPlugin(const ModChannel &chn) const;
- public:
- PLUGINDEX GetBestPlugin(const PlayState &playState, CHANNELINDEX nChn, PluginPriority priority, PluginMutePriority respectMutes) const;
- };
- #ifndef NO_PLUGINS
- inline IMixPlugin* CSoundFile::GetInstrumentPlugin(INSTRUMENTINDEX instr) const noexcept
- {
- if(instr > 0 && instr <= GetNumInstruments() && Instruments[instr] && Instruments[instr]->nMixPlug && Instruments[instr]->nMixPlug <= MAX_MIXPLUGINS)
- return m_MixPlugins[Instruments[instr]->nMixPlug - 1].pMixPlugin;
- else
- return nullptr;
- }
- #endif
- #define FADESONGDELAY 100
- MPT_CONSTEXPRINLINE int8 MOD2XMFineTune(int v) { return static_cast<int8>(static_cast<uint8>(v) << 4); }
- MPT_CONSTEXPRINLINE int8 XM2MODFineTune(int v) { return static_cast<int8>(static_cast<uint8>(v) >> 4); }
- void ReadInstrumentExtensionField(ModInstrument* pIns, const uint32 code, const uint16 size, FileReader &file);
- void ReadExtendedInstrumentProperty(ModInstrument* pIns, const uint32 code, FileReader &file);
- void ReadExtendedInstrumentProperties(ModInstrument* pIns, FileReader &file);
- OPENMPT_NAMESPACE_END
|