From: <sag...@us...> - 2013-03-17 16:06:03
|
Revision: 1593 http://sourceforge.net/p/modplug/code/1593 Author: saga-games Date: 2013-03-17 16:05:52 +0000 (Sun, 17 Mar 2013) Log Message: ----------- [Ref] Small changes here and there. Modified Paths: -------------- trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/soundlib/ITTools.cpp trunk/OpenMPT/soundlib/ITTools.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/ModInstrument.cpp trunk/OpenMPT/soundlib/ModInstrument.h trunk/OpenMPT/soundlib/RowVisitor.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/soundlib/WAVTools.h trunk/OpenMPT/soundlib/XMTools.cpp Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-03-17 16:05:52 UTC (rev 1593) @@ -1333,25 +1333,25 @@ PUSHBUTTON "Macro Help",IDC_BUTTON3,300,84,50,14 END -IDD_CHORDEDIT DIALOGEX 0, 0, 245, 148 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +IDD_CHORDEDIT DIALOGEX 0, 0, 245, 156 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Chord Editor" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN DEFPUSHBUTTON "Close",IDOK,191,10,50,14 CONTROL "",IDC_KEYBOARD1,"Static",SS_WHITERECT | SS_NOTIFY,4,76,237,56,WS_EX_CLIENTEDGE - GROUPBOX "",IDC_STATIC,4,4,183,67 - COMBOBOX IDC_COMBO1,10,24,83,114,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Shortcut Key:",IDC_STATIC,10,14,57,8 - LTEXT "Base Key:",IDC_STATIC,104,14,40,8 - COMBOBOX IDC_COMBO2,104,24,48,89,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_COMBO3,10,52,48,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Note #1",IDC_STATIC,10,42,39,8 - COMBOBOX IDC_COMBO4,67,52,48,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Note #2",IDC_STATIC,67,42,39,8 - COMBOBOX IDC_COMBO5,123,52,48,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Note #3",IDC_STATIC,123,42,39,8 - LTEXT "Note: you need to enable multichannel-record in order to enter chords.",IDC_STATIC,4,136,237,10 + GROUPBOX "",IDC_STATIC,4,4,185,67 + COMBOBOX IDC_COMBO1,12,24,52,114,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Shortcut Key:",IDC_STATIC,12,12,57,8 + LTEXT "Base Key:",IDC_STATIC,72,12,40,8 + COMBOBOX IDC_COMBO2,72,24,52,89,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO3,12,54,52,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Note #1",IDC_STATIC,12,42,39,8 + COMBOBOX IDC_COMBO4,72,54,52,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Note #2",IDC_STATIC,72,42,39,8 + COMBOBOX IDC_COMBO5,132,54,52,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Note #3",IDC_STATIC,132,42,39,8 + LTEXT "In ""Relative"" base note mode, all notes are relative to a previously entered note in the pattern cell where the chord is entered.",IDC_STATIC,6,136,234,20 END IDD_LAYER3CONVERT DIALOGEX 0, 0, 280, 202 @@ -1796,7 +1796,7 @@ LEFTMARGIN, 4 RIGHTMARGIN, 241 TOPMARGIN, 4 - BOTTOMMARGIN, 146 + BOTTOMMARGIN, 154 END IDD_LAYER3CONVERT, DIALOG Modified: trunk/OpenMPT/soundlib/ITTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITTools.cpp 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/ITTools.cpp 2013-03-17 16:05:52 UTC (rev 1593) @@ -72,8 +72,8 @@ // Convert IT/MPTM envelope data into OpenMPT's internal envelope format - To be used by ITInstrToMPT() -void ITEnvelope::ConvertToMPT(InstrumentEnvelope &mptEnv, BYTE envOffset, int maxNodes) const -//------------------------------------------------------------------------------------------- +void ITEnvelope::ConvertToMPT(InstrumentEnvelope &mptEnv, uint8 envOffset, int maxNodes) const +//-------------------------------------------------------------------------------------------- { // Envelope Flags mptEnv.dwFlags.set(ENV_ENABLED, (flags & ITEnvelope::envEnabled) != 0); @@ -149,7 +149,7 @@ // Sample Map for(size_t i = 0; i < 120; i++) { - BYTE note = keyboard[i * 2]; + uint8 note = keyboard[i * 2]; SAMPLEINDEX ins = keyboard[i * 2 + 1]; if(ins < MAX_SAMPLES) { @@ -160,7 +160,7 @@ mptIns.NoteMap[i] = note + 1u; } else { - mptIns.NoteMap[i] = static_cast<BYTE>(i + 1); + mptIns.NoteMap[i] = static_cast<uint8>(i + 1); } } @@ -354,7 +354,7 @@ // Sample Map for(size_t i = 0; i < 120; i++) { - BYTE note = keyboard[i * 2]; + uint8 note = keyboard[i * 2]; SAMPLEINDEX ins = keyboard[i * 2 + 1]; if(ins < MAX_SAMPLES) { @@ -365,7 +365,7 @@ mptIns.NoteMap[i] = note + 1u; } else { - mptIns.NoteMap[i] = static_cast<BYTE>(i + 1); + mptIns.NoteMap[i] = static_cast<uint8>(i + 1); } } @@ -479,9 +479,9 @@ //StringFixer::WriteString<StringFixer::nullTerminated>(name, m_szNames[nsmp]); // Volume / Panning - gvl = static_cast<BYTE>(mptSmp.nGlobalVol); - vol = static_cast<BYTE>(mptSmp.nVolume / 4); - dfp = static_cast<BYTE>(mptSmp.nPan / 4); + gvl = static_cast<uint8>(mptSmp.nGlobalVol); + vol = static_cast<uint8>(mptSmp.nVolume / 4); + dfp = static_cast<uint8>(mptSmp.nPan / 4); if(mptSmp.uFlags & CHN_PANNING) dfp |= ITSample::enablePanning; // Sample Format / Loop Flags @@ -508,7 +508,7 @@ flags |= ITSample::sampleCompressed; if(compressIT215) { - cvt |= ITSample::cvtIT215Compression; + cvt |= ITSample::cvtDelta; } } } else @@ -555,11 +555,11 @@ // Volume / Panning mptSmp.nVolume = vol * 4; - LimitMax(mptSmp.nVolume, WORD(256)); + LimitMax(mptSmp.nVolume, uint16(256)); mptSmp.nGlobalVol = gvl; - LimitMax(mptSmp.nGlobalVol, WORD(64)); + LimitMax(mptSmp.nGlobalVol, uint16(64)); mptSmp.nPan = (dfp & 0x7F) * 4; - LimitMax(mptSmp.nPan, WORD(256)); + LimitMax(mptSmp.nPan, uint16(256)); if(dfp & ITSample::enablePanning) mptSmp.uFlags |= CHN_PANNING; // Loop Flags @@ -611,7 +611,7 @@ if(flags & ITSample::sampleCompressed) { // IT 2.14 packed sample - sampleIO |= (cvt & ITSample::cvtIT215Compression) ? SampleIO::IT215 : SampleIO::IT214; + sampleIO |= (cvt & ITSample::cvtDelta) ? SampleIO::IT215 : SampleIO::IT214; } else { // MODPlugin :( Modified: trunk/OpenMPT/soundlib/ITTools.h =================================================================== --- trunk/OpenMPT/soundlib/ITTools.h 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/ITTools.h 2013-03-17 16:05:52 UTC (rev 1593) @@ -103,9 +103,9 @@ uint8 reserved; // Reserved // Convert OpenMPT's internal envelope format to an IT/MPTM envelope. - void ConvertToIT(const InstrumentEnvelope &mptEnv, BYTE envOffset, BYTE envDefault); + void ConvertToIT(const InstrumentEnvelope &mptEnv, uint8 envOffset, uint8 envDefault); // Convert IT/MPTM envelope data into OpenMPT's internal envelope format - To be used by ITInstrToMPT() - void ConvertToMPT(InstrumentEnvelope &mptEnv, BYTE envOffset, int maxNodes) const; + void ConvertToMPT(InstrumentEnvelope &mptEnv, uint8 envOffset, int maxNodes) const; }; STATIC_ASSERT(sizeof(ITEnvelope) == 82); @@ -258,7 +258,6 @@ enablePanning = 0x80, cvtSignedSample = 0x01, - cvtIT215Compression = 0x04, cvtADPCMSample = 0xFF, // MODPlugin :( // ITTECH.TXT says these convert flags are "safe to ignore". IT doesn't ignore them, though, so why should we? :) Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-03-17 16:05:52 UTC (rev 1593) @@ -57,11 +57,11 @@ return false; } -void ReadTuningCollection(istream& iStrm, CTuningCollection& tc, const size_t) {tc.Deserialize(iStrm);} -void WriteTuningCollection(ostream& oStrm, const CTuningCollection& tc) {tc.Serialize(oStrm);} +static void ReadTuningCollection(istream& iStrm, CTuningCollection& tc, const size_t) {tc.Deserialize(iStrm);} +static void WriteTuningCollection(ostream& oStrm, const CTuningCollection& tc) {tc.Serialize(oStrm);} -void WriteTuningMap(ostream& oStrm, const CSoundFile& sf) -//------------------------------------------------------- +static void WriteTuningMap(ostream& oStrm, const CSoundFile& sf) +//-------------------------------------------------------------- { if(sf.GetNumInstruments() > 0) { @@ -120,6 +120,7 @@ } } + template<class TUNNUMTYPE, class STRSIZETYPE> static bool ReadTuningMap(istream& iStrm, map<uint16, string>& shortToTNameMap, const size_t maxNum = 500) //-------------------------------------------------------------------------------------------------------- @@ -147,8 +148,9 @@ return true; } -void ReadTuningMap(istream& iStrm, CSoundFile& csf, const size_t = 0) -//------------------------------------------------------------------- + +static void ReadTuningMap(istream& iStrm, CSoundFile& csf, const size_t = 0) +//-------------------------------------------------------------------------- { typedef map<WORD, string> MAP; typedef MAP::iterator MAP_ITER; @@ -225,8 +227,8 @@ // Impulse Tracker IT file support -uint8 ConvertVolParam(const ModCommand *m) -//---------------------------------------- +static uint8 ConvertVolParam(const ModCommand *m) +//----------------------------------------------- { return min(m->vol, 9); } @@ -266,8 +268,8 @@ } -void CopyPatternName(CPattern &pattern, FileReader &file) -//------------------------------------------------------- +static void CopyPatternName(CPattern &pattern, FileReader &file) +//-------------------------------------------------------------- { char name[MAX_PATTERNNAME] = ""; file.ReadString<StringFixer::maybeNullTerminated>(name, MAX_PATTERNNAME); @@ -410,7 +412,7 @@ // Reading Channels Pan Positions for(CHANNELINDEX i = 0; i < 64; i++) if(fileHeader.chnpan[i] != 0xFF) { - ChnSettings[i].nVolume = fileHeader.chnvol[i]; + ChnSettings[i].nVolume = Clamp(fileHeader.chnvol[i], uint8(0), uint8(64)); ChnSettings[i].nPan = 128; ChnSettings[i].dwFlags.reset(); if(fileHeader.chnpan[i] & 0x80) ChnSettings[i].dwFlags.set(CHN_MUTE); @@ -977,7 +979,7 @@ return bytes_written; // Write number of history entries - fnum = LittleEndianW(fnum); + SwapBytesLE(fnum); fwrite(&fnum, 2, 1, f); #ifdef MODPLUG_TRACKER @@ -1042,8 +1044,8 @@ itHeader.id = ITFileHeader::itMagic; StringFixer::WriteString<StringFixer::nullTerminated>(itHeader.songname, m_szNames[0]); - itHeader.highlight_minor = (BYTE)min(m_nDefaultRowsPerBeat, 0xFF); - itHeader.highlight_major = (BYTE)min(m_nDefaultRowsPerMeasure, 0xFF); + itHeader.highlight_minor = (uint8)Util::Min(m_nDefaultRowsPerBeat, ROWINDEX(uint8_max)); + itHeader.highlight_major = (uint8)Util::Min(m_nDefaultRowsPerMeasure, ROWINDEX(uint8_max)); if(GetType() == MOD_TYPE_MPT) { @@ -1056,13 +1058,13 @@ { // An additional "---" pattern is appended so Impulse Tracker won't ignore the last order item. // Interestingly, this can exceed IT's 256 order limit. Also, IT will always save at least two orders. - itHeader.ordnum = min(Order.GetLengthTailTrimmed(), specs.ordersMax) + 1; + itHeader.ordnum = Util::Min(Order.GetLengthTailTrimmed(), specs.ordersMax) + 1; if(itHeader.ordnum < 2) itHeader.ordnum = 2; } - itHeader.insnum = min(m_nInstruments, specs.instrumentsMax); - itHeader.smpnum = min(m_nSamples, specs.samplesMax); - itHeader.patnum = min(Patterns.GetNumPatterns(), specs.patternsMax); + itHeader.insnum = Util::Min(m_nInstruments, specs.instrumentsMax); + itHeader.smpnum = Util::Min(m_nSamples, specs.samplesMax); + itHeader.patnum = Util::Min(Patterns.GetNumPatterns(), specs.patternsMax); // Parapointers vector<uint32> patpos(itHeader.patnum, 0); @@ -1098,7 +1100,7 @@ } } - itHeader.flags = ITFileHeader::useStereoPlayback; + itHeader.flags = ITFileHeader::useStereoPlayback | ITFileHeader::useMIDIPitchController; itHeader.special = ITFileHeader::embedEditHistory | ITFileHeader::embedPatternHighlights; if(m_nInstruments) itHeader.flags |= ITFileHeader::instrumentMode; if(m_SongFlags[SONG_LINEARSLIDES]) itHeader.flags |= ITFileHeader::linearSlides; @@ -1171,10 +1173,11 @@ dwExtra += SaveITEditHistory(this, nullptr); // Comments + uint16 msglength = 0; if(m_lpszSongComments) { itHeader.special |= ITFileHeader::embedSongMessage; - itHeader.msglength = (uint16)min(strlen(m_lpszSongComments) + 1, uint16_max); + itHeader.msglength = msglength = (uint16)min(strlen(m_lpszSongComments) + 1, uint16_max); itHeader.msgoffset = dwHdrPos + dwExtra + (itHeader.insnum + itHeader.smpnum + itHeader.patnum) * 4; } @@ -1240,8 +1243,8 @@ dwPos = dwHdrPos + dwExtra + (itHeader.insnum + itHeader.smpnum + itHeader.patnum) * 4; if(itHeader.special & ITFileHeader::embedSongMessage) { - dwPos += itHeader.msglength; - fwrite(m_lpszSongComments, 1, itHeader.msglength, f); + dwPos += msglength; + fwrite(m_lpszSongComments, 1, msglength, f); } // Writing instruments @@ -1254,8 +1257,8 @@ { instSize = iti.ConvertToIT(*Instruments[nins], compatibilityExport, *this); } else - // Save Empty Instrument { + // Save Empty Instrument ModInstrument dummy; instSize = iti.ConvertToIT(dummy, compatibilityExport, *this); } @@ -1487,7 +1490,7 @@ bool compress = (::GetPrivateProfileInt("Misc", Samples[nsmp].GetNumChannels() > 1 ? "ITCompressionStereo" : "ITCompressionMono", 0, theApp.GetConfigFileName()) & type) != 0; #else bool compress = false; -#endif +#endif // MODPLUG_TRACKER // Old MPT will only consider the IT2.15 compression flag if the header version also indicates IT2.15. itss.ConvertToIT(Samples[nsmp], GetType(), compress, itHeader.cmwt >= 0x215); @@ -1513,9 +1516,9 @@ // Updating offsets fseek(f, dwHdrPos, SEEK_SET); - if (itHeader.insnum) fwrite(&inspos[0], 4, itHeader.insnum, f); - if (itHeader.smpnum) fwrite(&smppos[0], 4, itHeader.smpnum, f); - if (itHeader.patnum) fwrite(&patpos[0], 4, itHeader.patnum, f); + if(itHeader.insnum) fwrite(&inspos[0], 4, itHeader.insnum, f); + if(itHeader.smpnum) fwrite(&smppos[0], 4, itHeader.smpnum, f); + if(itHeader.patnum) fwrite(&patpos[0], 4, itHeader.patnum, f); if(GetType() == MOD_TYPE_IT) { @@ -1534,19 +1537,19 @@ srlztn::Ssb ssb(fout); ssb.BeginWrite("mptm", MptVersion::num); - if (GetTuneSpecificTunings().GetNumTunings() > 0) + if(GetTuneSpecificTunings().GetNumTunings() > 0) ssb.WriteItem(GetTuneSpecificTunings(), "0", 1, &WriteTuningCollection); - if (AreNonDefaultTuningsUsed(*this)) + if(AreNonDefaultTuningsUsed(*this)) ssb.WriteItem(*this, "1", 1, &WriteTuningMap); - if (Order.NeedsExtraDatafield()) + if(Order.NeedsExtraDatafield()) ssb.WriteItem(Order, "2", 1, &WriteModSequenceOld); - if (bNeedsMptPatSave) + if(bNeedsMptPatSave) ssb.WriteItem(Patterns, FileIdPatterns, strlen(FileIdPatterns), &WriteModPatterns); ssb.WriteItem(Order, FileIdSequences, strlen(FileIdSequences), &WriteModSequences); ssb.FinishWrite(); - if (ssb.m_Status & srlztn::SNT_FAILURE) + if(ssb.m_Status & srlztn::SNT_FAILURE) { #ifdef MODPLUG_TRACKER if(GetpModDoc()) @@ -1580,10 +1583,8 @@ UINT CSoundFile::SaveMixPlugins(FILE *f, BOOL bUpdate) //---------------------------------------------------- { - - uint32 chinfo[MAX_BASECHANNELS]; - CHAR s[32]; + char id[4]; uint32 nPluginSize; uint32 nTotalSize = 0; uint32 nChInfo = 0; @@ -1610,72 +1611,62 @@ nPluginSize += MPTxPlugDataSize + 4; //+4 is for size itself: sizeof(DWORD) is 4 // rewbs.modularPlugData - if (f) + if(f) { // write plugin ID - s[0] = 'F'; - s[1] = 'X'; - s[2] = '0' + (i/10); - s[3] = '0' + (i%10); - fwrite(s, 1, 4, f); + id[0] = 'F'; + id[1] = 'X'; + id[2] = '0' + (i / 10); + id[3] = '0' + (i % 10); + fwrite(id, 1, 4, f); // write plugin size: fwrite(&nPluginSize, 1, 4, f); fwrite(&plugin.Info, 1, sizeof(SNDMIXPLUGININFO), f); fwrite(&m_MixPlugins[i].nPluginDataSize, 1, 4, f); - if (m_MixPlugins[i].pPluginData) + if(m_MixPlugins[i].pPluginData) { fwrite(m_MixPlugins[i].pPluginData, 1, m_MixPlugins[i].nPluginDataSize, f); } - //rewbs.dryRatio fwrite(&MPTxPlugDataSize, 1, 4, f); //write ID for this xPlugData chunk: - s[0] = 'D'; s[1] = 'W'; s[2] = 'R'; s[3] = 'T'; - fwrite(s, 1, 4, f); + memcpy(id, "DWRT", 4); + fwrite(id, 1, 4, f); //Write chunk data itself (Could include size if you want variable size. Not necessary here.) fwrite(&(m_MixPlugins[i].fDryRatio), 1, sizeof(float), f); - //end rewbs.dryRatio - //rewbs.plugDefaultProgram - //if (nProgram>=0) { - s[0] = 'P'; s[1] = 'R'; s[2] = 'O'; s[3] = 'G'; - fwrite(s, 1, 4, f); - //Write chunk data itself (Could include size if you want variable size. Not necessary here.) - fwrite(&(m_MixPlugins[i].defaultProgram), 1, sizeof(long), f); - //} - //end rewbs.plugDefaultProgram + memcpy(id, "PROG", 4); + fwrite(id, 1, 4, f); + //Write chunk data itself (Could include size if you want variable size. Not necessary here.) + fwrite(&(m_MixPlugins[i].defaultProgram), 1, sizeof(long), f); } nTotalSize += nPluginSize + 8; } } - for (UINT j=0; j<m_nChannels; j++) + for(CHANNELINDEX j = 0; j < m_nChannels; j++) { -// -> CODE#0006 -// -> DESC="misc quantity changes" -// if (j < 64) - if (j < MAX_BASECHANNELS) -// -! BEHAVIOUR_CHANGE#0006 + if(j < MAX_BASECHANNELS) { - if ((chinfo[j] = ChnSettings[j].nMixPlugin) != 0) + if((chinfo[j] = ChnSettings[j].nMixPlugin) != 0) { - nChInfo = j+1; + nChInfo = j + 1; } } } - if (nChInfo) + if(nChInfo) { - if (f) + if(f) { - memcpy(&nPluginSize, "CHFX", 4); + memcpy(id, "CHFX", 4); + fwrite(id, 1, 4, f); + nPluginSize = nChInfo * 4; fwrite(&nPluginSize, 1, 4, f); - nPluginSize = nChInfo*4; - fwrite(&nPluginSize, 1, 4, f); fwrite(chinfo, 1, nPluginSize, f); } - nTotalSize += nChInfo*4 + 8; + nTotalSize += nChInfo * 4 + 8; } return nTotalSize; } Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/ModChannel.h 2013-03-17 16:05:52 UTC (rev 1593) @@ -46,8 +46,9 @@ FlagSet<ChannelFlags> dwOldFlags; // Flags from previous tick int32 nRampRightVol; int32 nRampLeftVol; - float nFilter_Y1, nFilter_Y2, nFilter_Y3, nFilter_Y4; - float nFilter_A0, nFilter_B0, nFilter_B1; + float nFilter_Y1, nFilter_Y2; // Mono / left channel filter memory + float nFilter_Y3, nFilter_Y4; // Right channel filter memory + float nFilter_A0, nFilter_B0, nFilter_B1; // Filter coeffs int32 nFilter_HP; int32 nROfs, nLOfs; int32 nRampLength; Modified: trunk/OpenMPT/soundlib/ModInstrument.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModInstrument.cpp 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/ModInstrument.cpp 2013-03-17 16:05:52 UTC (rev 1593) @@ -225,3 +225,38 @@ nCutSwing = nResSwing = 0; } } + + +// Get a set of all samples referenced by this instrument +std::set<SAMPLEINDEX> ModInstrument::GetSamples() const +//----------------------------------------------------- +{ + std::set<SAMPLEINDEX> referencedSamples; + + for(size_t i = 0; i < CountOf(Keyboard); i++) + { + // 0 isn't a sample. + if(Keyboard[i] != 0) + { + referencedSamples.insert(Keyboard[i]); + } + } + + return referencedSamples; +} + + +// Write sample references into a bool vector. If a sample is referenced by this instrument, true is written. +// The caller has to initialize the vector. +void ModInstrument::GetSamples(std::vector<bool> &referencedSamples) const +//------------------------------------------------------------------------ +{ + for(size_t i = 0; i < CountOf(Keyboard); i++) + { + // 0 isn't a sample. + if(Keyboard[i] != 0 && Keyboard[i] < referencedSamples.size()) + { + referencedSamples[Keyboard[i]] = true; + } + } +} Modified: trunk/OpenMPT/soundlib/ModInstrument.h =================================================================== --- trunk/OpenMPT/soundlib/ModInstrument.h 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/ModInstrument.h 2013-03-17 16:05:52 UTC (rev 1593) @@ -10,22 +10,21 @@ #pragma once -#include "../common/misc_util.h" -#include "../soundlib/tuning.h" +#include "tuning.h" #include <set> // Instrument Envelopes struct InstrumentEnvelope { - FlagSet<EnvelopeFlags> dwFlags; // envelope flags - uint32 nNodes; // amount of nodes used - uint8 nLoopStart; // loop start node - uint8 nLoopEnd; // loop end node - uint8 nSustainStart; // sustain start node - uint8 nSustainEnd; // sustain end node - uint8 nReleaseNode; // release node - uint16 Ticks[MAX_ENVPOINTS]; // envelope point position (x axis) - uint8 Values[MAX_ENVPOINTS]; // envelope point value (y axis) + FlagSet<EnvelopeFlags> dwFlags; // Envelope flags + uint32 nNodes; // Amount of nodes used + uint8 nLoopStart; // Loop start node + uint8 nLoopEnd; // Loop end node + uint8 nSustainStart; // Sustain start node + uint8 nSustainEnd; // Sustain end node + uint8 nReleaseNode; // Release node + uint16 Ticks[MAX_ENVPOINTS]; // Envelope point position (x axis) + uint8 Values[MAX_ENVPOINTS]; // Envelope point value (y axis) InstrumentEnvelope() { @@ -152,35 +151,11 @@ } // Get a set of all samples referenced by this instrument - std::set<SAMPLEINDEX> GetSamples() const - { - std::set<SAMPLEINDEX> referencedSamples; + std::set<SAMPLEINDEX> GetSamples() const; - for(size_t i = 0; i < CountOf(Keyboard); i++) - { - // 0 isn't a sample. - if(Keyboard[i] != 0) - { - referencedSamples.insert(Keyboard[i]); - } - } - - return referencedSamples; - } - // Write sample references into a bool vector. If a sample is referenced by this instrument, true is written. // The caller has to initialize the vector. - void GetSamples(std::vector<bool> &referencedSamples) const - { - for(size_t i = 0; i < CountOf(Keyboard); i++) - { - // 0 isn't a sample. - if(Keyboard[i] != 0 && Keyboard[i] < referencedSamples.size()) - { - referencedSamples[Keyboard[i]] = true; - } - } - } + void GetSamples(std::vector<bool> &referencedSamples) const; // Translate instrument properties between two given formats. void Convert(MODTYPE fromType, MODTYPE toType); Modified: trunk/OpenMPT/soundlib/RowVisitor.cpp =================================================================== --- trunk/OpenMPT/soundlib/RowVisitor.cpp 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/RowVisitor.cpp 2013-03-17 16:05:52 UTC (rev 1593) @@ -2,7 +2,7 @@ * RowVisitor.cpp * -------------- * Purpose: Class for managing which rows of a song has already been visited. Useful for detecting backwards jumps, loops, etc. - * Notes : The class keepts track of rows that have been visited by the player before. + * Notes : The class keeps track of rows that have been visited by the player before. * This way, we can tell when the module starts to loop, i.e. we can determine the song length, * or find out that a given point of the module can never be reached. * Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-03-17 16:05:52 UTC (rev 1593) @@ -2019,7 +2019,10 @@ // Check if we're dealing with FLAC in an OGG container. // We won't check for the "fLaC" signature but let libFLAC decide whether a file is valid or not, as some FLAC files might have e.g. leading ID3v2 data. file.Rewind(); - const bool isOgg = FLAC_API_SUPPORTS_OGG_FLAC && file.ReadMagic("OggS") && file.Seek(29) && file.ReadMagic("FLAC"); + if(!file.ReadMagic("fLaC")) + { + return false; + } file.Rewind(); FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new(); @@ -2034,11 +2037,7 @@ FLACDecoder client(file, *this, sample); // Init decoder - FLAC__StreamDecoderInitStatus initStatus; - if(isOgg) - initStatus = FLAC__stream_decoder_init_ogg_stream(decoder, FLACDecoder::read_cb, FLACDecoder::seek_cb, FLACDecoder::tell_cb, FLACDecoder::length_cb, FLACDecoder::eof_cb, FLACDecoder::write_cb, FLACDecoder::metadata_cb, FLACDecoder::error_cb, &client); - else - initStatus = FLAC__stream_decoder_init_stream(decoder, FLACDecoder::read_cb, FLACDecoder::seek_cb, FLACDecoder::tell_cb, FLACDecoder::length_cb, FLACDecoder::eof_cb, FLACDecoder::write_cb, FLACDecoder::metadata_cb, FLACDecoder::error_cb, &client); + FLAC__StreamDecoderInitStatus initStatus = FLAC__stream_decoder_init_stream(decoder, FLACDecoder::read_cb, FLACDecoder::seek_cb, FLACDecoder::tell_cb, FLACDecoder::length_cb, FLACDecoder::eof_cb, FLACDecoder::write_cb, FLACDecoder::metadata_cb, FLACDecoder::error_cb, &client); if(initStatus != FLAC__STREAM_DECODER_INIT_STATUS_OK) { return false; Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-03-17 16:05:52 UTC (rev 1593) @@ -167,11 +167,11 @@ // Envelope value boundaries -#define ENVELOPE_MIN 0 // vertical min value of a point -#define ENVELOPE_MID 32 // vertical middle line -#define ENVELOPE_MAX 64 // vertical max value of a point +#define ENVELOPE_MIN 0 // Vertical min value of a point +#define ENVELOPE_MID 32 // Vertical middle line +#define ENVELOPE_MAX 64 // Vertical max value of a point #define MAX_ENVPOINTS 240 // Maximum length of each instrument envelope -#define ENVELOPE_MAX_LENGTH 0x3FFF // max envelope length in ticks. note: this value seems to be conservatively low... +#define ENVELOPE_MAX_LENGTH 0x3FFF // Max envelope length in ticks. note: this value is only really required because too long envelopes won't be displayed properly in the instrument editor (win32 scrollbar issues) // Flags of 'dF..' datafield in extended instrument properties. Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-17 16:05:52 UTC (rev 1593) @@ -3521,7 +3521,18 @@ break; // SBx: Pattern Loop // SCx: Note Cut - case 0xC0: NoteCut(nChn, param); break; + case 0xC0: + if(param == 0) + { + //IT compatibility 22. SC0 == SC1 + if(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) + param = 1; + // ST3 doesn't cut notes with SC0 + else if(GetType() == MOD_TYPE_S3M) + return; + } + NoteCut(nChn, param); + break; // SDx: Note Delay // SEx: Pattern Delay for x rows // SFx: S3M: Not used, IT: Set Active Midi Macro @@ -4237,16 +4248,6 @@ void CSoundFile::NoteCut(CHANNELINDEX nChn, UINT nTick) //----------------------------------------------------- { - if(nTick == 0) - { - //IT compatibility 22. SC0 == SC1 - if(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) - nTick = 1; - // ST3 doesn't cut notes with SC0 - else if(GetType() == MOD_TYPE_S3M) - return; - } - if (m_nTickCount == nTick) { ModChannel *pChn = &Chn[nChn]; Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2013-03-17 16:05:52 UTC (rev 1593) @@ -9,6 +9,7 @@ #include "stdafx.h" +#include "Loaders.h" #include "WAVTools.h" Modified: trunk/OpenMPT/soundlib/WAVTools.h =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.h 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/WAVTools.h 2013-03-17 16:05:52 UTC (rev 1593) @@ -10,7 +10,6 @@ #pragma once -#include "Loaders.h" #include "ChunkReader.h" #pragma pack(push, 1) Modified: trunk/OpenMPT/soundlib/XMTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/XMTools.cpp 2013-03-17 14:35:03 UTC (rev 1592) +++ trunk/OpenMPT/soundlib/XMTools.cpp 2013-03-17 16:05:52 UTC (rev 1593) @@ -52,7 +52,7 @@ void XMInstrument::ConvertEnvelopeToXM(const InstrumentEnvelope &mptEnv, uint8 &numPoints, uint8 &flags, uint8 &sustain, uint8 &loopStart, uint8 &loopEnd, uint16 (&envData)[24]) //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { - numPoints = static_cast<uint8>(min(12, mptEnv.nNodes)); + numPoints = static_cast<uint8>(Util::Min(12u, mptEnv.nNodes)); // Envelope Data for(size_t i = 0; i < numPoints; i++) @@ -67,9 +67,9 @@ if(mptEnv.dwFlags[ENV_LOOP]) flags |= XMInstrument::envLoop; // Envelope Loops - sustain = static_cast<uint8>(min(12, mptEnv.nSustainStart)); - loopStart = static_cast<uint8>(min(12, mptEnv.nLoopStart)); - loopEnd = static_cast<uint8>(min(12, mptEnv.nLoopEnd)); + sustain = Util::Min(uint8(12), mptEnv.nSustainStart); + loopStart = Util::Min(uint8(12), mptEnv.nLoopStart); + loopEnd = Util::Min(uint8(12), mptEnv.nLoopEnd); } @@ -370,8 +370,8 @@ MemsetZero(*this); // Volume / Panning - vol = static_cast<uint8>(min(mptSmp.nVolume / 4, 64)); - pan = static_cast<uint8>(min(mptSmp.nPan, 255)); + vol = static_cast<uint8>(Util::Min(mptSmp.nVolume / 4u, 64u)); + pan = static_cast<uint8>(Util::Min(mptSmp.nPan, uint16(255))); // Sample Frequency if((fromType & (MOD_TYPE_MOD | MOD_TYPE_XM))) @@ -386,9 +386,9 @@ } flags = 0; - if((mptSmp.uFlags & CHN_LOOP)) + if(mptSmp.uFlags[CHN_LOOP]) { - flags |= (mptSmp.uFlags & CHN_PINGPONGLOOP) ? XMSample::sampleBidiLoop : XMSample::sampleLoop; + flags |= mptSmp.uFlags[CHN_PINGPONGLOOP] ? XMSample::sampleBidiLoop : XMSample::sampleLoop; } // Sample Length and Loops @@ -396,7 +396,7 @@ loopStart = mptSmp.nLoopStart; loopLength = mptSmp.nLoopEnd - mptSmp.nLoopStart; - if((mptSmp.uFlags & CHN_16BIT)) + if(mptSmp.uFlags[CHN_16BIT]) { flags |= XMSample::sample16Bit; length *= 2; @@ -404,7 +404,7 @@ loopLength *= 2; } - if((mptSmp.uFlags & CHN_STEREO) && !compatibilityExport) + if(mptSmp.uFlags[CHN_STEREO] && !compatibilityExport) { flags |= XMSample::sampleStereo; length *= 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |