From: <man...@us...> - 2015-02-27 11:22:31
|
Revision: 4795 http://sourceforge.net/p/modplug/code/4795 Author: manxorist Date: 2015-02-27 11:22:19 +0000 (Fri, 27 Feb 2015) Log Message: ----------- [Ref] Silence unused variable warning when compiled without assertions. Modified Paths: -------------- trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/soundlib/Fastmix.cpp Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2015-02-26 23:25:59 UTC (rev 4794) +++ trunk/OpenMPT/common/typedefs.h 2015-02-27 11:22:19 UTC (rev 4795) @@ -569,6 +569,8 @@ #define MPT_UNREFERENCED_PARAMETER(x) (void)(x) #endif +#define MPT_UNUSED_VARIABLE(x) MPT_UNREFERENCED_PARAMETER(x) + OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2015-02-26 23:25:59 UTC (rev 4794) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2015-02-27 11:22:19 UTC (rev 4795) @@ -453,7 +453,7 @@ uint32 targetpos = chn.nPos + (BufferLengthToSamples(nSmpCount, chn) >> 16); MixFuncTable::Functions[functionNdx | (chn.nRampLength ? MixFuncTable::ndxRamp : 0)](chn, m_Resampler, pbuffer, nSmpCount); - MPT_ASSERT(chn.nPos == targetpos); + MPT_ASSERT(chn.nPos == targetpos); MPT_UNUSED_VARIABLE(targetpos); chn.nROfs += *(pbufmax-2); chn.nLOfs += *(pbufmax-1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-02-27 22:14:31
|
Revision: 4796 http://sourceforge.net/p/modplug/code/4796 Author: saga-games Date: 2015-02-27 22:14:25 +0000 (Fri, 27 Feb 2015) Log Message: ----------- [Fix] S3M compatibility: Properly limit periods in S3M files and cut period when sliding too high (test case: PeriodLimit.s3m and channel 4 in shell shock (tmnt 3) by virt) Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/common/versionNumber.h 2015-02-27 22:14:25 UTC (rev 4796) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 02 +#define VER_MINORMINOR 03 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -654,8 +654,8 @@ } m_nSamples = std::max(SAMPLEINDEX(1), GetNumSamples()); - m_nMinPeriod = 8; - m_nMaxPeriod = 0xF000; + m_nMinPeriod = 0; + m_nMaxPeriod = int32_max; PATTERNINDEX numPats = std::min(static_cast<PATTERNINDEX>(patPos.size()), GetModSpecifications().patternsMax); Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -316,7 +316,7 @@ } // Bit 8 = Stereo (we always use stereo) - m_nSamplePreAmp = Clamp(fileHeader.masterVolume & 0x7F, 0x10, 0x7F); + m_nSamplePreAmp = std::max(fileHeader.masterVolume & 0x7F, 0x10); // Channel setup m_nChannels = 4; @@ -324,22 +324,18 @@ { ChnSettings[i].Reset(); - if(fileHeader.channels[i] == 0xFF) + if(fileHeader.channels[i] != 0xFF) { - ChnSettings[i].nPan = 128; - ChnSettings[i].dwFlags = CHN_MUTE; - } else - { m_nChannels = i + 1; ChnSettings[i].nPan = (fileHeader.channels[i] & 8) ? 0xCC : 0x33; // 200 : 56 - if(fileHeader.channels[i] & 0x80) - { - ChnSettings[i].dwFlags = CHN_MUTE; - // Detect Adlib channels here (except for OpenMPT 1.19 and older, which would write wrong channel types for PCM channels 16-32): - // c = channels[i] ^ 0x80; - // if(c >= 16 && c < 32) adlibChannel = true; - } } + if(fileHeader.channels[i] & 0x80) + { + ChnSettings[i].dwFlags = CHN_MUTE; + // Detect Adlib channels here (except for OpenMPT 1.19 and older, which would write wrong channel types for PCM channels 16-32): + // c = channels[i] ^ 0x80; + // if(c >= 16 && c < 32) adlibChannel = true; + } } if(m_nChannels < 1) { Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2015-02-27 22:14:25 UTC (rev 4796) @@ -56,9 +56,6 @@ const CHANNELINDEX MAX_BASECHANNELS = 127; // Max pattern channels. const CHANNELINDEX MAX_CHANNELS = 256; //200 // Maximum number of mixing channels. -#define MIN_PERIOD 0x0020 // Note: Period is an Amiga metric that is inverse to frequency. -#define MAX_PERIOD 0xFFFF // Periods in MPT are 4 times as fine as Amiga periods because of extra fine frequency slides. - #define FREQ_FRACBITS 4 // Number of fractional bits in return value of CSoundFile::GetFreqFromPeriod() // String lengths (including trailing null char) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -3195,7 +3195,15 @@ } else { pChn->nPeriod -= (int)(param * 4); - if (pChn->nPeriod < 1) pChn->nPeriod = 1; + if (pChn->nPeriod < 1) + { + pChn->nPeriod = 1; + if(GetType() == MOD_TYPE_S3M) + { + pChn->nFadeOutVol = 0; + pChn->dwFlags.set(CHN_NOTEFADE | CHN_FASTVOLRAMP); + } + } } } } @@ -3259,7 +3267,15 @@ } else { pChn->nPeriod -= (int)(param); - if (pChn->nPeriod < 1) pChn->nPeriod = 1; + if (pChn->nPeriod < 1) + { + pChn->nPeriod = 1; + if(GetType() == MOD_TYPE_S3M) + { + pChn->nFadeOutVol = 0; + pChn->dwFlags.set(CHN_NOTEFADE | CHN_FASTVOLRAMP); + } + } } } } @@ -4720,7 +4736,15 @@ { pChn->nPeriod += nFreqSlide; } - if(pChn->nPeriod < 1) pChn->nPeriod = 1; + if (pChn->nPeriod < 1) + { + pChn->nPeriod = 1; + if(GetType() == MOD_TYPE_S3M) + { + pChn->nFadeOutVol = 0; + pChn->dwFlags.set(CHN_NOTEFADE | CHN_FASTVOLRAMP); + } + } } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -1,4 +1,5 @@ -/* +in_p + /* * Sndfile.cpp * ----------- * Purpose: Core class of the playback engine. Every song is represented by a CSoundFile object. @@ -557,7 +558,7 @@ #ifndef MODPLUG_TRACKER m_nFreqFactor = m_nTempoFactor = 65536; #endif - m_nMinPeriod = MIN_PERIOD; + m_nMinPeriod = 32; m_nMaxPeriod = 0x7FFF; m_nRepeatCount = 0; m_PlayState.m_nSeqOverride = ORDERINDEX_INVALID; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Sndfile.h 2015-02-27 22:14:25 UTC (rev 4796) @@ -425,7 +425,12 @@ UINT m_nFreqFactor; // Pitch shift factor (65536 = no pitch shifting). Only used in libopenmpt (openmpt::ext::interactive::set_pitch_factor) UINT m_nTempoFactor; // Tempo factor (65536 = no tempo adjustment). Only used in libopenmpt (openmpt::ext::interactive::set_tempo_factor) #endif - int32 m_nMinPeriod, m_nMaxPeriod; // min period = highest possible frequency, max period = lowest possible frequency + + // Min Period = highest possible frequency, Max Period = lowest possible frequency for current format + // Note: Period is an Amiga metric that is inverse to frequency. + // Periods in MPT are 4 times as fine as Amiga periods because of extra fine frequency slides (introduced in the S3M format). + int32 m_nMinPeriod, m_nMaxPeriod; + int32 m_nRepeatCount; // -1 means repeat infinitely. ORDERINDEX m_nMaxOrderPosition; ModChannelSettings ChnSettings[MAX_BASECHANNELS]; // Initial channels settings Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -1915,7 +1915,9 @@ pChn->nCalcVolume = vol; // Update calculated volume for MIDI macros - if (pChn->nPeriod < m_nMinPeriod) pChn->nPeriod = m_nMinPeriod; + // ST3 only clamps the final output period, but never the channel's internal period. + // Test case: PeriodLimit.s3m + if (pChn->nPeriod < m_nMinPeriod && GetType() != MOD_TYPE_S3M) pChn->nPeriod = m_nMinPeriod; if(IsCompatibleMode(TRK_FASTTRACKER2)) Clamp(pChn->nPeriod, 1, 31999); period = pChn->nPeriod; @@ -1980,25 +1982,12 @@ ProcessSampleAutoVibrato(pChn, period, vibratoFactor, nPeriodFrac); // Final Period + // ST3 only clamps the final output period, but never the channel's internal period. + // Test case: PeriodLimit.s3m if (period <= m_nMinPeriod) { - // ST3 simply stops playback if frequency is too high. - // Test case: FreqLimits.s3m - if (GetType() & MOD_TYPE_S3M) pChn->nLength = 0; period = m_nMinPeriod; } - //rewbs: temporarily commenting out block to allow notes below A-0. - /*if (period > m_nMaxPeriod) - { - if ((m_nType & MOD_TYPE_IT) || (period >= 0x100000)) - { - pChn->nFadeOutVol = 0; - pChn->dwFlags |= CHN_NOTEFADE; - pChn->nRealVolume = 0; - } - period = m_nMaxPeriod; - nPeriodFrac = 0; - }*/ if(GetType() == MOD_TYPE_MPT && pIns != nullptr && pIns->pTuning != nullptr) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-03-01 21:40:23
|
Revision: 4801 http://sourceforge.net/p/modplug/code/4801 Author: saga-games Date: 2015-03-01 21:40:09 +0000 (Sun, 01 Mar 2015) Log Message: ----------- [New] Can now read PLM (Disorder Tracker 2) files Modified Paths: -------------- trunk/OpenMPT/installer/filetypes.iss trunk/OpenMPT/libopenmpt/foo_openmpt.cpp trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Tables.cpp Added Paths: ----------- trunk/OpenMPT/soundlib/Load_plm.cpp Modified: trunk/OpenMPT/installer/filetypes.iss =================================================================== --- trunk/OpenMPT/installer/filetypes.iss 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/installer/filetypes.iss 2015-03-01 21:40:09 UTC (rev 4801) @@ -38,6 +38,7 @@ Name: "associate_exotic\mt2"; Description: "MadTracker 2 (MT2)"; Name: "associate_exotic\mtm"; Description: "MultiTracker Modules (MTM)"; Name: "associate_exotic\okt"; Description: "Oktalyzer (OKT)"; +Name: "associate_exotic\plm"; Description: "Disorder Tracker 2 (PLM)"; Name: "associate_exotic\psm"; Description: "Epic Megagames MASI (PSM)"; Name: "associate_exotic\ptm"; Description: "PolyTracker (PTM)"; Name: "associate_exotic\stm"; Description: "Scream Tracker 2 (STM)"; @@ -80,6 +81,7 @@ Root: HKCR; Subkey: ".mt2"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\mt2 Root: HKCR; Subkey: ".mtm"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\mtm Root: HKCR; Subkey: ".okt"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\okt +Root: HKCR; Subkey: ".plm"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\plm Root: HKCR; Subkey: ".psm"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\psm Root: HKCR; Subkey: ".ptm"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\ptm Root: HKCR; Subkey: ".stm"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\stm Modified: trunk/OpenMPT/libopenmpt/foo_openmpt.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/foo_openmpt.cpp 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/libopenmpt/foo_openmpt.cpp 2015-03-01 21:40:09 UTC (rev 4801) @@ -314,6 +314,7 @@ "*.digi" ";" "*.imf" ";" "*.j2b" ";" + "*.plm" ";" "*.gdm" ";" "*.umx" ";" "*.mo3" ";" Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2015-03-01 21:40:09 UTC (rev 4801) @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> @@ -298,6 +298,7 @@ <ClCompile Include="..\soundlib\Load_mtm.cpp" /> <ClCompile Include="..\soundlib\Load_okt.cpp" /> <ClCompile Include="..\soundlib\Load_psm.cpp" /> + <ClCompile Include="..\soundlib\Load_plm.cpp" /> <ClCompile Include="..\soundlib\Load_ptm.cpp" /> <ClCompile Include="..\soundlib\Load_s3m.cpp" /> <ClCompile Include="..\soundlib\Load_stm.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2015-03-01 21:40:09 UTC (rev 4801) @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <Filter Include="Source Files"> @@ -370,6 +370,9 @@ <ClCompile Include="..\soundlib\Load_psm.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> + <ClCompile Include="..\soundlib\Load_plm.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> <ClCompile Include="..\soundlib\Load_ptm.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2015-03-01 21:40:09 UTC (rev 4801) @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> @@ -308,6 +308,7 @@ <ClCompile Include="..\soundlib\Load_mtm.cpp" /> <ClCompile Include="..\soundlib\Load_okt.cpp" /> <ClCompile Include="..\soundlib\Load_psm.cpp" /> + <ClCompile Include="..\soundlib\Load_plm.cpp" /> <ClCompile Include="..\soundlib\Load_ptm.cpp" /> <ClCompile Include="..\soundlib\Load_s3m.cpp" /> <ClCompile Include="..\soundlib\Load_stm.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2015-03-01 21:40:09 UTC (rev 4801) @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <Filter Include="Source Files"> @@ -376,6 +376,9 @@ <ClCompile Include="..\soundlib\Load_psm.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> + <ClCompile Include="..\soundlib\Load_plm.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> <ClCompile Include="..\soundlib\Load_ptm.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2015-03-01 21:40:09 UTC (rev 4801) @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> @@ -302,6 +302,7 @@ <ClCompile Include="..\soundlib\Load_mtm.cpp" /> <ClCompile Include="..\soundlib\Load_okt.cpp" /> <ClCompile Include="..\soundlib\Load_psm.cpp" /> + <ClCompile Include="..\soundlib\Load_plm.cpp" /> <ClCompile Include="..\soundlib\Load_ptm.cpp" /> <ClCompile Include="..\soundlib\Load_s3m.cpp" /> <ClCompile Include="..\soundlib\Load_stm.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2015-03-01 21:40:09 UTC (rev 4801) @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <Filter Include="Source Files"> @@ -370,6 +370,9 @@ <ClCompile Include="..\soundlib\Load_psm.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> + <ClCompile Include="..\soundlib\Load_plm.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> <ClCompile Include="..\soundlib\Load_ptm.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-03-01 21:40:09 UTC (rev 4801) @@ -1249,7 +1249,7 @@ "FastTracker Modules (*.xm)|*.xm;*.xmz|" "Impulse Tracker Modules (*.it)|*.it;*.itz|" "OpenMPT Modules (*.mptm)|*.mptm;*.mptmz|" - "Other Modules (mtm,okt,mdl,669,far,...)|*.mtm;*.669;*.ult;*.wow;*.far;*.mdl;*.okt;*.dmf;*.ptm;*.med;*.ams;*.dbm;*.digi;*.dsm;*.umx;*.amf;*.psm;*.mt2;*.gdm;*.imf;*.itp;*.j2b;*.ice;*.st26|" + "Other Modules (mtm,okt,mdl,669,far,...)|*.mtm;*.669;*.ult;*.wow;*.far;*.mdl;*.okt;*.dmf;*.ptm;*.med;*.ams;*.dbm;*.digi;*.dsm;*.umx;*.amf;*.psm;*.mt2;*.gdm;*.imf;*.itp;*.j2b;*.ice;*.st26;*.plm|" "Wave Files (*.wav)|*.wav|" "MIDI Files (*.mid,*.rmi)|*.mid;*.rmi;*.smf|" "All Files (*.*)|*.*||") Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2015-03-01 21:40:09 UTC (rev 4801) @@ -1894,6 +1894,10 @@ > </File> <File + RelativePath="..\soundlib\load_plm.cpp" + > + </File> + <File RelativePath="..\soundlib\load_ptm.cpp" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2015-03-01 21:40:09 UTC (rev 4801) @@ -765,6 +765,7 @@ <ClCompile Include="..\soundlib\ITCompression.cpp" /> <ClCompile Include="..\soundlib\ITTools.cpp" /> <ClCompile Include="..\soundlib\Load_digi.cpp" /> + <ClCompile Include="..\soundlib\Load_plm.cpp" /> <ClCompile Include="..\soundlib\Message.cpp" /> <ClCompile Include="..\soundlib\MIDIEvents.cpp" /> <ClCompile Include="..\soundlib\MIDIMacros.cpp" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2015-03-01 21:40:09 UTC (rev 4801) @@ -547,6 +547,9 @@ <ClCompile Include="..\sounddev\SoundDeviceUtilities.cpp"> <Filter>Source Files\sounddev</Filter> </ClCompile> + <ClCompile Include="..\soundlib\Load_plm.cpp"> + <Filter>Source Files\soundlib\Module Loaders</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> Added: trunk/OpenMPT/soundlib/Load_plm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_plm.cpp (rev 0) +++ trunk/OpenMPT/soundlib/Load_plm.cpp 2015-03-01 21:40:09 UTC (rev 4801) @@ -0,0 +1,340 @@ +/* + * Load_plm.cpp + * ------------ + * Purpose: PLM (Disorder Tracker 2) module loader + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "Loaders.h" + + +OPENMPT_NAMESPACE_BEGIN + +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(push, 1) +#endif + +struct PACKED PLMFileHeader +{ + char magic[4]; // "PLM\x1A" + uint8 headerSize; // Number of bytes in header, including magic bytes + uint8 version; // version code of file format (0x10) + char songName[48]; + uint8 numChannels; + uint8 flags; // unused? + uint8 maxVol; // Maximum volume for vol slides, normally 0x40 + uint8 amplify; // SoundBlaster amplify, 0x40 = no amplify + uint8 tempo; + uint8 speed; + uint8 panPos[32]; // 0...15 + uint8 numSamples; + uint8 numPatterns; + uint16 numOrders; + + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(numOrders); + } +}; + +STATIC_ASSERT(sizeof(PLMFileHeader) == 96); + + +struct PACKED PLMSampleHeader +{ + enum SampleFlags + { + smp16Bit = 1, + }; + + char magic[4]; // "PLS\x1A" + uint8 headerSize; // Number of bytes in header, including magic bytes + uint8 version; + char name[32]; + char filename[12]; + uint8 panning; // 0...15, 255 = no pan + uint8 volume; // 0...64 + uint8 flags; // See SampleFlags + uint16 sampleRate; + char unused[4]; + uint32 loopStart; + uint32 loopEnd; + uint32 length; + + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(sampleRate); + SwapBytesLE(loopStart); + SwapBytesLE(loopEnd); + SwapBytesLE(length); + } +}; + +STATIC_ASSERT(sizeof(PLMSampleHeader) == 71); + + +struct PACKED PLMPatternHeader +{ + uint32 size; + uint8 numRows; + uint8 numChannels; + uint8 color; + char name[25]; + + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(size); + } +}; + +STATIC_ASSERT(sizeof(PLMPatternHeader) == 32); + + +struct PACKED PLMOrderItem +{ + uint16 x; // Starting position of pattern + uint8 y; // Number of first channel + uint8 pattern; + + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(x); + } +}; + +STATIC_ASSERT(sizeof(PLMOrderItem) == 4); + +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(pop) +#endif + + +bool CSoundFile::ReadPLM(FileReader &file, ModLoadingFlags loadFlags) +//------------------------------------------------------------------- +{ + file.Rewind(); + + PLMFileHeader fileHeader; + if(!file.ReadConvertEndianness(fileHeader) + || memcmp(fileHeader.magic, "PLM\x1A", 4) + || fileHeader.version != 0x10 + || fileHeader.numChannels == 0 || fileHeader.numChannels > 32 + || !file.Seek(fileHeader.headerSize) + || !file.CanRead(4 * (fileHeader.numOrders + fileHeader.numPatterns + fileHeader.numSamples))) + { + return false; + } else if(loadFlags == onlyVerifyHeader) + { + return true; + } + + InitializeGlobals(); + InitializeChannels(); + m_nType = MOD_TYPE_PLM; + madeWithTracker = "Disorder Tracker 2"; + mpt::String::Read<mpt::String::maybeNullTerminated>(songName, fileHeader.songName); + m_nChannels = fileHeader.numChannels + 1; // Additional channel for writing pattern breaks + m_nSamplePreAmp = fileHeader.amplify; + m_nDefaultTempo = fileHeader.tempo; + m_nDefaultSpeed = fileHeader.speed; + for(CHANNELINDEX chn = 0; chn < fileHeader.numChannels; chn++) + { + ChnSettings[chn].nPan = fileHeader.panPos[chn] * 0x11; + } + m_nSamples = fileHeader.numSamples; + + std::vector<PLMOrderItem> order(fileHeader.numOrders); + for(uint16 i = 0; i < fileHeader.numOrders; i++) + { + PLMOrderItem ord; + file.ReadConvertEndianness(ord); + order[i] = ord; + } + + std::vector<uint32> patternPos, samplePos; + file.ReadVectorLE(patternPos, fileHeader.numPatterns); + file.ReadVectorLE(samplePos, fileHeader.numSamples); + + for(SAMPLEINDEX smp = 0; smp < fileHeader.numSamples; smp++) + { + ModSample &sample = Samples[smp + 1]; + sample.Initialize(); + + if(samplePos[smp] == 0) continue; + file.Seek(samplePos[smp]); + PLMSampleHeader sampleHeader; + file.ReadConvertEndianness(sampleHeader); + + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[smp + 1], sampleHeader.name); + mpt::String::Read<mpt::String::maybeNullTerminated>(sample.filename, sampleHeader.filename); + if(sampleHeader.panning <= 15) + { + sample.uFlags.set(CHN_PANNING); + sample.nPan = sampleHeader.panning * 0x11; + } + sample.nGlobalVol = std::min(sampleHeader.volume, uint8(64)); + sample.nC5Speed = sampleHeader.sampleRate; + sample.nLoopStart = sampleHeader.loopStart; + sample.nLoopEnd = sampleHeader.loopEnd; + sample.nLength = sampleHeader.length; + if(sample.nLoopEnd > sample.nLoopStart) sample.uFlags.set(CHN_LOOP); + sample.SanitizeLoops(); + file.Seek(samplePos[smp] + sampleHeader.headerSize); + SampleIO( + (sampleHeader.flags & PLMSampleHeader::smp16Bit) ? SampleIO::_16bit : SampleIO::_8bit, + SampleIO::mono, + SampleIO::bigEndian, + SampleIO::unsignedPCM) + .ReadSample(sample, file); + } + + Order.clear(); + // PLM is basically one huge continuous pattern, so we split it up into smaller patterns. + const ROWINDEX rowsPerPat = 64; + + static const ModCommand::COMMAND effTrans[] = + { + CMD_NONE, + CMD_PORTAMENTOUP, + CMD_PORTAMENTODOWN, + CMD_TONEPORTAMENTO, + CMD_VOLUMESLIDE, + CMD_TREMOLO, + CMD_VIBRATO, + CMD_S3MCMDEX, // Tremolo Waveform + CMD_S3MCMDEX, // Vibrato Waveform + CMD_TEMPO, + CMD_SPEED, + CMD_POSITIONJUMP, // Jump to order + CMD_POSITIONJUMP, // Break to end of this order + CMD_OFFSET, + CMD_S3MCMDEX, // GUS Panning + CMD_RETRIG, + CMD_S3MCMDEX, // Note Delay + CMD_S3MCMDEX, // Note Cut + CMD_S3MCMDEX, // Pattern Delay + CMD_FINEVIBRATO, + CMD_VIBRATOVOL, + CMD_TONEPORTAVOL + }; + + for(uint16 i = 0; i < fileHeader.numOrders; i++) + { + const PLMOrderItem &ord = order[i]; + if(ord.pattern >= fileHeader.numPatterns || ord.y > fileHeader.numChannels) continue; + + file.Seek(patternPos[ord.pattern]); + PLMPatternHeader patHeader; + file.ReadConvertEndianness(patHeader); + + ORDERINDEX curOrd = ord.x / rowsPerPat; + ROWINDEX curRow = ord.x % rowsPerPat; + const CHANNELINDEX numChannels = std::min<CHANNELINDEX>(patHeader.numChannels, fileHeader.numChannels - ord.y); + + for(ROWINDEX r = 0; r < patHeader.numRows; r++, curRow++) + { + if(curRow >= rowsPerPat) + { + curRow = 0; + curOrd++; + } + if(curOrd >= Order.size()) + { + PATTERNINDEX pat = Patterns.Insert(rowsPerPat); + Order.resize(curOrd + 1); + Order[curOrd] = pat; + } + PATTERNINDEX pat = Order[curOrd]; + if(!Patterns.IsValidPat(pat)) break; + + ModCommand *m = Patterns[pat].GetpModCommand(curRow, ord.y); + for(CHANNELINDEX c = 0; c < numChannels; c++, m++) + { + uint8 data[5]; + file.ReadArray(data); + if(data[0]) + m->note = (data[0] >> 4) * 12 + (data[0] & 0x0F) + 12 + NOTE_MIN; + else + m->note = NOTE_NONE; + m->instr = data[1]; + m->volcmd = VOLCMD_VOLUME; + if(data[2] != 0xFF) + m->vol = data[2]; + else + m->volcmd = VOLCMD_NONE; + + if(data[3] < CountOf(effTrans)) + { + m->command = effTrans[data[3]]; + m->param = data[4]; + // Fix some commands + switch(data[3]) + { + case 0x07: // Tremolo waveform + m->param = 0x40 | (m->param & 0x03); + break; + case 0x08: // Vibrato waveform + m->param = 0x30 | (m->param & 0x03); + break; + case 0x0B: // Jump to order + if(m->param < fileHeader.numOrders) + { + uint16 target = order[m->param].x; + m->param = static_cast<ModCommand::PARAM>(target / rowsPerPat); + ModCommand *mBreak = Patterns[pat].GetpModCommand(curRow, m_nChannels - 1); + mBreak->command = CMD_PATTERNBREAK; + mBreak->param = static_cast<ModCommand::PARAM>(target % rowsPerPat); + } + break; + case 0x0C: // Jump to end of order + { + uint16 target = ord.x + patHeader.numRows; + m->param = static_cast<ModCommand::PARAM>(target / rowsPerPat); + ModCommand *mBreak = Patterns[pat].GetpModCommand(curRow, m_nChannels - 1); + mBreak->command = CMD_PATTERNBREAK; + mBreak->param = static_cast<ModCommand::PARAM>(target % rowsPerPat); + } + break; + case 0x0E: // GUS Panning + m->param = 0x80 | (m->param & 0x0F); + break; + case 0x10: // Delay Note + m->param = 0xD0 | std::min<ModCommand::PARAM>(m->param, 0x0F); + break; + case 0x11: // Cut Note + m->param = 0xC0 | std::min<ModCommand::PARAM>(m->param, 0x0F); + break; + case 0x12: // Pattern Delay + m->param = 0x60 | std::min<ModCommand::PARAM>(m->param, 0x0F); + break; + case 0x04: // Volume Slide + case 0x14: // Vibrato + Volume Slide + case 0x15: // Tone Portamento + Volume Slide + // If both nibbles of a volume slide are set, act as fine volume slide up + if((m->param & 0xF0) && (m->param & 0x0F) && (m->param & 0xF0) != 0xF0) + { + m->param |= 0x0F; + } + break; + } + } + } + if(patHeader.numChannels > numChannels) + { + file.Skip(5 * (patHeader.numChannels - numChannels)); + } + } + } + + return true; +} + +OPENMPT_NAMESPACE_END Property changes on: trunk/OpenMPT/soundlib/Load_plm.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2015-03-01 21:40:09 UTC (rev 4801) @@ -98,6 +98,7 @@ MOD_TYPE_AMS2 = 0x4000000, MOD_TYPE_DIGI = 0x8000000, MOD_TYPE_UAX = 0x10000000, // sampleset as module + MOD_TYPE_PLM = 0x20000000, }; DECLARE_FLAGSET(MODTYPE) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-01 21:40:09 UTC (rev 4801) @@ -5028,7 +5028,7 @@ { if (note == NOTE_NONE || (note >= NOTE_MIN_SPECIAL)) return 0; note -= NOTE_MIN; - if (GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_MT2|MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_MDL|MOD_TYPE_ULT|MOD_TYPE_WAV|MOD_TYPE_669 + if (GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_MT2|MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_MDL|MOD_TYPE_ULT|MOD_TYPE_WAV|MOD_TYPE_669|MOD_TYPE_PLM |MOD_TYPE_FAR|MOD_TYPE_DMF|MOD_TYPE_PTM|MOD_TYPE_AMS|MOD_TYPE_AMS2|MOD_TYPE_DBM|MOD_TYPE_AMF|MOD_TYPE_PSM|MOD_TYPE_J2B|MOD_TYPE_IMF)) { if(m_SongFlags[SONG_LINEARSLIDES]) Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2015-03-01 21:40:09 UTC (rev 4801) @@ -764,6 +764,7 @@ && !ReadGDM(file, loadFlags) && !ReadIMF(file, loadFlags) && !ReadDIGI(file, loadFlags) + && !ReadPLM(file, loadFlags) && !ReadAM(file, loadFlags) && !ReadJ2B(file, loadFlags) && !ReadMO3(file, loadFlags) @@ -1813,8 +1814,8 @@ // Get length of a tick in sample, with tick-to-tick tempo correction in modern tempo mode. // This has to be called exactly once per tick because otherwise the error accumulation // goes wrong. -UINT CSoundFile::GetTickDuration(UINT tempo, UINT speed, ROWINDEX rowsPerBeat) -//---------------------------------------------------------------------------- +uint32_t CSoundFile::GetTickDuration(uint32_t tempo, uint32_t speed, ROWINDEX rowsPerBeat) +//---------------------------------------------------------------------------------------- { UINT retval = 0; switch(m_nTempoMode) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/soundlib/Sndfile.h 2015-03-01 21:40:09 UTC (rev 4801) @@ -646,7 +646,7 @@ void RecalculateSamplesPerTick(); double GetRowDuration(UINT tempo, UINT speed) const; - UINT GetTickDuration(UINT tempo, UINT speed, ROWINDEX rowsPerBeat); + uint32_t GetTickDuration(uint32_t tempo, uint32_t speed, ROWINDEX rowsPerBeat); // A repeat count value of -1 means infinite loop void SetRepeatCount(int n) { m_nRepeatCount = n; } @@ -695,6 +695,7 @@ bool ReadAM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadJ2B(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadDIGI(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); + bool ReadPLM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadMID(const uint8 *lpStream, DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule); static std::vector<const char *> GetSupportedExtensions(bool otherFormats); Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2015-03-01 14:49:49 UTC (rev 4800) +++ trunk/OpenMPT/soundlib/Tables.cpp 2015-03-01 21:40:09 UTC (rev 4801) @@ -45,14 +45,14 @@ static const ModFormatInfo modFormatInfo[] = { { MOD_TYPE_MOD, "ProTracker", "mod" }, - { MOD_TYPE_S3M, "ScreamTracker III", "s3m" }, + { MOD_TYPE_S3M, "ScreamTracker 3", "s3m" }, { MOD_TYPE_XM, "FastTracker II", "xm" }, { MOD_TYPE_IT, "Impulse Tracker", "it" }, #ifdef MPT_EXTERNAL_SAMPLES { MOD_TYPE_IT, "Impulse Tracker Project", "itp" }, #endif { MOD_TYPE_MPT, "OpenMPT", "mptm" }, - { MOD_TYPE_STM, "ScreamTracker II", "stm" }, + { MOD_TYPE_STM, "ScreamTracker 2", "stm" }, { MOD_TYPE_MOD, "NoiseTracker", "nst" }, { MOD_TYPE_MOD, "Soundtracker", "m15" }, { MOD_TYPE_MOD, "Soundtracker", "stk" }, @@ -79,12 +79,13 @@ { MOD_TYPE_DIGI, "DigiBooster", "digi" }, { MOD_TYPE_IMF, "Imago Orpheus", "imf" }, { MOD_TYPE_J2B, "Galaxy Sound System", "j2b" }, + { MOD_TYPE_PLM, "Disorder Tracker 2", "plm" }, #ifndef NO_ARCHIVE_SUPPORT // Compressed modules { MOD_TYPE_MOD, "ProTracker", "mdz" }, { MOD_TYPE_MOD, "ProTracker", "mdr" }, - { MOD_TYPE_S3M, "ScreamTracker III", "s3z" }, + { MOD_TYPE_S3M, "ScreamTracker 3", "s3z" }, { MOD_TYPE_XM, "FastTracker II", "xmz" }, { MOD_TYPE_IT, "Impulse Tracker", "itz" }, { MOD_TYPE_MPT, "OpenMPT", "mptmz" }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-03-01 21:58:16
|
Revision: 4803 http://sourceforge.net/p/modplug/code/4803 Author: saga-games Date: 2015-03-01 21:58:09 +0000 (Sun, 01 Mar 2015) Log Message: ----------- [Fix] Missing reference to Load_plm.cpp in autotools makefile [Mod] Loading PLM files as S3M is just enough. Modified Paths: -------------- trunk/OpenMPT/build/autotools/Makefile.am trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/build/autotools/Makefile.am =================================================================== --- trunk/OpenMPT/build/autotools/Makefile.am 2015-03-01 21:48:01 UTC (rev 4802) +++ trunk/OpenMPT/build/autotools/Makefile.am 2015-03-01 21:58:09 UTC (rev 4803) @@ -147,6 +147,7 @@ libopenmpt_la_SOURCES += soundlib/Load_mt2.cpp libopenmpt_la_SOURCES += soundlib/Load_mtm.cpp libopenmpt_la_SOURCES += soundlib/Load_okt.cpp +libopenmpt_la_SOURCES += soundlib/Load_plm.cpp libopenmpt_la_SOURCES += soundlib/Load_psm.cpp libopenmpt_la_SOURCES += soundlib/Load_ptm.cpp libopenmpt_la_SOURCES += soundlib/Load_s3m.cpp Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2015-03-01 21:48:01 UTC (rev 4802) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2015-03-01 21:58:09 UTC (rev 4803) @@ -1331,6 +1331,7 @@ case MOD_TYPE_DSM: case MOD_TYPE_AMF: case MOD_TYPE_MTM: + case MOD_TYPE_PLM: return MOD_TYPE_S3M; case MOD_TYPE_AMS: case MOD_TYPE_AMS2: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-03 11:42:06
|
Revision: 4810 http://sourceforge.net/p/modplug/code/4810 Author: manxorist Date: 2015-03-03 11:41:53 +0000 (Tue, 03 Mar 2015) Log Message: ----------- [Fix] Skip files too big for UnpackPP20. (fixes 64bit warning) Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/soundlib/Mmcmp.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-03-02 23:07:31 UTC (rev 4809) +++ trunk/OpenMPT/common/misc_util.h 2015-03-03 11:41:53 UTC (rev 4810) @@ -272,7 +272,7 @@ { // Returns true iff Tdst can represent the value val. -// Use as if(Util::TypeCanHold<uin8>(-1)). +// Use as if(Util::TypeCanHoldValue<uint8>(-1)). template <typename Tdst, typename Tsrc> inline bool TypeCanHoldValue(Tsrc val) { Modified: trunk/OpenMPT/soundlib/Mmcmp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmcmp.cpp 2015-03-02 23:07:31 UTC (rev 4809) +++ trunk/OpenMPT/soundlib/Mmcmp.cpp 2015-03-03 11:41:53 UTC (rev 4810) @@ -837,6 +837,7 @@ file.Rewind(); unpackedData.clear(); + if(!Util::TypeCanHoldValue<uint32>(file.GetLength())) return false; if(!file.CanRead(PP20_PACKED_SIZE_MIN)) return false; if(!file.ReadMagic("PP20")) return false; file.Seek(file.GetLength() - 4); @@ -847,7 +848,7 @@ if(dstLen == 0) return false; unpackedData.resize(dstLen); file.Seek(4); - bool result = PP20_DoUnpack(reinterpret_cast<const uint8 *>(file.GetRawData()), file.GetLength() - 4, reinterpret_cast<uint8 *>(&(unpackedData[0])), dstLen); + bool result = PP20_DoUnpack(reinterpret_cast<const uint8 *>(file.GetRawData()), static_cast<uint32>(file.GetLength() - 4), reinterpret_cast<uint8 *>(&(unpackedData[0])), dstLen); return result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-03 16:07:13
|
Revision: 4813 http://sourceforge.net/p/modplug/code/4813 Author: manxorist Date: 2015-03-03 16:07:07 +0000 (Tue, 03 Mar 2015) Log Message: ----------- [Ref] Silence charset conversion warnings related to file formats storing paths to external samples in locale encoding. There is nothing we can do in that case anyway, thus there is no use in emitting compiler warnings. Modified Paths: -------------- trunk/OpenMPT/common/mptPathString.h trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp Modified: trunk/OpenMPT/common/mptPathString.h =================================================================== --- trunk/OpenMPT/common/mptPathString.h 2015-03-03 15:55:39 UTC (rev 4812) +++ trunk/OpenMPT/common/mptPathString.h 2015-03-03 16:07:07 UTC (rev 4813) @@ -152,6 +152,7 @@ mpt::ustring ToUnicode() const { return mpt::ToUnicode(path); } #if defined(MPT_WITH_CHARSET_LOCALE) MPT_DEPRECATED_PATH static PathString FromLocale(const std::string &path) { return PathString(mpt::ToWide(mpt::CharsetLocale, path)); } + static PathString FromLocaleSilent(const std::string &path) { return PathString(mpt::ToWide(mpt::CharsetLocale, path)); } #endif static PathString FromUTF8(const std::string &path) { return PathString(mpt::ToWide(mpt::CharsetUTF8, path)); } static PathString FromWide(const std::wstring &path) { return PathString(path); } @@ -189,6 +190,7 @@ #endif mpt::ustring ToUnicode() const { return mpt::ToUnicode(mpt::CharsetLocale, path); } static PathString FromLocale(const std::string &path) { return PathString(path); } + static PathString FromLocaleSilent(const std::string &path) { return PathString(path); } static PathString FromUTF8(const std::string &path) { return PathString(mpt::ToCharset(mpt::CharsetLocale, mpt::CharsetUTF8, path)); } #if MPT_WSTRING_CONVERT static PathString FromWide(const std::wstring &path) { return PathString(mpt::ToCharset(mpt::CharsetLocale, path)); } Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2015-03-03 15:55:39 UTC (rev 4812) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2015-03-03 16:07:07 UTC (rev 4813) @@ -149,7 +149,7 @@ file.ReadString<mpt::String::maybeNullTerminated>(path, size); if(version <= 0x00000102) { - instrPaths[ins] = mpt::PathString::FromLocale(path); + instrPaths[ins] = mpt::PathString::FromLocaleSilent(path); } else { instrPaths[ins] = mpt::PathString::FromUTF8(path); @@ -264,7 +264,7 @@ FileReader file = GetFileReader(f); if(!ReadInstrumentFromFile(ins + 1, file, mayNormalize)) { - AddToLog("Unable to open instrument: " + instrPaths[ins].ToLocale()); + AddToLog(LogWarning, MPT_USTRING("Unable to open instrument: ") + instrPaths[ins].ToUnicode()); } } Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2015-03-03 15:55:39 UTC (rev 4812) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2015-03-03 16:07:07 UTC (rev 4813) @@ -1061,7 +1061,7 @@ // Relative path in same folder or sub folder filename = ".\\" + filename; } - SetSamplePath(i + 1, mpt::PathString::FromLocale(filename)); + SetSamplePath(i + 1, mpt::PathString::FromLocaleSilent(filename)); #else #if defined(MPT_WITH_CHARSET_LOCALE) AddToLog(LogWarning, mpt::String::Print(MPT_USTRING("Loading external sample %1 ('%2') failed: External samples are not supported."), i, mpt::ToUnicode(mpt::CharsetLocale, filename))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-03 17:39:18
|
Revision: 4814 http://sourceforge.net/p/modplug/code/4814 Author: manxorist Date: 2015-03-03 17:39:05 +0000 (Tue, 03 Mar 2015) Log Message: ----------- [Var] lhasa: Silence type conversion warnings in foreign code which we do not intent to fix. Modified Paths: -------------- trunk/OpenMPT/build/gen/lhasa.vcproj trunk/OpenMPT/build/gen/lhasa.vcxproj trunk/OpenMPT/include/lhasa.premake4.lua Modified: trunk/OpenMPT/build/gen/lhasa.vcproj =================================================================== --- trunk/OpenMPT/build/gen/lhasa.vcproj 2015-03-03 16:07:07 UTC (rev 4813) +++ trunk/OpenMPT/build/gen/lhasa.vcproj 2015-03-03 17:39:05 UTC (rev 4814) @@ -42,6 +42,7 @@ /> <Tool Name="VCCLCompilerTool" + AdditionalOptions="/wd4244 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\..\include\msinttypes\inttypes;..\..\include\msinttypes\stdint" PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" @@ -120,6 +121,7 @@ /> <Tool Name="VCCLCompilerTool" + AdditionalOptions="/wd4244 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\..\include\msinttypes\inttypes;..\..\include\msinttypes\stdint" PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" @@ -197,7 +199,7 @@ /> <Tool Name="VCCLCompilerTool" - AdditionalOptions="/MP" + AdditionalOptions="/wd4244 /wd4267 /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\msinttypes\inttypes;..\..\include\msinttypes\stdint" PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" @@ -276,7 +278,7 @@ /> <Tool Name="VCCLCompilerTool" - AdditionalOptions="/MP" + AdditionalOptions="/wd4244 /wd4267 /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\msinttypes\inttypes;..\..\include\msinttypes\stdint" PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" @@ -354,7 +356,7 @@ /> <Tool Name="VCCLCompilerTool" - AdditionalOptions="/GL- /MP" + AdditionalOptions="/wd4244 /wd4267 /GL- /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\msinttypes\inttypes;..\..\include\msinttypes\stdint" PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" @@ -433,7 +435,7 @@ /> <Tool Name="VCCLCompilerTool" - AdditionalOptions="/GL- /MP" + AdditionalOptions="/wd4244 /wd4267 /GL- /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\msinttypes\inttypes;..\..\include\msinttypes\stdint" PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" Modified: trunk/OpenMPT/build/gen/lhasa.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/lhasa.vcxproj 2015-03-03 16:07:07 UTC (rev 4813) +++ trunk/OpenMPT/build/gen/lhasa.vcxproj 2015-03-03 17:39:05 UTC (rev 4814) @@ -111,6 +111,7 @@ </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> + <AdditionalOptions>/wd4244 /wd4267 %(AdditionalOptions)</AdditionalOptions> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\..\include\msinttypes\inttypes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -138,6 +139,7 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> + <AdditionalOptions>/wd4244 /wd4267 %(AdditionalOptions)</AdditionalOptions> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\..\include\msinttypes\inttypes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -165,7 +167,7 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> - <AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions> + <AdditionalOptions>/wd4244 /wd4267 /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\msinttypes\inttypes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -196,7 +198,7 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> - <AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions> + <AdditionalOptions>/wd4244 /wd4267 /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\msinttypes\inttypes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -227,7 +229,7 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'"> <ClCompile> - <AdditionalOptions>/GL- /MP %(AdditionalOptions)</AdditionalOptions> + <AdditionalOptions>/wd4244 /wd4267 /GL- /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\msinttypes\inttypes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -257,7 +259,7 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'"> <ClCompile> - <AdditionalOptions>/GL- /MP %(AdditionalOptions)</AdditionalOptions> + <AdditionalOptions>/wd4244 /wd4267 /GL- /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\msinttypes\inttypes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> Modified: trunk/OpenMPT/include/lhasa.premake4.lua =================================================================== --- trunk/OpenMPT/include/lhasa.premake4.lua 2015-03-03 16:07:07 UTC (rev 4813) +++ trunk/OpenMPT/include/lhasa.premake4.lua 2015-03-03 17:39:05 UTC (rev 4814) @@ -44,6 +44,7 @@ "../include/lhasa/lib/public/lha_reader.h", "../include/lhasa/lib/public/lhasa.h", } + buildoptions { "/wd4244", "/wd4267" } configuration "vs2008" includedirs { "../include/msinttypes/stdint" } dofile "../build/premake4-defaults-LIB.lua" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-03-03 19:02:42
|
Revision: 4815 http://sourceforge.net/p/modplug/code/4815 Author: saga-games Date: 2015-03-03 19:02:34 +0000 (Tue, 03 Mar 2015) Log Message: ----------- [New] Instrument tab Can now load and save envelopes (http://bugs.openmpt.org/view.php?id=398) [Mod] OpenMPT: Version is now 1.24.02.04 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_ins.h trunk/OpenMPT/mptrack/res/envelope_toolbar.png trunk/OpenMPT/mptrack/res/originals/envelope_toolbar.pfi trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-03-03 17:39:05 UTC (rev 4814) +++ trunk/OpenMPT/common/versionNumber.h 2015-03-03 19:02:34 UTC (rev 4815) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 03 +#define VER_MINORMINOR 04 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2015-03-03 17:39:05 UTC (rev 4814) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2015-03-03 19:02:34 UTC (rev 4815) @@ -674,8 +674,11 @@ DefineKeyCommand(kcSampleCenterLoopEnd, 1917, _T("Center loop end in view")); DefineKeyCommand(kcSampleCenterSustainStart, 1918, _T("Center sustain loop start in view")); DefineKeyCommand(kcSampleCenterSustainEnd, 1919, _T("Center sustain loop end in view")); + DefineKeyCommand(kcInstrumentEnvelopeLoad, 1920, _T("Load Envelope")); + DefineKeyCommand(kcInstrumentEnvelopeSave, 1921, _T("Save Envelope")); + // Add new key commands here. #ifdef _DEBUG Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2015-03-03 17:39:05 UTC (rev 4814) +++ trunk/OpenMPT/mptrack/CommandSet.h 2015-03-03 19:02:34 UTC (rev 4815) @@ -620,6 +620,8 @@ kcInstrumentLoad=kcStartInstrumentMisc, kcInstrumentSave, kcInstrumentNew, + kcInstrumentEnvelopeLoad, + kcInstrumentEnvelopeSave, kcInstrumentEnvelopeZoomIn, kcInstrumentEnvelopeZoomOut, kcInstrumentEnvelopePointPrev, Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2015-03-03 17:39:05 UTC (rev 4814) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2015-03-03 19:02:34 UTC (rev 4815) @@ -246,6 +246,8 @@ IIMAGE_NOZOOMIN, IIMAGE_ZOOMOUT, IIMAGE_NOZOOMOUT, + IIMAGE_SAVE, + IIMAGE_LOAD, ENVIMG_NUMIMAGES }; Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2015-03-03 17:39:05 UTC (rev 4814) +++ trunk/OpenMPT/mptrack/Moddoc.h 2015-03-03 19:02:34 UTC (rev 4815) @@ -245,8 +245,10 @@ BOOL ExpandPattern(PATTERNINDEX nPattern); BOOL ShrinkPattern(PATTERNINDEX nPattern); - bool CopyEnvelope(UINT nIns, enmEnvelopeTypes nEnv); - bool PasteEnvelope(UINT nIns, enmEnvelopeTypes nEnv); + bool CopyEnvelope(INSTRUMENTINDEX nIns, enmEnvelopeTypes nEnv); + bool SaveEnvelope(INSTRUMENTINDEX nIns, enmEnvelopeTypes nEnv, const mpt::PathString &fileName); + bool PasteEnvelope(INSTRUMENTINDEX nIns, enmEnvelopeTypes nEnv); + bool LoadEnvelope(INSTRUMENTINDEX nIns, enmEnvelopeTypes nEnv, const mpt::PathString &fileName); LRESULT ActivateView(UINT nIdView, DWORD dwParam); void UpdateAllViews(CView *pSender, UpdateHint hint, CObject *pHint=NULL); Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2015-03-03 17:39:05 UTC (rev 4814) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2015-03-03 19:02:34 UTC (rev 4815) @@ -17,6 +17,7 @@ #include "modsmp_ctrl.h" #include "../common/misc_util.h" #include "../common/StringFixer.h" +#include "../common/mptFileIO.h" // VST cloning #include "Vstplug.h" #include "VstPresets.h" @@ -225,6 +226,10 @@ { m_SndFile.ChnSettings[nChn] = settings[newOrder[nChn]]; m_SndFile.m_PlayState.Chn[nChn] = chns[newOrder[nChn]]; + if(chns[newOrder[nChn]].nMasterChn > 0 && chns[newOrder[nChn]].nMasterChn <= nRemainingChannels) + { + m_SndFile.m_PlayState.Chn[nChn].nMasterChn = newOrder[chns[newOrder[nChn]].nMasterChn - 1] + 1; + } if(recordStates[newOrder[nChn]] == 1) Record1Channel(nChn, true); if(recordStates[newOrder[nChn]] == 2) Record2Channel(nChn, true); m_SndFile.m_bChannelMuteTogglePending[nChn] = chnMutePendings[newOrder[nChn]]; @@ -989,50 +994,119 @@ ///////////////////////////////////////////////////////////////////////////////////////// // Copy/Paste envelope -static LPCSTR pszEnvHdr = "Modplug Tracker Envelope\r\n"; -static LPCSTR pszEnvFmt = "%d,%d,%d,%d,%d,%d,%d,%d\r\n"; +static const CHAR *pszEnvHdr = "ModPlug Tracker Envelope\r\n"; +static const CHAR *pszEnvFmt = "%d,%d,%d,%d,%d,%d,%d,%d\r\n"; -bool CModDoc::CopyEnvelope(UINT nIns, enmEnvelopeTypes nEnv) -//---------------------------------------------------------- +static bool EnvelopeToString(CStringA &s, const InstrumentEnvelope &env) +//---------------------------------------------------------------------- { - CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - HANDLE hCpy; - CHAR s[4096]; - ModInstrument *pIns; - DWORD dwMemSize; - - if ((nIns < 1) || (nIns > m_SndFile.m_nInstruments) || (!m_SndFile.Instruments[nIns]) || (!pMainFrm)) return false; - BeginWaitCursor(); - pIns = m_SndFile.Instruments[nIns]; - if(pIns == nullptr) return false; - - const InstrumentEnvelope &env = pIns->GetEnvelope(nEnv); - // We don't want to copy empty envelopes if(env.nNodes == 0) { return false; } - strcpy(s, pszEnvHdr); - wsprintf(s + strlen(s), pszEnvFmt, env.nNodes, env.nSustainStart, env.nSustainEnd, env.nLoopStart, env.nLoopEnd, + s.Preallocate(2048); + s = pszEnvHdr; + s.AppendFormat(pszEnvFmt, env.nNodes, env.nSustainStart, env.nSustainEnd, env.nLoopStart, env.nLoopEnd, env.dwFlags[ENV_SUSTAIN] ? 1 : 0, env.dwFlags[ENV_LOOP] ? 1 : 0, env.dwFlags[ENV_CARRY] ? 1 : 0); - for (UINT i = 0; i < env.nNodes; i++) + for(uint32 i = 0; i < env.nNodes; i++) { - if (strlen(s) >= sizeof(s)-32) break; - wsprintf(s+strlen(s), "%d,%d\r\n", env.Ticks[i], env.Values[i]); + s.AppendFormat("%d,%d\r\n", env.Ticks[i], env.Values[i]); } - //Writing release node - if(strlen(s) < sizeof(s) - 32) - wsprintf(s+strlen(s), "%u\r\n", env.nReleaseNode); + // Writing release node + s.AppendFormat("%u\r\n", env.nReleaseNode); + return true; +} - dwMemSize = strlen(s)+1; + +static bool StringToEnvelope(const std::string &s, InstrumentEnvelope &env, const CModSpecifications &specs) +//---------------------------------------------------------------------------------------------------------- +{ + uint32 susBegin = 0, susEnd = 0, loopBegin = 0, loopEnd = 0, bSus = 0, bLoop = 0, bCarry = 0, nPoints = 0, releaseNode = ENV_RELEASE_NODE_UNSET; + size_t length = s.size(), pos = strlen(pszEnvHdr); + if (length <= pos || mpt::strnicmp(s.c_str(), pszEnvHdr, pos - 2)) + { + return false; + } + sscanf(&s[pos], pszEnvFmt, &nPoints, &susBegin, &susEnd, &loopBegin, &loopEnd, &bSus, &bLoop, &bCarry); + while (pos < length && s[pos] != '\r' && s[pos] != '\n') pos++; + + nPoints = MIN(nPoints, specs.envelopePointsMax); + if (susEnd >= nPoints) susEnd = 0; + if (susBegin > susEnd) susBegin = susEnd; + if (loopEnd >= nPoints) loopEnd = 0; + if (loopBegin > loopEnd) loopBegin = loopEnd; + + env.nNodes = nPoints; + env.nSustainStart = susBegin; + env.nSustainEnd = susEnd; + env.nLoopStart = loopBegin; + env.nLoopEnd = loopEnd; + env.nReleaseNode = releaseNode; + env.dwFlags.set(ENV_LOOP, bLoop != 0); + env.dwFlags.set(ENV_SUSTAIN, bSus != 0); + env.dwFlags.set(ENV_CARRY, bCarry != 0); + env.dwFlags.set(ENV_ENABLED, nPoints > 0); + + int oldn = 0; + for (uint32 i = 0; i < nPoints; i++) + { + while (pos < length && (s[pos] < '0' || s[pos] > '9')) pos++; + if (pos >= length) break; + int n1 = atoi(&s[pos]); + while (pos < length && s[pos] != ',') pos++; + while (pos < length && (s[pos] < '0' || s[pos] > '9')) pos++; + if (pos >= length) break; + int n2 = atoi(&s[pos]); + if (n1 < oldn) n1 = oldn + 1; + Limit(n2, ENVELOPE_MIN, ENVELOPE_MAX); + env.Ticks[i] = (uint16)n1; + env.Values[i] = (uint8)n2; + oldn = n1; + while (pos < length && s[pos] != '\r' && s[pos] != '\n') pos++; + if (pos >= length) break; + } + env.Ticks[0] = 0; + + // Read release node information. + env.nReleaseNode = ENV_RELEASE_NODE_UNSET; + if(pos < length) + { + uint8 r = static_cast<uint8>(atoi(&s[pos])); + if(r == 0 || r >= nPoints || !specs.hasReleaseNode) + r = ENV_RELEASE_NODE_UNSET; + env.nReleaseNode = r; + } + return true; +} + + +bool CModDoc::CopyEnvelope(INSTRUMENTINDEX nIns, enmEnvelopeTypes nEnv) +//--------------------------------------------------------------------- +{ + CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + HANDLE hCpy; + DWORD dwMemSize; + + if ((nIns < 1) || (nIns > m_SndFile.m_nInstruments) || (!m_SndFile.Instruments[nIns]) || (!pMainFrm)) return false; + BeginWaitCursor(); + const ModInstrument *pIns = m_SndFile.Instruments[nIns]; + if(pIns == nullptr) return false; + + CStringA s; + EnvelopeToString(s, pIns->GetEnvelope(nEnv)); + + dwMemSize = s.GetLength() + 1; if ((pMainFrm->OpenClipboard()) && ((hCpy = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, dwMemSize))!=NULL)) { EmptyClipboard(); LPBYTE p = (LPBYTE)GlobalLock(hCpy); - memcpy(p, s, dwMemSize); + if(p != nullptr) + { + memcpy(p, s.GetString(), dwMemSize); + } GlobalUnlock(hCpy); SetClipboardData (CF_TEXT, (HANDLE)hCpy); CloseClipboard(); @@ -1042,12 +1116,35 @@ } -bool CModDoc::PasteEnvelope(UINT nIns, enmEnvelopeTypes nEnv) -//----------------------------------------------------------- +bool CModDoc::SaveEnvelope(INSTRUMENTINDEX nIns, enmEnvelopeTypes nEnv, const mpt::PathString &fileName) +//------------------------------------------------------------------------------------------------------ { + if (nIns < 1 || nIns > m_SndFile.m_nInstruments || !m_SndFile.Instruments[nIns]) return false; + BeginWaitCursor(); + const ModInstrument *pIns = m_SndFile.Instruments[nIns]; + if(pIns == nullptr) return false; + + CStringA s; + EnvelopeToString(s, pIns->GetEnvelope(nEnv)); + + FILE *f = mpt_fopen(fileName, "wb"); + if(f == nullptr) + { + EndWaitCursor(); + return false; + } + fwrite(s.GetString(), s.GetLength(), 1, f); + fclose(f); + EndWaitCursor(); + return true; +} + + +bool CModDoc::PasteEnvelope(INSTRUMENTINDEX nIns, enmEnvelopeTypes nEnv) +//---------------------------------------------------------------------- +{ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - - if ((nIns < 1) || (nIns > m_SndFile.m_nInstruments) || (!m_SndFile.Instruments[nIns]) || (!pMainFrm)) return false; + if (nIns < 1 || nIns > m_SndFile.m_nInstruments || !m_SndFile.Instruments[nIns] || !pMainFrm) return false; BeginWaitCursor(); if (!pMainFrm->OpenClipboard()) { @@ -1057,72 +1154,34 @@ HGLOBAL hCpy = ::GetClipboardData(CF_TEXT); LPCSTR p; bool result = false; - if ((hCpy) && ((p = (LPSTR)GlobalLock(hCpy)) != NULL)) + if ((hCpy) && ((p = (LPSTR)GlobalLock(hCpy)) != nullptr)) { - ModInstrument *pIns = m_SndFile.Instruments[nIns]; - - UINT susBegin = 0, susEnd = 0, loopBegin = 0, loopEnd = 0, bSus = 0, bLoop = 0, bCarry = 0, nPoints = 0, releaseNode = ENV_RELEASE_NODE_UNSET; - DWORD dwMemSize = GlobalSize(hCpy), dwPos = strlen(pszEnvHdr); - if ((dwMemSize > dwPos) && (!mpt::strnicmp(p, pszEnvHdr, dwPos - 2))) - { - sscanf(p + dwPos, pszEnvFmt, &nPoints, &susBegin, &susEnd, &loopBegin, &loopEnd, &bSus, &bLoop, &bCarry); - while ((dwPos < dwMemSize) && (p[dwPos] != '\r') && (p[dwPos] != '\n')) dwPos++; - - nPoints = MIN(nPoints, m_SndFile.GetModSpecifications().envelopePointsMax); - if (susEnd >= nPoints) susEnd = 0; - if (susBegin > susEnd) susBegin = susEnd; - if (loopEnd >= nPoints) loopEnd = 0; - if (loopBegin > loopEnd) loopBegin = loopEnd; - - InstrumentEnvelope &env = pIns->GetEnvelope(nEnv); - - env.nNodes = nPoints; - env.nSustainStart = susBegin; - env.nSustainEnd = susEnd; - env.nLoopStart = loopBegin; - env.nLoopEnd = loopEnd; - env.nReleaseNode = releaseNode; - env.dwFlags.set(ENV_LOOP, bLoop != 0); - env.dwFlags.set(ENV_SUSTAIN, bSus != 0); - env.dwFlags.set(ENV_CARRY, bCarry != 0); - env.dwFlags.set(ENV_ENABLED, nPoints > 0); - - int oldn = 0; - for (UINT i=0; i<nPoints; i++) - { - while ((dwPos < dwMemSize) && ((p[dwPos] < '0') || (p[dwPos] > '9'))) dwPos++; - if (dwPos >= dwMemSize) break; - int n1 = atoi(p+dwPos); - while ((dwPos < dwMemSize) && (p[dwPos] != ',')) dwPos++; - while ((dwPos < dwMemSize) && ((p[dwPos] < '0') || (p[dwPos] > '9'))) dwPos++; - if (dwPos >= dwMemSize) break; - int n2 = atoi(p+dwPos); - if (n1 < oldn) n1 = oldn + 1; - env.Ticks[i] = (WORD)n1; - env.Values[i] = (BYTE)n2; - oldn = n1; - while ((dwPos < dwMemSize) && (p[dwPos] != '\r') && (p[dwPos] != '\n')) dwPos++; - if (dwPos >= dwMemSize) break; - } - - //Read releasenode information. - if(dwPos < dwMemSize) - { - BYTE r = static_cast<BYTE>(atoi(p + dwPos)); - if(r == 0 || r >= nPoints || !m_SndFile.GetModSpecifications().hasReleaseNode) - r = ENV_RELEASE_NODE_UNSET; - env.nReleaseNode = r; - } - } + std::string data(p, p + GlobalSize(hCpy)); GlobalUnlock(hCpy); CloseClipboard(); - result = true; + + result = StringToEnvelope(data, m_SndFile.Instruments[nIns]->GetEnvelope(nEnv), m_SndFile.GetModSpecifications()); } EndWaitCursor(); return result; } +bool CModDoc::LoadEnvelope(INSTRUMENTINDEX nIns, enmEnvelopeTypes nEnv, const mpt::PathString &fileName) +//------------------------------------------------------------------------------------------------------ +{ + InputFile f(fileName); + if (nIns < 1 || nIns > m_SndFile.m_nInstruments || !m_SndFile.Instruments[nIns] || !f.IsValid()) return false; + BeginWaitCursor(); + FileReader file = GetFileReader(f); + std::string data; + file.ReadNullString(data, 1 << 20); + bool result = StringToEnvelope(data, m_SndFile.Instruments[nIns]->GetEnvelope(nEnv), m_SndFile.GetModSpecifications()); + EndWaitCursor(); + return result; +} + + // Check which channels contain note data. maxRemoveCount specified how many empty channels are reported at max. void CModDoc::CheckUsedChannels(std::vector<bool> &usedMask, CHANNELINDEX maxRemoveCount) const //--------------------------------------------------------------------------------------------- Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2015-03-03 17:39:05 UTC (rev 4814) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2015-03-03 19:02:34 UTC (rev 4815) @@ -23,6 +23,7 @@ #include "ScaleEnvPointsDlg.h" #include "../soundlib/MIDIEvents.h" #include "../common/StringFixer.h" +#include "FileDialog.h" OPENMPT_NAMESPACE_BEGIN @@ -44,7 +45,7 @@ #define ENV_LEFTBAR_CYBTN 22 -const UINT cLeftBarButtons[ENV_LEFTBAR_BUTTONS] = +static const UINT cLeftBarButtons[ENV_LEFTBAR_BUTTONS] = { ID_ENVSEL_VOLUME, ID_ENVSEL_PANNING, @@ -65,6 +66,9 @@ ID_SEPARATOR, ID_ENVELOPE_ZOOM_IN, ID_ENVELOPE_ZOOM_OUT, + ID_SEPARATOR, + ID_ENVELOPE_LOAD, + ID_ENVELOPE_SAVE, }; @@ -103,6 +107,8 @@ ON_COMMAND(ID_ENVELOPE_VIEWGRID, OnEnvToggleGrid) //rewbs.envRowGrid ON_COMMAND(ID_ENVELOPE_ZOOM_IN, OnEnvZoomIn) ON_COMMAND(ID_ENVELOPE_ZOOM_OUT, OnEnvZoomOut) + ON_COMMAND(ID_ENVELOPE_LOAD, OnEnvLoad) + ON_COMMAND(ID_ENVELOPE_SAVE, OnEnvSave) ON_COMMAND(ID_ENVSEL_VOLUME, OnSelectVolumeEnv) ON_COMMAND(ID_ENVSEL_PANNING, OnSelectPanningEnv) ON_COMMAND(ID_ENVSEL_PITCH, OnSelectPitchEnv) @@ -155,6 +161,7 @@ CModScrollView::OnInitialUpdate(); ModifyStyleEx(0, WS_EX_ACCEPTFILES); UpdateScrollSize(); + UpdateNcButtonState(); } @@ -752,6 +759,8 @@ case ID_ENVELOPE_VIEWGRID: if (m_bGrid) dwStyle |= NCBTNS_CHECKED; break; case ID_ENVELOPE_ZOOM_IN: if (m_fZoom >= ENV_MAX_ZOOM) dwStyle |= NCBTNS_DISABLED; break; case ID_ENVELOPE_ZOOM_OUT: if (m_fZoom <= ENV_MIN_ZOOM) dwStyle |= NCBTNS_DISABLED; break; + case ID_ENVELOPE_LOAD: + case ID_ENVELOPE_SAVE: if (GetInstrumentPtr() == nullptr) dwStyle |= NCBTNS_DISABLED; break; } if (m_nBtnMouseOver == i) { @@ -1261,6 +1270,8 @@ case ID_ENVELOPE_VIEWGRID: nImage = IIMAGE_GRID; break; case ID_ENVELOPE_ZOOM_IN: nImage = (dwStyle & NCBTNS_DISABLED) ? IIMAGE_NOZOOMIN : IIMAGE_ZOOMIN; break; case ID_ENVELOPE_ZOOM_OUT: nImage = (dwStyle & NCBTNS_DISABLED) ? IIMAGE_NOZOOMOUT : IIMAGE_ZOOMOUT; break; + case ID_ENVELOPE_LOAD: nImage = IIMAGE_LOAD; break; + case ID_ENVELOPE_SAVE: nImage = IIMAGE_SAVE; break; } pDC->Draw3dRect(rect.left-1, rect.top-1, ENV_LEFTBAR_CXBTN+2, ENV_LEFTBAR_CYBTN+2, c3, c4); pDC->Draw3dRect(rect.left, rect.top, ENV_LEFTBAR_CXBTN, ENV_LEFTBAR_CYBTN, c1, c2); @@ -2219,6 +2230,8 @@ case kcInstrumentNew: SendCtrlMessage(IDC_INSTRUMENT_NEW); return wParam; // envelope editor + case kcInstrumentEnvelopeLoad: OnEnvLoad(); return wParam; + case kcInstrumentEnvelopeSave: OnEnvSave(); return wParam; case kcInstrumentEnvelopeZoomIn: OnEnvZoomIn(); return wParam; case kcInstrumentEnvelopeZoomOut: OnEnvZoomOut(); return wParam; case kcInstrumentEnvelopePointPrev: EnvKbdSelectPrevPoint(); return wParam; @@ -2528,4 +2541,47 @@ } +void CViewInstrument::OnEnvLoad() +//------------------------------- +{ + if(GetInstrumentPtr() == nullptr) return; + + FileDialog dlg = OpenFileDialog() + .DefaultExtension("envelope") + .ExtensionFilter("Instrument Envelopes (*.envelope)|*.envelope||") + .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_INSTRUMENTS)); + if(!dlg.Show(this)) return; + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_INSTRUMENTS); + + if(GetDocument()->LoadEnvelope(m_nInstrument, m_nEnv, dlg.GetFirstFile())) + { + SetModified(InstrumentHint(m_nInstrument).Envelope(), true); + } +} + + +void CViewInstrument::OnEnvSave() +//------------------------------- +{ + InstrumentEnvelope *env = GetEnvelopePtr(); + if(env == nullptr || env->nNodes == 0) + { + MessageBeep(MB_ICONWARNING); + return; + } + + FileDialog dlg = SaveFileDialog() + .DefaultExtension("envelope") + .ExtensionFilter("Instrument Envelopes (*.envelope)|*.envelope||") + .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_INSTRUMENTS)); + if(!dlg.Show(this)) return; + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_INSTRUMENTS); + + if(!GetDocument()->SaveEnvelope(m_nInstrument, m_nEnv, dlg.GetFirstFile())) + { + Reporting::Error(L"Unable to save file " + dlg.GetFirstFile().ToWide(), L"OpenMPT", this); + } +} + + OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/View_ins.h =================================================================== --- trunk/OpenMPT/mptrack/View_ins.h 2015-03-03 17:39:05 UTC (rev 4814) +++ trunk/OpenMPT/mptrack/View_ins.h 2015-03-03 19:02:34 UTC (rev 4815) @@ -18,7 +18,7 @@ #define INSSTATUS_SPLITCURSOR 0x04 // Non-Client toolbar buttons -#define ENV_LEFTBAR_BUTTONS 19 +#define ENV_LEFTBAR_BUTTONS 22 //========================================== class CViewInstrument: public CModScrollView @@ -204,7 +204,9 @@ afx_msg void OnEnvPanChanged(); afx_msg void OnEnvPitchChanged(); afx_msg void OnEnvFilterChanged(); - afx_msg void OnEnvToggleGrid(); //rewbs.envRowGrid + afx_msg void OnEnvToggleGrid(); + afx_msg void OnEnvLoad(); + afx_msg void OnEnvSave(); afx_msg void OnEditCopy(); afx_msg void OnEditPaste(); afx_msg void OnEditSampleMap(); Modified: trunk/OpenMPT/mptrack/res/envelope_toolbar.png =================================================================== (Binary files differ) Modified: trunk/OpenMPT/mptrack/res/originals/envelope_toolbar.pfi =================================================================== (Binary files differ) Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2015-03-03 17:39:05 UTC (rev 4814) +++ trunk/OpenMPT/mptrack/resource.h 2015-03-03 19:02:34 UTC (rev 4815) @@ -1227,6 +1227,8 @@ #define ID_HELP_EXAMPLEMODULES 44459 #define ID_FILE_SAVEASTEMPLATE 44460 #define ID_ORDERLIST_INSERT_SEPARATOR 44461 +#define ID_ENVELOPE_LOAD 44462 +#define ID_ENVELOPE_SAVE 44463 #define ID_PLUGINEDITOR_SLIDERS_BASE 44500 // From here: Command range [ID_PLUGINEDITOR_SLIDERS_BASE, ID_PLUGINEDITOR_SLIDERS_BASE + NUM_PLUGINEDITOR_PARAMETERS] #define ID_PLUGINEDITOR_EDIT_BASE 44550 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-08 09:53:28
|
Revision: 4835 http://sourceforge.net/p/modplug/code/4835 Author: manxorist Date: 2015-03-08 09:53:22 +0000 (Sun, 08 Mar 2015) Log Message: ----------- [Ref] Template Util::AlignDown and Util::AlignUp. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-03-07 16:54:34 UTC (rev 4834) +++ trunk/OpenMPT/common/misc_util.h 2015-03-08 09:53:22 UTC (rev 4835) @@ -529,13 +529,15 @@ } // rounds x up to multiples of target - forceinline uint32 AlignUp(uint32 x, uint32 target) + template <typename T> + T AlignUp(T x, T target) { return ((x + (target - 1)) / target) * target; } // rounds x down to multiples of target - forceinline uint32 AlignDown(uint32 x, uint32 target) + template <typename T> + T AlignDown(T x, T target) { return (x / target) * target; } Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-03-07 16:54:34 UTC (rev 4834) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-03-08 09:53:22 UTC (rev 4835) @@ -220,8 +220,8 @@ } m_bMixRunning = FALSE; m_nDSoundBufferSize = Util::Round<int32>(m_Settings.Latency * pwfx->nAvgBytesPerSec); - m_nDSoundBufferSize = Util::AlignUp(m_nDSoundBufferSize, bytesPerFrame); - m_nDSoundBufferSize = Clamp(m_nDSoundBufferSize, Util::AlignUp(DSBSIZE_MIN, bytesPerFrame), Util::AlignDown(DSBSIZE_MAX, bytesPerFrame)); + m_nDSoundBufferSize = Util::AlignUp<uint32>(m_nDSoundBufferSize, bytesPerFrame); + m_nDSoundBufferSize = Clamp(m_nDSoundBufferSize, Util::AlignUp<uint32>(DSBSIZE_MIN, bytesPerFrame), Util::AlignDown<uint32>(DSBSIZE_MAX, bytesPerFrame)); if(!m_Settings.ExclusiveMode) { // Set the format of the primary buffer Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-03-07 16:54:34 UTC (rev 4834) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-03-08 09:53:22 UTC (rev 4835) @@ -155,8 +155,8 @@ return false; } m_nWaveBufferSize = Util::Round<int32>(m_Settings.UpdateInterval * pwfx->nAvgBytesPerSec); - m_nWaveBufferSize = Util::AlignUp(m_nWaveBufferSize, pwfx->nBlockAlign); - m_nWaveBufferSize = Clamp(m_nWaveBufferSize, static_cast<uint32>(WAVEOUT_MINBUFFERFRAMECOUNT * pwfx->nBlockAlign), static_cast<uint32>(Util::AlignDown(WAVEOUT_MAXBUFFERSIZE, pwfx->nBlockAlign))); + m_nWaveBufferSize = Util::AlignUp<uint32>(m_nWaveBufferSize, pwfx->nBlockAlign); + m_nWaveBufferSize = Clamp(m_nWaveBufferSize, static_cast<uint32>(WAVEOUT_MINBUFFERFRAMECOUNT * pwfx->nBlockAlign), static_cast<uint32>(Util::AlignDown<uint32>(WAVEOUT_MAXBUFFERSIZE, pwfx->nBlockAlign))); std::size_t numBuffers = Util::Round<int32>(m_Settings.Latency * pwfx->nAvgBytesPerSec / m_nWaveBufferSize); numBuffers = Clamp(numBuffers, WAVEOUT_MINBUFFERS, WAVEOUT_MAXBUFFERS); m_nPreparedHeaders = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-08 12:40:21
|
Revision: 4838 http://sourceforge.net/p/modplug/code/4838 Author: manxorist Date: 2015-03-08 12:40:08 +0000 (Sun, 08 Mar 2015) Log Message: ----------- [Ref] Silence a 64bit warning. Modified Paths: -------------- trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2015-03-08 11:12:40 UTC (rev 4837) +++ trunk/OpenMPT/mptrack/Vstplug.h 2015-03-08 12:40:08 UTC (rev 4838) @@ -394,7 +394,7 @@ public: static char s_szHostProductString[64]; static char s_szHostVendorString[64]; - static VstIntPtr s_nHostVendorVersion; + static VstInt32 s_nHostVendorVersion; #else // NO_VST public: Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2015-03-08 11:12:40 UTC (rev 4837) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2015-03-08 12:40:08 UTC (rev 4838) @@ -33,7 +33,7 @@ char CVstPluginManager::s_szHostProductString[64] = "OpenMPT"; char CVstPluginManager::s_szHostVendorString[64] = "OpenMPT project"; -VstIntPtr CVstPluginManager::s_nHostVendorVersion = MptVersion::num; +VstInt32 CVstPluginManager::s_nHostVendorVersion = MptVersion::num; typedef AEffect * (VSTCALLBACK * PVSTPLUGENTRY)(audioMasterCallback); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-03-10 18:20:42
|
Revision: 4853 http://sourceforge.net/p/modplug/code/4853 Author: saga-games Date: 2015-03-10 18:20:29 +0000 (Tue, 10 Mar 2015) Log Message: ----------- [Imp] Add keyboard shortcuts for channel transpose and channel duplicate [Mod] OpenMPT: Version is now 1.24.02.05 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/View_pat.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-03-10 17:45:38 UTC (rev 4852) +++ trunk/OpenMPT/common/versionNumber.h 2015-03-10 18:20:29 UTC (rev 4853) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 04 +#define VER_MINORMINOR 05 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2015-03-10 17:45:38 UTC (rev 4852) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2015-03-10 18:20:29 UTC (rev 4853) @@ -676,6 +676,8 @@ DefineKeyCommand(kcSampleCenterSustainEnd, 1919, _T("Center sustain loop end in view")); DefineKeyCommand(kcInstrumentEnvelopeLoad, 1920, _T("Load Envelope")); DefineKeyCommand(kcInstrumentEnvelopeSave, 1921, _T("Save Envelope")); + DefineKeyCommand(kcChannelTranspose, 1922, _T("Transpose Channel")); + DefineKeyCommand(kcChannelDuplicate, 1923, _T("Duplicate Channel")); Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2015-03-10 17:45:38 UTC (rev 4852) +++ trunk/OpenMPT/mptrack/CommandSet.h 2015-03-10 18:20:29 UTC (rev 4853) @@ -287,6 +287,8 @@ kcChannelRecordSelect, kcChannelSplitRecordSelect, kcChannelReset, + kcChannelTranspose, + kcChannelDuplicate, kcChannelSettings, kcEndChannelKeys = kcChannelSettings, kcCopyAndLoseSelection, Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2015-03-10 17:45:38 UTC (rev 4852) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2015-03-10 18:20:29 UTC (rev 4853) @@ -2894,7 +2894,7 @@ void CViewPattern::OnTransposeChannel() //------------------------------------- { - CInputDlg dlg(this, "Enter transpose amount:", -(NOTE_MAX - NOTE_MIN), (NOTE_MAX - NOTE_MIN), m_nTransposeAmount); + CInputDlg dlg(this, "Enter transpose amount (affects all patterns):", -(NOTE_MAX - NOTE_MIN), (NOTE_MAX - NOTE_MIN), m_nTransposeAmount); if(dlg.DoModal() == IDOK) { m_nTransposeAmount = dlg.resultNumber; @@ -4540,6 +4540,8 @@ quickChannelProperties.Show(GetDocument(), m_Cursor.GetChannel(), m_nPattern, CPoint(windowPos.left + windowPos.Width() / 2, windowPos.top + windowPos.Height() / 2)); return wParam; } + case kcChannelTranspose: m_MenuCursor = m_Cursor; OnTransposeChannel(); return wParam; + case kcChannelDuplicate: m_MenuCursor = m_Cursor; OnDuplicateChannel(); return wParam; case kcDecreaseSpacing: if(m_nSpacing > 0) SetSpacing(m_nSpacing - 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-10 19:21:00
|
Revision: 4855 http://sourceforge.net/p/modplug/code/4855 Author: manxorist Date: 2015-03-10 19:20:54 +0000 (Tue, 10 Mar 2015) Log Message: ----------- [Ref] Kill SettingMetadata which remained unused. Modified Paths: -------------- trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/mptrack/Settings.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2015-03-10 18:24:07 UTC (rev 4854) +++ trunk/OpenMPT/mptrack/Settings.cpp 2015-03-10 19:20:54 UTC (rev 4855) @@ -140,7 +140,7 @@ backend->RemoveSetting(path); } -SettingValue SettingsContainer::ReadSetting(const SettingPath &path, const SettingValue &def, const SettingMetadata &metadata) const +SettingValue SettingsContainer::ReadSetting(const SettingPath &path, const SettingValue &def) const { ASSERT(theApp.InGuiThread()); ASSERT(!CMainFrame::GetMainFrame() || (CMainFrame::GetMainFrame() && !CMainFrame::GetMainFrame()->InNotifyHandler())); // This is a slow path, use CachedSetting for stuff that is accessed in notify handler. @@ -148,7 +148,6 @@ if(entry == map.end()) { entry = map.insert(map.begin(), std::make_pair(path, SettingState(def).assign(BackendsReadSetting(path, def), false))); - mapMetadata[path] = metadata; } return entry->second; } @@ -250,7 +249,7 @@ #else // !MPT_SETTINGS_CACHE -SettingValue SettingsContainer::ReadSetting(const SettingPath &path, const SettingValue &def, const SettingMetadata & /*metadata*/ ) const +SettingValue SettingsContainer::ReadSetting(const SettingPath &path, const SettingValue &def) const { return backend->ReadSetting(path, def); } Modified: trunk/OpenMPT/mptrack/Settings.h =================================================================== --- trunk/OpenMPT/mptrack/Settings.h 2015-03-10 18:24:07 UTC (rev 4854) +++ trunk/OpenMPT/mptrack/Settings.h 2015-03-10 19:20:54 UTC (rev 4855) @@ -469,27 +469,6 @@ }; -#if defined(MPT_SETTINGS_CACHE) - -struct SettingMetadata -{ - mpt::ustring description; - SettingMetadata() {} - SettingMetadata(const AnyStringLocale &description) - : description(description) - { - return; - } -}; - -#else // !MPT_SETTINGS_CACHE - -struct SettingMetadata -{ -}; - -#endif // MPT_SETTINGS_CACHE - class ISettingChanged { public: @@ -511,11 +490,9 @@ public: typedef std::map<SettingPath,SettingState> SettingsMap; - typedef std::map<SettingPath,SettingMetadata> SettingsMetaMap; typedef std::map<SettingPath,std::set<ISettingChanged*> > SettingsListenerMap; private: mutable SettingsMap map; - mutable SettingsMetaMap mapMetadata; mutable SettingsListenerMap mapListeners; void WriteSettings(); @@ -529,7 +506,7 @@ void BackendsWriteSetting(const SettingPath &path, const SettingValue &val); void BackendsRemoveSetting(const SettingPath &path); void NotifyListeners(const SettingPath &path); - SettingValue ReadSetting(const SettingPath &path, const SettingValue &def, const SettingMetadata &metadata) const; + SettingValue ReadSetting(const SettingPath &path, const SettingValue &def) const; void WriteSetting(const SettingPath &path, const SettingValue &val, SettingFlushMode flushMode); void ForgetSetting(const SettingPath &path); void RemoveSetting(const SettingPath &path); @@ -540,14 +517,14 @@ SettingsContainer(ISettingsBackend *backend); void SetImmediateFlush(bool newImmediateFlush); template <typename T> - T Read(const SettingPath &path, const T &def = T(), const SettingMetadata &metadata = SettingMetadata()) const + T Read(const SettingPath &path, const T &def = T()) const { - return FromSettingValue<T>(ReadSetting(path, ToSettingValue<T>(def), metadata)); + return FromSettingValue<T>(ReadSetting(path, ToSettingValue<T>(def))); } template <typename T> - T Read(const AnyStringLocale §ion, const AnyStringLocale &key, const T &def = T(), const SettingMetadata &metadata = SettingMetadata()) const + T Read(const AnyStringLocale §ion, const AnyStringLocale &key, const T &def = T()) const { - return FromSettingValue<T>(ReadSetting(SettingPath(section, key), ToSettingValue<T>(def), metadata)); + return FromSettingValue<T>(ReadSetting(SettingPath(section, key), ToSettingValue<T>(def))); } template <typename T> void Write(const SettingPath &path, const T &val, SettingFlushMode flushMode = SettingWriteBack) @@ -623,17 +600,17 @@ return; } public: - Setting(SettingsContainer &conf_, const AnyStringLocale §ion, const AnyStringLocale &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) + Setting(SettingsContainer &conf_, const AnyStringLocale §ion, const AnyStringLocale &key, const T&def) : conf(conf_) , path(section, key) { - conf.Read(path, def, metadata); // set default value + conf.Read(path, def); // set default value } - Setting(SettingsContainer &conf_, const SettingPath &path_, const T&def, const SettingMetadata &metadata = SettingMetadata()) + Setting(SettingsContainer &conf_, const SettingPath &path_, const T&def) : conf(conf_) , path(path_) { - conf.Read(path, def, metadata); // set default value + conf.Read(path, def); // set default value } SettingPath GetPath() const { @@ -679,20 +656,20 @@ conf.Register(this, path); } public: - CachedSetting(SettingsContainer &conf_, const AnyStringLocale §ion, const AnyStringLocale &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) + CachedSetting(SettingsContainer &conf_, const AnyStringLocale §ion, const AnyStringLocale &key, const T&def) : value(def) , conf(conf_) , path(section, key) { - value = conf.Read(path, def, metadata); + value = conf.Read(path, def); conf.Register(this, path); } - CachedSetting(SettingsContainer &conf_, const SettingPath &path_, const T&def, const SettingMetadata &metadata = SettingMetadata()) + CachedSetting(SettingsContainer &conf_, const SettingPath &path_, const T&def) : value(def) , conf(conf_) , path(path_) { - value = conf.Read(path, def, metadata); + value = conf.Read(path, def); conf.Register(this, path); } ~CachedSetting() @@ -755,19 +732,19 @@ return; } public: - Setting(SettingsContainer &conf_, const AnyStringLocale §ion, const AnyStringLocale &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) + Setting(SettingsContainer &conf_, const AnyStringLocale §ion, const AnyStringLocale &key, const T&def) : value(def) , conf(conf_) , path(section, key) { - value = conf.Read(path, def, metadata); + value = conf.Read(path, def); } - Setting(SettingsContainer &conf_, const SettingPath &path_, const T&def, const SettingMetadata &metadata = SettingMetadata()) + Setting(SettingsContainer &conf_, const SettingPath &path_, const T&def) : value(def) , conf(conf_) , path(path_) { - value = conf.Read(path, def, metadata); + value = conf.Read(path, def); } ~Setting() { Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2015-03-10 18:24:07 UTC (rev 4854) +++ trunk/OpenMPT/test/test.cpp 2015-03-10 19:20:54 UTC (rev 4855) @@ -941,7 +941,7 @@ { DefaultSettingsContainer conf; - int32 foobar = conf.Read("Test", "bar", 23, SettingMetadata("foobar")); + int32 foobar = conf.Read("Test", "bar", 23); conf.Write("Test", "bar", 64); conf.Write("Test", "bar", 42); conf.Read("Test", "baz", 4711); @@ -951,7 +951,7 @@ { DefaultSettingsContainer conf; - int32 foobar = conf.Read("Test", "bar", 28, SettingMetadata("foobar")); + int32 foobar = conf.Read("Test", "bar", 28); VERIFY_EQUAL(foobar, 42); conf.Write("Test", "bar", 43); } @@ -959,7 +959,7 @@ { DefaultSettingsContainer conf; - int32 foobar = conf.Read("Test", "bar", 123, SettingMetadata("foobar")); + int32 foobar = conf.Read("Test", "bar", 123); VERIFY_EQUAL(foobar, 43); conf.Write("Test", "bar", 88); } @@ -967,7 +967,7 @@ { DefaultSettingsContainer conf; - Setting<int> foo(conf, "Test", "bar", 99, SettingMetadata("something")); + Setting<int> foo(conf, "Test", "bar", 99); VERIFY_EQUAL(foo, 88); @@ -977,7 +977,7 @@ { DefaultSettingsContainer conf; - Setting<int> foo(conf, "Test", "bar", 99, SettingMetadata("something")); + Setting<int> foo(conf, "Test", "bar", 99); VERIFY_EQUAL(foo, 7); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-10 21:33:09
|
Revision: 4856 http://sourceforge.net/p/modplug/code/4856 Author: manxorist Date: 2015-03-10 21:33:04 +0000 (Tue, 10 Mar 2015) Log Message: ----------- [Ref] Remove dead code. Modified Paths: -------------- trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2015-03-10 19:20:54 UTC (rev 4855) +++ trunk/OpenMPT/mptrack/Vstplug.h 2015-03-10 21:33:04 UTC (rev 4856) @@ -374,7 +374,6 @@ bool RemovePlugin(VSTPluginLib *); bool CreateMixPlugin(SNDMIXPLUGIN &, CSoundFile &); void OnIdle(); - static void ReportPlugException(LPCSTR format,...); static void ReportPlugException(const std::wstring &msg); static void ReportPlugException(const std::string &msg); Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2015-03-10 19:20:54 UTC (rev 4855) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2015-03-10 21:33:04 UTC (rev 4856) @@ -630,20 +630,6 @@ } -void CVstPluginManager::ReportPlugException(LPCSTR format,...) -//------------------------------------------------------------ -{ - CHAR cBuf[1024]; - va_list va; - va_start(va, format); - wvsprintf(cBuf, format, va); - Reporting::Notification(cBuf); -#ifdef VST_LOG - Log(cBuf); -#endif - va_end(va); -} - void CVstPluginManager::ReportPlugException(const std::string &msg) { Reporting::Notification(msg.c_str()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-11 12:28:48
|
Revision: 4859 http://sourceforge.net/p/modplug/code/4859 Author: manxorist Date: 2015-03-11 12:28:42 +0000 (Wed, 11 Mar 2015) Log Message: ----------- [Ref] Replace a couple of Stringify with mpt::ToString. [Ref] Do not provide Stringify macro for libopenmpt anymore. It's only still used in tracker code now. Modified Paths: -------------- trunk/OpenMPT/common/mptString.h trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/soundlib/tuning.cpp trunk/OpenMPT/soundlib/tuningbase.cpp trunk/OpenMPT/soundlib/tuningcollection.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2015-03-11 12:26:01 UTC (rev 4858) +++ trunk/OpenMPT/common/mptString.h 2015-03-11 12:28:42 UTC (rev 4859) @@ -929,10 +929,12 @@ } // namespace mpt +#ifdef MODPLUG_TRACKER #define Stringify(x) mpt::ToString(x) #if MPT_WSTRING_FORMAT #define StringifyW(x) mpt::ToWString(x) #endif +#endif namespace mpt { namespace String { Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2015-03-11 12:26:01 UTC (rev 4858) +++ trunk/OpenMPT/mptrack/Settings.cpp 2015-03-11 12:28:42 UTC (rev 4859) @@ -315,7 +315,7 @@ double IniFileSettingsBackend::ReadSettingRaw(const SettingPath &path, double def) const { std::vector<WCHAR> buf(128); - while(::GetPrivateProfileStringW(GetSection(path).c_str(), GetKey(path).c_str(), StringifyW(def).c_str(), &buf[0], static_cast<DWORD>(buf.size()), filename.AsNative().c_str()) == buf.size() - 1) + while(::GetPrivateProfileStringW(GetSection(path).c_str(), GetKey(path).c_str(), mpt::ToWString(def).c_str(), &buf[0], static_cast<DWORD>(buf.size()), filename.AsNative().c_str()) == buf.size() - 1) { if(buf.size() == std::numeric_limits<DWORD>::max()) { @@ -363,17 +363,17 @@ void IniFileSettingsBackend::WriteSettingRaw(const SettingPath &path, double val) { - ::WritePrivateProfileStringW(GetSection(path).c_str(), GetKey(path).c_str(), StringifyW(val).c_str(), filename.AsNative().c_str()); + ::WritePrivateProfileStringW(GetSection(path).c_str(), GetKey(path).c_str(), mpt::ToWString(val).c_str(), filename.AsNative().c_str()); } void IniFileSettingsBackend::WriteSettingRaw(const SettingPath &path, int32 val) { - ::WritePrivateProfileStringW(GetSection(path).c_str(), GetKey(path).c_str(), StringifyW(val).c_str(), filename.AsNative().c_str()); + ::WritePrivateProfileStringW(GetSection(path).c_str(), GetKey(path).c_str(), mpt::ToWString(val).c_str(), filename.AsNative().c_str()); } void IniFileSettingsBackend::WriteSettingRaw(const SettingPath &path, bool val) { - ::WritePrivateProfileStringW(GetSection(path).c_str(), GetKey(path).c_str(), StringifyW(val).c_str(), filename.AsNative().c_str()); + ::WritePrivateProfileStringW(GetSection(path).c_str(), GetKey(path).c_str(), mpt::ToWString(val).c_str(), filename.AsNative().c_str()); } void IniFileSettingsBackend::RemoveSettingRaw(const SettingPath &path) Modified: trunk/OpenMPT/soundlib/tuning.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuning.cpp 2015-03-11 12:26:01 UTC (rev 4858) +++ trunk/OpenMPT/soundlib/tuning.cpp 2015-03-11 12:28:42 UTC (rev 4859) @@ -165,7 +165,7 @@ if(nmi != m_NoteNameMap.end()) { rValue = nmi->second; - (x >= 0) ? rValue += Stringify(middlePeriodNumber + x/m_GroupSize) : rValue += Stringify(middlePeriodNumber + (x+1)/m_GroupSize - 1); + (x >= 0) ? rValue += mpt::ToString(middlePeriodNumber + x/m_GroupSize) : rValue += mpt::ToString(middlePeriodNumber + (x+1)/m_GroupSize - 1); } else { @@ -176,7 +176,7 @@ rValue += ":"; - (x >= 0) ? rValue += Stringify(middlePeriodNumber + x/m_GroupSize) : rValue += Stringify(middlePeriodNumber + (x+1)/m_GroupSize - 1); + (x >= 0) ? rValue += mpt::ToString(middlePeriodNumber + x/m_GroupSize) : rValue += mpt::ToString(middlePeriodNumber + (x+1)/m_GroupSize - 1); } return rValue; } Modified: trunk/OpenMPT/soundlib/tuningbase.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuningbase.cpp 2015-03-11 12:26:01 UTC (rev 4858) +++ trunk/OpenMPT/soundlib/tuningbase.cpp 2015-03-11 12:28:42 UTC (rev 4859) @@ -198,7 +198,7 @@ if(i != m_NoteNameMap.end()) return i->second; else - return Stringify(x); + return mpt::ToString(x); } Modified: trunk/OpenMPT/soundlib/tuningcollection.h =================================================================== --- trunk/OpenMPT/soundlib/tuningcollection.h 2015-03-11 12:26:01 UTC (rev 4858) +++ trunk/OpenMPT/soundlib/tuningcollection.h 2015-03-11 12:28:42 UTC (rev 4859) @@ -104,7 +104,7 @@ mpt::PathString GetSaveFilePath() const {return m_SavefilePath;} #endif // MODPLUG_NO_FILESAVE - std::string GetVersionString() const {return Stringify(static_cast<int>(s_SerializationVersion));} + std::string GetVersionString() const {return mpt::ToString(static_cast<int>(s_SerializationVersion));} size_t GetNameLengthMax() const {return 256;} Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2015-03-11 12:26:01 UTC (rev 4858) +++ trunk/OpenMPT/test/test.cpp 2015-03-11 12:28:42 UTC (rev 4859) @@ -396,15 +396,15 @@ //----------------------------------------- { - VERIFY_EQUAL(Stringify(1.5f), "1.5"); - VERIFY_EQUAL(Stringify(true), "1"); - VERIFY_EQUAL(Stringify(false), "0"); - //VERIFY_EQUAL(Stringify('A'), "A"); // deprecated - //VERIFY_EQUAL(Stringify(L'A'), "A"); // deprecated + VERIFY_EQUAL(mpt::ToString(1.5f), "1.5"); + VERIFY_EQUAL(mpt::ToString(true), "1"); + VERIFY_EQUAL(mpt::ToString(false), "0"); + //VERIFY_EQUAL(mpt::ToString('A'), "A"); // deprecated + //VERIFY_EQUAL(mpt::ToString(L'A'), "A"); // deprecated - VERIFY_EQUAL(Stringify(0), "0"); - VERIFY_EQUAL(Stringify(-23), "-23"); - VERIFY_EQUAL(Stringify(42), "42"); + VERIFY_EQUAL(mpt::ToString(0), "0"); + VERIFY_EQUAL(mpt::ToString(-23), "-23"); + VERIFY_EQUAL(mpt::ToString(42), "42"); VERIFY_EQUAL(mpt::fmt::hex<3>((int32)-1), "ffffffff"); VERIFY_EQUAL(mpt::fmt::hex(0x123e), "123e"); @@ -418,15 +418,15 @@ VERIFY_EQUAL(mpt::wfmt::hex0<2>(0x123e), L"123e"); #endif - VERIFY_EQUAL(Stringify(-87.0f), "-87"); - if(Stringify(-0.5e-6) != "-5e-007" - && Stringify(-0.5e-6) != "-5e-07" - && Stringify(-0.5e-6) != "-5e-7" + VERIFY_EQUAL(mpt::ToString(-87.0f), "-87"); + if(mpt::ToString(-0.5e-6) != "-5e-007" + && mpt::ToString(-0.5e-6) != "-5e-07" + && mpt::ToString(-0.5e-6) != "-5e-7" ) { VERIFY_EQUAL(true, false); } - VERIFY_EQUAL(Stringify(58.65403492763), "58.654"); + VERIFY_EQUAL(mpt::ToString(58.65403492763), "58.654"); VERIFY_EQUAL(mpt::Format("%3.1f").ToString(23.42), "23.4"); VERIFY_EQUAL(ConvertStrTo<uint32>("586"), 586u); @@ -445,8 +445,8 @@ VERIFY_EQUAL(ConvertStrTo<double>("-0.5e-6"), -0.5e-6); VERIFY_EQUAL(ConvertStrTo<double>("58.65403492763"), 58.65403492763); - VERIFY_EQUAL(ConvertStrTo<float>(Stringify(-87.0)), -87.0); - VERIFY_EQUAL(ConvertStrTo<double>(Stringify(-0.5e-6)), -0.5e-6); + VERIFY_EQUAL(ConvertStrTo<float>(mpt::ToString(-87.0)), -87.0); + VERIFY_EQUAL(ConvertStrTo<double>(mpt::ToString(-0.5e-6)), -0.5e-6); TestFloatFormats(0.0f); TestFloatFormats(1.0f); @@ -922,7 +922,7 @@ template <> inline SettingValue ToSettingValue(const Test::CustomSettingsTestType &val) { - return SettingValue(Stringify(val.x) + "|" + Stringify(val.y), "myType"); + return SettingValue(mpt::ToString(val.x) + "|" + mpt::ToString(val.y), "myType"); } namespace Test { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-03-11 14:16:07
|
Revision: 4862 http://sourceforge.net/p/modplug/code/4862 Author: saga-games Date: 2015-03-11 14:15:51 +0000 (Wed, 11 Mar 2015) Log Message: ----------- [Mod] The MPTM volume column offset command has been revamped: In the sample editor, 9 custom cue points can be selected for each sample, which can then be triggered using o01... o09. [Mod] Related changes (e.g. showing proper value readout for volume column effects in the note properties) [Mod] OpenMPT: Version is now 1.24.02.06 Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/AppendModule.cpp trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/EffectInfo.cpp trunk/OpenMPT/mptrack/EffectInfo.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/MPTrackUtil.h trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/PatternClipboard.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_smp.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_mtm.cpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/ModSample.cpp trunk/OpenMPT/soundlib/ModSample.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/soundlib/WAVTools.h trunk/OpenMPT/soundlib/modcommand.cpp trunk/OpenMPT/soundlib/modcommand.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.h trunk/OpenMPT/test/test.cpp trunk/OpenMPT/test/test.mptm Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/common/misc_util.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -574,6 +574,71 @@ return (x / target) * target; } + // Insert a range of items [insStart, insEnd], and possibly shift item fix to the left. + template<typename T> + void InsertItem(const T insStart, const T insEnd, T &fix) + { + ASSERT(insEnd >= insStart); + if(fix >= insStart) + { + fix += (insEnd - insStart + 1); + } + } + + // Insert a range of items [insStart, insEnd], and possibly shift items in range [fixStart, fixEnd] to the right. + template<typename T> + void InsertRange(const T insStart, const T insEnd, T &fixStart, T &fixEnd) + { + ASSERT(insEnd >= insStart); + const T insLength = insEnd - insStart + 1; + if(fixStart >= insEnd) + { + fixStart += insLength; + } + if(fixEnd >= insEnd) + { + fixEnd += insLength; + } + } + + // Delete a range of items [delStart, delEnd], and possibly shift item fix to the left. + template<typename T> + void DeleteItem(const T delStart, const T delEnd, T &fix) + { + ASSERT(delEnd >= delStart); + if(fix > delEnd) + { + fix -= (delEnd - delStart + 1); + } + } + + // Delete a range of items [delStart, delEnd], and possibly shift items in range [fixStart, fixEnd] to the left. + template<typename T> + void DeleteRange(const T delStart, const T delEnd, T &fixStart, T &fixEnd) + { + ASSERT(delEnd >= delStart); + const T delLength = delEnd - delStart + 1; + if(delStart < fixStart && delEnd < fixStart) + { + // cut part is before loop start + fixStart -= delLength; + fixEnd -= delLength; + } else if(delStart < fixStart && delEnd < fixEnd) + { + // cut part is partly before loop start + fixStart = delStart; + fixEnd -= delLength; + } else if(delStart >= fixStart && delEnd < fixEnd) + { + // cut part is in the loop + fixEnd -= delLength; + } else if(delStart >= fixStart && delStart < fixEnd && delEnd > fixEnd) + { + // cut part is partly before loop end + fixEnd = delStart; + } + } + // Greatest Common Divisor. Always returns non-negative number. template <class T> T gcd(T a, T b) Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/common/versionNumber.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 05 +#define VER_MINORMINOR 06 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/AppendModule.cpp =================================================================== --- trunk/OpenMPT/mptrack/AppendModule.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/AppendModule.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -272,7 +272,7 @@ for(CHANNELINDEX chn = 0; chn < copyChannels; chn++, src++, m++) { *m = *src; - m->Convert(source.GetType(), m_SndFile.GetType()); + m->Convert(source.GetType(), m_SndFile.GetType(), source); if(m->IsPcNote()) { if(m->instr && m->instr < pluginMapping.size()) m->instr = static_cast<ModCommand::INSTR>(pluginMapping[m->instr]); Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -471,7 +471,7 @@ DefineKeyCommand(kcSampleZoomUp, 1386, _T("Zoom Out")); DefineKeyCommand(kcSampleZoomDown, 1387, _T("Zoom In")); //time saving HACK: - for(size_t j = kcSampStartNotes; j <= kcInsNoteMapEndNoteStops; j++) + for(int j = kcSampStartNotes; j <= kcInsNoteMapEndNoteStops; j++) { DefineKeyCommand((CommandID)j, 1388 + j - kcSampStartNotes, _T("Auto Note in some context"), kcHidden, kcNoDummy); } @@ -511,7 +511,7 @@ DefineKeyCommand(kcPrevDocument, 1693, _T("Previous Document")); DefineKeyCommand(kcNextDocument, 1694, _T("Next Document")); //time saving HACK: - for(size_t j = kcVSTGUIStartNotes; j <= kcVSTGUIEndNoteStops; j++) + for(int j = kcVSTGUIStartNotes; j <= kcVSTGUIEndNoteStops; j++) { DefineKeyCommand((CommandID)j, 1695 + j - kcVSTGUIStartNotes, _T("Auto Note in some context"), kcHidden, kcNoDummy); } @@ -678,6 +678,12 @@ DefineKeyCommand(kcInstrumentEnvelopeSave, 1921, _T("Save Envelope")); DefineKeyCommand(kcChannelTranspose, 1922, _T("Transpose Channel")); DefineKeyCommand(kcChannelDuplicate, 1923, _T("Duplicate Channel")); + for(int j = kcStartSampleCues; j <= kcEndSampleCues; j++) + { + TCHAR s[32]; + wsprintf(s, "Preview Sample Cue %u", j - kcStartSampleCues + 1); + DefineKeyCommand((CommandID)j, 1924 + j - kcStartSampleCues, s); + } Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/CommandSet.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -699,6 +699,9 @@ kcSampleAutotune, kcEndSampleEditing=kcSampleAutotune, + kcStartSampleCues, + kcEndSampleCues = kcStartSampleCues + 8, + //kcSampStartNotes to kcInsNoteMapEndNoteStops must be contiguous. kcSampStartNotes, kcSampNoteC_0=kcSampStartNotes, Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -331,10 +331,7 @@ if(isPlaying && sndFile.m_SongFlags[SONG_PATTERNLOOP]) { - sndFile.m_PlayState.m_nPattern = n; - sndFile.m_PlayState.m_nCurrentOrder = sndFile.m_PlayState.m_nNextOrder = m_nScrollPos; pMainFrm->ResetNotificationBuffer(); - sndFile.m_PlayState.m_nNextRow = 0; // update channel parameters and play time m_pModDoc.SetElapsedTime(m_nScrollPos, 0, !sndFile.m_SongFlags[SONG_PAUSED | SONG_STEP]); @@ -343,13 +340,9 @@ } else if(m_pParent.GetFollowSong()) { FlagSet<SongFlags> pausedFlags = sndFile.m_SongFlags & (SONG_PAUSED | SONG_STEP | SONG_PATTERNLOOP); - - sndFile.m_PlayState.m_nCurrentOrder = m_nScrollPos; - sndFile.SetCurrentOrder(m_nScrollPos); - sndFile.m_SongFlags.set(pausedFlags); - // update channel parameters and play time m_pModDoc.SetElapsedTime(m_nScrollPos, 0, !sndFile.m_SongFlags[SONG_PAUSED | SONG_STEP]); + sndFile.m_SongFlags.set(pausedFlags); if(isPlaying) pMainFrm->ResetNotificationBuffer(); changedPos = true; Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -1601,7 +1601,9 @@ // "normal" volume command TCHAR sztmp[64] = ""; effectInfo.GetVolCmdInfo(effectInfo.GetIndexFromVolCmd(m->volcmd), sztmp); - s.Format("%s (%u)", sztmp, m->vol); + _tcscat(sztmp, _T(": ")); + effectInfo.GetVolCmdParamInfo(*m, sztmp + strlen(sztmp)); + s = sztmp; } break; Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -876,7 +876,7 @@ {VOLCMD_PORTAUP, MOD_TYPE_ITMPT, "Portamento up"}, {VOLCMD_PORTADOWN, MOD_TYPE_ITMPT, "Portamento down"}, {VOLCMD_DELAYCUT, MOD_TYPE_NONE, ""}, - {VOLCMD_OFFSET, MOD_TYPE_MPT, "Offset"}, + {VOLCMD_OFFSET, MOD_TYPE_MPT, "Sample Cue"}, }; STATIC_ASSERT(CountOf(gVolCmdInfo) == (MAX_VOLCMDS - 1)); @@ -935,4 +935,80 @@ } +bool EffectInfo::GetVolCmdParamInfo(const ModCommand &m, LPSTR s) const +//--------------------------------------------------------------------- +{ + if(s == nullptr) return false; + s[0] = 0; + + switch(m.volcmd) + { + case VOLCMD_VOLSLIDEUP: + case VOLCMD_VOLSLIDEDOWN: + case VOLCMD_FINEVOLUP: + case VOLCMD_FINEVOLDOWN: + if(m.vol > 0 || sndFile.GetType() == MOD_TYPE_XM) + { + sprintf(s, "%c%u", + (m.volcmd == VOLCMD_VOLSLIDEUP || m.volcmd == VOLCMD_FINEVOLUP) ? '+' : '-', + m.vol); + } else + { + strcpy(s, "continue"); + } + break; + + case VOLCMD_PORTAUP: + case VOLCMD_PORTADOWN: + case VOLCMD_TONEPORTAMENTO: + if(m.vol > 0) + { + ModCommand::PARAM param = m.vol << 2; + ModCommand::COMMAND cmd = CMD_PORTAMENTOUP; + if(m.volcmd == VOLCMD_PORTADOWN) + { + cmd = CMD_PORTAMENTODOWN; + } else if(m.volcmd == VOLCMD_TONEPORTAMENTO) + { + cmd = CMD_TONEPORTAMENTO; + if(sndFile.GetType() != MOD_TYPE_XM) param = ImpulseTrackerPortaVolCmd[m.vol & 0x0F]; + } + sprintf(s, "%u (%c%02X)", + m.vol, + sndFile.GetModSpecifications().GetEffectLetter(static_cast<ModCommand::COMMAND>(m.volcmd == VOLCMD_PORTAUP ? CMD_PORTAMENTOUP : CMD_PORTAMENTODOWN)), + m.vol << 2); + } else + { + strcpy(s, "continue"); + } + break; + + case VOLCMD_OFFSET: + if(m.vol) + { + SmpLength param; + SAMPLEINDEX smp = m.instr; + if(smp > 0 && smp <= sndFile.GetNumInstruments() && m.IsNote() && sndFile.Instruments[smp] != nullptr) + { + smp = sndFile.Instruments[smp]->Keyboard[m.note - NOTE_MIN]; + } + if(smp > 0 && smp <= sndFile.GetNumSamples() && m.vol > 0 && m.vol <= CountOf(sndFile.GetSample(smp).cues)) + param = sndFile.GetSample(smp).cues[m.vol - 1]; + else + param = m.vol << 11; + sprintf(s, "Cue %u: %u", m.vol, param); + } else + { + strcpy(s, "continue"); + } + break; + + default: + sprintf(s, "%u", m.vol); + break; + } + return true; +} + + OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/EffectInfo.h =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/EffectInfo.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -60,6 +60,8 @@ ModCommand::VOLCMD GetVolCmdFromIndex(UINT ndx) const; // Get range information, effect name, etc... from a given effect. bool GetVolCmdInfo(UINT ndx, LPSTR s, ModCommand::VOL *prangeMin = nullptr, ModCommand::VOL *prangeMax = nullptr) const; + // Get effect name and parameter description + bool GetVolCmdParamInfo(const ModCommand &m, LPSTR s) const; }; OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -358,6 +358,9 @@ newCat.separators.push_back(kcEndSampleEditing); //-------------------------------------- for(int c = kcStartSampleMisc; c <= kcEndSampleMisc; c++) newCat.commands.push_back(c); + newCat.separators.push_back(kcEndSampleMisc); //-------------------------------------- + for(int c = kcStartSampleCues; c <= kcEndSampleCues; c++) + newCat.commands.push_back(c); commandCategories.push_back(newCat); } Modified: trunk/OpenMPT/mptrack/MPTrackUtil.h =================================================================== --- trunk/OpenMPT/mptrack/MPTrackUtil.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/MPTrackUtil.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -31,71 +31,6 @@ namespace Util { - // Insert a range of items [insStart, insEnd], and possibly shift item fix to the left. - template<typename T> - void InsertItem(const T insStart, const T insEnd, T &fix) - { - ASSERT(insEnd >= insStart); - if(fix >= insStart) - { - fix += (insEnd - insStart + 1); - } - } - - // Insert a range of items [insStart, insEnd], and possibly shift items in range [fixStart, fixEnd] to the right. - template<typename T> - void InsertRange(const T insStart, const T insEnd, T &fixStart, T &fixEnd) - { - ASSERT(insEnd >= insStart); - const T insLength = insEnd - insStart + 1; - if(fixStart >= insEnd) - { - fixStart += insLength; - } - if(fixEnd >= insEnd) - { - fixEnd += insLength; - } - } - - // Delete a range of items [delStart, delEnd], and possibly shift item fix to the left. - template<typename T> - void DeleteItem(const T delStart, const T delEnd, T &fix) - { - ASSERT(delEnd >= delStart); - if(fix > delEnd) - { - fix -= (delEnd - delStart + 1); - } - } - - // Delete a range of items [delStart, delEnd], and possibly shift items in range [fixStart, fixEnd] to the left. - template<typename T> - void DeleteRange(const T delStart, const T delEnd, T &fixStart, T &fixEnd) - { - ASSERT(delEnd >= delStart); - const T delLength = delEnd - delStart + 1; - if(delStart < fixStart && delEnd < fixStart) - { - // cut part is before loop start - fixStart -= delLength; - fixEnd -= delLength; - } else if(delStart < fixStart && delEnd < fixEnd) - { - // cut part is partly before loop start - fixStart = delStart; - fixEnd -= delLength; - } else if(delStart >= fixStart && delEnd < fixEnd) - { - // cut part is in the loop - fixEnd -= delLength; - } else if(delStart >= fixStart && delStart < fixEnd && delEnd > fixEnd) - { - // cut part is partly before loop end - fixEnd = delStart; - } - } - // Get horizontal DPI resolution forceinline int GetDPIx(HWND hwnd) { Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -263,7 +263,7 @@ } } - m->Convert(nOldType, nNewType); + m->Convert(nOldType, nNewType, m_SndFile); // When converting to XM, avoid the E60 bug. if(newTypeIsXM) Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -2417,7 +2417,6 @@ m_SndFile.LoopPattern(nPat); else m_SndFile.LoopPattern(PATTERNINDEX_INVALID); - m_SndFile.m_PlayState.m_nNextRow = 0; // set playback timer in the status bar (and update channel status) SetElapsedTime(nOrd, 0, true); @@ -2472,7 +2471,6 @@ if ((nOrd < m_SndFile.Order.size()) && (m_SndFile.Order[nOrd] == nPat)) m_SndFile.m_PlayState.m_nCurrentOrder = m_SndFile.m_PlayState.m_nNextOrder = nOrd; m_SndFile.m_SongFlags.reset(SONG_PAUSED | SONG_STEP); m_SndFile.LoopPattern(nPat); - m_SndFile.m_PlayState.m_nNextRow = nRow; // set playback timer in the status bar (and update channel status) SetElapsedTime(nOrd, nRow, true); @@ -2530,7 +2528,6 @@ m_SndFile.DontLoopPattern(nPat, nRow); else m_SndFile.LoopPattern(nPat); - m_SndFile.m_PlayState.m_nNextRow = nRow; // set playback timer in the status bar (and update channel status) SetElapsedTime(nOrd, nRow, true); Modified: trunk/OpenMPT/mptrack/PatternClipboard.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/PatternClipboard.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -759,7 +759,7 @@ // of the old modcommand would falsely be interpreted being of type // origFormat and ConvertCommand could change them. if(pasteFormat != sndFile.GetType() && (!doMixPaste || origModCmd.IsEmpty(false))) - m.Convert(pasteFormat, sndFile.GetType()); + m.Convert(pasteFormat, sndFile.GetType(), sndFile); // Adjust pattern selection if(col == startChan) startPoint.SetColumn(startChan, firstCol); Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -896,6 +896,7 @@ sldVolParam.SetPos(0); sldVolParam.EnableWindow(FALSE); } + UpdateVolCmdValue(); } @@ -1008,9 +1009,9 @@ modDoc->UpdateAllViews(NULL, RowHint(editPos.row), NULL); if(volCmdChanged) - { UpdateVolCmdRange(); - } + else + UpdateVolCmdValue(); } } @@ -1071,6 +1072,24 @@ } +void CEditCommand::UpdateVolCmdValue() +//------------------------------------ +{ + CHAR s[64] = ""; + if(m->IsPcNote()) + { + // plugin param control note + uint16 plugParam = static_cast<uint16>(sldVolParam.GetPos()); + wsprintf(s, "Value: %u", plugParam); + } else + { + // process as effect + effectInfo.GetVolCmdParamInfo(*m, s); + } + SetDlgItemText(IDC_TEXT2, s); +} + + void CEditCommand::UpdateEffectValue(bool set) //-------------------------------------------- { Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -143,6 +143,7 @@ void InitEffect(); void UpdateVolCmdRange(); + void UpdateVolCmdValue(); void UpdateEffectRange(bool set); void UpdateEffectValue(bool set); Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -4730,14 +4730,14 @@ case kcSetVolumeVolSlideDown: volcmd = VOLCMD_VOLSLIDEDOWN; break; case kcSetVolumeFineVolUp: volcmd = VOLCMD_FINEVOLUP; break; case kcSetVolumeFineVolDown: volcmd = VOLCMD_FINEVOLDOWN; break; - case kcSetVolumeVibratoSpd: if (pSndFile->GetType() & MOD_TYPE_XM) volcmd = VOLCMD_VIBRATOSPEED; break; + case kcSetVolumeVibratoSpd: volcmd = VOLCMD_VIBRATOSPEED; break; case kcSetVolumeVibrato: volcmd = VOLCMD_VIBRATODEPTH; break; - case kcSetVolumeXMPanLeft: if (pSndFile->GetType() & MOD_TYPE_XM) volcmd = VOLCMD_PANSLIDELEFT; break; - case kcSetVolumeXMPanRight: if (pSndFile->GetType() & MOD_TYPE_XM) volcmd = VOLCMD_PANSLIDERIGHT; break; + case kcSetVolumeXMPanLeft: volcmd = VOLCMD_PANSLIDELEFT; break; + case kcSetVolumeXMPanRight: volcmd = VOLCMD_PANSLIDERIGHT; break; case kcSetVolumePortamento: volcmd = VOLCMD_TONEPORTAMENTO; break; - case kcSetVolumeITPortaUp: if (pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) volcmd = VOLCMD_PORTAUP; break; - case kcSetVolumeITPortaDown: if (pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) volcmd = VOLCMD_PORTADOWN; break; - case kcSetVolumeITOffset: if (pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) volcmd = VOLCMD_OFFSET; break; //rewbs.volOff + case kcSetVolumeITPortaUp: volcmd = VOLCMD_PORTAUP; break; + case kcSetVolumeITPortaDown: volcmd = VOLCMD_PORTADOWN; break; + case kcSetVolumeITOffset: volcmd = VOLCMD_OFFSET; break; } UINT max = 64; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -108,6 +108,7 @@ ON_COMMAND(ID_SAMPLE_ADDSILENCE, OnAddSilence) ON_COMMAND(ID_SAMPLE_GRID, OnChangeGridSize) ON_COMMAND(ID_SAMPLE_QUICKFADE, OnQuickFade) + ON_COMMAND_RANGE(ID_SAMPLE_CUE_1, ID_SAMPLE_CUE_9, OnSetCuePoint) ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateUndo) ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateRedo) ON_MESSAGE(WM_MOD_MIDIMSG, OnMidiMsg) @@ -160,6 +161,7 @@ pMainFrm->SetXInfoText(""); } UpdateScrollSize(); + UpdateNcButtonState(); } @@ -1734,8 +1736,8 @@ CModDoc *pModDoc = GetDocument(); if (pModDoc) { - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - const ModSample &sample = pSndFile->GetSample(m_nSample); + const CSoundFile &sndFile = pModDoc->GetrSoundFile(); + const ModSample &sample = sndFile.GetSample(m_nSample); HMENU hMenu = ::CreatePopupMenu(); CInputHandler* ih = (CMainFrame::GetMainFrame())->GetInputHandler(); if (!hMenu) return; @@ -1745,12 +1747,12 @@ { ::AppendMenu(hMenu, MF_STRING | (CanZoomSelection() ? 0 : MF_GRAYED), ID_SAMPLE_ZOOMONSEL, _T("Zoom\t") + ih->GetKeyTextFromCommand(kcSampleZoomSelection)); ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_SETLOOP, _T("Set As Loop")); - if (pSndFile->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) + if (sndFile.GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_SETSUSTAINLOOP, _T("Set As Sustain Loop")); ::AppendMenu(hMenu, MF_SEPARATOR, 0, ""); } else { - CHAR s[256]; + TCHAR s[256]; SmpLength dwPos = ScreenToSample(pt.x); if (dwPos <= sample.nLength) { @@ -1762,7 +1764,7 @@ ::AppendMenu(hMenu, MF_STRING | (dwPos >= sample.nLoopStart + 4 ? 0 : MF_GRAYED), ID_SAMPLE_SETLOOPEND, s); - if (pSndFile->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) + if (sndFile.GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) { //Set sustain loop points ::AppendMenu(hMenu, MF_SEPARATOR, 0, ""); @@ -1773,6 +1775,20 @@ ::AppendMenu(hMenu, MF_STRING | (dwPos >= sample.nSustainStart + 4 ? 0 : MF_GRAYED), ID_SAMPLE_SETSUSTAINEND, s); } + + if(sndFile.GetModSpecifications().HasVolCommand(VOLCMD_OFFSET)) + { + ::AppendMenu(hMenu, MF_SEPARATOR, 0, _T("")); + HMENU hCueMenu = ::CreatePopupMenu(); + for(int i = 0; i < 9; i++) + { + wsprintf(s, _T("Cue &%c: %u"), '1' + i, sndFile.GetSample(m_nSample).cues[i]); + ::AppendMenu(hCueMenu, MF_STRING, ID_SAMPLE_CUE_1 + i, s); + } + wsprintf(s, _T("Set Sample Cu&e to:\t%u"), dwPos); + ::AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(hCueMenu), s); + } + ::AppendMenu(hMenu, MF_SEPARATOR, 0, _T("")); m_dwMenuParam = dwPos; } @@ -1985,19 +2001,6 @@ } -// Update loop points after deleting a sample selection -void CViewSample::AdjustLoopPoints(SmpLength &loopStart, SmpLength &loopEnd, SmpLength length) const -//-------------------------------------------------------------------------------------------------- -{ - Util::DeleteRange(m_dwBeginSel, m_dwEndSel - 1, loopStart, loopEnd); - LimitMax(loopEnd, length); - if(loopStart + 4 >= loopEnd) - { - loopStart = loopEnd = 0; - } -} - - void CViewSample::OnEditDelete() //------------------------------ { @@ -2024,29 +2027,7 @@ pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_delete, "Delete Selection", m_dwBeginSel, m_dwEndSel); CriticalSection cs; - - const SmpLength selStart = m_dwBeginSel * sample.GetBytesPerSample(); - const SmpLength selEnd = m_dwEndSel * sample.GetBytesPerSample(); - const SmpLength smpEnd = sample.nLength * sample.GetBytesPerSample(); - sample.nLength -= (m_dwEndSel - m_dwBeginSel); - - memmove(sample.pSample8 + selStart, sample.pSample8 + selEnd, smpEnd - selEnd); - - // adjust loop points - AdjustLoopPoints(sample.nLoopStart, sample.nLoopEnd, sample.nLength); - AdjustLoopPoints(sample.nSustainStart, sample.nSustainEnd, sample.nLength); - - if(sample.nLoopEnd == 0) - { - sample.uFlags.reset(CHN_LOOP | CHN_PINGPONGLOOP); - } - - if(sample.nSustainEnd == 0) - { - sample.uFlags.reset(CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN); - } - - sample.PrecomputeLoops(sndFile); + ctrlSmp::RemoveRange(sample, m_dwBeginSel, m_dwEndSel, sndFile); } SetCurSel(0, 0); SetModified(updateHint, true, true); @@ -2103,6 +2084,8 @@ { // We want to store some loop metadata as well. memSize += sizeof(RIFFChunk) + sizeof(WAVSampleInfoChunk) + 2 * sizeof(WAVSampleLoop); + // ...and cue points, too. + memSize += sizeof(RIFFChunk) + sizeof(uint32_t) + CountOf(sample.cues) * sizeof(WAVCuePoint); } ASSERT((memSize % 2u) == 0); @@ -2138,6 +2121,7 @@ if(addLoopInfo) { file.WriteLoopInformation(sample); + file.WriteCueInformation(sample); } file.WriteExtraInformation(sample, sndFile.GetType(), sndFile.GetSampleName(m_nSample)); @@ -2729,6 +2713,23 @@ } +void CViewSample::OnSetCuePoint(UINT nID) +//--------------------------------------- +{ + nID -= ID_SAMPLE_CUE_1; + CModDoc *pModDoc = GetDocument(); + if (pModDoc) + { + CSoundFile &sndFile = pModDoc->GetrSoundFile(); + ModSample &sample = sndFile.GetSample(m_nSample); + + pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Set Cue Point"); + sample.cues[nID] = m_dwMenuParam; + SetModified(SampleHint().Info().Data(), true, false); + } +} + + void CViewSample::OnZoomUp() //-------------------------- { @@ -3015,7 +3016,7 @@ if(noteChannel[note - NOTE_MIN] != CHANNELINDEX_INVALID) { // Release sustain loop on key up - pModDoc->GetrSoundFile().KeyOff(&GetDocument()->GetrSoundFile().m_PlayState.Chn[noteChannel[note - NOTE_MIN]]); + sndFile.KeyOff(&sndFile.m_PlayState.Chn[noteChannel[note - NOTE_MIN]]); } break; case seNoteOffOnKeyUp: @@ -3027,6 +3028,11 @@ } return wParam; } + } else if(wParam >= kcStartSampleCues && wParam <= kcEndSampleCues) + { + const ModSample &sample = sndFile.GetSample(m_nSample); + SmpLength offset = sample.cues[wParam - kcStartSampleCues]; + if(offset < sample.nLength) PlayNote(NOTE_MIDDLEC, offset); } // Pass on to ctrl_smp Modified: trunk/OpenMPT/mptrack/View_smp.h =================================================================== --- trunk/OpenMPT/mptrack/View_smp.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/View_smp.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -43,7 +43,7 @@ int m_nZoom; // < 0: Zoom into sample (2^x:1 ratio), 0: Auto zoom, > 0: Zoom out (1:2^x ratio) FlagSet<Flags> m_dwStatus; SmpLength m_dwBeginSel, m_dwEndSel, m_dwBeginDrag, m_dwEndDrag; - DWORD m_dwMenuParam; + SmpLength m_dwMenuParam; SmpLength m_nGridSegments; SAMPLEINDEX m_nSample; @@ -101,8 +101,6 @@ SmpLength ScrollPosToSamplePos() const {return ScrollPosToSamplePos(m_nZoom);} inline SmpLength ScrollPosToSamplePos(int nZoom) const; - void AdjustLoopPoints(SmpLength &loopStart, SmpLength &loopEnd, SmpLength length) const; - void OnMonoConvert(ctrlSmp::StereoToMonoMode convert); public: @@ -162,6 +160,7 @@ afx_msg void OnSetLoopEnd(); afx_msg void OnSetSustainStart(); afx_msg void OnSetSustainEnd(); + afx_msg void OnSetCuePoint(UINT nID); afx_msg void OnZoomUp(); afx_msg void OnZoomDown(); afx_msg void OnDrawingToggle(); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/mptrack.rc 2015-03-11 14:15:51 UTC (rev 4862) @@ -1318,7 +1318,7 @@ COMBOBOX IDC_COMBO2,114,18,149,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Volume Command:",IDC_STATIC,6,36,71,8 COMBOBOX IDC_COMBO3,6,48,102,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Value:",IDC_STATIC,114,36,150,8 + LTEXT "Value:",IDC_TEXT2,114,36,150,8 CONTROL "",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,114,48,150,12 LTEXT "Effect Type:",IDC_STATIC,6,66,55,8 COMBOBOX IDC_COMBO4,6,78,102,83,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP Modified: trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb =================================================================== --- trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb 2015-03-11 14:15:51 UTC (rev 4862) @@ -304,6 +304,15 @@ 8:1908:2:65:1 //Transpose -1 (Note Map): Ctrl+A (KeyDown) 8:1909:3:81:1 //Transpose +12 (Note Map): Shift+Ctrl+Q (KeyDown) 8:1910:3:65:1 //Transpose -12 (Note Map): Shift+Ctrl+A (KeyDown) +8:1924:1:49:1 //Preview Sample Cue 1: Shift+1 (KeyDown) +8:1925:1:50:1 //Preview Sample Cue 2: Shift+2 (KeyDown) +8:1926:1:51:1 //Preview Sample Cue 3: Shift+3 (KeyDown) +8:1927:1:52:1 //Preview Sample Cue 4: Shift+4 (KeyDown) +8:1928:1:53:1 //Preview Sample Cue 5: Shift+5 (KeyDown) +8:1929:1:54:1 //Preview Sample Cue 6: Shift+6 (KeyDown) +8:1930:1:55:1 //Preview Sample Cue 7: Shift+7 (KeyDown) +8:1931:1:56:1 //Preview Sample Cue 8: Shift+8 (KeyDown) +8:1932:1:57:1 //Preview Sample Cue 9: Shift+9 (KeyDown) //----( Instrument Context [bottom] (9) )------------ 9:1837:0:107:5 //Zoom In: NUM PLUS (KeyDown|KeyHold) Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/mptrack/resource.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -1092,7 +1092,6 @@ #define ID_MODTREE_SOLO 32898 #define ID_ESTIMATESONGLENGTH 32899 #define ID_PATTERN_VISUALIZE_EFFECT 32900 -#define ID_ACCELERATOR32900 32900 #define ID_PATTERN_PLAYNOLOOP 32901 #define ID_PATTERN_OPEN_RANDOMIZER 32905 #define ID_PATTERN_INTERPOLATE_NOTE 32906 @@ -1229,9 +1228,12 @@ #define ID_INTERNETUPDATE 44458 #define ID_HELP_EXAMPLEMODULES 44459 #define ID_FILE_SAVEASTEMPLATE 44460 -#define ID_ORDERLIST_INSERT_SEPARATOR 44461 -#define ID_ENVELOPE_LOAD 44462 -#define ID_ENVELOPE_SAVE 44463 +#define ID_SAMPLE_CUE_1 44461 +// From here: Command range [ID_SAMPLE_CUE_1, ID_SAMPLE_CUE_9] +#define ID_SAMPLE_CUE_9 44469 +#define ID_ORDERLIST_INSERT_SEPARATOR 44470 +#define ID_ENVELOPE_LOAD 44471 +#define ID_ENVELOPE_SAVE 44472 #define ID_PLUGINEDITOR_SLIDERS_BASE 44500 // From here: Command range [ID_PLUGINEDITOR_SLIDERS_BASE, ID_PLUGINEDITOR_SLIDERS_BASE + NUM_PLUGINEDITOR_PARAMETERS] #define ID_PLUGINEDITOR_EDIT_BASE 44550 Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -2078,6 +2078,27 @@ WRITEMODULAR('R','P','.','.', m_nRestartPos); } + // Sample cues + if(GetType() == MOD_TYPE_MPT) + { + for(SAMPLEINDEX smp = 1; smp <= GetNumSamples(); smp++) + { + const ModSample &sample = Samples[smp]; + if(sample.nLength && sample.HasCustomCuePoints()) + { + // Write one chunk for every sample. + // Rationale: chunks are limited to 65536 bytes, which can easily be reached + // with the amount of samples that OpenMPT supports. + WRITEMODULARHEADER('S','E','U','C', 2 + CountOf(sample.cues) * 4); + mpt::IO::WriteIntLE<uint16_t>(f, smp); + for(int i = 0; i < CountOf(sample.cues); i++) + { + mpt::IO::WriteIntLE<uint32_t>(f, sample.cues[i]); + } + } + } + } + //Additional flags for XM/IT/MPTM if(m_ModFlags) { @@ -2235,8 +2256,23 @@ } } } + break; - break; + case MAGIC4LE('C','U','E','S'): + // Sample cues + if(size > 2) + { + SAMPLEINDEX smp = chunk.ReadUint16LE(); + if(smp > 0 && smp <= GetNumSamples()) + { + ModSample &sample = Samples[smp]; + for(int i = 0; i < CountOf(sample.cues); i++) + { + sample.cues[i] = chunk.ReadUint32LE(); + } + } + } + break; } } Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -341,7 +341,7 @@ m.param = p.fxparam1; that->ConvertModCommand(m); #ifdef MODPLUG_TRACKER - m.Convert(MOD_TYPE_XM, MOD_TYPE_IT); + m.Convert(MOD_TYPE_XM, MOD_TYPE_IT, *that); #endif // MODPLUG_TRACKER } else { Modified: trunk/OpenMPT/soundlib/Load_mtm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mtm.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/soundlib/Load_mtm.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -186,7 +186,7 @@ if(cmd != 0 || param != 0) { ConvertModCommand(*m); - m->Convert(MOD_TYPE_MOD, MOD_TYPE_S3M); + m->Convert(MOD_TYPE_MOD, MOD_TYPE_S3M, *this); } } } Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/soundlib/ModChannel.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -62,6 +62,7 @@ // Information not used in the mixer const ModInstrument *pModInstrument; // Currently assigned instrument slot SmpLength proTrackerOffset; // Offset for instrument-less notes in ProTracker mode + SmpLength oldOffset; FlagSet<ChannelFlags> dwOldFlags; // Flags from previous tick int32 newLeftVol, newRightVol; int32 nRealVolume, nRealPan; @@ -83,10 +84,11 @@ int32 nRetrigCount, nRetrigParam; ROWINDEX nPatternLoop; CHANNELINDEX nMasterChn; + ModCommand rowCommand; // 8-bit members uint8 resamplingMode; - uint8 nRestoreResonanceOnNewNote; //Like above - uint8 nRestoreCutoffOnNewNote; //Like above + uint8 nRestoreResonanceOnNewNote; // See nRestorePanOnNewNote + uint8 nRestoreCutoffOnNewNote; // ditto uint8 nNote, nNNA; uint8 nLastNote; // Last note, ignoring note offs and cuts - for MIDI macros uint8 nArpeggioLastNote, nArpeggioBaseNote; // For plugin arpeggio @@ -99,7 +101,7 @@ uint8 nPanbrelloType, nPanbrelloSpeed, nPanbrelloDepth; int8 nPanbrelloOffset, nPanbrelloRandomMemory; uint8 nOldCmdEx, nOldVolParam, nOldTempo; - uint8 nOldOffset, nOldHiOffset; + uint8 nOldHiOffset; uint8 nCutOff, nResonance; uint8 nTremorCount, nTremorParam; uint8 nPatternLoopCount; @@ -108,30 +110,28 @@ uint8 nEFxSpeed, nEFxDelay; // memory for Invert Loop (EFx, .MOD only) uint8 nNoteSlideCounter, nNoteSlideSpeed, nNoteSlideStep; // IMF / PTM Note Slide uint8 lastZxxParam; // Memory for \xx slides - bool isFirstTick; + bool isFirstTick : 1; - ModCommand rowCommand; + //-->Variables used to make user-definable tuning modes work with pattern effects. + //If true, freq should be recalculated in ReadNote() on first tick. + //Currently used only for vibrato things - using in other context might be + //problematic. + bool m_ReCalculateFreqOnFirstTick : 1; - //NOTE_PCs memory. - float m_plugParamValueStep, m_plugParamTargetValue; - uint16 m_RowPlugParam; - PLUGINDEX m_RowPlug; + //To tell whether to calculate frequency. + bool m_CalculateFreq : 1; - //-->Variables used to make user-definable tuning modes work with pattern effects. int32 m_PortamentoFineSteps, m_PortamentoTickSlide; uint32 m_Freq; float m_VibratoDepth; + //<---- - //If true, freq should be recalculated in ReadNote() on first tick. - //Currently used only for vibrato things - using in other context might be - //problematic. - bool m_ReCalculateFreqOnFirstTick; + //NOTE_PCs memory. + float m_plugParamValueStep, m_plugParamTargetValue; + uint16 m_RowPlugParam; + PLUGINDEX m_RowPlug; - //To tell whether to calculate frequency. - bool m_CalculateFreq; - //<---- - void ClearRowCmd() { rowCommand = ModCommand::Empty(); } // Get a reference to a specific envelope of this channel Modified: trunk/OpenMPT/soundlib/ModSample.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSample.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/soundlib/ModSample.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -126,6 +126,12 @@ nVibDepth = 0; nVibRate = 0; filename[0] = '\0'; + + // Default cues compatible with old-style volume column offset + for(int i = 0; i < 9; i++) + { + cues[i] = (i + 1) << 11; + } } @@ -339,4 +345,16 @@ } +// Check if the sample's cue points are the default cue point set. +bool ModSample::HasCustomCuePoints() const +//---------------------------------------- +{ + for(SmpLength i = 0; i < CountOf(cues); i++) + { + if(cues[i] != (i + 1) << 11) return true; + } + return false; +} + + OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/soundlib/ModSample.h =================================================================== --- trunk/OpenMPT/soundlib/ModSample.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/soundlib/ModSample.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -39,6 +39,7 @@ uint8 nVibRate; // Auto vibrato rate (speed) //char name[MAX_SAMPLENAME]; // Maybe it would be nicer to have sample names here, but that would require some refactoring. Also, the current structure size is 64 Bytes - would adding the sample name here slow down the mixer (cache misses)? char filename [MAX_SAMPLEFILENAME]; + SmpLength cues[9]; ModSample(MODTYPE type = MOD_TYPE_NONE) { @@ -96,6 +97,9 @@ void TransposeToFrequency(); static int FrequencyToTranspose(uint32 freq); void FrequencyToTranspose(); + + // Check if the sample's cue points are the default cue point set. + bool HasCustomCuePoints() const; }; OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -490,6 +490,10 @@ file.WriteLoopInformation(sample); file.WriteExtraInformation(sample, GetType()); + if(sample.HasCustomCuePoints()) + { + file.WriteCueInformation(sample); + } FileTags tags; tags.title = mpt::ToUnicode(mpt::CharsetLocale, m_szNames[nSample]); @@ -2193,11 +2197,12 @@ FLAC__StreamMetadata *metadata[] = { FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT), - FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), - FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), + FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), // MPT sample information + FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), // Loop points + FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), // Cue points }; - const bool writeLoopData = sample.uFlags[CHN_LOOP | CHN_SUSTAINLOOP]; + unsigned numBlocks = 2; if(metadata[0]) { // Store sample name @@ -2229,10 +2234,10 @@ FLAC__metadata_object_application_set_data(metadata[1], reinterpret_cast<FLAC__byte *>(&chunk), length, true); } - if(metadata[2] && writeLoopData) + if(metadata[numBlocks] && sample.uFlags[CHN_LOOP | CHN_SUSTAINLOOP]) { // Store loop points - memcpy(metadata[2]->data.application.id, "riff", 4); + memcpy(metadata[numBlocks]->data.application.id, "riff", 4); struct { @@ -2263,14 +2268,42 @@ chunk.loops[0].ConvertEndianness(); chunk.loops[1].ConvertEndianness(); - FLAC__metadata_object_application_set_data(metadata[2], reinterpret_cast<FLAC__byte *>(&chunk), length, true); + FLAC__metadata_object_application_set_data(metadata[numBlocks], reinterpret_cast<FLAC__byte *>(&chunk), length, true); + numBlocks++; } + if(metadata[numBlocks] && sample.HasCustomCuePoints()) + { + // Store cue points + memcpy(metadata[numBlocks]->data.application.id, "riff", 4); + struct + { + RIFFChunk header; + uint32_t numPoints; + WAVCuePoint cues[CountOf(sample.cues)]; + } chunk; + + chunk.header.id = RIFFChunk::idcue_; + chunk.header.length = 4 + sizeof(chunk.cues); + + for(uint32_t i = 0; i < CountOf(sample.cues); i++) + { + chunk.cues[i].ConvertToWAV(i, sample.cues[i]); + chunk.cues[i].ConvertEndianness(); + } + + const uint32_t length = sizeof(RIFFChunk) + chunk.header.length; + chunk.header.ConvertEndianness(); + + FLAC__metadata_object_application_set_data(metadata[numBlocks], reinterpret_cast<FLAC__byte *>(&chunk), length, true); + numBlocks++; + } + FLAC__stream_encoder_set_channels(encoder, sample.GetNumChannels()); FLAC__stream_encoder_set_bits_per_sample(encoder, sample.GetElementarySampleSize() * 8); FLAC__stream_encoder_set_sample_rate(encoder, sample.GetSampleRate(GetType())); FLAC__stream_encoder_set_total_samples_estimate(encoder, sample.nLength); - FLAC__stream_encoder_set_metadata(encoder, metadata, writeLoopData ? 3 : 2); + FLAC__stream_encoder_set_metadata(encoder, metadata, numBlocks); #ifdef MODPLUG_TRACKER FLAC__stream_encoder_set_compression_level(encoder, TrackerSettings::Instance().m_FLACCompressionLevel); #endif // MODPLUG_TRACKER Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2015-03-11 14:15:51 UTC (rev 4862) @@ -166,7 +166,7 @@ #define CHN_SAMPLEFLAGS (CHN_16BIT | CHN_LOOP | CHN_PINGPONGLOOP | CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN | CHN_PANNING | CHN_STEREO | CHN_PINGPONGFLAG | CHN_REVERSE) #define CHN_CHANNELFLAGS (~CHN_SAMPLEFLAGS) -// Sample flags fit into the first 16 bits, and with the current memory layout, storing them as a 16-bit integer gives struct ModSample a nice cacheable 64 bytes size in 32-bit builds. +// Sample flags fit into the first 16 bits, and with the current memory layout, storing them as a 16-bit integer packs struct ModSample nicely. typedef FlagSet<ChannelFlags, uint16> SampleFlags; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-11 12:55:36 UTC (rev 4861) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-11 14:15:51 UTC (rev 4862) @@ -112,10 +112,6 @@ const bool hasSearchTarget = target.mode != GetLengthTarget::NoTarget; const bool adjustSamplePos = (adjustMode & eAdjustSamplePositions) == eAdjustSamplePositions; - ROWINDEX nRow = target.startRow, nNextRow = nRow; - ROWINDEX nNextPatStartRow = 0; // FT2 E60 bug - ORDERINDEX nCurrentOrder = target.startOrder, nNextOrder = nCurrentOrder; - SEQUENCEINDEX sequence = target.sequence; if(sequence > Order.GetNumSequences()) sequence = Order.GetCurrentSequenceIndex(); const ModSequence &orderList = Order.GetSequence(sequence); @@ -124,6 +120,9 @@ // Temporary visited rows vector (so that GetLength() won't interfere with the player code if the module is playing at the same time) RowVisitor visitedRows(*this, sequence); + memory.state.m_nNextRow = memory.state.m_nRow = target.startRow; + memory.state.m_nNextOrder = memory.state.m_nCurrentOrder = target.startOrder; + // Optimize away channels for which it's pointless to adjust sample positions std::vector<bool> adjustSampleChn(GetNumChannels(), true); if(adjustSamplePos && target.mode == GetLengthTarget::SeekPosition) @@ -178,43 +177,43 @@ } uint32 rowDelay = 0, tickDelay = 0; - nRow = nNextRow; - nCurrentOrder = nNextOrder; + memory.state.m_nRow = memory.state.m_nNextRow; + memory.state.m_nCurrentOrder = memory.state.m_nNextOrder; - if(nCurrentOrder >= orderList.size()) + if(memory.state.m_nCurrentOrder >= orderList.size()) break; // Check if pattern is valid - PATTERNINDEX nPattern = orderList[nCurrentOrder]; + memory.state.m_nPattern = orderList[memory.state.m_nCurrentOrder]; bool positionJumpOnThisRow = false; bool patternBreakOnThisRow = false; bool patternLoopEndedOnThisRow = false, patternLoopStartedOnThisRow = false; - if(nPattern == orderList.GetIgnoreIndex() && target.mode == GetLengthTarget::SeekPosition && nCurrentOrder == target.pos.order) + if(memory.state.m_nPattern == orderList.GetIgnoreIndex() && target.mode == GetLengthTarget::SeekPosition && memory.state.m_nCurrentOrder == target.pos.order) { // Early test: Target is inside +++ pattern retval.targetReached = true; break; } - while(nPattern >= Patterns.Size()) + while(memory.state.m_nPattern >= Patterns.Size()) { // End of song? - if((nPattern == orderList.GetInvalidPatIndex()) || (nCurrentOrder >= orderList.size())) + if((memory.state.m_nPattern == orderList.GetInvalidPatIndex()) || (memory.state.m_nCurrentOrder >= orderList.size())) { - if(nCurrentOrder == m_nRestartPos) + if(memory.state.m_nCurrentOrder == m_nRestartPos) break; else - nCurrentOrder = m_nRestartPos; + memory.state.m_nCurrentOrder = m_nRestartPos; } else { - nCurrentOrder++; + memory.state.m_nCurrentOrder++; } - nPattern = (nCurrentOrder < orderList.size()) ? orderList[nCurrentOrder] : orderList.GetInvalidPatIndex(); - nNextOrder = nCurrentOrder; - if((!Patterns.IsValidPat(nPattern)) && visitedRows.IsVisited(nCurrentOrder, 0, true)) + memory.state.m_nPattern = (memory.state.m_nCurrentOrder < orderList.size()) ? orderList[memory.state.m_nCurrentOrder] : orderList.GetInvalidPatIndex(); + memory.state.m_nNextOrder = memory.state.m_nCurrentOrder; + if((!Patterns.IsValidPat(memory.state.m_nPattern)) && visitedRows.IsVisited(memory.state.m_nCurrentOrder, 0, true)) { - if(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(nNextOrder, nNextRow, true)) + if(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(memory.state.m_nNextOrder, memory.state.m_nNextRow, true)) { // We aren't searching for a specific row, or we couldn't find any more unvisited rows. break; @@ -223,24 +222,24 @@ // We haven't found the target row yet, but we found some other unplayed row... continue searching from here. retval.duration = memory.elapsedTime; results.push_back(retval); - retval.startRow = nNextRow; - retval.startOrder = nNextOrder; + retval.startRow = memory.state.m_nNextRow; + retval.startOrder = memory.state.m_nNextOrder; memory.Reset(); - nRow = nNextRow; - nCurrentOrder = nNextOrder; - nPattern = orderList[nCurrentOrder]; + memory.state.m_nRow = memory.state.m_nNextRow; + memory.state.m_nCurrentOrder = memory.state.m_nNextOrder; + memory.state.m_nPattern = orderList[memory.state.m_nCurrentOrder]; break; } } } // Skip non-existing patterns - if((nPattern >= Patterns.Size()) || (!Patterns[nPattern])) + if((memory.state.m_nPattern >= Patterns.Size()) || (!Patterns[memory.state.m_nPattern])) { // If there isn't even a tune, we should probably stop here. - if(nCurrentOrder == m_nRestartPos) + if(memory.state.m_nCurrentOrder == m_nRestartPos) { - if(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(nNextOrder, nNextRow, true)) + if(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(memory.state.m_nNextOrder, memory.state.m_nNextRow, true)) { // We aren't searching for a specific row, or we couldn't find any more unvisited rows. break; @@ -249,29 +248,29 @@ // We haven't found the target row yet, but we found some other unplayed row... continue searching from here. retval.duration = memory.elapsedTime; results.push_back(retval); - retval.startRow = nNextRow; - retval.startOrder = nNextOrder; + retval.startRow = memory.state.m_nNextRow; + retval.startOrder = memory.state.m_nNextOrder; memory.Reset(); continue; } } - nNextOrder = nCurrentOrder + 1; + memory.state.m_nNextOrder = memory.state.m_nCurrentOrder + 1; continue; } // Should never happen - if(nRow >= Patterns[nPattern].GetNumRows()) - nRow = 0; + if(memory.state.m_nRow >= Patterns[memory.state.m_nPattern].GetNumRows()) + memory.state.m_nRow = 0; // Check whether target was reached. - if(target.mode == GetLengthTarget::SeekPosition && nCurrentOrder == target.pos.order && nRow == target.pos.row) + if(target.mode == GetLengthTarget::SeekPosition && memory.state.m_nCurrentOrder == target.pos.order && memory.state.m_nRow == target.pos.row) { retval.targetReached = true; break; } - if(visitedRows.IsVisited(nCurrentOrder, nRow, true)) + if(visitedRows.IsVisited(memory.state.m_nCurrentOrder, memory.state.m_nRow, true)) { - if(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(nNextOrder, nNextRow, true)) + if(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(memory.state.m_nNextOrder, memory.state.m_nNextRow, true)) { // We aren't searching for a specific row, or we couldn't find any more unvisited rows. break; @@ -280,28 +279,27 @@ // We haven't found the target row yet, but we found some other unplayed row... continue searching from here. retval.duration = memory.elapsedTime; results.push_back(retval); - retval.startRow = nNextRow; - retval.startOrder = nNextOrder; + retval.startRow = memory.state.m_nNextRow; + retval.startOrder = memory.state.m_nNextOrder; memory.Reset(); continue; } } - retval.endOrder = nCurrentOrder; - retval.endRow = nRow; + retval.endOrder = memory.state.m_nCurrentOrder; + retval.endRow = memory.state.m_nRow; // Update next position - nNextRow = nRow + 1; + memory.state.m_nNextRow = memory.state.m_nRow + 1; - if(!nRow) + if(!memory.state.m_nRow) { for(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++) memory.chnSettings[chn].patLoop = memory.elapsedTime; } ModChannel *pChn = memory.state.Chn; - ModCommand *p = Patterns[nPattern].GetRow(nRow); - ModCommand *nextRow = nullptr; + ModCommand *p = Patterns[memory.state.m_nPattern].GetRow(memory.state.m_nRow); for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); p++, pChn++, nChn++) if(!p->IsEmpty()) { if(IsCompatibleMode(TRK_SCREAMTRACKER) && ChnSettings[nChn].dwFlags[CHN_MUTE]) // not even effects are processed on muted S3M channels @@ -322,12 +320,12 @@ // Position Jump case CMD_POSITIONJUMP: positionJumpOnThisRow = true; - nNextOrder = (ORDERINDEX)param; - nNextPatStartRow = 0; // FT2 E60 bug + memory.state.m_nNextOrder = (ORDERINDEX)param; + memory.state.m_nNextPatStartRow = 0; // FT2 E60 bug // see http://forum.openmpt.org/index.php?topic=2769.0 - FastTracker resets Dxx if Bxx is called _after_ Dxx // Test case: PatternJump.mod if(!patternBreakOnThisRow || (GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM))) - nNextRow = 0; + memory.state.m_nNextRow = 0; if ((adjustMode & eAdjust)) { @@ -337,36 +335,24 @@ break; // Pattern Break case CMD_PATTERNBREAK: - if(param >= 64 && (GetType() & MOD_TYPE_S3M)) { - // ST3 ignores invalid pattern breaks. - break; - } - patternBreakOnThisRow = true; - //Try to check next row for XPARAM - nextRow = nullptr; - nNextPatStartRow = 0; // FT2 E60 bug - if (nRow < Patterns[nPattern].GetNumRows() - 1) - { - nextRow = Patterns[nPattern].GetpModCommand(nRow + 1, nChn); - } - if (nextRow && nextRow->command == CMD_XPARAM) - { - nNextRow = (param << 8) + nextRow->param; - } else - { - nNextRow = param; - } + ROWINDEX row = PatternBreak(memory.state, nChn, param); + if(row != ROWINDEX_INVALID) + { + patternBreakOnThisRow = true; + memory.state.m_nNextRow = row; - if (!positionJumpOnThisRow) - { - nNextOrder = nCurrentOrder + 1; + if(!positionJumpOnThisRow) + { + memory.state.m_nNextOrder = memory.state.m_nCurrentOrder + 1; + } + if(adjustMode & eAdjust) + { + pChn->nPatternLoopCount = 0; + pChn->nPatternLoop = 0; + } + } } - if ((adjustMode & eAdjust)) - { - pChn->nPatternLoopCount = 0; - pChn->nPatternLoop = 0; - } break; // Set Speed case CMD_SPEED: @@ -456,7 +442,7 @@ for(CHANNELINDEX c = firstChn; c <= lastChn; c++) { memory.chnSettings[c].patLoop = memory.elapsedTime; - memory.chnSettings[c].patLoopStart = nRow; + memory.chnSettings[c].patLoopStart = memory.state.m_nRow; } patternLoopStartedOnThisRow = true; } @@ -473,13 +459,13 @@ // Pattern Loop if (param & 0x0F) { - nNextPatStartRow = memory.chnSettings[nChn].patLoopStart; // FT2 E60 bug + memory.state.m_nNextPatStartRow = memory.chnSettings[nChn].patLoopStart; // FT2 E60 bug patternLoopEndedOnThisRow = true; } else { patternLoopStartedOnThisRow = true; memory.chnSettings[nChn].patLoop = memory.elapsedTime; - memory.chnSettings[nChn].patLoopStart = nRow; + memory.chnSettings[nChn].patLoopStart = memory.state.m_nRow; } } break; @@ -489,6 +475,8 @@ if(((param & 0xF0) == 0xA0) && !IsCompatibleMode(TRK_FASTTRACKER2)) pChn->nOldHiOffset = param & 0x0F; break; } + + // The following calculations are not interesting if we just want to get the song length. if ((adjustMode & eAdjust) == 0) continue; switch(command) { @@ -503,7 +491,7 @@ break; // Offset case CMD_OFFSET: - if (param) pChn->nOldOffset = param; + if (param) pChn->oldOffset = param << 8; break; // Volume Slide case CMD_VOLUMESLIDE: @@ -594,12 +582,12 @@ } } - if(nNextRow >= Patterns[nPattern].GetNumRows()) + if(memory.state.m_nNextRow >= Patterns[memory.state.m_nPattern].GetNumRows()) { - nNextOrder = nCurrentOrder + 1; - nNextRow = 0; - if(IsCompatibleMode(TRK_FASTTRACKER2)) nNextRow = nNextPatStartRow; // FT2 E60 bug - nNextPatStartRow = 0; + memory.state.m_nNextOrder = memory.state.m_nCurrentOrder + 1; + memory.state.m_nNextRow = 0; + if(IsCompatibleMode(TRK_FASTTRACKER2)) memory.state.m_nNextRow = memory.state.m_nNextPatStartRow; // FT2 E60 bug + memory.state.m_nNextPatStartRow = 0; } // Interpret F00 effect in XM files as "stop song" @@ -609,9 +597,9 @@ } ROWINDEX rowsPerBeat = m_nDefaultRowsPerBeat; - if(Patterns[nPattern].GetOverrideSignature()) + if(Patterns[memory.state.m_nPattern].GetOverrideSignature()) { - rowsPerBeat = Patterns[nPattern].GetRowsPerBeat(); + rowsPerBeat = Patterns[memory.state.m_nPattern].GetRowsPerBeat(); } const uint32 tickDuration = GetTickDuration(memory.state.m_nMusicTempo, memory.state.m_nMusicSpeed, rowsPerBeat); @@ -624,7 +612,7 @@ { // Super experimental and dirty sample seeking pChn = memory.state.Chn; - p = Patterns[nPattern].GetRow(nRow); + p = Patterns[memory.state.m_nPattern].GetRow(memory.state.m_nRow); for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); p++, pChn++, nChn++) { if(!adjustSampleChn[nChn]) @@ -650,17 +638,30 @@ { startTick = paramHi; } + + if(p->command == CMD_OFFSET) + { + SmpLength offset = CalculateXParam(memory.state.m_nPattern, memory.state.m_nRow, nChn); + if(offset < 256) + { + offset <<= 8; + if(offset == 0) offset = pChn->oldOffset; + offset += static_cast<SmpLength>(pChn->nOldHiOffset) << 16; + } + SampleOffset(nChn, offset); + } else if(p->volcmd == VOLCMD_OFFSET) + { + if(p->vol <= CountOf(pChn->pModSample->cues) && pChn->pModSample != nullptr) + { + SmpLength offset; + if(p->vol == 0) + offset = pChn->oldOffset; + else + offset = pChn->oldOffset = pChn->pModSample->cues[p->vol - 1]; + SampleOffset(nChn, offset); + } + } } - if(p->command == CMD_OFFSET) - { - // TODO: xParam not supported! (Note: xParam doesn't use hiOffset) - if(p->param != 0) pChn->nOldOffset = p->param; - if(p->IsNote()) pChn->nPos = (pChn->nOldHiOffset << 16) + (pChn->nOldOffset << 8); - } else if(p->volcmd == VOLCMD_OFFSET) - { - if(p->vol != 0) pChn->nOldOffset = p->vol << 3; - if(p->IsNote()) pChn->nPos = (pChn->nOldHiOffset << 16) + (pChn->nOldOffset << 8); - } if(p->note == NOTE_KEYOFF || p->note == NOTE_NOTECUT || (p->note == NOTE_FADE && GetNumInstruments()) || ((p->command == CMD_MODCMDEX || p->command == CMD_S3MCMDEX) && (p->param & 0xF0) == 0xC0 && paramLo < numTicks) @@ -800,7 +801,7 @@ if(patternLoopEndedOnThisRow) { - p = Patterns[nPattern].GetRow(nRow); + p = Patterns[memory.state.m_nPattern].GetRow(memory.state.m_nRow); std::map<double, int> startTimes; // This is really just a simple estimation for nested pattern loops. It should handle cases correctly where all parallel loops start and end on the same row. // If one of them starts or ends "in between", it will most likely calculate a wrong duration. @@ -822,7 +823,7 @@ if(GetType() == MOD_TYPE_IT) { // IT pattern loop start row update - at the end of a pattern loop, set pattern loop start to next row (for upcoming pattern loops with missing SB0) - p = Patterns[nPattern].GetRow(nRow); + p = Patterns[memory.state.m_nPattern].GetRow(memory.state.m_nRow); for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); p++, nChn++) { if((p->command == CMD_S3MCMDEX && p->param >= 0xB1 && p->param <= 0xBF)) @@ -836,14 +837,14 @@ if(retval.targetReached || target.mode == GetLengthTarget::NoTarget) { - retval.lastOrder = nCurrentOrder; - retval.lastRow = nRow; + retval.lastOrder = memory.state.m_nCurrentOrder; + retval.lastRow = memory.state.m_nRow; } retval.duration = memory.elapsedTime; results.push_back(retval); // Store final variables - if((adjustMode & eAdjust)) + if(adjustMode & eAdjust) { if(retval.targetReached || target.mode == GetLengthTarget::NoTarget) { @@ -856,12 +857,7 @@ if(memory.state.Chn[n].nLastNote != NOTE_NONE) { m_PlayState.Chn[n].nNewNote = memory.state.Chn[n].nLastNote; - if(ModCommand::IsNote(memory.state.Chn[n].nLastNote)) - { - m_PlayState.Chn[n].nLastNote = memory.state.Chn[n].nLastNote; - } } - if(memory.state.Chn[n].nNewIns) m_PlayState.Chn[n].nNewIns = memory.state.Chn[n].nNewIns; if(memory.chnSettings[n].vol != 0xFF) { ... [truncated message content] |
From: <man...@us...> - 2015-03-11 16:21:48
|
Revision: 4872 http://sourceforge.net/p/modplug/code/4872 Author: manxorist Date: 2015-03-11 16:21:42 +0000 (Wed, 11 Mar 2015) Log Message: ----------- [Ref] Kill Stringify and StringifyW. Modified Paths: -------------- trunk/OpenMPT/common/mptString.h trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/tuningRatioMapWnd.cpp Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2015-03-11 15:56:44 UTC (rev 4871) +++ trunk/OpenMPT/common/mptString.h 2015-03-11 16:21:42 UTC (rev 4872) @@ -929,13 +929,6 @@ } // namespace mpt -#ifdef MODPLUG_TRACKER -#define Stringify(x) mpt::ToString(x) -#if MPT_WSTRING_FORMAT -#define StringifyW(x) mpt::ToWString(x) -#endif -#endif - namespace mpt { namespace String { namespace detail Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2015-03-11 15:56:44 UTC (rev 4871) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2015-03-11 16:21:42 UTC (rev 4872) @@ -1344,7 +1344,7 @@ m_EditPitchTempoLock.EnableWindow(pIns->wPitchToTempoLock > 0 ? TRUE : FALSE); if(pIns->wPitchToTempoLock > 0) { - m_EditPitchTempoLock.SetWindowText(Stringify(pIns->wPitchToTempoLock).c_str()); + m_EditPitchTempoLock.SetWindowText(mpt::ToString(pIns->wPitchToTempoLock).c_str()); } // Pitch Wheel Depth @@ -1561,7 +1561,7 @@ // Pitch/Tempo lock { const CModSpecifications& specs = m_sndFile.GetModSpecifications(); - std::string str = std::string("Tempo range: ") + Stringify(specs.tempoMin) + std::string(" - ") + Stringify(specs.tempoMax); + std::string str = std::string("Tempo range: ") + mpt::ToString(specs.tempoMin) + std::string(" - ") + mpt::ToString(specs.tempoMax); if(str.size() >= 250) str.resize(250); strcpy(pszText, str.c_str()); return TRUE; @@ -2755,7 +2755,7 @@ { ptl = m_sndFile.m_nDefaultTempo; } - m_EditPitchTempoLock.SetWindowText(Stringify(ptl).c_str()); + m_EditPitchTempoLock.SetWindowText(mpt::ToString(ptl).c_str()); for(INSTRUMENTINDEX i = firstIns; i <= lastIns; i++) { @@ -2818,7 +2818,7 @@ changed = true; } - if(changed) m_EditPitchTempoLock.SetWindowText(Stringify(ptlTempo).c_str()); + if(changed) m_EditPitchTempoLock.SetWindowText(mpt::ToString(ptlTempo).c_str()); } Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2015-03-11 15:56:44 UTC (rev 4871) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2015-03-11 16:21:42 UTC (rev 4872) @@ -1385,7 +1385,7 @@ const bool editSequence = nSeq >= sndFile.Order.GetNumSequences(); if(nSeq == MAX_SEQUENCES + 2) { - std::wstring str = L"Delete sequence " + StringifyW(sndFile.Order.GetCurrentSequenceIndex()) + L": " + mpt::ToWide(mpt::CharsetLocale, sndFile.Order.GetName()) + L"?"; + std::wstring str = L"Delete sequence " + mpt::ToWString(sndFile.Order.GetCurrentSequenceIndex()) + L": " + mpt::ToWide(mpt::CharsetLocale, sndFile.Order.GetName()) + L"?"; if (Reporting::Confirm(str) == cnfYes) sndFile.Order.RemoveSequence(); else Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2015-03-11 15:56:44 UTC (rev 4871) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2015-03-11 16:21:42 UTC (rev 4872) @@ -186,7 +186,7 @@ m_eReport.FmtLines(TRUE); m_eReport.SetWindowText(""); - m_eChordWaitTime.SetWindowText(Stringify(TrackerSettings::Instance().gnAutoChordWaitTime).c_str()); + m_eChordWaitTime.SetWindowText(mpt::ToString(TrackerSettings::Instance().gnAutoChordWaitTime).c_str()); return TRUE; } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2015-03-11 15:56:44 UTC (rev 4871) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2015-03-11 16:21:42 UTC (rev 4872) @@ -2904,7 +2904,7 @@ mpt::PathString sName; for(size_t i = 0; i < 1000; ++i) { - sName += MPT_PATHSTRING("newTemplate") + mpt::PathString::FromWide(StringifyW(i)); + sName += MPT_PATHSTRING("newTemplate") + mpt::PathString::FromWide(mpt::ToWString(i)); sName += MPT_PATHSTRING(".") + mpt::PathString::FromUTF8(m_SndFile.GetModSpecifications().fileExtension); if (!Util::sdOs::IsPathFileAvailable(templateFolder + sName, Util::sdOs::FileModeExists)) break; Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-03-11 15:56:44 UTC (rev 4871) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-03-11 16:21:42 UTC (rev 4872) @@ -1039,7 +1039,7 @@ { cc += ","; } - cc += Stringify(i); + cc += mpt::ToString(i); first = false; } } Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2015-03-11 15:56:44 UTC (rev 4871) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2015-03-11 16:21:42 UTC (rev 4872) @@ -252,7 +252,7 @@ m_EditTuningCollectionName.SetWindowText(m_pActiveTuningCollection->GetName().c_str()); m_EditTuningCollectionVersion.SetWindowText(m_pActiveTuningCollection->GetVersionString().c_str()); m_EditTuningCollectionEditMask.SetWindowText(m_pActiveTuningCollection->GetEditMaskString().c_str()); - m_EditTuningCollectionItemNum.SetWindowText(Stringify(m_pActiveTuningCollection->GetNumTunings()).c_str()); + m_EditTuningCollectionItemNum.SetWindowText(mpt::ToString(m_pActiveTuningCollection->GetNumTunings()).c_str()); ::SetWindowTextW(m_EditTuningCollectionPath.m_hWnd, m_pActiveTuningCollection->GetSaveFilePath().ToWide().c_str()); } //<-- Updating tuning collection part @@ -266,7 +266,7 @@ m_EditName.Invalidate(); //Finetunesteps-edit - m_EditFineTuneSteps.SetWindowText(Stringify(m_pActiveTuning->GetFineStepCount()).c_str()); + m_EditFineTuneSteps.SetWindowText(mpt::ToString(m_pActiveTuning->GetFineStepCount()).c_str()); m_EditFineTuneSteps.Invalidate(); //Making sure that ratiomap window is showing and @@ -282,10 +282,10 @@ if(period > 0) { m_EditSteps.EnableWindow(); - m_EditSteps.SetWindowText(Stringify(period).c_str()); + m_EditSteps.SetWindowText(mpt::ToString(period).c_str()); m_EditRatioPeriod.EnableWindow(); - m_EditRatioPeriod.SetWindowText(Stringify(GroupRatio).c_str()); + m_EditRatioPeriod.SetWindowText(mpt::ToString(GroupRatio).c_str()); } else //case: m_pActiveTuning is of type general. { @@ -607,7 +607,7 @@ return; m_RatioEditApply = false; - m_EditRatio.SetWindowText(Stringify(m_pActiveTuning->GetRatio(note)).c_str()); + m_EditRatio.SetWindowText(mpt::ToString(m_pActiveTuning->GetRatio(note)).c_str()); m_NoteEditApply = false; m_EditNotename.SetWindowText(m_pActiveTuning->GetNoteName(note).c_str()); @@ -718,7 +718,7 @@ delete pT; pT = nullptr; if (m_TempTunings.GetNumTunings() >= CTuningCollection::s_nMaxTuningCount) { - sLoadReport += L"-Failed to load file " + fileNameExt + L": maximum number(" + StringifyW(CTuningCollection::s_nMaxTuningCount) + L") of temporary tunings is already open.\n"; + sLoadReport += L"-Failed to load file " + fileNameExt + L": maximum number(" + mpt::ToWString(CTuningCollection::s_nMaxTuningCount) + L") of temporary tunings is already open.\n"; } else // Case: Can't add tuning to tuning collection for unknown reason. { @@ -736,7 +736,7 @@ { if (a == enSclImportAddTuningFailure && m_TempTunings.GetNumTunings() >= CTuningCollection::s_nMaxTuningCount) { - sLoadReport += L"-Failed to load file " + fileNameExt + L": maximum number(" + StringifyW(CTuningCollection::s_nMaxTuningCount) + L") of temporary tunings is already open.\n"; + sLoadReport += L"-Failed to load file " + fileNameExt + L": maximum number(" + mpt::ToWString(CTuningCollection::s_nMaxTuningCount) + L") of temporary tunings is already open.\n"; } else { @@ -797,7 +797,7 @@ const BYTE BS = 5; char buffer[BS]; m_EditFineTuneSteps.GetWindowText(buffer, BS); - m_EditFineTuneSteps.SetWindowText(Stringify(m_pActiveTuning->SetFineStepCount(ConvertStrTo<CTuning::USTEPINDEXTYPE>(buffer))).c_str()); + m_EditFineTuneSteps.SetWindowText(mpt::ToString(m_pActiveTuning->SetFineStepCount(ConvertStrTo<CTuning::USTEPINDEXTYPE>(buffer))).c_str()); m_ModifiedTCs[GetpTuningCollection(m_pActiveTuning)] = true; m_EditFineTuneSteps.Invalidate(); } @@ -1407,7 +1407,7 @@ switch(id) { case enSclImportFailTooManyNotes: - AfxFormatString1(sMsg, IDS_SCL_IMPORT_FAIL_8, Stringify(s_nSclImportMaxNoteCount).c_str()); + AfxFormatString1(sMsg, IDS_SCL_IMPORT_FAIL_8, mpt::ToString(s_nSclImportMaxNoteCount).c_str()); return sMsg; case enSclImportFailTooLargeNumDenomIntegers: Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2015-03-11 15:56:44 UTC (rev 4871) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2015-03-11 16:21:42 UTC (rev 4872) @@ -514,7 +514,7 @@ for(UINT iMidi = 0; iMidi < 128; iMidi++) { DWORD dwImage = IMAGE_INSTRMUTE; - s = StringifyW(iMidi) + L": " + mpt::ToWide(mpt::CharsetASCII, szMidiProgramNames[iMidi]); + s = mpt::ToWString(iMidi) + L": " + mpt::ToWide(mpt::CharsetASCII, szMidiProgramNames[iMidi]); const LPARAM param = (MODITEM_MIDIINSTRUMENT << MIDILIB_SHIFT) | iMidi; if(!midiLib.MidiMap[iMidi].empty()) { @@ -3658,7 +3658,7 @@ else if(pat == sndFile.Order.GetIgnoreIndex()) text = "+++"; else - text = Stringify(pat); + text = mpt::ToString(pat); doLabelEdit = true; } break; Modified: trunk/OpenMPT/mptrack/tuningRatioMapWnd.cpp =================================================================== --- trunk/OpenMPT/mptrack/tuningRatioMapWnd.cpp 2015-03-11 15:56:44 UTC (rev 4871) +++ trunk/OpenMPT/mptrack/tuningRatioMapWnd.cpp 2015-03-11 16:21:42 UTC (rev 4872) @@ -80,7 +80,7 @@ std::string temp; if(isValidNote) { - temp = "(" + Stringify(noteToDraw) + ") " + m_pTuning->GetNoteName(noteToDraw); + temp = "(" + mpt::ToString(noteToDraw) + ") " + m_pTuning->GetNoteName(noteToDraw); } if(isValidNote && temp.size()+1 < sizeofS) @@ -104,7 +104,7 @@ rect.InflateRect(1, 1); } dc.SetTextColor((bHighLight) ? colorTextSel : colorText); - std::string str = Stringify(m_pTuning->GetRatio(noteToDraw)); + std::string str = mpt::ToString(m_pTuning->GetRatio(noteToDraw)); dc.DrawText(str.c_str(), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } rect.SetRect(rcClient.left+m_cxFont*2-1, rcClient.top, rcClient.left+m_cxFont*2+3, ypaint); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-11 16:33:54
|
Revision: 4873 http://sourceforge.net/p/modplug/code/4873 Author: manxorist Date: 2015-03-11 16:33:48 +0000 (Wed, 11 Mar 2015) Log Message: ----------- [Ref] Replace mpt::String::PrintW with mpt::String::Print. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/common/mptString.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/plugins/PluginManager.cpp trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2015-03-11 16:21:42 UTC (rev 4872) +++ trunk/OpenMPT/common/BuildSettings.h 2015-03-11 16:33:48 UTC (rev 4873) @@ -270,7 +270,7 @@ #if defined(MODPLUG_TRACKER) || MPT_USTRING_MODE_WIDE - // mpt::ToWString, mpt::wfmt, mpt::String::PrintW, ConvertStrTo<std::wstring> + // mpt::ToWString, mpt::wfmt, ConvertStrTo<std::wstring> // Required by the tracker to ease interfacing with WinAPI. // Required by MPT_USTRING_MODE_WIDE to ease type tunneling in mpt::String::Print. #define MPT_WSTRING_FORMAT 1 Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2015-03-11 16:21:42 UTC (rev 4872) +++ trunk/OpenMPT/common/Logging.cpp 2015-03-11 16:33:48 UTC (rev 4873) @@ -71,7 +71,7 @@ } #endif // LOG_TO_FILE { - OutputDebugStringW(mpt::String::PrintW(L"%1(%2): +%3 %4 [%5]\n" + OutputDebugStringW(mpt::String::Print(L"%1(%2): +%3 %4 [%5]\n" , mpt::ToWide(mpt::CharsetASCII, context.file) , context.line , mpt::wfmt::dec<6>(diff) Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2015-03-11 16:21:42 UTC (rev 4872) +++ trunk/OpenMPT/common/mptString.h 2015-03-11 16:33:48 UTC (rev 4873) @@ -1386,8 +1386,6 @@ ); } -#define PrintW Print - } } // namespace mpt::String OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-03-11 16:21:42 UTC (rev 4872) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-03-11 16:33:48 UTC (rev 4873) @@ -128,7 +128,7 @@ else //Case: Valid path but opening fails. { const int nOdc = theApp.GetOpenDocumentCount(); - Reporting::Notification(mpt::String::PrintW(L"Opening \"%1\" failed. This can happen if " + Reporting::Notification(mpt::String::Print(L"Opening \"%1\" failed. This can happen if " L"no more documents can be opened or if the file type was not " L"recognised. If the former is true, it's " L"recommended to close some documents as otherwise a crash is likely" @@ -1813,7 +1813,7 @@ } else if(dialogShown) { CWnd *text = pluginScanDlg.GetDlgItem(IDC_SCANTEXT); - std::wstring scanStr = mpt::String::PrintW(L"Scanning Plugin %1 / %2...\n%3", plug, numPlugins, plugPath); + std::wstring scanStr = mpt::String::Print(L"Scanning Plugin %1 / %2...\n%3", plug, numPlugins, plugPath); SetWindowTextW(text->m_hWnd, scanStr.c_str()); MSG msg; while(::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2015-03-11 16:21:42 UTC (rev 4872) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2015-03-11 16:33:48 UTC (rev 4873) @@ -1088,7 +1088,7 @@ } } catch (...) { - ReportPlugException(mpt::String::PrintW(L"Exception in Dispatch(%1)!", opCode)); + ReportPlugException(mpt::String::Print(L"Exception in Dispatch(%1)!", opCode)); } return result; @@ -1208,7 +1208,7 @@ ResetSilence(); } catch (...) { - ReportPlugException(mpt::String::PrintW(L"Exception in SetParameter(%1, %2)!", nIndex, fValue)); + ReportPlugException(mpt::String::Print(L"Exception in SetParameter(%1, %2)!", nIndex, fValue)); } } @@ -1348,7 +1348,7 @@ ResetSilence(); } catch (...) { - ReportPlugException(mpt::String::PrintW(L"Exception in ProcessVSTEvents(numEvents:%1)!", + ReportPlugException(mpt::String::Print(L"Exception in ProcessVSTEvents(numEvents:%1)!", vstEvents.GetNumEvents())); } } @@ -1499,7 +1499,7 @@ { Bypass(); const wchar_t *processMethod = (m_Effect.flags & effFlagsCanReplacing) ? L"processReplacing" : L"process"; - ReportPlugException(mpt::String::PrintW(L"The plugin threw an exception in %1. It has automatically been set to \"Bypass\".", processMethod)); + ReportPlugException(mpt::String::Print(L"The plugin threw an exception in %1. It has automatically been set to \"Bypass\".", processMethod)); } ASSERT(outputBuffers != nullptr); Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2015-03-11 16:21:42 UTC (rev 4872) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2015-03-11 16:33:48 UTC (rev 4873) @@ -177,7 +177,7 @@ plug->pluginId2 = clsid.Data1; plug->category = VSTPluginLib::catDMO; #ifdef DMO_LOG - Log(mpt::String::PrintW(L"Found \"%1\" clsid=%2\n", plug->libraryName, plug->dllPath)); + Log(mpt::String::Print(L"Found \"%1\" clsid=%2\n", plug->libraryName, plug->dllPath)); #endif } } @@ -261,7 +261,7 @@ } } catch(...) { - CVstPluginManager::ReportPlugException(mpt::String::PrintW(L"Exception caught in LoadLibrary (%1)", pluginPath)); + CVstPluginManager::ReportPlugException(mpt::String::Print(L"Exception caught in LoadLibrary (%1)", pluginPath)); } if(library != nullptr && library != INVALID_HANDLE_VALUE) @@ -423,7 +423,7 @@ FreeLibrary(hLib); } catch(...) { - CVstPluginManager::ReportPlugException(mpt::String::PrintW(L"Exception while trying to load plugin \"%1\"!\n", plug->libraryName)); + CVstPluginManager::ReportPlugException(mpt::String::Print(L"Exception while trying to load plugin \"%1\"!\n", plug->libraryName)); } // Now it should be safe to assume that this plugin loaded properly. :) @@ -465,7 +465,7 @@ delete plug; } catch (...) { - CVstPluginManager::ReportPlugException(mpt::String::PrintW(L"Exception while trying to release plugin \"%1\"!\n", pFactory->libraryName)); + CVstPluginManager::ReportPlugException(mpt::String::Print(L"Exception while trying to release plugin \"%1\"!\n", pFactory->libraryName)); } return true; @@ -584,7 +584,7 @@ } } catch(...) { - CVstPluginManager::ReportPlugException(mpt::String::PrintW(L"Exception while trying to create plugin \"%1\"!\n", pFound->libraryName)); + CVstPluginManager::ReportPlugException(mpt::String::Print(L"Exception while trying to create plugin \"%1\"!\n", pFound->libraryName)); } return validPlugin; Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2015-03-11 16:21:42 UTC (rev 4872) +++ trunk/OpenMPT/test/test.cpp 2015-03-11 16:33:48 UTC (rev 4873) @@ -491,7 +491,6 @@ #if MPT_WSTRING_FORMAT VERIFY_EQUAL(mpt::String::Print(std::wstring(L"%1%2%3"),1,2,3), L"123"); VERIFY_EQUAL(mpt::String::Print(L"%1%2%3",1,2,3), L"123"); - VERIFY_EQUAL(mpt::String::PrintW(L"%1%2%3",1,2,3), L"123"); #endif // escaping and error behviour of '%' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-11 20:28:01
|
Revision: 4875 http://sourceforge.net/p/modplug/code/4875 Author: manxorist Date: 2015-03-11 20:27:52 +0000 (Wed, 11 Mar 2015) Log Message: ----------- [Ref] For the sake of consistency, convert all std integer types to our own ones in soundlib/ and common/. Converting the whole codebase to std::?int??_t would only bloat blame history once again, after the conversion from Win32 types to our own integer types without _t suffix, which happened in the recent past years. Modified Paths: -------------- trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/soundlib/WAVTools.h Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/common/Logging.cpp 2015-03-11 20:27:52 UTC (rev 4875) @@ -45,7 +45,7 @@ // remove eol if already present message = mpt::String::RTrim(message, MPT_USTRING("\r\n")); #if defined(MODPLUG_TRACKER) - static uint64_t s_lastlogtime = 0; + static uint64 s_lastlogtime = 0; uint64 cur = mpt::Date::ANSI::Now(); uint64 diff = cur/10000 - s_lastlogtime; s_lastlogtime = cur/10000; Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2015-03-11 20:27:52 UTC (rev 4875) @@ -705,7 +705,7 @@ if(plugin.IsAutoSuspendable() && pState->inputSilenceCount >= m_MixerSettings.gdwMixingFreq * 4) { bool isSilent = true; - for(uint32_t i = 0; i < nCount; i++) + for(uint32 i = 0; i < nCount; i++) { if(pOutL[i] > FLT_EPSILON || pOutL[i] < -FLT_EPSILON || pOutR[i] > FLT_EPSILON || pOutR[i] < -FLT_EPSILON) Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2015-03-11 20:27:52 UTC (rev 4875) @@ -2090,10 +2090,10 @@ // Rationale: chunks are limited to 65536 bytes, which can easily be reached // with the amount of samples that OpenMPT supports. WRITEMODULARHEADER('S','E','U','C', 2 + CountOf(sample.cues) * 4); - mpt::IO::WriteIntLE<uint16_t>(f, smp); + mpt::IO::WriteIntLE<uint16>(f, smp); for(std::size_t i = 0; i < CountOf(sample.cues); i++) { - mpt::IO::WriteIntLE<uint32_t>(f, sample.cues[i]); + mpt::IO::WriteIntLE<uint32>(f, sample.cues[i]); } } } Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/soundlib/ModChannel.h 2015-03-11 20:27:52 UTC (rev 4875) @@ -21,8 +21,8 @@ struct EnvInfo { FlagSet<EnvelopeFlags> flags; - uint32_t nEnvPosition; - int32_t nEnvValueAtReleaseJump; + uint32 nEnvPosition; + int32 nEnvValueAtReleaseJump; void Reset() { @@ -34,16 +34,16 @@ // Information used in the mixer (should be kept tight for better caching) // Byte sizes are for 32-bit builds and 32-bit integer / float mixer const void *pCurrentSample; // Currently playing sample (nullptr if no sample is playing) - uint32_t nPos; // Current play position - uint32_t nPosLo; // 16-bit fractional part of play position - int32_t nInc; // 16.16 fixed point sample speed relative to mixing frequency (0x10000 = one sample per output sample, 0x20000 = two samples per output sample, etc...) - int32_t leftVol; // 0...4096 (12 bits, since 16 bits + 12 bits = 28 bits = 0dB in integer mixer, see MIXING_ATTENUATION) - int32_t rightVol; // Ditto - int32_t leftRamp; // Ramping delta, 20.12 fixed point (see VOLUMERAMPPRECISION) - int32_t rightRamp; // Ditto + uint32 nPos; // Current play position + uint32 nPosLo; // 16-bit fractional part of play position + int32 nInc; // 16.16 fixed point sample speed relative to mixing frequency (0x10000 = one sample per output sample, 0x20000 = two samples per output sample, etc...) + int32 leftVol; // 0...4096 (12 bits, since 16 bits + 12 bits = 28 bits = 0dB in integer mixer, see MIXING_ATTENUATION) + int32 rightVol; // Ditto + int32 leftRamp; // Ramping delta, 20.12 fixed point (see VOLUMERAMPPRECISION) + int32 rightRamp; // Ditto // Up to here: 32 bytes - int32_t rampLeftVol; // Current ramping volume, 20.12 fixed point (see VOLUMERAMPPRECISION) - int32_t rampRightVol; // Ditto + int32 rampLeftVol; // Current ramping volume, 20.12 fixed point (see VOLUMERAMPPRECISION) + int32 rampRightVol; // Ditto mixsample_t nFilter_Y[2][2]; // Filter memory - two history items per sample channel mixsample_t nFilter_A0, nFilter_B0, nFilter_B1; // Filter coeffs mixsample_t nFilter_HP; @@ -54,7 +54,7 @@ SmpLength nLoopEnd; FlagSet<ChannelFlags> dwFlags; mixsample_t nROfs, nLOfs; - uint32_t nRampLength; + uint32 nRampLength; // Up to here: 100 bytes const ModSample *pModSample; // Currently assigned sample slot (can already be stopped) @@ -64,52 +64,52 @@ SmpLength proTrackerOffset; // Offset for instrument-less notes in ProTracker mode SmpLength oldOffset; FlagSet<ChannelFlags> dwOldFlags; // Flags from previous tick - int32_t newLeftVol, newRightVol; - int32_t nRealVolume, nRealPan; - int32_t nVolume, nPan, nFadeOutVol; - int32_t nPeriod, nC5Speed, nPortamentoDest; - int32_t cachedPeriod, glissandoPeriod; - int32_t nCalcVolume; // Calculated channel volume, 14-Bit (without global volume, pre-amp etc applied) - for MIDI macros + int32 newLeftVol, newRightVol; + int32 nRealVolume, nRealPan; + int32 nVolume, nPan, nFadeOutVol; + int32 nPeriod, nC5Speed, nPortamentoDest; + int32 cachedPeriod, glissandoPeriod; + int32 nCalcVolume; // Calculated channel volume, 14-Bit (without global volume, pre-amp etc applied) - for MIDI macros EnvInfo VolEnv, PanEnv, PitchEnv; // Envelope playback info - int32_t nGlobalVol; // Channel volume (CV in ITTECH.TXT) - int32_t nInsVol; // Sample / Instrument volume (SV * IV in ITTECH.TXT) - int32_t nFineTune, nTranspose; - int32_t nPortamentoSlide, nAutoVibDepth; - uint32_t nAutoVibPos, nVibratoPos, nTremoloPos, nPanbrelloPos; - int32_t nVolSwing, nPanSwing; - int32_t nCutSwing, nResSwing; - int32_t nRestorePanOnNewNote; //If > 0, nPan should be set to nRestorePanOnNewNote - 1 on new note. Used to recover from panswing. - uint32_t nEFxOffset; // offset memory for Invert Loop (EFx, .MOD only) - int32_t nRetrigCount, nRetrigParam; + int32 nGlobalVol; // Channel volume (CV in ITTECH.TXT) + int32 nInsVol; // Sample / Instrument volume (SV * IV in ITTECH.TXT) + int32 nFineTune, nTranspose; + int32 nPortamentoSlide, nAutoVibDepth; + uint32 nAutoVibPos, nVibratoPos, nTremoloPos, nPanbrelloPos; + int32 nVolSwing, nPanSwing; + int32 nCutSwing, nResSwing; + int32 nRestorePanOnNewNote; //If > 0, nPan should be set to nRestorePanOnNewNote - 1 on new note. Used to recover from panswing. + uint32 nEFxOffset; // offset memory for Invert Loop (EFx, .MOD only) + int32 nRetrigCount, nRetrigParam; ROWINDEX nPatternLoop; CHANNELINDEX nMasterChn; ModCommand rowCommand; // 8-bit members - uint8_t resamplingMode; - uint8_t nRestoreResonanceOnNewNote; // See nRestorePanOnNewNote - uint8_t nRestoreCutoffOnNewNote; // ditto - uint8_t nNote, nNNA; - uint8_t nLastNote; // Last note, ignoring note offs and cuts - for MIDI macros - uint8_t nArpeggioLastNote, nArpeggioBaseNote; // For plugin arpeggio - uint8_t nNewNote, nNewIns, nOldIns, nCommand, nArpeggio; - uint8_t nOldVolumeSlide, nOldFineVolUpDown; - uint8_t nOldPortaUpDown, nOldFinePortaUpDown, nOldExtraFinePortaUpDown; - uint8_t nOldPanSlide, nOldChnVolSlide; - uint8_t nOldGlobalVolSlide; - uint8_t nVibratoType, nVibratoSpeed, nVibratoDepth; - uint8_t nTremoloType, nTremoloSpeed, nTremoloDepth; - uint8_t nPanbrelloType, nPanbrelloSpeed, nPanbrelloDepth; - int8_t nPanbrelloOffset, nPanbrelloRandomMemory; - uint8_t nOldCmdEx, nOldVolParam, nOldTempo; - uint8_t nOldHiOffset; - uint8_t nCutOff, nResonance; - uint8_t nTremorCount, nTremorParam; - uint8_t nPatternLoopCount; - uint8_t nLeftVU, nRightVU; - uint8_t nActiveMacro, nFilterMode; - uint8_t nEFxSpeed, nEFxDelay; // memory for Invert Loop (EFx, .MOD only) - uint8_t nNoteSlideCounter, nNoteSlideSpeed, nNoteSlideStep; // IMF / PTM Note Slide - uint8_t lastZxxParam; // Memory for \xx slides + uint8 resamplingMode; + uint8 nRestoreResonanceOnNewNote; // See nRestorePanOnNewNote + uint8 nRestoreCutoffOnNewNote; // ditto + uint8 nNote, nNNA; + uint8 nLastNote; // Last note, ignoring note offs and cuts - for MIDI macros + uint8 nArpeggioLastNote, nArpeggioBaseNote; // For plugin arpeggio + uint8 nNewNote, nNewIns, nOldIns, nCommand, nArpeggio; + uint8 nOldVolumeSlide, nOldFineVolUpDown; + uint8 nOldPortaUpDown, nOldFinePortaUpDown, nOldExtraFinePortaUpDown; + uint8 nOldPanSlide, nOldChnVolSlide; + uint8 nOldGlobalVolSlide; + uint8 nVibratoType, nVibratoSpeed, nVibratoDepth; + uint8 nTremoloType, nTremoloSpeed, nTremoloDepth; + uint8 nPanbrelloType, nPanbrelloSpeed, nPanbrelloDepth; + int8 nPanbrelloOffset, nPanbrelloRandomMemory; + uint8 nOldCmdEx, nOldVolParam, nOldTempo; + uint8 nOldHiOffset; + uint8 nCutOff, nResonance; + uint8 nTremorCount, nTremorParam; + uint8 nPatternLoopCount; + uint8 nLeftVU, nRightVU; + uint8 nActiveMacro, nFilterMode; + uint8 nEFxSpeed, nEFxDelay; // memory for Invert Loop (EFx, .MOD only) + uint8 nNoteSlideCounter, nNoteSlideSpeed, nNoteSlideStep; // IMF / PTM Note Slide + uint8 lastZxxParam; // Memory for \xx slides bool isFirstTick : 1; //-->Variables used to make user-definable tuning modes work with pattern effects. @@ -121,15 +121,15 @@ //To tell whether to calculate frequency. bool m_CalculateFreq : 1; - int32_t m_PortamentoFineSteps, m_PortamentoTickSlide; + int32 m_PortamentoFineSteps, m_PortamentoTickSlide; - uint32_t m_Freq; + uint32 m_Freq; float m_VibratoDepth; //<---- //NOTE_PCs memory. float m_plugParamValueStep, m_plugParamTargetValue; - uint16_t m_RowPlugParam; + uint16 m_RowPlugParam; PLUGINDEX m_RowPlug; void ClearRowCmd() { rowCommand = ModCommand::Empty(); } @@ -172,7 +172,7 @@ void Reset(ResetFlags resetMask, const CSoundFile &sndFile, CHANNELINDEX sourceChannel); - typedef uint32_t volume_t; + typedef uint32 volume_t; volume_t GetVSTVolume() { return (pModInstrument) ? pModInstrument->nGlobalVol * 4 : nVolume; } // Check if the channel has a valid MIDI output. This function guarantees that pModInstrument != nullptr. @@ -193,8 +193,8 @@ struct ModChannelSettings { FlagSet<ChannelFlags> dwFlags; // Channel flags - uint16_t nPan; // Initial pan (0...256) - uint16_t nVolume; // Initial channel volume (0...64) + uint16 nPan; // Initial pan (0...256) + uint16 nVolume; // Initial channel volume (0...64) PLUGINDEX nMixPlugin; // Assigned plugin char szName[MAX_CHANNELNAME]; // Channel name Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2015-03-11 20:27:52 UTC (rev 4875) @@ -2279,20 +2279,20 @@ struct { RIFFChunk header; - uint32_t numPoints; + uint32 numPoints; WAVCuePoint cues[CountOf(sample.cues)]; } chunk; chunk.header.id = RIFFChunk::idcue_; chunk.header.length = 4 + sizeof(chunk.cues); - for(uint32_t i = 0; i < CountOf(sample.cues); i++) + for(uint32 i = 0; i < CountOf(sample.cues); i++) { chunk.cues[i].ConvertToWAV(i, sample.cues[i]); chunk.cues[i].ConvertEndianness(); } - const uint32_t length = sizeof(RIFFChunk) + chunk.header.length; + const uint32 length = sizeof(RIFFChunk) + chunk.header.length; chunk.header.ConvertEndianness(); FLAC__metadata_object_application_set_data(metadata[numBlocks], reinterpret_cast<FLAC__byte *>(&chunk), length, true); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-11 20:27:52 UTC (rev 4875) @@ -374,17 +374,17 @@ break; } { - uint32_t tempo = CalculateXParam(memory.state.m_nPattern, memory.state.m_nRow, nChn); + uint32 tempo = CalculateXParam(memory.state.m_nPattern, memory.state.m_nRow, nChn); if ((adjustMode & eAdjust) && (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT))) { - if (tempo) pChn->nOldTempo = static_cast<uint8_t>(tempo); else tempo = pChn->nOldTempo; + if (tempo) pChn->nOldTempo = static_cast<uint8>(tempo); else tempo = pChn->nOldTempo; } if (tempo >= 0x20) memory.state.m_nMusicTempo = tempo; else { // Tempo Slide - uint32_t tempoDiff = (tempo & 0x0F) * (memory.state.m_nMusicSpeed - 1); + uint32 tempoDiff = (tempo & 0x0F) * (memory.state.m_nMusicSpeed - 1); if ((tempo & 0xF0) == 0x10) { memory.state.m_nMusicTempo += tempoDiff; @@ -560,7 +560,7 @@ case CMD_CHANNELVOLSLIDE: { if (param) pChn->nOldChnVolSlide = param; else param = pChn->nOldChnVolSlide; - int32_t volume = pChn->nGlobalVol; + int32 volume = pChn->nGlobalVol; if((param & 0x0F) == 0x0F && (param & 0xF0)) volume += (param >> 4); // Fine Up else if((param & 0xF0) == 0xF0 && (param & 0x0F)) @@ -1554,7 +1554,7 @@ void CSoundFile::ApplyInstrumentPanning(ModChannel *pChn, const ModInstrument *instr, const ModSample *smp) const //--------------------------------------------------------------------------------------------------------------- { - int32_t newPan = int32_min; + int32 newPan = int32_min; // Default instrument panning if(instr != nullptr && instr->dwFlags[INS_SETPANNING]) newPan = instr->nPan; @@ -1585,13 +1585,13 @@ if (!pChn->nFadeOutVol) return 0; // All channels are used: check for lowest volume CHANNELINDEX result = 0; - uint32_t vol = 64*65536; // 25% - uint32_t envpos = int32_max; + uint32 vol = 64*65536; // 25% + uint32 envpos = int32_max; const ModChannel *pj = &m_PlayState.Chn[m_nChannels]; for (CHANNELINDEX j=m_nChannels; j<MAX_CHANNELS; j++, pj++) { if (!pj->nFadeOutVol) return j; - uint32_t v = pj->nVolume; + uint32 v = pj->nVolume; if(pj->dwFlags[CHN_NOTEFADE]) v = v * pj->nFadeOutVol; else @@ -3002,13 +3002,13 @@ // Calculate full parameter for effects that support parameter extension at the given pattern location. // maxCommands sets the maximum number of XParam commands to look at for this effect // isExtended returns if the command is actually using any XParam extensions. -uint32_t CSoundFile::CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn, bool *isExtended) const +uint32 CSoundFile::CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn, bool *isExtended) const //------------------------------------------------------------------------------------------------------------ { if(isExtended != nullptr) *isExtended = false; ROWINDEX maxCommands = 4; const ModCommand *m = Patterns[pat].GetpModCommand(row, chn); - uint32_t val = m->param; + uint32 val = m->param; switch(m->command) { @@ -3408,7 +3408,7 @@ if((!m_SongFlags[SONG_ITCOMPATGXX] && IsCompatibleMode(TRK_IMPULSETRACKER)) || GetType() == MOD_TYPE_PLM) { if(param == 0) param = pChn->nOldPortaUpDown; - pChn->nOldPortaUpDown = static_cast<uint8_t>(param); + pChn->nOldPortaUpDown = static_cast<uint8>(param); } if(GetType() == MOD_TYPE_MPT && pChn->pModInstrument && pChn->pModInstrument->pTuning) @@ -3428,7 +3428,7 @@ (pChn->nPortamentoDest < 0 && pChn->nPortamentoSlide > 0)) pChn->nPortamentoSlide = -pChn->nPortamentoSlide; - pChn->m_PortamentoTickSlide = static_cast<int32_t>((m_PlayState.m_nTickCount + 1.0) * pChn->nPortamentoSlide / m_PlayState.m_nMusicSpeed); + pChn->m_PortamentoTickSlide = static_cast<int32>((m_PlayState.m_nTickCount + 1.0) * pChn->nPortamentoSlide / m_PlayState.m_nMusicSpeed); if(pChn->dwFlags[CHN_GLISSANDO]) { @@ -3821,7 +3821,7 @@ //------------------------------------------------------------------------------ { ModChannel *pChn = &m_PlayState.Chn[nChn]; - uint8_t command = param & 0xF0; + uint8 command = param & 0xF0; param &= 0x0F; switch(command) { @@ -3894,7 +3894,7 @@ //------------------------------------------------------------------------------ { ModChannel *pChn = &m_PlayState.Chn[nChn]; - uint8_t command = param & 0xF0; + uint8 command = param & 0xF0; param &= 0x0F; switch(command) { @@ -4038,7 +4038,7 @@ // SAx: Set 64k Offset case 0xA0: if(m_SongFlags[SONG_FIRSTTICK]) { - pChn->nOldHiOffset = static_cast<uint8_t>(param); + pChn->nOldHiOffset = static_cast<uint8>(param); if (!IsCompatibleMode(TRK_IMPULSETRACKER) && pChn->rowCommand.IsNote()) { SmpLength pos = param << 16; @@ -4068,7 +4068,7 @@ case 0xF0: if(GetType() != MOD_TYPE_S3M) { - pChn->nActiveMacro = static_cast<uint8_t>(param); + pChn->nActiveMacro = static_cast<uint8>(param); } break; } @@ -4747,7 +4747,7 @@ if(m_SongFlags[SONG_LINEARSLIDES] && GetType() != MOD_TYPE_XM) { // IT Linear slides - const int32_t nOldPeriod = pChn->nPeriod; + const int32 nOldPeriod = pChn->nPeriod; if (nFreqSlide < 0) { UINT n = (-nFreqSlide) / 4; @@ -4955,7 +4955,7 @@ if(p->nPatternLoopCount) return ROWINDEX_INVALID; } } - pChn->nPatternLoopCount = static_cast<uint8_t>(param); + pChn->nPatternLoopCount = static_cast<uint8>(param); } m_PlayState.m_nNextPatStartRow = pChn->nPatternLoop; // Nasty FT2 E60 bug emulation! return pChn->nPatternLoop; @@ -4968,10 +4968,10 @@ } -void CSoundFile::GlobalVolSlide(ModCommand::PARAM param, uint8_t &nOldGlobalVolSlide) +void CSoundFile::GlobalVolSlide(ModCommand::PARAM param, uint8 &nOldGlobalVolSlide) //----------------------------------------------------------------------------------- { - int32_t nGlbSlide = 0; + int32 nGlbSlide = 0; if (param) nOldGlobalVolSlide = param; else param = nOldGlobalVolSlide; if((GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))) @@ -5394,9 +5394,9 @@ const int tickParam = static_cast<int>((m_PlayState.m_nTickCount + 1.0) * param / m_PlayState.m_nMusicSpeed); pChn->m_PortamentoFineSteps += (param >= 0) ? tickParam - pChn->nOldFinePortaUpDown : tickParam + pChn->nOldFinePortaUpDown; if(m_PlayState.m_nTickCount + 1 == m_PlayState.m_nMusicSpeed) - pChn->nOldFinePortaUpDown = static_cast<int8_t>(std::abs(param)); + pChn->nOldFinePortaUpDown = static_cast<int8>(std::abs(param)); else - pChn->nOldFinePortaUpDown = static_cast<int8_t>(std::abs(tickParam)); + pChn->nOldFinePortaUpDown = static_cast<int8>(std::abs(tickParam)); pChn->m_CalculateFreq = true; } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2015-03-11 20:27:52 UTC (rev 4875) @@ -1810,8 +1810,8 @@ // Get length of a tick in sample, with tick-to-tick tempo correction in modern tempo mode. // This has to be called exactly once per tick because otherwise the error accumulation // goes wrong. -uint32_t CSoundFile::GetTickDuration(uint32_t tempo, uint32_t speed, ROWINDEX rowsPerBeat) -//---------------------------------------------------------------------------------------- +uint32 CSoundFile::GetTickDuration(uint32 tempo, uint32 speed, ROWINDEX rowsPerBeat) +//---------------------------------------------------------------------------------- { UINT retval = 0; switch(m_nTempoMode) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/soundlib/Sndfile.h 2015-03-11 20:27:52 UTC (rev 4875) @@ -646,7 +646,7 @@ void RecalculateSamplesPerTick(); double GetRowDuration(UINT tempo, UINT speed) const; - uint32_t GetTickDuration(uint32_t tempo, uint32_t speed, ROWINDEX rowsPerBeat); + uint32 GetTickDuration(uint32 tempo, uint32 speed, ROWINDEX rowsPerBeat); // A repeat count value of -1 means infinite loop void SetRepeatCount(int n) { m_nRepeatCount = n; } @@ -781,7 +781,7 @@ void NoteChange(ModChannel *pChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false) const; void InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true) const; void ApplyInstrumentPanning(ModChannel *pChn, const ModInstrument *instr, const ModSample *smp) const; - uint32_t CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn, bool *isExtended = nullptr) const; + uint32 CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn, bool *isExtended = nullptr) const; // Channel Effects void KeyOff(ModChannel *pChn) const; @@ -850,7 +850,7 @@ void ExtendedChannelEffect(ModChannel *, UINT param); void InvertLoop(ModChannel* pChn); ROWINDEX PatternBreak(PlayState &state, CHANNELINDEX chn, uint8 param) const; - void GlobalVolSlide(ModCommand::PARAM param, uint8_t &nOldGlobalVolSlide); + void GlobalVolSlide(ModCommand::PARAM param, uint8 &nOldGlobalVolSlide); void ProcessMacroOnChannel(CHANNELINDEX nChn); void ProcessMIDIMacro(CHANNELINDEX nChn, bool isSmooth, char *macro, uint8 param = 0, PLUGINDEX plugin = 0); Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2015-03-11 20:27:52 UTC (rev 4875) @@ -187,9 +187,9 @@ // Read cue points if(cueChunk.IsValid()) { - uint32_t numPoints = cueChunk.ReadUint32LE(); + uint32 numPoints = cueChunk.ReadUint32LE(); LimitMax(numPoints, CountOf(sample.cues)); - for(uint32_t i = 0; i < numPoints; i++) + for(uint32 i = 0; i < numPoints; i++) { WAVCuePoint cuePoint; cueChunk.ReadConvertEndianness(cuePoint); @@ -559,10 +559,10 @@ { StartChunk(RIFFChunk::idcue_); { - const uint32_t numPoints = SwapBytesLE_(CountOf(sample.cues)); + const uint32 numPoints = SwapBytesLE_(CountOf(sample.cues)); Write(numPoints); } - for(uint32_t i = 0; i < CountOf(sample.cues); i++) + for(uint32 i = 0; i < CountOf(sample.cues); i++) { WAVCuePoint cuePoint; cuePoint.ConvertToWAV(i, sample.cues[i]); Modified: trunk/OpenMPT/soundlib/WAVTools.h =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.h 2015-03-11 16:59:34 UTC (rev 4874) +++ trunk/OpenMPT/soundlib/WAVTools.h 2015-03-11 20:27:52 UTC (rev 4875) @@ -327,7 +327,7 @@ } // Set up sample information - void ConvertToWAV(uint32_t id_, SmpLength offset_) + void ConvertToWAV(uint32 id_, SmpLength offset_) { id = id_; position = offset_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-03-14 23:20:37
|
Revision: 4887 http://sourceforge.net/p/modplug/code/4887 Author: saga-games Date: 2015-03-14 23:20:30 +0000 (Sat, 14 Mar 2015) Log Message: ----------- [Imp] Sample tab: Loop cross-fader can now be configured between constant power and constant volume. Post-loop fade added. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp trunk/OpenMPT/mptrack/SampleEditorDialogs.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.h Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2015-03-14 16:51:10 UTC (rev 4886) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2015-03-14 23:20:30 UTC (rev 4887) @@ -3147,42 +3147,32 @@ // Crossfade loop to create smooth loop transitions -#define DEFAULT_XFADE_LENGTH 16384 //4096 - -static SmpLength LimitXFadeLength(SmpLength len, const ModSample &sample) -{ - return Util::Min(len, sample.nLoopEnd - sample.nLoopStart, sample.nLoopEnd / 2); -} - void CCtrlSamples::OnXFade() //-------------------------- { - static SmpLength fadeLength = DEFAULT_XFADE_LENGTH; ModSample &sample = m_sndFile.GetSample(m_nSample); - if(sample.pSample == nullptr) return; - if(sample.nLoopEnd <= sample.nLoopStart || sample.nLoopEnd > sample.nLength) return; - // Case 1: The loop start is preceeded by > XFADE_LENGTH samples. Nothing has to be adjusted. - // Case 2: The actual loop is shorter than XFADE_LENGTH samples. - // Case 3: There is not enough sample material before the loop start. Move the loop start. - fadeLength = LimitXFadeLength(fadeLength, sample); + if(sample.pSample == nullptr + || sample.nLoopEnd <= sample.nLoopStart || sample.nLoopEnd > sample.nLength) + { + MessageBeep(MB_ICONWARNING); + return; + } + const SmpLength maxSamples = Util::Min(sample.nLength, sample.nLoopStart, sample.nLoopEnd / 2); - CSampleXFadeDlg dlg(this, fadeLength, LimitXFadeLength(sample.nLength, sample)); + CSampleXFadeDlg dlg(this, sample.nLoopEnd - sample.nLoopStart, maxSamples); if(dlg.DoModal() == IDOK) { - fadeLength = dlg.m_nSamples; + SmpLength fadeSamples = dlg.PercentToSamples(dlg.m_fadeLength); + LimitMax(fadeSamples, maxSamples); + if(fadeSamples < 2) return; - if(fadeLength < 4) return; + m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_update, "Crossfade", + sample.nLoopEnd - fadeSamples, + sample.nLoopEnd + (dlg.m_afterloopFade ? std::min(sample.nLength - sample.nLoopEnd, fadeSamples) : 0)); - m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_update, "Crossfade", sample.nLoopEnd - fadeLength, sample.nLoopEnd); - // If we want to fade nFadeLength bytes, we need as much sample material before the loop point. nFadeLength has been adjusted above. - if(sample.nLoopStart < fadeLength) + if(ctrlSmp::XFadeSample(sample, fadeSamples, dlg.m_fadeLaw, dlg.m_afterloopFade, m_sndFile)) { - sample.nLoopStart = fadeLength; - } - - if(ctrlSmp::XFadeSample(sample, fadeLength, m_sndFile)) - { SetModified(SampleHint().Info().Data(), true, true); } else { Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp 2015-03-14 16:51:10 UTC (rev 4886) +++ trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp 2015-03-14 23:20:30 UTC (rev 4887) @@ -220,6 +220,17 @@ ///////////////////////////////////////////////////////////////////////// // Sample cross-fade dialog +uint32 CSampleXFadeDlg::m_fadeLength = 20000; +uint32 CSampleXFadeDlg::m_fadeLaw = 50000; +bool CSampleXFadeDlg::m_afterloopFade = true; + +BEGIN_MESSAGE_MAP(CSampleXFadeDlg, CDialog) + ON_WM_HSCROLL() + ON_EN_CHANGE(IDC_EDIT1, OnFadeLengthChanged) + ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipText) +END_MESSAGE_MAP() + + void CSampleXFadeDlg::DoDataExchange(CDataExchange* pDX) //------------------------------------------------------ { @@ -227,6 +238,8 @@ //{{AFX_DATA_MAP(CSampleGridDlg) DDX_Control(pDX, IDC_EDIT1, m_EditSamples); DDX_Control(pDX, IDC_SPIN1, m_SpinSamples); + DDX_Control(pDX, IDC_SLIDER1, m_SliderLength); + DDX_Control(pDX, IDC_SLIDER2, m_SliderFadeLaw); //}}AFX_DATA_MAP } @@ -235,10 +248,21 @@ //---------------------------------- { CDialog::OnInitDialog(); - m_SpinSamples.SetRange32(0, m_nMaxSamples); - m_SpinSamples.SetPos(m_nSamples); - SetDlgItemInt(IDC_EDIT1, m_nSamples, FALSE); + m_editLocked = true; + m_SpinSamples.SetRange32(0, std::min(m_loopLength, m_maxLength)); GetDlgItem(IDC_EDIT1)->SetFocus(); + m_SliderLength.SetRange(0, 100000); + m_SliderLength.SetPos(m_fadeLength); + m_SliderFadeLaw.SetRange(0, 100000); + m_SliderFadeLaw.SetPos(m_fadeLaw); + CheckDlgButton(IDC_CHECK1, m_afterloopFade ? BST_CHECKED : BST_UNCHECKED); + + SmpLength numSamples = PercentToSamples(m_SliderLength.GetPos()); + numSamples = Util::Min(numSamples, m_loopLength, m_maxLength); + m_SpinSamples.SetPos(numSamples); + SetDlgItemInt(IDC_EDIT1, numSamples, FALSE); + + m_editLocked = false; return TRUE; } @@ -246,12 +270,76 @@ void CSampleXFadeDlg::OnOK() //-------------------------- { - m_nSamples = GetDlgItemInt(IDC_EDIT1, NULL, FALSE); - LimitMax(m_nSamples, m_nMaxSamples); + m_fadeLength = m_SliderLength.GetPos(); + m_fadeLaw = m_SliderFadeLaw.GetPos(); + m_afterloopFade = IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED; + Limit(m_fadeLength, uint32(0), uint32(100000)); CDialog::OnOK(); } +void CSampleXFadeDlg::OnFadeLengthChanged() +//----------------------------------------- +{ + if(m_editLocked) return; + SmpLength numSamples = GetDlgItemInt(IDC_EDIT1, NULL, FALSE); + numSamples = Util::Min(numSamples, m_loopLength, m_maxLength); + m_SliderLength.SetPos(SamplesToPercent(numSamples)); +} + + +void CSampleXFadeDlg::OnHScroll(UINT, UINT, CScrollBar *sb) +//--------------------------------------------------------- +{ + if(sb == (CScrollBar *)(&m_SliderLength)) + { + m_editLocked = true; + SmpLength numSamples = PercentToSamples(m_SliderLength.GetPos()); + if(numSamples > m_maxLength) + { + numSamples = m_maxLength; + m_SliderLength.SetPos(SamplesToPercent(numSamples)); + } + m_SpinSamples.SetPos(numSamples); + SetDlgItemInt(IDC_EDIT1, numSamples, FALSE); + m_editLocked = false; + } +} + + +BOOL CSampleXFadeDlg::OnToolTipText(UINT, NMHDR *pNMHDR, LRESULT *pResult) +//------------------------------------------------------------------------ +{ + TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR; + UINT_PTR nID = pNMHDR->idFrom; + if(pTTT->uFlags & TTF_IDISHWND) + { + // idFrom is actually the HWND of the tool + nID = (UINT_PTR)::GetDlgCtrlID((HWND)nID); + } + switch(nID) + { + case IDC_SLIDER1: + { + uint32 percent = m_SliderLength.GetPos(); + wsprintf(pTTT->szText, _T("%u.%03u%% of the loop (%u samples)"), percent / 1000, percent % 1000, PercentToSamples(percent)); + } + break; + case IDC_SLIDER2: + _tcscpy(pTTT->szText, _T("Slide towards constant power for fixing badly looped samples.")); + break; + default: + return FALSE; + } + *pResult = 0; + + // bring the tooltip window above other popup windows + ::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0, + SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); + return TRUE; +} + + ///////////////////////////////////////////////////////////////////////// // Resampling dialog Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/SampleEditorDialogs.h 2015-03-14 16:51:10 UTC (rev 4886) +++ trunk/OpenMPT/mptrack/SampleEditorDialogs.h 2015-03-14 23:20:30 UTC (rev 4887) @@ -139,19 +139,35 @@ //=================================== { public: - SmpLength m_nSamples, m_nMaxSamples; + static uint32 m_fadeLength; + static uint32 m_fadeLaw; + static bool m_afterloopFade; + SmpLength m_loopLength, m_maxLength; protected: + CSliderCtrl m_SliderLength, m_SliderFadeLaw; CEdit m_EditSamples; CSpinButtonCtrl m_SpinSamples; + bool m_editLocked : 1; public: - CSampleXFadeDlg(CWnd *parent, SmpLength nSamples, UINT nMaxSamples) : CDialog(IDD_SAMPLE_XFADE, parent), m_nSamples(nSamples), m_nMaxSamples(nMaxSamples) { }; + CSampleXFadeDlg(CWnd *parent, SmpLength loopLength, SmpLength maxLength) + : CDialog(IDD_SAMPLE_XFADE, parent) + , m_loopLength(loopLength) + , m_maxLength(maxLength) + , m_editLocked(true) { }; + SmpLength PercentToSamples(uint32 percent) const { return Util::muldivr_unsigned(percent, m_loopLength, 100000); } + uint32 SamplesToPercent(SmpLength samples) const { return Util::muldivr_unsigned(samples, 100000, m_loopLength); } + protected: virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); virtual void OnOK(); + afx_msg void OnFadeLengthChanged(); + afx_msg void OnHScroll(UINT, UINT, CScrollBar *); + afx_msg BOOL OnToolTipText(UINT, NMHDR *pNMHDR, LRESULT *pResult); + DECLARE_MESSAGE_MAP() }; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2015-03-14 16:51:10 UTC (rev 4886) +++ trunk/OpenMPT/mptrack/mptrack.rc 2015-03-14 23:20:30 UTC (rev 4887) @@ -193,17 +193,21 @@ LTEXT "Grid Segments:",IDC_STATIC,6,8,60,8 END -IDD_SAMPLE_XFADE DIALOGEX 0, 0, 178, 82 +IDD_SAMPLE_XFADE DIALOGEX 0, 0, 292, 82 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Sample Crossfader" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,66,60,50,14 - PUSHBUTTON "Cancel",IDCANCEL,120,60,50,14 - EDITTEXT IDC_EDIT1,108,6,54,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,144,6,11,14 - LTEXT "Higher numbers generate smoother loop transitions. However, the number is limited by the loop length and the amount of samples before the loop start.",IDC_STATIC,6,24,168,36 - LTEXT "Samples used for fading:",IDC_STATIC,6,8,96,8 + DEFPUSHBUTTON "OK",IDOK,180,60,50,14 + PUSHBUTTON "Cancel",IDCANCEL,234,60,50,14 + RTEXT "&Samples used for fading:",IDC_STATIC,6,8,84,8 + CONTROL "",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,96,5,120,15 + EDITTEXT IDC_EDIT1,222,6,54,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,258,6,11,14 + RTEXT "&Constant Volume",IDC_STATIC,30,27,60,8 + CONTROL "",IDC_SLIDER2,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,96,24,120,15 + LTEXT "Constant Power",IDC_STATIC,222,27,60,8 + CONTROL "&Post-loop fade",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,42,180,12 END IDD_OPTIONS_UPDATE DIALOGEX 0, 0, 286, 281 @@ -432,7 +436,7 @@ IDD_SAMPLE_XFADE, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 171 + RIGHTMARGIN, 285 TOPMARGIN, 7 BOTTOMMARGIN, 75 END Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2015-03-14 16:51:10 UTC (rev 4886) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2015-03-14 23:20:30 UTC (rev 4887) @@ -566,8 +566,8 @@ template <class T> -void ReverseSampleImpl(T *pStart, const SmpLength nLength) -//-------------------------------------------------------- +static void ReverseSampleImpl(T *pStart, const SmpLength nLength) +//--------------------------------------------------------------- { for(SmpLength i = 0; i < nLength / 2; i++) { @@ -604,8 +604,8 @@ template <class T> -void UnsignSampleImpl(T *pStart, const SmpLength nLength) -//------------------------------------------------------- +static void UnsignSampleImpl(T *pStart, const SmpLength nLength) +//-------------------------------------------------------------- { const T offset = (std::numeric_limits<T>::min)(); for(SmpLength i = 0; i < nLength; i++) @@ -639,8 +639,8 @@ template <class T> -void InvertSampleImpl(T *pStart, const SmpLength nLength) -//------------------------------------------------------- +static void InvertSampleImpl(T *pStart, const SmpLength nLength) +//-------------------------------------------------------------- { for(SmpLength i = 0; i < nLength; i++) { @@ -673,42 +673,49 @@ template <class T> -void XFadeSampleImpl(T *pStart, const SmpLength nOffset, SmpLength nFadeLength) -//----------------------------------------------------------------------------- +static void XFadeSampleImpl(const T *srcIn, const T *srcOut, T *output, const SmpLength fadeLength, double e) +//----------------------------------------------------------------------------------------------------------- { - const double length = 1.0 / static_cast<double>(nFadeLength); - for(SmpLength i = 0; i < nFadeLength; i++) + const double length = 1.0 / static_cast<double>(fadeLength); + for(SmpLength i = 0; i < fadeLength; i++, srcIn++, srcOut++, output++) { - // Constant-power crossfade - double fact1 = std::sqrt(i * length); - double fact2 = std::sqrt((nFadeLength - i) * length); + double fact1 = std::pow(i * length, e); + double fact2 = std::pow((fadeLength - i) * length, e); int32 val = static_cast<int32>( - static_cast<double>(pStart[nOffset + i]) * fact2 + - static_cast<double>(pStart[i]) * fact1); + static_cast<double>(*srcIn) * fact1 + + static_cast<double>(*srcOut) * fact2); Limit(val, std::numeric_limits<T>::min(), std::numeric_limits<T>::max()); - pStart[nOffset + i] = static_cast<T>(val); + *output = static_cast<T>(val); } } // X-Fade sample data to create smooth loop transitions -bool XFadeSample(ModSample &smp, SmpLength iFadeLength, CSoundFile &sndFile) -//-------------------------------------------------------------------------- +bool XFadeSample(ModSample &smp, SmpLength iFadeLength, int fadeLaw, bool afterloopFade, CSoundFile &sndFile) +//----------------------------------------------------------------------------------------------------------- { if(!smp.HasSampleData()) return false; if(smp.nLoopEnd <= smp.nLoopStart || smp.nLoopEnd > smp.nLength) return false; if(smp.nLoopStart < iFadeLength) return false; - SmpLength start = smp.nLoopStart - iFadeLength; - SmpLength end = smp.nLoopEnd - iFadeLength; - start *= smp.GetNumChannels(); - end *= smp.GetNumChannels(); + const SmpLength start = (smp.nLoopStart - iFadeLength) * smp.GetNumChannels(); + const SmpLength end = (smp.nLoopEnd - iFadeLength) * smp.GetNumChannels(); + const SmpLength afterloopStart = smp.nLoopStart * smp.GetNumChannels(); + const SmpLength afterloopEnd = smp.nLoopEnd * smp.GetNumChannels(); + const SmpLength afterLoopLength = std::min(smp.nLength - smp.nLoopEnd, iFadeLength) * smp.GetNumChannels(); iFadeLength *= smp.GetNumChannels(); + // e=0.5: constant power crossfade (for uncorrelated samples), e=1.0: constant volume crossfade (for perfectly correlated samples) + const double e = 1.0 - fadeLaw / 200000.0; + if(smp.GetElementarySampleSize() == 2) - XFadeSampleImpl(smp.pSample16 + start, end - start, iFadeLength); - else if(smp.GetElementarySampleSize() == 1) - XFadeSampleImpl(smp.pSample8 + start, end - start, iFadeLength); - else + { + XFadeSampleImpl(smp.pSample16 + start, smp.pSample16 + end, smp.pSample16 + end, iFadeLength, e); + if(afterloopFade) XFadeSampleImpl(smp.pSample16 + afterloopEnd, smp.pSample16 + afterloopStart, smp.pSample16 + afterloopEnd, afterLoopLength, e); + } else if(smp.GetElementarySampleSize() == 1) + { + XFadeSampleImpl(smp.pSample8 + start, smp.pSample8 + end, smp.pSample8 + end, iFadeLength, e); + if(afterloopFade) XFadeSampleImpl(smp.pSample8 + afterloopEnd, smp.pSample8 + afterloopStart, smp.pSample8 + afterloopEnd, afterLoopLength, e); + } else return false; PrecomputeLoops(smp, sndFile, true); @@ -717,8 +724,8 @@ template <class T> -void ConvertStereoToMonoMixImpl(T *pDest, const SmpLength length) -//--------------------------------------------------------------- +static void ConvertStereoToMonoMixImpl(T *pDest, const SmpLength length) +//---------------------------------------------------------------------- { const T *pEnd = pDest + length; for(T *pSource = pDest; pDest != pEnd; pDest++, pSource += 2) @@ -729,8 +736,8 @@ template <class T> -void ConvertStereoToMonoOneChannelImpl(T *pDest, const SmpLength length) -//---------------------------------------------------------------------- +static void ConvertStereoToMonoOneChannelImpl(T *pDest, const SmpLength length) +//----------------------------------------------------------------------------- { const T *pEnd = pDest + length; for(T *pSource = pDest; pDest != pEnd; pDest++, pSource += 2) Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.h =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.h 2015-03-14 16:51:10 UTC (rev 4886) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.h 2015-03-14 23:20:30 UTC (rev 4887) @@ -80,7 +80,7 @@ bool InvertSample(ModSample &smp, SmpLength iStart, SmpLength iEnd, CSoundFile &sndFile); // Crossfade sample data to create smooth loops -bool XFadeSample(ModSample &smp, SmpLength iFadeLength, CSoundFile &sndFile); +bool XFadeSample(ModSample &smp, SmpLength iFadeLength, int fadeLaw, bool afterloopFade, CSoundFile &sndFile); enum StereoToMonoMode { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-03-20 15:49:10
|
Revision: 4901 http://sourceforge.net/p/modplug/code/4901 Author: saga-games Date: 2015-03-20 15:48:55 +0000 (Fri, 20 Mar 2015) Log Message: ----------- [Imp] GetLength now handles panning commands (http://bugs.openmpt.org/view.php?id=657) [Imp] Handle row delay in GetLength (more) correctly [Imp] Further performance improvements to GetLength [Mod] OpenMPT: Version is now 1.24.02.07 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-03-19 15:38:34 UTC (rev 4900) +++ trunk/OpenMPT/common/versionNumber.h 2015-03-20 15:48:55 UTC (rev 4901) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 06 +#define VER_MINORMINOR 07 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-19 15:38:34 UTC (rev 4900) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-20 15:48:55 UTC (rev 4901) @@ -52,7 +52,7 @@ ROWINDEX patLoopStart; uint32 ticksToRender; // When using sample sync, we still need to render this many ticks bool incChanged; // When using sample sync, note frequency has changed - BYTE vol; + uint8 vol; void Reset() { @@ -104,6 +104,10 @@ const SmpLength sampleEnd = chn.dwFlags[CHN_LOOP] ? chn.nLoopEnd : chn.nLength; const SmpLength loopLength = chn.nLoopEnd - chn.nLoopStart; bool stopNote = false; + + int32 inc = chn.nInc * tickDuration; + if(chn.dwFlags[CHN_PINGPONGFLAG]) inc = -inc; + for(uint32 i = 0; i < numTicks; i++) { bool updateInc = (chn.PitchEnv.flags & (ENV_ENABLED | ENV_FILTER)) == ENV_ENABLED; @@ -136,11 +140,11 @@ { chn.nInc = sndFile.GetChannelIncrement(&chn, chn.nPeriod, 0); chnSettings[channel].incChanged = false; + inc = chn.nInc * tickDuration; + if(chn.dwFlags[CHN_PINGPONGFLAG]) inc = -inc; } - int32 inc = chn.nInc; - if(chn.dwFlags[CHN_PINGPONGFLAG]) inc = -inc; - chn.nPosLo += inc * tickDuration; + chn.nPosLo += inc; chn.nPos += ((int32)chn.nPosLo >> 16); chn.nPosLo &= 0xFFFF; @@ -211,9 +215,23 @@ memory.state.m_nNextRow = memory.state.m_nRow = target.startRow; memory.state.m_nNextOrder = memory.state.m_nCurrentOrder = target.startOrder; - // Optimize away channels for which it's pointless to adjust sample positions + // Fast LUTs for commands that are too weird / complicated / whatever to emulate in sample position adjust mode. + std::bitset<MAX_EFFECTS> forbiddenCommands; + std::bitset<MAX_VOLCMDS> forbiddenVolCommands; + if(adjustSamplePos) { + forbiddenCommands.set(CMD_ARPEGGIO); forbiddenCommands.set(CMD_PORTAMENTOUP); + forbiddenCommands.set(CMD_PORTAMENTODOWN); forbiddenCommands.set(CMD_VIBRATOVOL); + forbiddenCommands.set(CMD_TONEPORTAVOL); forbiddenCommands.set(CMD_VOLUMESLIDE); + forbiddenCommands.set(CMD_XFINEPORTAUPDOWN); forbiddenCommands.set(CMD_NOTESLIDEUP); + forbiddenCommands.set(CMD_NOTESLIDEUPRETRIG); forbiddenCommands.set(CMD_NOTESLIDEDOWN); + forbiddenCommands.set(CMD_NOTESLIDEDOWNRETRIG); + forbiddenVolCommands.set(VOLCMD_PORTAUP); forbiddenVolCommands.set(VOLCMD_PORTADOWN); + forbiddenVolCommands.set(VOLCMD_VOLSLIDEUP); forbiddenVolCommands.set(VOLCMD_VOLSLIDEDOWN); + forbiddenVolCommands.set(VOLCMD_FINEVOLUP); forbiddenVolCommands.set(VOLCMD_FINEVOLDOWN); + + // Optimize away channels for which it's pointless to adjust sample positions for(CHANNELINDEX i = 0; i < GetNumChannels(); i++) { if(ChnSettings[i].dwFlags[CHN_MUTE]) memory.chnSettings[i].ticksToRender = GetLengthMemory::IGNORE_CHANNEL; @@ -237,22 +255,6 @@ } } - // Initalize fast LUTs for commands that are too weird / complicated / whatever to emulate in sample position adjust mode. - std::bitset<MAX_EFFECTS> forbiddenCommands; - std::bitset<MAX_VOLCMDS> forbiddenVolCommands; - if(adjustSamplePos) - { - forbiddenCommands.set(CMD_ARPEGGIO); forbiddenCommands.set(CMD_PORTAMENTOUP); - forbiddenCommands.set(CMD_PORTAMENTODOWN); forbiddenCommands.set(CMD_VIBRATOVOL); - forbiddenCommands.set(CMD_TONEPORTAVOL); forbiddenCommands.set(CMD_VOLUMESLIDE); - forbiddenCommands.set(CMD_XFINEPORTAUPDOWN); forbiddenCommands.set(CMD_NOTESLIDEUP); - forbiddenCommands.set(CMD_NOTESLIDEUPRETRIG); forbiddenCommands.set(CMD_NOTESLIDEDOWN); - forbiddenCommands.set(CMD_NOTESLIDEDOWNRETRIG); - forbiddenVolCommands.set(VOLCMD_PORTAUP); forbiddenVolCommands.set(VOLCMD_PORTADOWN); - forbiddenVolCommands.set(VOLCMD_VOLSLIDEUP); forbiddenVolCommands.set(VOLCMD_VOLSLIDEDOWN); - forbiddenVolCommands.set(VOLCMD_FINEVOLUP); forbiddenVolCommands.set(VOLCMD_FINEVOLDOWN); - } - // If samples are being synced , force them to resync if tick duration changes uint32 oldTickDuration = 0; @@ -391,22 +393,63 @@ const ModCommand *p = Patterns[memory.state.m_nPattern].GetRow(memory.state.m_nRow); // For various effects, we need to know first how many ticks there are in this row. - for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++) + for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, p++) { - if(p[nChn].command == CMD_SPEED) + if(IsCompatibleMode(TRK_SCREAMTRACKER) && ChnSettings[nChn].dwFlags[CHN_MUTE]) // not even effects are processed on muted S3M channels + continue; + switch(p->command) { + case CMD_SPEED: #ifdef MODPLUG_TRACKER // FT2 appears to be decrementing the tick count before checking for zero, // so it effectively counts down 65536 ticks with speed = 0 (song speed is a 16-bit variable in FT2) - if(GetType() == MOD_TYPE_XM && !p[nChn].param) + if(GetType() == MOD_TYPE_XM && !p->param) { memory.state.m_nMusicSpeed = uint16_max; } #endif // MODPLUG_TRACKER - if(p[nChn].param > 0) memory.state.m_nMusicSpeed = p[nChn].param; + if(p->param > 0) memory.state.m_nMusicSpeed = p->param; + break; + + case CMD_TEMPO: + if(m_SongFlags[SONG_VBLANK_TIMING]) + { + // ProTracker MODs with VBlank timing: All Fxx parameters set the tick count. + if(p->param != 0) memory.state.m_nMusicSpeed = p->param; + } + break; + + case CMD_S3MCMDEX: + if((p->param & 0xF0) == 0x60) + { + // Fine Pattern Delay + tickDelay += (p->param & 0x0F); + } if((p->param & 0xF0) == 0xE0 && !rowDelay) + { + // Pattern Delay + if(!(GetType() & MOD_TYPE_S3M) || (p->param & 0x0F) != 0) + { + // While Impulse Tracker *does* count S60 as a valid row delay (and thus ignores any other row delay commands on the right), + // Scream Tracker 3 simply ignores such commands. + rowDelay = 1 + (p->param & 0x0F); + } + } + break; + + case CMD_MODCMDEX: + if((p->param & 0xF0) == 0xE0) + { + // Pattern Delay + rowDelay = 1 + (p->param & 0x0F); + } + break; } } + if(rowDelay == 0) rowDelay = 1; + const uint32 numTicks = (memory.state.m_nMusicSpeed + tickDelay) * rowDelay; + const uint32 nonRowTicks = numTicks - rowDelay; + p = Patterns[memory.state.m_nPattern].GetRow(memory.state.m_nRow); for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); p++, pChn++, nChn++) if(!p->IsEmpty()) { if(IsCompatibleMode(TRK_SCREAMTRACKER) && ChnSettings[nChn].dwFlags[CHN_MUTE]) // not even effects are processed on muted S3M channels @@ -414,6 +457,7 @@ ModCommand::COMMAND command = p->command; ModCommand::PARAM param = p->param; ModCommand::NOTE note = p->note; + if (p->instr) { pChn->nNewIns = p->instr; @@ -463,13 +507,8 @@ break; // Set Tempo case CMD_TEMPO: - if(m_SongFlags[SONG_VBLANK_TIMING]) + if(!m_SongFlags[SONG_VBLANK_TIMING]) { - // ProTracker MODs with VBlank timing: All Fxx parameters set the tick count. - if(param != 0) memory.state.m_nMusicSpeed = param; - break; - } - { uint32 tempo = CalculateXParam(memory.state.m_nPattern, memory.state.m_nRow, nChn); if ((adjustMode & eAdjust) && (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT))) { @@ -480,7 +519,7 @@ else { // Tempo Slide - uint32 tempoDiff = (tempo & 0x0F) * (memory.state.m_nMusicSpeed - 1); + uint32 tempoDiff = (tempo & 0x0F) * nonRowTicks; if ((tempo & 0xF0) == 0x10) { memory.state.m_nMusicTempo += tempoDiff; @@ -498,26 +537,23 @@ else memory.state.m_nMusicTempo = Clamp(memory.state.m_nMusicTempo, GetModSpecifications().tempoMin, GetModSpecifications().tempoMax); break; + case CMD_S3MCMDEX: - if((param & 0xF0) == 0x60) + switch(param & 0xF0) { - // Fine Pattern Delay - tickDelay += (param & 0x0F); - } else if((param & 0xF0) == 0xE0 && !rowDelay) - { - // Pattern Delay - if(!(GetType() & MOD_TYPE_S3M) || (param & 0x0F) != 0) + case 0x90: + if(param <= 0x91) { - // While Impulse Tracker *does* count S60 as a valid row delay (and thus ignores any other row delay commands on the right), - // Scream Tracker 3 simply ignores such commands. - rowDelay = 1 + (param & 0x0F); + pChn->dwFlags.set(CHN_SURROUND, param == 0x91); } - } else if((param & 0xF0) == 0xA0) - { + break; + + case 0xA0: // High sample offset pChn->nOldHiOffset = param & 0x0F; - } else if((param & 0xF0) == 0xB0) - { + break; + + case 0xB0: // Pattern Loop if (param & 0x0F) { @@ -538,16 +574,13 @@ } patternLoopStartedOnThisRow = true; } + break; } break; case CMD_MODCMDEX: - if((param & 0xF0) == 0xE0) + if ((param & 0xF0) == 0x60) { - // Pattern Delay - rowDelay = 1 + (param & 0x0F); - } else if ((param & 0xF0) == 0x60) - { // Pattern Loop if (param & 0x0F) { @@ -638,12 +671,12 @@ param >>= 4; param <<= 1; if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1; - memory.state.m_nGlobalVolume += param * (memory.state.m_nMusicSpeed - 1); + memory.state.m_nGlobalVolume += param * nonRowTicks; } else { param = (param & 0x0F) << 1; if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1; - memory.state.m_nGlobalVolume -= param * (memory.state.m_nMusicSpeed - 1); + memory.state.m_nGlobalVolume -= param * nonRowTicks; } Limit(memory.state.m_nGlobalVolume, 0, 256); break; @@ -659,14 +692,28 @@ else if((param & 0xF0) == 0xF0 && (param & 0x0F)) volume -= (param & 0x0F); // Fine Down else if(param & 0x0F) // Down - volume -= (param & 0x0F) * (memory.state.m_nMusicSpeed - 1); + volume -= (param & 0x0F) * nonRowTicks; else // Up - volume += ((param & 0xF0) >> 4) * (memory.state.m_nMusicSpeed - 1); + volume += ((param & 0xF0) >> 4) * nonRowTicks; Limit(volume, 0, 64); pChn->nGlobalVol = volume; } break; + case CMD_PANNING8: + Panning(pChn, p->param, _8bit); + break; + case CMD_MODCMDEX: + case CMD_S3MCMDEX: + if((p->param & 0xF0) == 0x80) + { + Panning(pChn, (p->param & 0x0F), _4bit); + } + break; } + if(p->volcmd == VOLCMD_PANNING) + { + Panning(pChn, p->vol, _6bit); + } } if(memory.state.m_nNextRow >= Patterns[memory.state.m_nPattern].GetNumRows()) @@ -690,7 +737,6 @@ } const uint32 tickDuration = GetTickDuration(memory.state.m_nMusicTempo, memory.state.m_nMusicSpeed, rowsPerBeat); - const uint32 numTicks = (memory.state.m_nMusicSpeed + tickDelay) * MAX(rowDelay, 1); const uint32 rowDuration = tickDuration * numTicks; memory.elapsedTime += static_cast<double>(rowDuration) / static_cast<double>(m_MixerSettings.gdwMixingFreq); memory.state.m_lTotalSampleCount += rowDuration; @@ -713,6 +759,7 @@ if(p->instr) pChn->proTrackerOffset = 0; if(p->IsNote()) { + int32 setPan = pChn->nPan; pChn->nNewNote = pChn->nLastNote; if(pChn->nNewIns != 0) InstrumentChange(pChn, pChn->nNewIns, porta); NoteChange(pChn, p->note, porta); @@ -727,6 +774,14 @@ } if(!porta) memory.chnSettings[nChn].ticksToRender = 0; + // Panning commands have to be re-applied after a note change with potential pan change. + if(p->command == CMD_PANNING8 + || ((p->command == CMD_MODCMDEX || p->command == CMD_S3MCMDEX) && paramHi == 0x8) + || p->volcmd == VOLCMD_PANNING) + { + pChn->nPan = setPan; + } + if(p->command == CMD_OFFSET) { bool isExtended = false; @@ -766,16 +821,6 @@ { pChn->nVolume = p->vol * 4; } - if(p->command == CMD_PANNING8) - { - Panning(pChn, p->param); - } else if(((p->command == CMD_MODCMDEX) || (p->command == CMD_S3MCMDEX)) && (p->param & 0xF0) == 0x80) - { - Panning(pChn, ((p->param & 0x0F) * 256 + 8) / 15); - } else if(p->volcmd == VOLCMD_PANNING) - { - pChn->nPan = p->vol * 4; - } if(pChn->pModSample && !stopNote) { @@ -2806,7 +2851,7 @@ { break; } - Panning(pChn, param); + Panning(pChn, param, _8bit); break; // Panning Slide @@ -3607,27 +3652,39 @@ } -void CSoundFile::Panning(ModChannel *pChn, UINT param) const -//---------------------------------------------------------- +void CSoundFile::Panning(ModChannel *pChn, uint32 param, PanningType panBits) const +//--------------------------------------------------------------------------------- { - if (!m_SongFlags[SONG_SURROUNDPAN]) + if (!m_SongFlags[SONG_SURROUNDPAN] && (panBits == 8 || IsCompatibleMode(TRK_ALLTRACKERS))) { pChn->dwFlags.reset(CHN_SURROUND); } - if(!(GetType() & (MOD_TYPE_S3M | MOD_TYPE_DSM | MOD_TYPE_AMF | MOD_TYPE_MTM))) + if(panBits == _4bit) { - // Real 8-bit panning - pChn->nPan = param; + // 0...15 panning + pChn->nPan = (param * 256 + 8) / 15; + } else if(panBits == _6bit) + { + // 0...64 panning + if(param > 64) param = 64; + pChn->nPan = param * 4; } else { - // 7-bit panning + surround - if(param <= 0x80) + if(!(GetType() & (MOD_TYPE_S3M | MOD_TYPE_DSM | MOD_TYPE_AMF | MOD_TYPE_MTM))) { - pChn->nPan = param << 1; - } else if(param == 0xA4) + // Real 8-bit panning + pChn->nPan = param; + } else { - pChn->dwFlags.set(CHN_SURROUND); - pChn->nPan = 0x80; + // 7-bit panning + surround + if(param <= 0x80) + { + pChn->nPan = param << 1; + } else if(param == 0xA4) + { + pChn->dwFlags.set(CHN_SURROUND); + pChn->nPan = 0x80; + } } } @@ -3925,18 +3982,12 @@ // E7x: Set Tremolo WaveForm case 0x70: pChn->nTremoloType = param & 0x07; break; // E8x: Set 4-bit Panning - case 0x80: if(m_SongFlags[SONG_FIRSTTICK] && !m_SongFlags[SONG_PT1XMODE]) - { - //IT compatibility 20. (Panning always resets surround state) - if(IsCompatibleMode(TRK_ALLTRACKERS) && !m_SongFlags[SONG_SURROUNDPAN]) - { - pChn->dwFlags.reset(CHN_SURROUND); - } - //pChn->nPan = (param << 4) + 8; - pChn->nPan = (param * 256 + 8) / 15; - pChn->dwFlags.set(CHN_FASTVOLRAMP); - } - break; + case 0x80: + if(m_SongFlags[SONG_FIRSTTICK] && !m_SongFlags[SONG_PT1XMODE]) + { + Panning(pChn, param, _4bit); + } + break; // E9x: Retrig case 0x90: RetrigNote(nChn, param); break; // EAx: Fine Volume Up @@ -4085,25 +4136,12 @@ } break; // S8x: Set 4-bit Panning - case 0x80: if(m_SongFlags[SONG_FIRSTTICK]) - { - // IT Compatibility (and other trackers as well): panning disables surround (unless panning in rear channels is enabled, which is not supported by the original trackers anyway) - if(IsCompatibleMode(TRK_ALLTRACKERS) && !m_SongFlags[SONG_SURROUNDPAN]) - { - pChn->dwFlags.reset(CHN_SURROUND); - } - //pChn->nPan = (param << 4) + 8; - pChn->nPan = (param * 256 + 8) / 15; - pChn->dwFlags.set(CHN_FASTVOLRAMP); - - //IT compatibility 20. Set pan overrides random pan - if(IsCompatibleMode(TRK_IMPULSETRACKER)) - { - pChn->nPanSwing = 0; - pChn->nPanbrelloOffset = 0; - } - } - break; + case 0x80: + if(m_SongFlags[SONG_FIRSTTICK]) + { + Panning(pChn, param, _4bit); + } + break; // S9x: Sound Control case 0x90: ExtendedChannelEffect(pChn, param); break; // SAx: Set 64k Offset Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2015-03-19 15:38:34 UTC (rev 4900) +++ trunk/OpenMPT/soundlib/Sndfile.h 2015-03-20 15:48:55 UTC (rev 4901) @@ -821,6 +821,13 @@ uint32 GetChannelIncrement(ModChannel *pChn, uint32 period, int periodFrac) const; protected: + // Type of panning command + enum PanningType + { + _4bit = 4, + _6bit = 6, + _8bit = 8, + }; // Channel Effects void UpdateS3MEffectMemory(ModChannel *pChn, ModCommand::PARAM param) const; void PortamentoUp(CHANNELINDEX nChn, ModCommand::PARAM param, const bool doFinePortamentoAsRegular = false); @@ -841,7 +848,7 @@ void FineVolumeDown(ModChannel *pChn, ModCommand::PARAM param, bool volCol) const; void Tremolo(ModChannel *pChn, UINT param) const; void Panbrello(ModChannel *pChn, UINT param) const; - void Panning(ModChannel *pChn, UINT param) const; + void Panning(ModChannel *pChn, uint32 param, PanningType panBits) const; void RetrigNote(CHANNELINDEX nChn, int param, int offset = 0); void SampleOffset(CHANNELINDEX nChn, SmpLength param); void NoteCut(CHANNELINDEX nChn, UINT nTick, bool cutSample); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-03-29 01:18:23
|
Revision: 4910 http://sourceforge.net/p/modplug/code/4910 Author: saga-games Date: 2015-03-29 01:18:09 +0000 (Sun, 29 Mar 2015) Log Message: ----------- [Fix] Seeking code could be influenced by PC events. [Ref] We really don't need size_t for macro lengths. [Ref] Rename panning bitness enums to be more self-explanatory. [Mod] OpenMPT: Version is now 1.24.02.08 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-03-28 22:23:27 UTC (rev 4909) +++ trunk/OpenMPT/common/versionNumber.h 2015-03-29 01:18:09 UTC (rev 4910) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 07 +#define VER_MINORMINOR 08 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-28 22:23:27 UTC (rev 4909) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-29 01:18:09 UTC (rev 4910) @@ -397,6 +397,11 @@ { if(IsCompatibleMode(TRK_SCREAMTRACKER) && ChnSettings[nChn].dwFlags[CHN_MUTE]) // not even effects are processed on muted S3M channels continue; + if(p->IsPcNote()) + { + pChn[nChn].rowCommand.Clear(); + continue; + } pChn[nChn].rowCommand = *p; switch(p->command) { @@ -700,19 +705,19 @@ } break; case CMD_PANNING8: - Panning(pChn, param, _8bit); + Panning(pChn, param, Pan8bit); break; case CMD_MODCMDEX: case CMD_S3MCMDEX: if((param & 0xF0) == 0x80) { - Panning(pChn, (param & 0x0F), _4bit); + Panning(pChn, (param & 0x0F), Pan4bit); } break; } if(pChn->rowCommand.volcmd == VOLCMD_PANNING) { - Panning(pChn, pChn->rowCommand.vol, _6bit); + Panning(pChn, pChn->rowCommand.vol, Pan6bit); } } @@ -2850,7 +2855,7 @@ { break; } - Panning(pChn, param, _8bit); + Panning(pChn, param, Pan8bit); break; // Panning Slide @@ -3658,11 +3663,11 @@ { pChn->dwFlags.reset(CHN_SURROUND); } - if(panBits == _4bit) + if(panBits == Pan4bit) { // 0...15 panning pChn->nPan = (param * 256 + 8) / 15; - } else if(panBits == _6bit) + } else if(panBits == Pan6bit) { // 0...64 panning if(param > 64) param = 64; @@ -3984,7 +3989,7 @@ case 0x80: if(m_SongFlags[SONG_FIRSTTICK] && !m_SongFlags[SONG_PT1XMODE]) { - Panning(pChn, param, _4bit); + Panning(pChn, param, Pan4bit); } break; // E9x: Retrig @@ -4138,7 +4143,7 @@ case 0x80: if(m_SongFlags[SONG_FIRSTTICK]) { - Panning(pChn, param, _4bit); + Panning(pChn, param, Pan4bit); } break; // S9x: Sound Control @@ -4272,18 +4277,18 @@ // [in] macro: Actual MIDI Macro string // [in] param: Parameter for parametric macros (Z00 - Z7F) // [in] plugin: Plugin to send MIDI message to (if not specified but needed, it is autodetected) -void CSoundFile::ProcessMIDIMacro(CHANNELINDEX nChn, bool isSmooth, char *macro, uint8 param, PLUGINDEX plugin) -//------------------------------------------------------------------------------------------------------------- +void CSoundFile::ProcessMIDIMacro(CHANNELINDEX nChn, bool isSmooth, const char *macro, uint8 param, PLUGINDEX plugin) +//------------------------------------------------------------------------------------------------------------------- { - ModChannel *pChn = &m_PlayState.Chn[nChn]; - const ModInstrument *pIns = GetNumInstruments() ? pChn->pModInstrument : nullptr; + ModChannel &chn = m_PlayState.Chn[nChn]; + const ModInstrument *pIns = GetNumInstruments() ? chn.pModInstrument : nullptr; unsigned char out[MACRO_LENGTH]; - size_t outPos = 0; // output buffer position, which also equals the number of complete bytes - const uint8 lastZxxParam = pChn->lastZxxParam; + uint32 outPos = 0; // output buffer position, which also equals the number of complete bytes + const uint8 lastZxxParam = chn.lastZxxParam; bool firstNibble = true; - for(size_t pos = 0; pos < (MACRO_LENGTH - 1) && macro[pos]; pos++) + for(uint32 pos = 0; pos < (MACRO_LENGTH - 1) && macro[pos]; pos++) { bool isNibble = false; // did we parse a nibble or a byte value? unsigned char data = 0; // data that has just been parsed @@ -4304,29 +4309,29 @@ data = (unsigned char)GetBestMidiChannel(nChn); } else if(macro[pos] == 'n') // n: note value (last triggered note) { - if(ModCommand::IsNote(pChn->nLastNote)) + if(ModCommand::IsNote(chn.nLastNote)) { - data = (unsigned char)(pChn->nLastNote - NOTE_MIN); + data = (unsigned char)(chn.nLastNote - NOTE_MIN); } } else if(macro[pos] == 'v') // v: velocity { // This is "almost" how IT does it - apparently, IT seems to lag one row behind on global volume or channel volume changes. - const int swing = (IsCompatibleMode(TRK_IMPULSETRACKER) || GetModFlag(MSF_OLDVOLSWING)) ? pChn->nVolSwing : 0; - const int vol = Util::muldiv((pChn->nVolume + swing) * m_PlayState.m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 20); + const int swing = (IsCompatibleMode(TRK_IMPULSETRACKER) || GetModFlag(MSF_OLDVOLSWING)) ? chn.nVolSwing : 0; + const int vol = Util::muldiv((chn.nVolume + swing) * m_PlayState.m_nGlobalVolume, chn.nGlobalVol * chn.nInsVol, 1 << 20); data = (unsigned char)Clamp(vol / 2, 1, 127); - //data = (unsigned char)MIN((pChn->nVolume * pChn->nGlobalVol * m_nGlobalVolume) >> (1 + 6 + 8), 127); + //data = (unsigned char)MIN((chn.nVolume * chn.nGlobalVol * m_nGlobalVolume) >> (1 + 6 + 8), 127); } else if(macro[pos] == 'u') // u: volume (calculated) { // Same note as with velocity applies here, but apparently also for instrument / sample volumes? - const int vol = Util::muldiv(pChn->nCalcVolume * m_PlayState.m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 26); + const int vol = Util::muldiv(chn.nCalcVolume * m_PlayState.m_nGlobalVolume, chn.nGlobalVol * chn.nInsVol, 1 << 26); data = (unsigned char)Clamp(vol / 2, 1, 127); - //data = (unsigned char)MIN((pChn->nCalcVolume * pChn->nGlobalVol * m_nGlobalVolume) >> (7 + 6 + 8), 127); + //data = (unsigned char)MIN((chn.nCalcVolume * chn.nGlobalVol * m_nGlobalVolume) >> (7 + 6 + 8), 127); } else if(macro[pos] == 'x') // x: pan set { - data = (unsigned char)std::min(pChn->nPan / 2, 127); + data = (unsigned char)std::min(chn.nPan / 2, 127); } else if(macro[pos] == 'y') // y: calculated pan { - data = (unsigned char)std::min(pChn->nRealPan / 2, 127); + data = (unsigned char)std::min(chn.nRealPan / 2, 127); } else if(macro[pos] == 'a') // a: high byte of bank select { if(pIns && pIns->wMidiBank) @@ -4348,14 +4353,14 @@ } else if(macro[pos] == 'z') // z: macro data { data = param & 0x7F; - if(isSmooth && pChn->lastZxxParam < 0x80 + if(isSmooth && chn.lastZxxParam < 0x80 && (outPos < 3 || out[outPos - 3] != 0xF0 || out[outPos - 2] < 0xF0)) { // Interpolation for external MIDI messages - interpolation for internal messages // is handled separately to allow for more than 7-bit granularity where it's possible data = (uint8)CalculateSmoothParamChange((float)lastZxxParam, (float)data); } - pChn->lastZxxParam = data; + chn.lastZxxParam = data; } else // unrecognized byte (e.g. space char) { continue; @@ -4396,10 +4401,10 @@ } // Macro string has been parsed and translated, now send the message(s)... - size_t sendPos = 0; + uint32 sendPos = 0; while(sendPos < outPos) { - size_t sendLen = 0; + uint32 sendLen = 0; if(out[sendPos] == 0xF0) { // SysEx start @@ -4410,7 +4415,7 @@ } else { // SysEx message, find end of message - for(size_t i = sendPos + 1; i < outPos; i++) + for(uint32 i = sendPos + 1; i < outPos; i++) { if(out[i] == 0xF7) { @@ -4444,7 +4449,7 @@ break; } - size_t bytesSent = SendMIDIData(nChn, isSmooth, out + sendPos, sendLen, plugin); + uint32 bytesSent = SendMIDIData(nChn, isSmooth, out + sendPos, sendLen, plugin); // Ideally (if there's no error in the macro data), we should have sendLen == bytesSent. if(bytesSent > 0) { @@ -4453,9 +4458,7 @@ { sendPos += sendLen; } - } - } @@ -4479,7 +4482,7 @@ // Process MIDI macro data parsed by ProcessMIDIMacro... return bytes sent on success, 0 on (parse) failure. -size_t CSoundFile::SendMIDIData(CHANNELINDEX nChn, bool isSmooth, const unsigned char *macro, size_t macroLen, PLUGINDEX plugin) +uint32 CSoundFile::SendMIDIData(CHANNELINDEX nChn, bool isSmooth, const unsigned char *macro, uint32 macroLen, PLUGINDEX plugin) //------------------------------------------------------------------------------------------------------------------------------ { if(macroLen < 1) @@ -4620,10 +4623,10 @@ pPlugin->MidiSysexSend(reinterpret_cast<const char *>(macro), macroLen); } else { - for(size_t pos = 0; pos < macroLen; pos += 3) + for(uint32 pos = 0; pos < macroLen; pos += 3) { uint32 curData = 0; - memcpy(&curData, macro + pos, std::min<size_t>(3, macroLen - pos)); + memcpy(&curData, macro + pos, std::min<uint32>(3, macroLen - pos)); pPlugin->MidiSend(curData); } } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2015-03-28 22:23:27 UTC (rev 4909) +++ trunk/OpenMPT/soundlib/Sndfile.h 2015-03-29 01:18:09 UTC (rev 4910) @@ -824,9 +824,9 @@ // Type of panning command enum PanningType { - _4bit = 4, - _6bit = 6, - _8bit = 8, + Pan4bit = 4, + Pan6bit = 6, + Pan8bit = 8, }; // Channel Effects void UpdateS3MEffectMemory(ModChannel *pChn, ModCommand::PARAM param) const; @@ -861,16 +861,16 @@ void GlobalVolSlide(ModCommand::PARAM param, uint8 &nOldGlobalVolSlide); void ProcessMacroOnChannel(CHANNELINDEX nChn); - void ProcessMIDIMacro(CHANNELINDEX nChn, bool isSmooth, char *macro, uint8 param = 0, PLUGINDEX plugin = 0); + void ProcessMIDIMacro(CHANNELINDEX nChn, bool isSmooth, const char *macro, uint8 param = 0, PLUGINDEX plugin = 0); float CalculateSmoothParamChange(float currentValue, float param) const; - size_t SendMIDIData(CHANNELINDEX nChn, bool isSmooth, const unsigned char *macro, size_t macroLen, PLUGINDEX plugin); + uint32 SendMIDIData(CHANNELINDEX nChn, bool isSmooth, const unsigned char *macro, uint32 macroLen, PLUGINDEX plugin); void SetupChannelFilter(ModChannel *pChn, bool bReset, int flt_modifier = 256) const; // Low-Level effect processing void DoFreqSlide(ModChannel *pChn, LONG nFreqSlide) const; void UpdateTimeSignature(); - UINT GetNumTicksOnCurrentRow() const + uint32 GetNumTicksOnCurrentRow() const { return (m_PlayState.m_nMusicSpeed + m_PlayState.m_nFrameDelay) * MAX(m_PlayState.m_nPatternDelay, 1); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-03-30 11:39:58
|
Revision: 4913 http://sourceforge.net/p/modplug/code/4913 Author: manxorist Date: 2015-03-30 11:39:45 +0000 (Mon, 30 Mar 2015) Log Message: ----------- [Ref] sounddev: Make the debugging checks agnostic of the actual implementation of the locking mechanism in AudioCriticalSection.h. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-03-30 11:39:45 UTC (rev 4913) @@ -662,6 +662,14 @@ } +bool CMainFrame::SoundSourceIsLockedByCurrentThread() const +//--------------------------------------------------------- +{ + MPT_TRACE(); + return CriticalSection::IsLocked(); +} + + void CMainFrame::FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback) //----------------------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2015-03-30 11:39:45 UTC (rev 4913) @@ -407,6 +407,7 @@ uint64 SoundSourceGetReferenceClockNowNanoseconds() const; void SoundSourcePreStartCallback(); void SoundSourcePostStopCallback(); + bool SoundSourceIsLockedByCurrentThread() const; void FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback); void AudioRead(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, void *buffer); void AudioDone(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, int64 streamPosition); Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-03-30 11:39:45 UTC (rev 4913) @@ -279,6 +279,18 @@ } +bool Base::SourceIsLockedByCurrentThread() const +//---------------------------------------------- +{ + MPT_TRACE(); + if(!m_Source) + { + return false; + } + return m_Source->SoundSourceIsLockedByCurrentThread(); +} + + void Base::SourceFillAudioBufferLocked() //-------------------------------------- { Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-03-30 11:39:45 UTC (rev 4913) @@ -74,6 +74,7 @@ virtual uint64 SoundSourceGetReferenceClockNowNanoseconds() const = 0; // timeGetTime()*1000000 on Windows virtual void SoundSourcePreStartCallback() = 0; virtual void SoundSourcePostStopCallback() = 0; + virtual bool SoundSourceIsLockedByCurrentThread() const = 0; virtual void FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback) = 0; // take any locks needed while rendering audio and then call FillAudioBuffer virtual void AudioRead(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, void *buffer) = 0; virtual void AudioDone(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, int64 streamPosition) = 0; // in sample frames @@ -593,6 +594,7 @@ uint64 SourceGetReferenceClockNowNanoseconds() const; void SourceNotifyPreStart(); void SourceNotifyPostStop(); + bool SourceIsLockedByCurrentThread() const; void SourceFillAudioBufferLocked(); void SourceAudioPreRead(std::size_t numFrames); void SourceAudioRead(void *buffer, std::size_t numFrames); Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-03-30 11:39:45 UTC (rev 4913) @@ -19,9 +19,6 @@ #include "../common/StringFixer.h" #include "../soundlib/SampleFormatConverters.h" -// DEBUG: -#include "../common/AudioCriticalSection.h" - #include <algorithm> @@ -514,7 +511,7 @@ { if(silence) { - if(CriticalSection::IsLocked()) + if(SourceIsLockedByCurrentThread()) { MPT_ASSERT_MSG(false, "AudioCriticalSection locked while stopping ASIO"); } else @@ -523,7 +520,7 @@ } } else { - if(CriticalSection::IsLocked()) + if(SourceIsLockedByCurrentThread()) { MPT_ASSERT_MSG(false, "AudioCriticalSection locked while starting ASIO"); } else @@ -542,7 +539,7 @@ //------------------------------- { MPT_TRACE(); - MPT_ASSERT_ALWAYS_MSG(!CriticalSection::IsLocked(), "AudioCriticalSection locked while starting ASIO"); + MPT_ASSERT_ALWAYS_MSG(!SourceIsLockedByCurrentThread(), "AudioCriticalSection locked while starting ASIO"); if(m_Settings.KeepDeviceRunning) { @@ -586,7 +583,7 @@ //-------------------------------------------- { MPT_TRACE(); - MPT_ASSERT_ALWAYS_MSG(!CriticalSection::IsLocked(), "AudioCriticalSection locked while stopping ASIO"); + MPT_ASSERT_ALWAYS_MSG(!SourceIsLockedByCurrentThread(), "AudioCriticalSection locked while stopping ASIO"); if(m_Settings.KeepDeviceRunning && !force) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-04-04 12:20:06
|
Revision: 4915 http://sourceforge.net/p/modplug/code/4915 Author: manxorist Date: 2015-04-04 12:19:59 +0000 (Sat, 04 Apr 2015) Log Message: ----------- [Fix] Do not assume that Windows has support for all the codepages that we require and return empty string on conversion failure. Instead, check if a codepage is available before using it and fallback to our internal conversion functions and tables otherwise. For the tracker, codepage availability is determined at program start and cached, for libopenmpt, availability is tested on demand in order to avoid global state. Modified Paths: -------------- trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/mptString.h trunk/OpenMPT/mptrack/Mptrack.cpp Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2015-04-01 19:55:21 UTC (rev 4914) +++ trunk/OpenMPT/common/mptString.cpp 2015-04-04 12:19:59 UTC (rev 4915) @@ -13,7 +13,7 @@ #if defined(MPT_CHARSET_CODECVTUTF8) #include <codecvt> #endif -#if defined(MPT_CHARSET_INTERNAL) +#if defined(MPT_CHARSET_INTERNAL) || defined(MPT_CHARSET_WIN32) #include <cstdlib> #endif #include <iomanip> @@ -85,7 +85,7 @@ }; */ -#if defined(MPT_CHARSET_CODECVTUTF8) || defined(MPT_CHARSET_INTERNAL) +#if defined(MPT_CHARSET_CODECVTUTF8) || defined(MPT_CHARSET_INTERNAL) || defined(MPT_CHARSET_WIN32) static const uint32 CharsetTableISO8859_15[256] = { 0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, @@ -144,7 +144,7 @@ 0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248,0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0 }; -#endif // MPT_CHARSET_CODECVTUTF8 || MPT_CHARSET_INTERNAL +#endif // MPT_CHARSET_CODECVTUTF8 || MPT_CHARSET_INTERNAL || MPT_CHARSET_WIN32 #define C(x) (static_cast<uint8>((x))) @@ -255,7 +255,7 @@ return res; } -#if defined(MPT_CHARSET_CODECVTUTF8) || defined(MPT_CHARSET_INTERNAL) +#if defined(MPT_CHARSET_CODECVTUTF8) || defined(MPT_CHARSET_INTERNAL) || defined(MPT_CHARSET_WIN32) static std::wstring FromAscii(const std::string &str, wchar_t replacement = L'\uFFFD') //------------------------------------------------------------------------------------ @@ -341,8 +341,8 @@ const char * in_begin = str.data(); const char * in_end = in_begin + str.size(); out.resize((in_end - in_begin) * (facet.max_length() + 1)); - wchar_t * out_begin = out.data(); - wchar_t * out_end = out.data() + out.size(); + wchar_t * out_begin = &(out[0]); + wchar_t * out_end = &(out[0]) + out.size(); const char * in_next = nullptr; wchar_t * out_next = nullptr; do @@ -354,8 +354,8 @@ { out.resize(out.size() * 2); in_begin = in_next; - out_begin = out.data() + (out_next - out_begin); - out_end = out.data() + out.size(); + out_begin = &(out[0]) + (out_next - out_begin); + out_end = &(out[0]) + out.size(); continue; } if(result == codecvt_type::error) @@ -367,7 +367,7 @@ in_begin = in_next; out_begin = out_next; } while(result == codecvt_type::error && in_next < in_end && out_next < out_end); - return std::wstring(out.data(), out_next); + return std::wstring(&(out[0]), out_next); } static std::string LocaleEncode(const std::wstring &str, const std::locale & locale, char replacement = '?') @@ -385,8 +385,8 @@ const wchar_t * in_begin = str.data(); const wchar_t * in_end = in_begin + str.size(); out.resize((in_end - in_begin) * (facet.max_length() + 1)); - char * out_begin = out.data(); - char * out_end = out.data() + out.size(); + char * out_begin = &(out[0]); + char * out_end = &(out[0]) + out.size(); const wchar_t * in_next = nullptr; char * out_next = nullptr; do @@ -398,8 +398,8 @@ { out.resize(out.size() * 2); in_begin = in_next; - out_begin = out.data() + (out_next - out_begin); - out_end = out.data() + out.size(); + out_begin = &(out[0]) + (out_next - out_begin); + out_end = &(out[0]) + out.size(); continue; } if(result == codecvt_type::error) @@ -411,7 +411,7 @@ in_begin = in_next; out_begin = out_next; } while(result == codecvt_type::error && in_next < in_end && out_next < out_end); - return std::string(out.data(), out_next); + return std::string(&(out[0]), out_next); } static std::wstring FromLocale(const std::string &str, wchar_t replacement = L'\uFFFD') @@ -478,7 +478,7 @@ #endif -#endif // MPT_CHARSET_CODECVTUTF8 || MPT_CHARSET_INTERNAL +#endif // MPT_CHARSET_CODECVTUTF8 || MPT_CHARSET_INTERNAL || MPT_CHARSET_WIN32 #if defined(MPT_CHARSET_CODECVTUTF8) @@ -500,7 +500,7 @@ #endif // MPT_CHARSET_CODECVTUTF8 -#if defined(MPT_CHARSET_INTERNAL) +#if defined(MPT_CHARSET_INTERNAL) || defined(MPT_CHARSET_WIN32) static std::wstring FromUTF8(const std::string &str, wchar_t replacement = L'\uFFFD') //----------------------------------------------------------------------------------- @@ -659,10 +659,79 @@ } -#endif // MPT_CHARSET_INTERNAL +#endif // MPT_CHARSET_INTERNAL || MPT_CHARSET_WIN32 #if defined(MPT_CHARSET_WIN32) +static bool TestCodePage(UINT cp) +{ + CPINFOEX cpinfo; + MemsetZero(cpinfo); + return GetCPInfoEx(cp, 0, &cpinfo) ? true : false; +} + +#ifdef MODPLUG_TRACKER + +static bool HasCharsetUTF8 = true; +static bool HasCharsetASCII = true; +static bool HasCharsetISO8859_1 = true; +static bool HasCharsetISO8859_15 = true; +static bool HasCharsetCP437 = true; +static bool HasCharsetWindows1252 = true; + +void InitCharsets() +{ + HasCharsetUTF8 = TestCodePage(CP_UTF8); + HasCharsetASCII = TestCodePage(20127); + HasCharsetISO8859_1 = TestCodePage(28591); + HasCharsetISO8859_15 = TestCodePage(28605); + HasCharsetCP437 = TestCodePage(437); + HasCharsetWindows1252 = TestCodePage(1252); +} + +static bool HasCharset(Charset charset) +{ + switch(charset) + { + case CharsetUTF8: return HasCharsetUTF8; break; + case CharsetASCII: return HasCharsetASCII; break; + case CharsetISO8859_1: return HasCharsetISO8859_1; break; + case CharsetISO8859_15: return HasCharsetISO8859_15; break; + case CharsetCP437: return HasCharsetCP437; break; + case CharsetWindows1252: return HasCharsetWindows1252; break; + } + return false; +} + +#else // !MODPLUG_TRACKER + +static bool HasCharset(Charset charset) +{ + switch(charset) + { + case CharsetUTF8: return TestCodePage(CP_UTF8); break; + case CharsetASCII: return TestCodePage(20127); break; + case CharsetISO8859_1: return TestCodePage(28591); break; + case CharsetISO8859_15: return TestCodePage(28605); break; + case CharsetCP437: return TestCodePage(437); break; + case CharsetWindows1252: return TestCodePage(1252); break; + } + return false; +} + +#endif // MODPLUG_TRACKER + +#else // !MPT_CHARSET_WIN32 + +void InitCharsets() +{ + return; +} + +#endif // MPT_CHARSET_WIN32 + +#if defined(MPT_CHARSET_WIN32) + static UINT CharsetToCodepage(Charset charset) { switch(charset) @@ -759,6 +828,11 @@ #endif // MPT_CHARSET_ICONV +#if !defined(MPT_CHARSET_ICONV) +template<typename Tdststring> +Tdststring EncodeImplFallback(Charset charset, const std::wstring &src); +#endif // !MPT_CHARSET_ICONV + // templated on 8bit strings because of type-safe variants template<typename Tdststring> Tdststring EncodeImpl(Charset charset, const std::wstring &src) @@ -780,6 +854,10 @@ #endif #endif #if defined(MPT_CHARSET_WIN32) + if(!HasCharset(charset)) + { + return EncodeImplFallback<Tdststring>(charset, src); + } const UINT codepage = CharsetToCodepage(charset); int required_size = WideCharToMultiByte(codepage, 0, src.c_str(), -1, nullptr, 0, nullptr, nullptr); if(required_size <= 0) @@ -827,6 +905,15 @@ conv = iconv_t(); return reinterpret_cast<const typename Tdststring::value_type*>(&encoded_string[0]); #else + return EncodeImplFallback<Tdststring<(charset, src); + #endif +} + + +#if !defined(MPT_CHARSET_ICONV) +template<typename Tdststring> +Tdststring EncodeImplFallback(Charset charset, const std::wstring &src) +{ std::string out; switch(charset) { @@ -843,10 +930,15 @@ case CharsetWindows1252: out = String::To8bit(src, CharsetTableWindows1252); break; } return Tdststring(out.begin(), out.end()); - #endif } +#endif // !MPT_CHARSET_ICONV +#if !defined(MPT_CHARSET_ICONV) +template<typename Tsrcstring> +std::wstring DecodeImplFallback(Charset charset, const Tsrcstring &src); +#endif // !MPT_CHARSET_ICONV + // templated on 8bit strings because of type-safe variants template<typename Tsrcstring> std::wstring DecodeImpl(Charset charset, const Tsrcstring &src) @@ -869,6 +961,10 @@ #endif #endif #if defined(MPT_CHARSET_WIN32) + if(!HasCharset(charset)) + { + return DecodeImplFallback<Tsrcstring>(charset, src); + } const UINT codepage = CharsetToCodepage(charset); int required_size = MultiByteToWideChar(codepage, 0, reinterpret_cast<const char*>(src.c_str()), -1, nullptr, 0); if(required_size <= 0) @@ -920,6 +1016,14 @@ conv = iconv_t(); return &wide_string[0]; #else + return DecodeImplFallback<Tsrcstring>(charset, src); + #endif +} + +#if !defined(MPT_CHARSET_ICONV) +template<typename Tsrcstring> +std::wstring DecodeImplFallback(Charset charset, const Tsrcstring &src) +{ std::string in(src.begin(), src.end()); std::wstring out; switch(charset) @@ -937,8 +1041,8 @@ case CharsetWindows1252: out = String::From8bit(in, CharsetTableWindows1252); break; } return out; - #endif } +#endif // !MPT_CHARSET_ICONV // templated on 8bit strings because of type-safe variants Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2015-04-01 19:55:21 UTC (rev 4914) +++ trunk/OpenMPT/common/mptString.h 2015-04-04 12:19:59 UTC (rev 4915) @@ -30,6 +30,11 @@ { +#ifdef MODPLUG_TRACKER +void InitCharsets(); +#endif // MODPLUG_TRACKER + + template <typename Tstring> struct Traits { static const char * GetDefaultWhitespace() { return " \n\r\t"; } }; Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-04-01 19:55:21 UTC (rev 4914) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-04-04 12:19:59 UTC (rev 4915) @@ -920,6 +920,7 @@ BeginWaitCursor(); mpt::Windows::Version::Init(); + mpt::String::InitCharsets(); Log("OpenMPT Start"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-04-07 19:41:46
|
Revision: 4917 http://sourceforge.net/p/modplug/code/4917 Author: saga-games Date: 2015-04-07 19:41:33 +0000 (Tue, 07 Apr 2015) Log Message: ----------- [Fix] Samples in tree view were sometimes detuned since linear slides were not set for the preview module (http://bugs.openmpt.org/view.php?id=14). [Mod] Allow loading PAT files with 0 layers (fixes DOO.PAT) [Mod] Also display instrument number in pattern status bar if instrument name is empty (http://bugs.openmpt.org/view.php?id=671) [Mod] OpenMPT: Version is now 1.24.02.09 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-04-04 12:51:19 UTC (rev 4916) +++ trunk/OpenMPT/common/versionNumber.h 2015-04-07 19:41:33 UTC (rev 4917) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 08 +#define VER_MINORMINOR 09 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2015-04-04 12:51:19 UTC (rev 4916) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2015-04-07 19:41:33 UTC (rev 4917) @@ -1584,7 +1584,7 @@ } mpt::String::SetNullTerminator(sztmp); - if (sztmp[0]) s.Format("%d: %s", m->instr, sztmp); + s.Format("%d: %s", m->instr, sztmp); } break; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-04-04 12:51:19 UTC (rev 4916) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-04-07 19:41:33 UTC (rev 4917) @@ -1603,6 +1603,7 @@ m_WaveFile.Order.resize(1); m_WaveFile.Order[0] = 0; m_WaveFile.Patterns.Insert(0, 80); + m_WaveFile.m_SongFlags = SONG_LINEARSLIDES; } Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2015-04-04 12:51:19 UTC (rev 4916) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2015-04-07 19:41:33 UTC (rev 4917) @@ -55,7 +55,7 @@ uint8 header[3]; if(!file.CanRead(3)) return false; - file.ReadArrayLE(header); + file.ReadArray(header); file.SkipBack(3); return IsMPEG(header); } @@ -749,7 +749,7 @@ || memcmp(fileHeader.id, "ID#000002\0", 10) || !fileHeader.numInstr || !fileHeader.numSamples || !file.ReadConvertEndianness(instrHeader) - || !instrHeader.layers + //|| !instrHeader.layers // DOO.PAT has 0 layers || !file.ReadConvertEndianness(layerHeader) || !layerHeader.samples) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-04-11 13:44:38
|
Revision: 4924 http://sourceforge.net/p/modplug/code/4924 Author: saga-games Date: 2015-04-11 13:44:32 +0000 (Sat, 11 Apr 2015) Log Message: ----------- [New] MOD: In PT1/2 mode, implement ProTracker oneshot loops: If the loop start is right at the start of the sample, play through the whole sample once and then repeat just the loop part. [Mod] OpenMPT: Version is now 1.24.02.10 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-04-11 12:53:11 UTC (rev 4923) +++ trunk/OpenMPT/common/versionNumber.h 2015-04-11 13:44:32 UTC (rev 4924) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 09 +#define VER_MINORMINOR 10 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2015-04-11 12:53:11 UTC (rev 4923) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2015-04-11 13:44:32 UTC (rev 4924) @@ -481,22 +481,31 @@ } } - // ProTracker compatibility: Instrument changes without a note do not happen instantly, but rather when the sample loop has finished playing. - // Test case: PTInstrSwap.mod - if(m_SongFlags[SONG_PT1XMODE] && chn.nPos >= chn.nLoopEnd && chn.dwFlags[CHN_LOOP] && chn.nNewIns && chn.nNewIns <= GetNumSamples() && chn.pModSample != &Samples[chn.nNewIns]) + if(m_SongFlags[SONG_PT1XMODE] && chn.nPos >= chn.nLoopEnd && chn.dwFlags[CHN_LOOP]) { - const ModSample &smp = Samples[chn.nNewIns]; - chn.pModSample = &smp; - chn.pCurrentSample = smp.pSample; - chn.dwFlags = (chn.dwFlags & CHN_CHANNELFLAGS) | smp.uFlags; - chn.nLoopStart = smp.nLoopStart; - chn.nLoopEnd = smp.nLoopEnd; - chn.nLength = smp.uFlags[CHN_LOOP] ? smp.nLoopEnd : smp.nLength; - chn.nPos = chn.nLoopStart; - UpdateLookaheadPointers(samplePointer, lookaheadPointer, lookaheadStart, chn, resamplingMode); - if(!chn.pCurrentSample) + if(chn.nNewIns && chn.nNewIns <= GetNumSamples() && chn.pModSample != &Samples[chn.nNewIns]) { - break; + // ProTracker compatibility: Instrument changes without a note do not happen instantly, but rather when the sample loop has finished playing. + // Test case: PTInstrSwap.mod + const ModSample &smp = Samples[chn.nNewIns]; + chn.pModSample = &smp; + chn.pCurrentSample = smp.pSample; + chn.dwFlags = (chn.dwFlags & CHN_CHANNELFLAGS) | smp.uFlags; + chn.nLength = smp.uFlags[CHN_LOOP] ? smp.nLoopEnd : smp.nLength; + chn.nLoopStart = smp.nLoopStart; + chn.nLoopEnd = smp.nLoopEnd; + chn.nPos = chn.nLoopStart; + UpdateLookaheadPointers(samplePointer, lookaheadPointer, lookaheadStart, chn, resamplingMode); + if(!chn.pCurrentSample) + { + break; + } + } else if(chn.nLoopStart == 0) + { + // ProTracker "oneshot" loops (if loop start is 0, play the whole sample once and then repeat until loop end) + chn.nPos = 0; + chn.nPosLo = 0; + chn.nLoopEnd = chn.nLength = chn.pModSample->nLoopEnd; } } } while(nsamples > 0); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-04-11 12:53:11 UTC (rev 4923) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-04-11 13:44:32 UTC (rev 4924) @@ -255,7 +255,7 @@ } } - // If samples are being synced , force them to resync if tick duration changes + // If samples are being synced, force them to resync if tick duration changes uint32 oldTickDuration = 0; for (;;) @@ -1262,6 +1262,8 @@ pChn->nLength = pSmp->nLength; pChn->nLoopStart = pSmp->nLoopStart; pChn->nLoopEnd = pSmp->nLoopEnd; + // ProTracker "oneshot" loops (if loop start is 0, play the whole sample once and then repeat until loop end) + if(m_SongFlags[SONG_PT1XMODE] && pChn->nLoopStart == 0) pChn->nLoopEnd = pSmp->nLength; pChn->dwFlags |= (pSmp->uFlags & (CHN_SAMPLEFLAGS | CHN_SURROUND)); // IT Compatibility: Autovibrato reset @@ -1495,6 +1497,8 @@ pChn->nLoopEnd = pSmp->nLoopEnd; if (pChn->nLength > pChn->nLoopEnd) pChn->nLength = pChn->nLoopEnd; } + // ProTracker "oneshot" loops (if loop start is 0, play the whole sample once and then repeat until loop end) + if(m_SongFlags[SONG_PT1XMODE] && pChn->nLoopStart == 0) pChn->nLoopEnd = pChn->nLength = pSmp->nLength; if(pChn->dwFlags[CHN_REVERSE]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |