From: <sag...@us...> - 2014-10-26 15:28:05
|
Revision: 4504 http://sourceforge.net/p/modplug/code/4504 Author: saga-games Date: 2014-10-26 15:27:49 +0000 (Sun, 26 Oct 2014) Log Message: ----------- [New] MPTM files can now contain external (on-disk) samples. When checking the "Keep sample on disk" checkbox in the sample editor, the sample data is not stored directly in the MPTM file but a relative link to the original sample file is kept. [New] Tree view: Due to the change from external instruments in the ITP format to external samples in MPTM, "Set Path" and "Save" have been moved to samples, and "Reload" has been added to reload a waveform (also works in other formats as long as OpenMPT knows the sample path. External samples are marked with [external], missing external samples are marked with [missing]. [New] Instrument tab: ITI instruments can now (like MPTM files) contain external samples. Select "Impulse Tracker Instruments with external Samples" from the save dialog. [Reg] ITP support is now read-only, ITP files are imported as normal IT files. [Ref] Added new switch in BuildSettings.h: MPT_EXTERNAL_SAMPLES determines whether module loaders may load external samples / instruments (only supported in OpenMPT at the moment) [Mod] OpenMPT: Version is now 1.24.00.14 Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/mptIO.h trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/installer/filetypes.iss trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_smp.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/dlg_misc.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/ITTools.cpp trunk/OpenMPT/soundlib/ITTools.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/ModSample.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Tables.cpp trunk/OpenMPT/soundlib/mod_specifications.cpp trunk/OpenMPT/test/test.cpp trunk/OpenMPT/test/test.mptm Added Paths: ----------- trunk/OpenMPT/test/test.flac Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/common/BuildSettings.h 2014-10-26 15:27:49 UTC (rev 4504) @@ -97,6 +97,9 @@ // Enable std::istream support in class FileReader (this is generally not needed for the tracker, local files can easily be mmapped as they have been before introducing std::istream support) //#define MPT_FILEREADER_STD_ISTREAM +// Support for externally linked samples e.g. in MPTM files +#define MPT_EXTERNAL_SAMPLES + // Disable unarchiving support //#define NO_ARCHIVE_SUPPORT @@ -160,6 +163,7 @@ //#define NO_ASSERTS //#define NO_LOGGING #define MPT_FILEREADER_STD_ISTREAM +//#define MPT_EXTERNAL_SAMPLES #define NO_ARCHIVE_SUPPORT #define NO_REVERB #define NO_DSP @@ -324,6 +328,10 @@ #define MPT_WITH_FILEIO // Tracker requires disk file io #endif +#if defined(MPT_EXTERNAL_SAMPLES) && !defined(MPT_WITH_FILEIO) +#define MPT_WITH_FILEIO // External samples require disk file io +#endif + #if defined(MPT_WITH_FILEIO) && !defined(MPT_WITH_PATHSTRING) #define MPT_WITH_PATHSTRING // disk file io requires PathString #endif Modified: trunk/OpenMPT/common/mptIO.h =================================================================== --- trunk/OpenMPT/common/mptIO.h 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/common/mptIO.h 2014-10-26 15:27:49 UTC (rev 4504) @@ -267,7 +267,7 @@ template <typename T, typename Tfile> -inline bool WriteIntLE(Tfile & f, const T & v) +inline bool WriteIntLE(Tfile & f, const T v) { STATIC_ASSERT(std::numeric_limits<T>::is_integer); const T val = SwapBytesReturnLE(v); @@ -277,7 +277,7 @@ } template <typename T, typename Tfile> -inline bool WriteIntBE(Tfile & f, const T & v) +inline bool WriteIntBE(Tfile & f, const T v) { STATIC_ASSERT(std::numeric_limits<T>::is_integer); const T val = SwapBytesReturnBE(v); @@ -287,7 +287,7 @@ } template <typename Tfile> -inline bool WriteAdaptiveInt16LE(Tfile & f, const uint16 & v, std::size_t minSize = 0, std::size_t maxSize = 0) +inline bool WriteAdaptiveInt16LE(Tfile & f, const uint16 v, std::size_t minSize = 0, std::size_t maxSize = 0) { MPT_ASSERT(minSize == 0 || minSize == 1 || minSize == 2); MPT_ASSERT(maxSize == 0 || maxSize == 1 || maxSize == 2); @@ -306,7 +306,7 @@ } template <typename Tfile> -inline bool WriteAdaptiveInt32LE(Tfile & f, const uint32 & v, std::size_t minSize = 0, std::size_t maxSize = 0) +inline bool WriteAdaptiveInt32LE(Tfile & f, const uint32 v, std::size_t minSize = 0, std::size_t maxSize = 0) { MPT_ASSERT(minSize == 0 || minSize == 1 || minSize == 2 || minSize == 3 || minSize == 4); MPT_ASSERT(maxSize == 0 || maxSize == 1 || maxSize == 2 || maxSize == 3 || maxSize == 4); @@ -336,7 +336,7 @@ } template <typename Tfile> -inline bool WriteAdaptiveInt64LE(Tfile & f, const uint64 & v, std::size_t minSize = 0, std::size_t maxSize = 0) +inline bool WriteAdaptiveInt64LE(Tfile & f, const uint64 v, std::size_t minSize = 0, std::size_t maxSize = 0) { MPT_ASSERT(minSize == 0 || minSize == 1 || minSize == 2 || minSize == 4 || minSize == 8); MPT_ASSERT(maxSize == 0 || maxSize == 1 || maxSize == 2 || maxSize == 4 || maxSize == 8); @@ -360,6 +360,25 @@ } } +// Write a variable-length integer, as found in MIDI files. The number of written bytes is placed in the bytesWritten parameter. +template <typename Tfile, typename T> +bool WriteVarInt(Tfile & f, const T v, size_t *bytesWritten = nullptr) +{ + uint8 out[(sizeof(T) * 8 + 6) / 7]; + size_t numBytes = 0; + for(uint32 n = (sizeof(T) * 8) / 7; n > 0; n--) + { + if(v >= (1u << (n * 7u))) + { + out[numBytes++] = static_cast<uint8>(((v >> (n * 7u)) & 0x7F) | 0x80); + } + } + out[numBytes++] = static_cast<uint8>(v & 0x7F); + MPT_ASSERT(numBytes <= CountOf(out)); + if(bytesWritten != nullptr) *bytesWritten = numBytes; + return mpt::IO::WriteRaw(f, out, numBytes); +} + template <typename Tsize, typename Tfile> inline bool WriteSizedStringLE(Tfile & f, const std::string & str) { Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-26 15:27:49 UTC (rev 4504) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 13 +#define VER_MINORMINOR 14 //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/installer/filetypes.iss =================================================================== --- trunk/OpenMPT/installer/filetypes.iss 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/installer/filetypes.iss 2014-10-26 15:27:49 UTC (rev 4504) @@ -13,7 +13,6 @@ Name: "associate_common\s3m"; Description: "Scream Tracker 3 (S3M)"; Name: "associate_common\xm"; Description: "Fasttracker 2 (XM)"; Name: "associate_common\it"; Description: "Impulse Tracker (IT)"; -Name: "associate_common\itp"; Description: "Impulse Tracker Project (ITP)"; Name: "associate_common\mptm"; Description: "OpenMPT (MPTM)"; ; same, but compressed Name: "associate_common\compressed"; Description: "Above when compressed (MDR, MDZ, S3Z, XMZ, ITZ, MPTMZ)"; @@ -30,6 +29,7 @@ Name: "associate_exotic\gdm"; Description: "General Digital Music (GDM)"; Name: "associate_exotic\imf"; Description: "Imago Orpheus (IMF)"; Name: "associate_exotic\ice"; Description: "Ice Tracker (ICE)"; +Name: "associate_exotic\itp"; Description: "Impulse Tracker Project (ITP)"; Name: "associate_exotic\j2b"; Description: "Jazz Jackrabbit 2 Music (J2B)"; Name: "associate_exotic\m15"; Description: "Ultimate Soundtracker (M15)"; Name: "associate_exotic\mdl"; Description: "DigiTrakker (MDL)"; @@ -51,7 +51,6 @@ Root: HKCR; Subkey: ".s3m"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_common\s3m Root: HKCR; Subkey: ".xm"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_common\xm Root: HKCR; Subkey: ".it"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_common\it -Root: HKCR; Subkey: ".itp"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_common\itp Root: HKCR; Subkey: ".mptm"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_common\mptm ; same, but compressed Root: HKCR; Subkey: ".mdr"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_common\compressed @@ -72,6 +71,7 @@ Root: HKCR; Subkey: ".gdm"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\gdm Root: HKCR; Subkey: ".imf"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\imf Root: HKCR; Subkey: ".ice"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\ice +Root: HKCR; Subkey: ".itp"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\itp Root: HKCR; Subkey: ".j2b"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\j2b Root: HKCR; Subkey: ".m15"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\m15 Root: HKCR; Subkey: ".mdl"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\mdl Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -128,13 +128,7 @@ name += MPT_PATHSTRING(".AutoSave."); //append backup tag name += mpt::PathString::FromWide(timeStamp); //append timestamp name += MPT_PATHSTRING("."); //append extension - if(modDoc.GetrSoundFile().m_SongFlags[SONG_ITPROJECT]) - { - name += MPT_PATHSTRING("itp"); - } else - { - name += mpt::PathString::FromUTF8(modDoc.GetrSoundFile().GetModSpecifications().fileExtension); - } + name += mpt::PathString::FromUTF8(modDoc.GetrSoundFile().GetModSpecifications().fileExtension); return name; } @@ -168,9 +162,7 @@ break; case MOD_TYPE_IT: - success = sndFile.m_SongFlags[SONG_ITPROJECT] ? - sndFile.SaveITProject(fileName) : - sndFile.SaveIT(fileName); + success = sndFile.SaveIT(fileName); break; case MOD_TYPE_MPT: Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -513,7 +513,7 @@ EndWaitCursor(); - if(unusedInsSamples && !((sndFile.GetType() == MOD_TYPE_IT) && sndFile.m_SongFlags[SONG_ITPROJECT])) + if(unusedInsSamples) { // We don't remove an instrument's unused samples in an ITP. wsprintf(s, "OpenMPT detected %d sample%s referenced by an instrument,\n" @@ -696,15 +696,9 @@ return false; deleteInstrumentSamples removeSamples = doNoDeleteAssociatedSamples; - if(!sndFile.m_SongFlags[SONG_ITPROJECT]) // Never remove an instrument's samples in ITP. + if(Reporting::Confirm("Remove samples associated with unused instruments?", "Removing unused instruments", false, false, this) == cnfYes) { - if(Reporting::Confirm("Remove samples associated with unused instruments?", "Removing unused instruments", false, false, this) == cnfYes) - { - removeSamples = deleteAssociatedSamples; - } - } else - { - modDoc.AddToLog("Samples associated with an used instrument won't be removed in IT Project files."); + removeSamples = deleteAssociatedSamples; } BeginWaitCursor(); Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -204,7 +204,6 @@ void CCtrlGeneral::UpdateView(DWORD dwHint, CObject *pHint) //--------------------------------------------------------- { - CHAR s[256]; if (pHint == this) return; if (dwHint & HINT_MODSEQUENCE) { @@ -216,20 +215,12 @@ if (!m_bEditsLocked) { m_EditTitle.SetWindowText(m_sndFile.GetTitle().c_str()); - wsprintf(s, "%d", m_sndFile.m_nDefaultTempo); - m_EditTempo.SetWindowText(s); - wsprintf(s, "%d", m_sndFile.m_nDefaultSpeed); - m_EditSpeed.SetWindowText(s); - wsprintf(s, "%d", m_sndFile.m_nDefaultGlobalVolume / GetGlobalVolumeFactor()); - m_EditGlobalVol.SetWindowText(s); - wsprintf(s, "%d", m_sndFile.m_nRestartPos); - m_EditRestartPos.SetWindowText(s); - wsprintf(s, "%d", m_sndFile.m_nVSTiVolume); - m_EditVSTiVol.SetWindowText(s); - wsprintf(s, "%d", m_sndFile.m_nSamplePreAmp); - m_EditSamplePA.SetWindowText(s); - wsprintf(s, "%d", m_sndFile.m_nRestartPos); - m_EditRestartPos.SetWindowText(s); + SetDlgItemInt(IDC_EDIT_TEMPO, m_sndFile.m_nDefaultTempo, FALSE); + SetDlgItemInt(IDC_EDIT_SPEED, m_sndFile.m_nDefaultSpeed, FALSE); + SetDlgItemInt(IDC_EDIT_GLOBALVOL, m_sndFile.m_nDefaultGlobalVolume / GetGlobalVolumeFactor(), FALSE); + SetDlgItemInt(IDC_EDIT_RESTARTPOS, m_sndFile.m_nRestartPos, FALSE); + SetDlgItemInt(IDC_EDIT_VSTIVOL, m_sndFile.m_nVSTiVolume, FALSE); + SetDlgItemInt(IDC_EDIT_SAMPLEPA, m_sndFile.m_nSamplePreAmp, FALSE); } m_SliderGlobalVol.SetPos(MAX_SLIDER_GLOBAL_VOL-m_sndFile.m_nDefaultGlobalVolume); @@ -270,20 +261,16 @@ //on purpose(can be used to control play volume) // MOD Type - LPCSTR pszModType = "MOD (ProTracker)"; + TCHAR *modType = _T("MOD (ProTracker)"); switch(m_sndFile.GetType()) { - case MOD_TYPE_S3M: pszModType = "S3M (ScreamTracker)"; break; - case MOD_TYPE_XM: pszModType = "XM (FastTracker 2)"; break; -// -> CODE#0023 -// -> DESC="IT project files (.itp)" -// case MOD_TYPE_IT: pszModType = "IT (Impulse Tracker)"; break; - case MOD_TYPE_IT: pszModType = m_sndFile.m_SongFlags[SONG_ITPROJECT] ? "ITP (IT Project)" : "IT (Impulse Tracker)"; break; - case MOD_TYPE_MPT: pszModType = "MPTM (OpenMPT)"; break; - -// -! NEW_FEATURE#0023 + case MOD_TYPE_S3M: modType = _T("S3M (ScreamTracker)"); break; + case MOD_TYPE_XM: modType = _T("XM (FastTracker 2)"); break; + case MOD_TYPE_IT: modType = _T("IT (Impulse Tracker)"); break; + case MOD_TYPE_MPT: modType = _T("MPTM (OpenMPT)"); break; } - wsprintf(s, "%s, %d channel%s", pszModType, m_sndFile.GetNumChannels(), (m_sndFile.GetNumChannels() != 1) ? "s" : ""); + TCHAR s[256]; + wsprintf(s, _T("%s, %d channel%s"), modType, m_sndFile.GetNumChannels(), (m_sndFile.GetNumChannels() != 1) ? _T("s") : _T("")); m_EditModType.SetWindowText(s); } CheckDlgButton(IDC_CHECK_LOOPSONG, (TrackerSettings::Instance().gbLoopSong) ? TRUE : FALSE); Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -985,18 +985,7 @@ void CCtrlInstruments::SetModified(DWORD mask, bool updateAll, bool modified) //--------------------------------------------------------------------------- { - // -> CODE#0023 - // -> DESC="IT project files (.itp)" - if(m_modDoc.GetrSoundFile().m_SongFlags[SONG_ITPROJECT]) - { - if(m_modDoc.m_bsInstrumentModified[m_nInstrument - 1] != modified) - { - m_modDoc.m_bsInstrumentModified.set(m_nInstrument - 1, modified); - mask |= HINT_INSNAMES; - } - } m_modDoc.UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | mask, updateAll ? nullptr : this); - // -! NEW_FEATURE#0023 if(modified) m_modDoc.SetModified(); } @@ -1449,7 +1438,6 @@ if (!m_nInstrument) m_nInstrument = 1; if (m_sndFile.ReadInstrumentFromFile(m_nInstrument, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad)) { - m_sndFile.m_szInstrumentPath[m_nInstrument - 1] = fileName; SetModified(HINT_SAMPLEINFO | HINT_MODTYPE, true, false); bOk = TRUE; } @@ -1767,6 +1755,7 @@ "Compressed Impulse Tracker Instruments (*.iti)|*.iti||" : "Impulse Tracker Instruments (*.iti)|*.iti|" "Compressed Impulse Tracker Instruments (*.iti)|*.iti|" + "Impulse Tracker Instruments with external Samples (*.iti)|*.iti|" "FastTracker II Instruments (*.xi)|*.xi||") .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_INSTRUMENTS)) .FilterIndex(&index); @@ -1778,9 +1767,8 @@ if(!mpt::PathString::CompareNoCase(dlg.GetExtension(), MPT_PATHSTRING("xi"))) ok = m_sndFile.SaveXIInstrument(m_nInstrument, dlg.GetFirstFile()); else - ok = m_sndFile.SaveITIInstrument(m_nInstrument, dlg.GetFirstFile(), index == (m_sndFile.GetType() == MOD_TYPE_XM ? 3 : 2)); + ok = m_sndFile.SaveITIInstrument(m_nInstrument, dlg.GetFirstFile(), index == (m_sndFile.GetType() == MOD_TYPE_XM ? 3 : 2), m_sndFile.GetType() != MOD_TYPE_XM && index == 3); - m_sndFile.m_szInstrumentPath[m_nInstrument - 1] = dlg.GetFirstFile(); SetModified(HINT_MODTYPE | HINT_INSNAMES, true, false); m_modDoc.UpdateAllViews(nullptr, HINT_SMPNAMES, this); @@ -2437,11 +2425,6 @@ } } } - -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - m_modDoc.UpdateAllViews(NULL, HINT_INSNAMES, this); -// -! NEW_FEATURE#0023 } } if ((nCode == SB_ENDSCROLL) || (nCode == SB_THUMBPOSITION)) Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -87,6 +87,7 @@ ON_COMMAND(IDC_SAMPLE_XFADE, OnXFade) ON_COMMAND(IDC_SAMPLE_AUTOTUNE, OnAutotune) ON_COMMAND(IDC_CHECK1, OnSetPanningChanged) + ON_COMMAND(IDC_CHECK2, OnKeepSampleOnDisk) ON_COMMAND(ID_PREVINSTRUMENT, OnPrevInstrument) ON_COMMAND(ID_NEXTINSTRUMENT, OnNextInstrument) ON_COMMAND(IDC_BUTTON1, OnPitchShiftTimeStretch) @@ -515,8 +516,8 @@ } -BOOL CCtrlSamples::GetToolTipText(UINT uId, LPSTR pszText) -//-------------------------------------------------------- +BOOL CCtrlSamples::GetToolTipText(UINT uId, TCHAR *pszText) +//--------------------------------------------------------- { if ((pszText) && (uId)) { @@ -529,13 +530,16 @@ { const ModSample &sample = m_sndFile.GetSample(m_nSample); UINT nFreqHz = ModSample::TransposeToFrequency(sample.RelativeTone, sample.nFineTune); - wsprintf(pszText, "%ldHz", nFreqHz); + wsprintf(pszText, _T("%luHz"), nFreqHz); return TRUE; } break; case IDC_EDIT_STRETCHPARAMS: - wsprintf(pszText, "SequenceMs SeekwindowMs OverlapMs"); + _tcscpy(pszText, _T("SequenceMs SeekwindowMs OverlapMs")); return TRUE; + case IDC_CHECK2: + _tcscpy(pszText, _T("Keep a reference to the original waveform instead of saving it in the module.")); + return TRUE; } } return FALSE; @@ -662,7 +666,7 @@ DWORD d; m_SpinSample.SetRange(1, m_sndFile.GetNumSamples()); - + // Length / Type wsprintf(s, "%u-bit %s, len: %u", sample.GetElementarySampleSize() * 8, sample.uFlags[CHN_STEREO] ? "stereo" : "mono", sample.nLength); SetDlgItemText(IDC_TEXT5, s); @@ -750,6 +754,11 @@ wsprintf(s, "%lu", sample.nSustainEnd); m_EditSustainEnd.SetWindowText(s); } + if (dwHintMask & (HINT_MODTYPE | HINT_SAMPLEINFO | HINT_SMPNAMES)) + { + CheckDlgButton(IDC_CHECK2, m_sndFile.GetSample(m_nSample).uFlags[SMP_KEEPONDISK] ? BST_CHECKED : BST_UNCHECKED); + GetDlgItem(IDC_CHECK2)->EnableWindow((m_sndFile.SampleHasPath(m_nSample) && m_sndFile.GetType() == MOD_TYPE_MPT) ? TRUE : FALSE); + } if (!m_bInitialized) { // First update @@ -766,10 +775,18 @@ // updateAll: Update all views including this one. Otherwise, only update update other views. -void CCtrlSamples::SetModified(DWORD mask, bool updateAll) -//-------------------------------------------------------- +void CCtrlSamples::SetModified(DWORD mask, bool updateAll, bool waveformModified) +//------------------------------------------------------------------------------- { m_modDoc.SetModified(); + + if(waveformModified) + { + // Update on-disk sample status in tree + ModSample &sample = m_sndFile.GetSample(m_nSample); + if(sample.uFlags[SMP_KEEPONDISK] && !sample.uFlags[SMP_MODIFIED]) mask |= HINT_SMPNAMES; + sample.uFlags.set(SMP_MODIFIED); + } m_modDoc.UpdateAllViews(nullptr, mask | (m_nSample << HINT_SHIFT_SMP), updateAll ? nullptr : this); } @@ -856,6 +873,9 @@ { m_modDoc.GetSampleUndo().RemoveLastUndoStep(m_nSample); } + } else + { + m_sndFile.SetSamplePath(m_nSample, fileName); } EndWaitCursor(); @@ -877,7 +897,8 @@ sample.nPan = 128; sample.uFlags.set(CHN_PANNING); } - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES, true, false); + sample.uFlags.reset(SMP_MODIFIED | SMP_KEEPONDISK); } return true; } @@ -892,16 +913,10 @@ m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_replace, "Replace"); m_sndFile.ReadSampleFromSong(m_nSample, sndFile, nSample); - ModSample &sample = m_sndFile.GetSample(m_nSample); - if((m_sndFile.GetType() & MOD_TYPE_XM) && (!sample.uFlags[CHN_PANNING])) - { - sample.nPan = 128; - sample.uFlags.set(CHN_PANNING); - } EndWaitCursor(); - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES, true, false); return true; } @@ -1128,6 +1143,27 @@ ok = m_sndFile.SaveFLACSample(smp, fileName); else ok = m_sndFile.SaveWAVSample(smp, fileName); + + if(ok && !doBatchSave) + { + m_sndFile.SetSamplePath(smp, fileName); + ModSample &sample = m_sndFile.GetSample(smp); + sample.uFlags.reset(SMP_MODIFIED); + UpdateView(HINT_SAMPLEINFO); + + // Check if any other samples refer to the same file - that would be dangerous. + if(sample.uFlags[SMP_KEEPONDISK]) + { + for(SAMPLEINDEX i = 1; i <= m_sndFile.GetNumSamples(); i++) + { + if(i != smp && m_sndFile.GetSample(i).uFlags[SMP_KEEPONDISK] && m_sndFile.GetSamplePath(i) == m_sndFile.GetSamplePath(smp)) + { + m_sndFile.GetSample(i).uFlags.reset(SMP_KEEPONDISK); + m_modDoc.UpdateAllViews(nullptr, HINT_SMPNAMES | HINT_SAMPLEINFO | (i << HINT_SHIFT_SMP), this); + } + } + } + } } } EndWaitCursor(); @@ -1264,7 +1300,7 @@ if(bModified) { - SetModified(HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEDATA, false, true); } EndWaitCursor(); SwitchToView(); @@ -1312,7 +1348,7 @@ ApplyAmplifyImpl<int8>(sample.pSample8, selection.nStart, selection.nEnd, lAmp, fadeIn, fadeOut); } sample.PrecomputeLoops(m_sndFile, false); - SetModified(HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEDATA, false, true); EndWaitCursor(); SwitchToView(); } @@ -1377,7 +1413,7 @@ CString dcInfo; if(numModified) { - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, true); if(numModified == 1) { dcInfo.Format(GetStrI18N(TEXT("Removed DC offset (%.1f%%)")), fReportOffset * 100); @@ -1459,7 +1495,7 @@ const SmpLength newTotalLength = sample.nLength - selLength + newSelLength; const uint8 numChannels = sample.GetNumChannels(); - void *newSample = ModSample::AllocateSample(newTotalLength * numChannels, sample.GetElementarySampleSize()); + void *newSample = ModSample::AllocateSample(newTotalLength, sample.GetBytesPerSample()); if(newSample != nullptr) { @@ -1583,7 +1619,7 @@ { SetSelectionPoints(selection.nStart, newSelEnd); } - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, true); } EndWaitCursor(); @@ -1732,7 +1768,7 @@ } // Update sample view - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, true); } @@ -1854,7 +1890,7 @@ void *pNewSample = nullptr; if(nNewSampleLength <= MAX_SAMPLE_LENGTH) { - pNewSample = ModSample::AllocateSample(nNewSampleLength, nChn * smpsize); + pNewSample = ModSample::AllocateSample(nNewSampleLength, sample.GetBytesPerSample()); } if(pNewSample == nullptr) { @@ -2179,7 +2215,7 @@ m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_reverse, "Reverse", selection.nStart, selection.nEnd); if(ctrlSmp::ReverseSample(sample, selection.nStart, selection.nEnd, m_sndFile)) { - SetModified(HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEDATA, false, true); } else { m_modDoc.GetSampleUndo().RemoveLastUndoStep(m_nSample); @@ -2199,7 +2235,7 @@ m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_invert, "Invert", selection.nStart, selection.nEnd); if(ctrlSmp::InvertSample(sample, selection.nStart, selection.nEnd, m_sndFile) == true) { - SetModified(HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEDATA, false, true); } else { m_modDoc.GetSampleUndo().RemoveLastUndoStep(m_nSample); @@ -2224,7 +2260,7 @@ m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_unsign, "Unsign", selection.nStart, selection.nEnd); if(ctrlSmp::UnsignSample(sample, selection.nStart, selection.nEnd, m_sndFile) == true) { - SetModified(HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEDATA, false, true); } else { m_modDoc.GetSampleUndo().RemoveLastUndoStep(m_nSample); @@ -2277,7 +2313,7 @@ } } sample.PrecomputeLoops(m_sndFile, false); - SetModified(HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEDATA, false, true); } EndWaitCursor(); @@ -2315,7 +2351,7 @@ if (_tcscmp(s, m_sndFile.m_szNames[m_nSample])) { mpt::String::Copy(m_sndFile.m_szNames[m_nSample], s); - SetModified(HINT_SMPNAMES | HINT_SAMPLEINFO, false); + SetModified(HINT_SMPNAMES | HINT_SAMPLEINFO, false, false); } } @@ -2331,7 +2367,7 @@ if (_tcscmp(s, m_sndFile.GetSample(m_nSample).filename)) { mpt::String::Copy(m_sndFile.GetSample(m_nSample).filename, s); - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2346,7 +2382,7 @@ if (nVol != m_sndFile.GetSample(m_nSample).nVolume) { m_sndFile.GetSample(m_nSample).nVolume = (WORD)nVol; - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2360,7 +2396,7 @@ if (nVol != m_sndFile.GetSample(m_nSample).nGlobalVol) { m_sndFile.GetSample(m_nSample).nGlobalVol = (uint16)nVol; - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2380,7 +2416,7 @@ if(b != sample.uFlags[CHN_PANNING]) { sample.uFlags.set(CHN_PANNING, b); - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2404,7 +2440,7 @@ if (nPan != m_sndFile.GetSample(m_nSample).nPan) { m_sndFile.GetSample(m_nSample).nPan = (uint16)nPan; - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2431,7 +2467,7 @@ m_CbnBaseNote.SetCurSel(basenote); UnlockControls(); } - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } else { @@ -2440,7 +2476,7 @@ if ((n >= -128) && (n <= 127)) { m_sndFile.GetSample(m_nSample).nFineTune = (signed char)n; - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2468,14 +2504,14 @@ LockControls(); m_EditFineTune.SetWindowText(s); UnlockControls(); - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } else { if ((n >= -128) && (n < 128)) { sample.RelativeTone = (int8)n; - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } } @@ -2491,7 +2527,7 @@ m_sndFile.GetSample(m_nSample).nVibType = static_cast<uint8>(m_ComboAutoVib.GetItemData(n)); PropagateAutoVibratoChanges(); - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2508,7 +2544,7 @@ m_sndFile.GetSample(m_nSample).nVibDepth = static_cast<uint8>(n); PropagateAutoVibratoChanges(); - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2525,7 +2561,7 @@ m_sndFile.GetSample(m_nSample).nVibSweep = static_cast<uint8>(n); PropagateAutoVibratoChanges(); - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2542,7 +2578,7 @@ m_sndFile.GetSample(m_nSample).nVibRate = static_cast<uint8>(n); PropagateAutoVibratoChanges(); - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } } @@ -2576,7 +2612,7 @@ sample.PrecomputeLoops(m_sndFile); } ctrlSmp::UpdateLoopPoints(sample, m_sndFile); - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } @@ -2589,7 +2625,7 @@ if ((n >= 0) && (n < sample.nLength) && ((n < sample.nLoopEnd) || !sample.uFlags[CHN_LOOP])) { sample.SetLoop(n, sample.nLoopEnd, sample.uFlags[CHN_LOOP], sample.uFlags[CHN_PINGPONGLOOP], m_sndFile); - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false, false); } } @@ -2603,7 +2639,7 @@ if ((n >= 0) && (n <= sample.nLength) && ((n > sample.nLoopStart) || !sample.uFlags[CHN_LOOP])) { sample.SetLoop(sample.nLoopStart, n, sample.uFlags[CHN_LOOP], sample.uFlags[CHN_PINGPONGLOOP], m_sndFile); - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false, false); } } @@ -2637,7 +2673,7 @@ sample.PrecomputeLoops(m_sndFile); } ctrlSmp::UpdateLoopPoints(sample, m_sndFile); - SetModified(HINT_SAMPLEINFO, false); + SetModified(HINT_SAMPLEINFO, false, false); } @@ -2651,7 +2687,7 @@ && ((n < sample.nSustainEnd) || !sample.uFlags[CHN_SUSTAINLOOP])) { sample.SetSustainLoop(n, sample.nSustainEnd, sample.uFlags[CHN_SUSTAINLOOP], sample.uFlags[CHN_PINGPONGSUSTAIN], m_sndFile); - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false, false); } } @@ -2666,7 +2702,7 @@ && ((n > sample.nSustainStart) || !sample.uFlags[CHN_SUSTAINLOOP])) { sample.SetSustainLoop(sample.nSustainStart, n, sample.uFlags[CHN_SUSTAINLOOP], sample.uFlags[CHN_PINGPONGSUSTAIN], m_sndFile); - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false, false); } } @@ -2956,7 +2992,7 @@ if(nCode == SB_ENDSCROLL) SwitchToView(); if(redraw) { - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, false, false); } UnlockControls(); } @@ -3111,7 +3147,7 @@ if(ctrlSmp::XFadeSample(sample, fadeLength, m_sndFile)) { - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, true); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, true, true); } else { m_modDoc.GetSampleUndo().RemoveLastUndoStep(m_nSample); @@ -3139,13 +3175,32 @@ BeginWaitCursor(); m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Automatic Sample Tuning"); at.Apply(static_cast<double>(dlg.GetPitchReference()), dlg.GetTargetNote()); - SetModified(HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEINFO, true, false); EndWaitCursor(); } } } +void CCtrlSamples::OnKeepSampleOnDisk() +//------------------------------------- +{ + SAMPLEINDEX first = m_nSample, last = m_nSample; + if(CMainFrame::GetInputHandler()->ShiftPressed()) + { + first = 1; + last = m_sndFile.GetNumSamples(); + } + + const bool enable = IsDlgButtonChecked(IDC_CHECK2) != BST_UNCHECKED; + for(SAMPLEINDEX i = first; i <= last; i++) + { + m_sndFile.GetSample(i).uFlags.set(SMP_KEEPONDISK, enable && m_sndFile.SampleHasPath(i)); + m_modDoc.UpdateAllViews(nullptr, HINT_SAMPLEINFO | (i << HINT_SHIFT_SMP), this); + } +} + + // When changing auto vibrato properties, propagate them to other samples of the same instrument in XM edit mode. void CCtrlSamples::PropagateAutoVibratoChanges() const //---------------------------------------------------- Modified: trunk/OpenMPT/mptrack/Ctrl_smp.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.h 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/Ctrl_smp.h 2014-10-26 15:27:49 UTC (rev 4504) @@ -80,7 +80,7 @@ virtual void OnDeactivatePage(); virtual void UpdateView(DWORD dwHintMask=0, CObject *pObj=NULL); virtual LRESULT OnModCtrlMsg(WPARAM wParam, LPARAM lParam); - virtual BOOL GetToolTipText(UINT uId, LPSTR pszText); + virtual BOOL GetToolTipText(UINT uId, TCHAR *pszText); virtual BOOL PreTranslateMessage(MSG* pMsg); //}}AFX_VIRTUAL protected: @@ -122,6 +122,7 @@ afx_msg void OnVibSweepChanged(); afx_msg void OnVibRateChanged(); afx_msg void OnXFade(); + afx_msg void OnKeepSampleOnDisk(); afx_msg void OnVScroll(UINT, UINT, CScrollBar *); afx_msg LRESULT OnCustomKeyMsg(WPARAM, LPARAM); //rewbs.customKeys @@ -129,7 +130,7 @@ afx_msg void OnEnableStretchToSize(); afx_msg void OnEstimateSampleSize(); - void SetModified(DWORD mask, bool updateAll); + void SetModified(DWORD mask, bool updateAll, bool waveformModified); //}}AFX_MSG DECLARE_MESSAGE_MAP() Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -48,7 +48,6 @@ const TCHAR FileFilterXM[] = _T("FastTracker Modules (*.xm)|*.xm||"); const TCHAR FileFilterS3M[] = _T("ScreamTracker Modules (*.s3m)|*.s3m||"); const TCHAR FileFilterIT[] = _T("Impulse Tracker Modules (*.it)|*.it||"); -const TCHAR FileFilterITP[] = _T("Impulse Tracker Projects (*.itp)|*.itp||"); const TCHAR FileFilterMPT[] = _T("OpenMPT Modules (*.mptm)|*.mptm||"); const TCHAR FileFilterNone[] = _T(""); @@ -61,7 +60,7 @@ case MOD_TYPE_MOD: return FileFilterMOD; case MOD_TYPE_XM: return FileFilterXM; case MOD_TYPE_S3M: return FileFilterS3M; - case MOD_TYPE_IT: return (sndFile.m_SongFlags[SONG_ITPROJECT] ? FileFilterITP : FileFilterIT); + case MOD_TYPE_IT: return FileFilterIT; case MOD_TYPE_MPT: return FileFilterMPT; default: return FileFilterNone; } @@ -143,8 +142,6 @@ // Set the creation date of this file (or the load time if we're loading an existing file) time(&m_creationTime); - m_bsInstrumentModified.reset(); - #ifdef _DEBUG ModChannel *p = m_SndFile.m_PlayState.Chn; if (((DWORD)p) & 7) Log("ModChannel struct is not aligned (0x%08X)\n", p); @@ -185,11 +182,6 @@ m_SndFile.Create(FileReader(), CSoundFile::loadCompleteModule, this); m_SndFile.ChangeModTypeTo(CTrackApp::GetDefaultDocType()); - if(CTrackApp::IsProject()) - { - m_SndFile.m_SongFlags.set(SONG_ITPROJECT); - } - theApp.GetDefaultMidiMacro(m_SndFile.m_MidiCfg); m_SndFile.m_SongFlags.set(SONG_LINEARSLIDES & m_SndFile.GetModSpecifications().songFlags); if(!m_SndFile.m_MidiCfg.IsMacroDefaultSetupUsed()) @@ -423,7 +415,7 @@ case MOD_TYPE_MOD: bOk = m_SndFile.SaveMod(filename); break; case MOD_TYPE_S3M: bOk = m_SndFile.SaveS3M(filename); break; case MOD_TYPE_XM: bOk = m_SndFile.SaveXM(filename); break; - case MOD_TYPE_IT: bOk = (m_SndFile.m_SongFlags[SONG_ITPROJECT] ? m_SndFile.SaveITProject(filename) : m_SndFile.SaveIT(filename)); break; + case MOD_TYPE_IT: bOk = m_SndFile.SaveIT(filename); break; case MOD_TYPE_MPT: bOk = m_SndFile.SaveIT(filename); break; } EndWaitCursor(); @@ -444,79 +436,77 @@ } } else { - if(type == MOD_TYPE_IT && m_SndFile.m_SongFlags[SONG_ITPROJECT]) - Reporting::Error(_T("ITP projects need to have a path set for each instrument...")); - else - ErrorBox(IDS_ERR_SAVESONG, CMainFrame::GetMainFrame()); + ErrorBox(IDS_ERR_SAVESONG, CMainFrame::GetMainFrame()); } return bOk; } -// -> CODE#0023 -// -> DESC="IT project files (.itp)" BOOL CModDoc::SaveModified() //-------------------------- { - if((m_SndFile.GetType() & MOD_TYPE_IT) && m_SndFile.m_SongFlags[SONG_ITPROJECT] && !m_SndFile.m_SongFlags[SONG_ITPEMBEDIH]) + BOOL result = CDocument::SaveModified(); + if(result && m_SndFile.GetType() == MOD_TYPE_MPT) { - bool unsavedInstrument = false; - - for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.GetNumInstruments(); i++) + std::wstring prompt = L"The following external samples have been modified:\n"; + bool modified = false; + for(SAMPLEINDEX i = 1; i <= m_SndFile.GetNumSamples(); i++) { - if(m_bsInstrumentModified[i]) + if(m_SndFile.GetSample(i).uFlags.test_all(SMP_KEEPONDISK | SMP_MODIFIED)) { - unsavedInstrument = true; - break; + modified = true; + prompt += mpt::wfmt::dec0<2>(i) + L": " + m_SndFile.GetSamplePath(i).ToWide() + L"\n"; } } - if(unsavedInstrument && Reporting::Confirm("Do you want to save modified instruments?") == cnfYes) + ConfirmAnswer ans = cnfYes; + if(modified && (ans = Reporting::Confirm(prompt + L"Do you want to save them?", L"External Samples", true)) == cnfYes) { - for(INSTRUMENTINDEX i = 0; i < m_SndFile.GetNumInstruments(); i++) + for(SAMPLEINDEX i = 1; i <= m_SndFile.GetNumSamples(); i++) { - if(m_bsInstrumentModified[i]) + if(m_SndFile.GetSample(i).uFlags.test_all(SMP_KEEPONDISK | SMP_MODIFIED)) { - SaveInstrument(i + 1); + SaveSample(i); } } + } else if(ans == cnfCancel) + { + result = FALSE; } } - return CDocument::SaveModified(); + return result; } -bool CModDoc::SaveInstrument(INSTRUMENTINDEX instr) -//------------------------------------------------- +bool CModDoc::SaveSample(SAMPLEINDEX smp) +//--------------------------------------- { bool success = false; - if(instr > 0 && instr <= GetNumInstruments()) + if(smp > 0 && smp <= GetNumSamples()) { - instr--; - if(!m_SndFile.m_szInstrumentPath[instr].empty()) + const mpt::PathString filename = m_SndFile.GetSamplePath(smp); + if(!filename.empty()) { - const mpt::PathString dotExt = m_SndFile.m_szInstrumentPath[instr].GetFileExt(); - const bool iti = !mpt::PathString::CompareNoCase(dotExt, MPT_PATHSTRING(".iti")); - const bool xi = !mpt::PathString::CompareNoCase(dotExt, MPT_PATHSTRING(".xi")); + const mpt::PathString dotExt = filename.GetFileExt(); + const bool wav = !mpt::PathString::CompareNoCase(dotExt, MPT_PATHSTRING(".wav")); + const bool flac = !mpt::PathString::CompareNoCase(dotExt, MPT_PATHSTRING(".flac")); - if(iti || (!xi && m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) - success = m_SndFile.SaveITIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr], false); + if(flac || (!wav && TrackerSettings::Instance().m_defaultSampleFormat != dfWAV)) + success = m_SndFile.SaveFLACSample(smp, filename); else - success = m_SndFile.SaveXIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr]); + success = m_SndFile.SaveWAVSample(smp, filename); if(success) - m_bsInstrumentModified.reset(instr); + m_SndFile.GetSample(smp).uFlags.reset(SMP_MODIFIED); else - Reporting::Error(L"Error while saving\n" + m_SndFile.m_szInstrumentPath[instr].ToWide() + L"!"); + Reporting::Error(L"Unable to save sample:\n" + filename.ToWide()); } } return success; } -// -! NEW_FEATURE#0023 - void CModDoc::OnCloseDocument() //----------------------------- { @@ -567,9 +557,8 @@ //--------------------------------------------------------- { const mpt::PathString docFileName = GetPathNameMpt(); + const std::string defaultExtension = m_SndFile.GetModSpecifications().fileExtension; - std::string defaultExtension = m_SndFile.GetModSpecifications().fileExtension; - switch(m_SndFile.GetBestSaveFormat()) { case MOD_TYPE_MOD: @@ -581,21 +570,7 @@ MsgBoxHidable(XMCompatibilityExportTip); break; case MOD_TYPE_IT: -// -> CODE#0023 -// -> DESC="IT project files (.itp)" -// lpszDefExt = "it"; -// lpszFilter = "Impulse Tracker Modules (*.it)|*.it||"; -// strcpy(fext, ".it"); - if(m_SndFile.m_SongFlags[SONG_ITPROJECT]) - { - // Special case... - defaultExtension = "itp"; - } - else - { - MsgBoxHidable(ItCompatibilityExportTip); - } -// -! NEW_FEATURE#0023 + MsgBoxHidable(ItCompatibilityExportTip); break; case MOD_TYPE_MPT: break; @@ -2649,26 +2624,12 @@ newPath += fname; } - if(nNewType == MOD_TYPE_IT) - { - newPath += m_SndFile.m_SongFlags[SONG_ITPROJECT] ? MPT_PATHSTRING(".itp") : MPT_PATHSTRING(".it"); - } else - { - newPath += MPT_PATHSTRING(".") + mpt::PathString::FromUTF8(CSoundFile::GetModSpecifications(nNewType).fileExtension); - } - - if(nNewType != MOD_TYPE_IT || - (nNewType == MOD_TYPE_IT && - ( - (!mpt::PathString::CompareNoCase(fext, MPT_PATHSTRING(".it")) && m_SndFile.m_SongFlags[SONG_ITPROJECT]) || - (!mpt::PathString::CompareNoCase(fext, MPT_PATHSTRING(".itp")) && !m_SndFile.m_SongFlags[SONG_ITPROJECT]) - ) - ) - ) - m_ShowSavedialog = true; - //Forcing savedialog to appear after extension change - otherwise - //unnotified file overwriting may occur. + newPath += MPT_PATHSTRING(".") + mpt::PathString::FromUTF8(CSoundFile::GetModSpecifications(nNewType).fileExtension); + //Forcing savedialog to appear after extension change - otherwise + //unnotified file overwriting may occur. + m_ShowSavedialog = true; + SetPathName(newPath, FALSE); } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/Moddoc.h 2014-10-26 15:27:49 UTC (rev 4504) @@ -189,8 +189,6 @@ protected: std::bitset<MAX_BASECHANNELS> m_bsMultiRecordMask; std::bitset<MAX_BASECHANNELS> m_bsMultiSplitRecordMask; -public: - std::bitset<MAX_INSTRUMENTS> m_bsInstrumentModified; // which instruments have been modified? (for ITP functionality) protected: // create from serialization only CModDoc(); @@ -410,11 +408,8 @@ return mpt::PathString::TunnelOutofCString(CDocument::GetPathName()); } -// -> CODE#0023 -// -> DESC="IT project files (.itp)" virtual BOOL SaveModified(); - bool SaveInstrument(INSTRUMENTINDEX instr); -// -! NEW_FEATURE#0023 + bool SaveSample(SAMPLEINDEX smp); #ifndef UNICODE // MFC checks for writeable filename in there and issues SaveAs dialog if not. Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -296,6 +296,7 @@ std::vector<ModSample> sampleHeaders(oldNumSamples + 1); std::vector<SAMPLEINDEX> newIndex(oldNumSamples + 1, 0); // One of the new indexes for the old sample std::vector<std::string> sampleNames(oldNumSamples + 1); + std::vector<mpt::PathString> samplePaths(oldNumSamples + 1); for(SAMPLEINDEX i = 0; i < newNumSamples; i++) { @@ -316,6 +317,7 @@ m_SndFile.DestroySample(i); } sampleNames[i] = m_SndFile.m_szNames[i]; + samplePaths[i] = m_SndFile.GetSamplePath(i); } // Remove sample data references from now unused slots. @@ -350,12 +352,14 @@ } } strcpy(m_SndFile.m_szNames[i + 1], sampleNames[origSlot].c_str()); + m_SndFile.SetSamplePath(i + 1, samplePaths[origSlot]); } else { // Invalid sample reference. target.Initialize(m_SndFile.GetType()); target.pSample = nullptr; strcpy(m_SndFile.m_szNames[i + 1], ""); + m_SndFile.ResetSamplePath(i + 1); } } @@ -694,6 +698,9 @@ if(newSlot || !m_SndFile.m_szNames[i][0]) strcpy(m_SndFile.m_szNames[i], "untitled"); if(newSlot) m_SndFile.m_nSamples = i; m_SndFile.GetSample(i).Initialize(m_SndFile.GetType()); + + m_SndFile.ResetSamplePath(i); + SetModified(); return i; } @@ -782,11 +789,6 @@ if (pDup) { *pIns = *pDup; - // -> CODE#0023 - // -> DESC="IT project files (.itp)" - m_SndFile.m_szInstrumentPath[newins - 1] = m_SndFile.m_szInstrumentPath[nDuplicate - 1]; - m_bsInstrumentModified.reset(newins - 1); - // -! NEW_FEATURE#0023 } SetModified(); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -610,11 +610,6 @@ MODTYPE CTrackApp::m_nDefaultDocType = MOD_TYPE_IT; -// -> CODE#0023 -// -> DESC="IT project files (.itp)" -BOOL CTrackApp::m_nProject = FALSE; -// -! NEW_FEATURE#0023 - BEGIN_MESSAGE_MAP(CTrackApp, CWinApp) //{{AFX_MSG_MAP(CTrackApp) ON_COMMAND(ID_FILE_NEW, OnFileNew) @@ -622,10 +617,6 @@ ON_COMMAND(ID_FILE_NEWS3M, OnFileNewS3M) ON_COMMAND(ID_FILE_NEWXM, OnFileNewXM) ON_COMMAND(ID_FILE_NEWIT, OnFileNewIT) -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - ON_COMMAND(ID_NEW_ITPROJECT,OnFileNewITProject) -// -! NEW_FEATURE#0023 ON_COMMAND(ID_NEW_MPT, OnFileNewMPT) ON_COMMAND(ID_FILE_OPEN, OnFileOpen) ON_COMMAND(ID_FILE_CLOSEALL, OnFileCloseAll) @@ -1104,18 +1095,16 @@ // Default module type - MODTYPE nNewType = TrackerSettings::Instance().defaultModType; - bool bIsProject = false; + MODTYPE newType = TrackerSettings::Instance().defaultModType; // Get active document to make the new module of the same type CModDoc *pModDoc = CMainFrame::GetMainFrame()->GetActiveDoc(); if(pModDoc != nullptr) { - nNewType = pModDoc->GetrSoundFile().GetBestSaveFormat(); - bIsProject = pModDoc->GetrSoundFile().m_SongFlags[SONG_ITPROJECT]; + newType = pModDoc->GetrSoundFile().GetBestSaveFormat(); } - switch(nNewType) + switch(newType) { case MOD_TYPE_MOD: OnFileNewMOD(); @@ -1127,10 +1116,7 @@ OnFileNewXM(); break; case MOD_TYPE_IT: - if(bIsProject) - OnFileNewITProject(); - else - OnFileNewIT(); + OnFileNewIT(); break; case MOD_TYPE_MPT: default: @@ -1143,11 +1129,6 @@ void CTrackApp::OnFileNewMOD() //---------------------------- { -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - SetAsProject(FALSE); -// -! NEW_FEATURE#0023 - SetDefaultDocType(MOD_TYPE_MOD); if (m_pModTemplate) m_pModTemplate->OpenDocumentFile(mpt::PathString()); } @@ -1156,11 +1137,6 @@ void CTrackApp::OnFileNewS3M() //---------------------------- { -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - SetAsProject(FALSE); -// -! NEW_FEATURE#0023 - SetDefaultDocType(MOD_TYPE_S3M); if (m_pModTemplate) m_pModTemplate->OpenDocumentFile(mpt::PathString()); } @@ -1169,11 +1145,6 @@ void CTrackApp::OnFileNewXM() //--------------------------- { -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - SetAsProject(FALSE); -// -! NEW_FEATURE#0023 - SetDefaultDocType(MOD_TYPE_XM); if (m_pModTemplate) m_pModTemplate->OpenDocumentFile(mpt::PathString()); } @@ -1182,11 +1153,6 @@ void CTrackApp::OnFileNewIT() //--------------------------- { -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - SetAsProject(FALSE); -// -! NEW_FEATURE#0023 - SetDefaultDocType(MOD_TYPE_IT); if (m_pModTemplate) m_pModTemplate->OpenDocumentFile(mpt::PathString()); } @@ -1194,25 +1160,11 @@ void CTrackApp::OnFileNewMPT() //--------------------------- { - SetAsProject(FALSE); SetDefaultDocType(MOD_TYPE_MPT); if (m_pModTemplate) m_pModTemplate->OpenDocumentFile(mpt::PathString()); } - -// -> CODE#0023 -// -> DESC="IT project files (.itp)" -void CTrackApp::OnFileNewITProject() -//---------------------------------- -{ - SetAsProject(TRUE); - SetDefaultDocType(MOD_TYPE_IT); - if (m_pModTemplate) m_pModTemplate->OpenDocumentFile(mpt::PathString()); -} -// -! NEW_FEATURE#0023 - - void CTrackApp::OpenModulesDialog(std::vector<mpt::PathString> &files) //-------------------------------------------------------------------- { @@ -1243,12 +1195,8 @@ "ScreamTracker Modules (*.s3m,*.stm)|*.s3m;*.stm;*.s3z|" "FastTracker Modules (*.xm)|*.xm;*.xmz|" "Impulse Tracker Modules (*.it)|*.it;*.itz|" - // -> CODE#0023 - // -> DESC="IT project files (.itp)" - "Impulse Tracker Projects (*.itp)|*.itp;*.itpz|" - // -! NEW_FEATURE#0023 "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;*.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|" "Wave Files (*.wav)|*.wav|" "MIDI Files (*.mid,*.rmi)|*.mid;*.rmi;*.smf|" "All Files (*.*)|*.*||") Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/Mptrack.h 2014-10-26 15:27:49 UTC (rev 4504) @@ -162,7 +162,6 @@ // static data protected: static MODTYPE m_nDefaultDocType; - static BOOL m_nProject; static MIDILIBSTRUCT midiLibrary; public: @@ -226,12 +225,6 @@ public: -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - static BOOL IsProject() { return m_nProject; } - static VOID SetAsProject(BOOL n) { m_nProject = n; } -// -! NEW_FEATURE#0023 - mpt::PathString GetAppDirPath() {return m_szExePath;} // Returns '\'-ended executable directory path. static MODTYPE GetDefaultDocType() { return m_nDefaultDocType; } static void SetDefaultDocType(MODTYPE n) { m_nDefaultDocType = n; } @@ -318,10 +311,6 @@ afx_msg void OnFileNewXM(); afx_msg void OnFileNewIT(); afx_msg void OnFileNewMPT(); -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - afx_msg void OnFileNewITProject(); -// -! NEW_FEATURE#0023 afx_msg void OnFileOpen(); afx_msg void OnAppAbout(); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -146,7 +146,7 @@ , glTreeWindowWidth(conf, "Display", "MDITreeWidth", 160) , glGeneralWindowHeight(conf, "Display", "MDIGeneralHeight", 178) , glPatternWindowHeight(conf, "Display", "MDIPatternHeight", 152) - , glSampleWindowHeight(conf, "Display", "MDISampleHeight", 188) + , glSampleWindowHeight(conf, "Display", "MDISampleHeight", 190) , glInstrumentWindowHeight(conf, "Display", "MDIInstrumentHeight", 300) , glCommentsWindowHeight(conf, "Display", "MDICommentsHeight", 288) , glGraphWindowHeight(conf, "Display", "MDIGraphHeight", 288) Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -188,11 +188,7 @@ { CModDoc *pModDoc = GetDocument(); if(pModDoc == nullptr) return; -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - pModDoc->m_bsInstrumentModified.set(m_nInstrument - 1, true); - pModDoc->UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | HINT_INSNAMES | mask, updateAll ? nullptr : this); -// -! NEW_FEATURE#0023 + pModDoc->UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | mask, updateAll ? nullptr : this); pModDoc->SetModified(); } Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2014-10-26 11:18:46 UTC (rev 4503) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-10-26 15:27:49 UTC (rev 4504) @@ -168,11 +168,19 @@ // updateAll: Update all views including this one. Otherwise, only update update other views. -void CViewSample::SetModified(DWORD mask, bool updateAll) -//------------------------------------------------------- +void CViewSample::SetModified(DWORD mask, bool updateAll, bool waveformModified) +//------------------------------------------------------------------------------ { CModDoc *pModDoc = GetDocument(); pModDoc->SetModified(); + + if(waveformModified) + { + // Update on-disk sample status in tree + ModSample &sample = pModDoc->GetrSoundFile().GetSample(m_nSample); + if(sample.uFlags[SMP_KEEPONDISK] && !sample.uFlags[SMP_MODIFIED]) mask |= HINT_SMPNAMES; + sample.uFlags.set(SMP_MODIFIED); + } pModDoc->UpdateAllViews(nullptr, mask | (m_nSample << HINT_SHIFT_SMP), updateAll ? nullptr : this); } @@ -1624,7 +1632,7 @@ sndFile.GetSample(m_nSample).PrecomputeLoops(sndFile, false); InvalidateSample(); - SetModified(HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEDATA, false, true); } } else if (old != m_dwEndDrag) @@ -1679,7 +1687,7 @@ sndFile.GetSample(m_nSample).PrecomputeLoops(sndFile, false); InvalidateSample(); - SetModified(HINT_SAMPLEDATA, false); + SetModified(HINT_SAMPLEDATA, false, true); } else { // ctrl + click = play from cursor pos @@ -1933,7 +1941,7 @@ if ((sample.nLoopStart != m_dwBeginSel) || (sample.nLoopEnd != m_dwEndSel)) { sample.SetLoop(m_dwBeginSel, m_dwEndSel, true, sample.uFlags[CHN_PINGPONGLOOP], sndFile); - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, true); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, true, false); } } } @@ -1953,7 +1961,7 @@ if ((sample.nSustainStart != m_dwBeginSel) || (sample.nSustainEnd != m_dwEndSel)) { sample.SetSustainLoop(m_dwBeginSel, m_dwEndSel, true, sample.uFlags[CHN_PINGPONGSUSTAIN], sndFile); - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, true); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA, true, false); } } } @@ -2035,7 +2043,7 @@ sample.PrecomputeLoops(sndFile); } SetCurSel(0, 0); - SetModified(dwUpdateFlags, true); + SetModified(dwUpdateFlags, true, true); } @@ -2173,7 +2181,9 @@ GlobalUnlock(hCpy); SetCurSel(0, 0); sample.PrecomputeLoops(sndFile, true); - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES, true); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES, true, false); + + sndFile.ResetSamplePath(m_nSample); } CloseClipboard(); } @@ -2188,7 +2198,7 @@ if(pModDoc == nullptr) return; if(pModDoc->GetSampleUndo().Undo(m_nSample)) { - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES, true); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES, true, true); } } @@ -2200,7 +2210,7 @@ if(pModDoc == nullptr) return; if(pModDoc->GetSampleUndo().Redo(m_nSample)) { - SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES, true); + SetModified(HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES, true, true); } } @@ -2236,7 +2246,7 @@ sample.PrecomputeLoops(sndFile, false); cs.Leave(); - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, true); } } EndWaitCursor(); @@ -2255,17 +2265,16 @@ if(!sample.uFlags[CHN_16BIT] && sample.pSample != nullptr && sample.nLength != 0) { ASSERT(sample.GetElementarySampleSize() == 1); - const SmpLength numSamples = sample.nLength * sample.GetNumChannels(); - int16 *newSample = static_cast<int16 *>(ModSample::AllocateSample(numSamples, 2)); + int16 *newSample = static_cast<int16 *>(ModSample::AllocateSample(sample.nLength, 2 * sample.GetNumChannels())); if(newSample != nullptr) { pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_replace, "16-Bit Conversion"); - CopySample<SC::ConversionChain<SC::Convert<int16, int8>, SC::DecodeIdentity<int8> > >(newSample, numSamples, 1, sample.pSample8, sample.GetSampleSizeInBytes(), 1); + CopySample<SC::ConversionChain<SC::Convert<int16, int8>, SC::DecodeIdentity<int8> > >(newSample, sample.nLength * sample.GetNumChannels(), 1, sample.pSample8, sample.GetSampleSizeInBytes(), 1); sample.uFlags.set(CHN_16BIT); ctrlSmp::ReplaceSample(sample, newSample, sample.nLength, sndFile); sample.PrecomputeLoops(sndFile, false); - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, true); } } } @@ -2334,7 +2343,7 @@ right.nPan = 256; } } - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, true); } else { pModDoc->GetSampleUndo().RemoveLastUndoStep(m_nSample); @@ -2388,7 +2397,7 @@ cs.Leave(); SetCurSel(0, 0); - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, true); } EndWaitCursor(); } @@ -2587,7 +2596,7 @@ } if (bUpdate) { - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES, true, false); } CMDIChildWnd *pMDIFrame = (CMDIChildWnd *)GetParentFrame(); if (pMDIFrame) @@ -2654,7 +2663,7 @@ { pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Set Loop Start"); sample.SetLoop(m_dwMenuParam, sample.nLoopEnd, true, sample.uFlags[CHN_PINGPONGLOOP], sndFile); - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, false); } } } @@ -2672,7 +2681,7 @@ { pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Set Loop End"); sample.SetLoop(sample.nLoopStart, m_dwMenuParam, true, sample.uFlags[CHN_PINGPONGLOOP], sndFile); - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, false); } } } @@ -2690,7 +2699,7 @@ { pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Set Sustain Start"); sample.SetSustainLoop(m_dwMenuParam, sample.nSustainEnd, true, sample.uFlags[CHN_PINGPONGSUSTAIN], sndFile); - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, false); } } } @@ -2708,7 +2717,7 @@ { pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Set Sustain End"); sample.SetSustainLoop(sample.nSustainStart, m_dwMenuParam, true, sample.uFlags[CHN_PINGPONGSUSTAIN], sndFile); - SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true); + SetModified(HINT_SAMPLEDATA | HINT_SAMPLEINFO, true, false); } } } @@ -2776,8 +2785,12 @@ if(dlg.m_nEditOption == addsilence_resize) { // resize - dlg.m_nSamples = new size - if(dlg.m_nSamples != sample.nLength) + if(dlg.m_nSamples == 0) { + pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_replace, "Delete Sample"); + sndFile.DestroySampleThreadsafe(m_nSample); + } else if(dlg.m_nSamples != sample.nLength) + { CriticalSection cs; if(dlg.m_nSamples < sample.nLength) // make it... [truncated message content] |
From: <man...@us...> - 2014-10-27 19:32:12
|
Revision: 4512 http://sourceforge.net/p/modplug/code/4512 Author: manxorist Date: 2014-10-27 19:31:59 +0000 (Mon, 27 Oct 2014) Log Message: ----------- [Mod] libopenmpt: For dynamic loading of external libraries, use libltdl from libtool instead of libdl from libc. This allows better portability to non-Linux/BSD systems at the expence of a libtool dependency. [Imp] build: Support libunmo3 in autotools based libopenmpt builds via --enable-unmo3 . Modified Paths: -------------- trunk/OpenMPT/Makefile trunk/OpenMPT/build/autotools/Makefile.am trunk/OpenMPT/build/autotools/autoconfiscate.sh trunk/OpenMPT/build/autotools/configure.ac trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/libopenmpt/dox/changelog.md trunk/OpenMPT/libopenmpt/dox/dependencies.md trunk/OpenMPT/libopenmpt/dox/quickstart.md Modified: trunk/OpenMPT/Makefile =================================================================== --- trunk/OpenMPT/Makefile 2014-10-27 19:20:44 UTC (rev 4511) +++ trunk/OpenMPT/Makefile 2014-10-27 19:31:59 UTC (rev 4512) @@ -277,7 +277,7 @@ ifeq ($(USE_MO3),1) CPPFLAGS_MO3 := -DMPT_WITH_MO3 -LDLIBS_MO3 := -ldl +LDLIBS_MO3 := -lltdl else endif Modified: trunk/OpenMPT/build/autotools/Makefile.am =================================================================== --- trunk/OpenMPT/build/autotools/Makefile.am 2014-10-27 19:20:44 UTC (rev 4511) +++ trunk/OpenMPT/build/autotools/Makefile.am 2014-10-27 19:31:59 UTC (rev 4512) @@ -68,10 +68,10 @@ lib_LTLIBRARIES += libopenmpt.la libopenmpt_la_LDFLAGS = -version-info 0:7:0 nobase_include_HEADERS += libopenmpt/libopenmpt.h libopenmpt/libopenmpt.hpp libopenmpt/libopenmpt_version.h libopenmpt/libopenmpt_config.h libopenmpt/libopenmpt_stream_callbacks_fd.h libopenmpt/libopenmpt_stream_callbacks_file.h -libopenmpt_la_CPPFLAGS = -DLIBOPENMPT_BUILD -I$(srcdir)/build/svn_version -I$(srcdir)/ -I$(srcdir)/common $(ZLIB_CFLAGS) +libopenmpt_la_CPPFLAGS = -DLIBOPENMPT_BUILD -I$(srcdir)/build/svn_version -I$(srcdir)/ -I$(srcdir)/common $(ZLIB_CFLAGS) $(LTDL_CPPFLAGS) libopenmpt_la_CXXFLAGS = $(ZLIB_CFLAGS) libopenmpt_la_CFLAGS = $(ZLIB_CFLAGS) -libopenmpt_la_LIBADD = $(ZLIB_LIBS) +libopenmpt_la_LIBADD = $(ZLIB_LIBS) $(LTDL_LIBS) libopenmpt_la_SOURCES = libopenmpt_la_SOURCES += build/svn_version/svn_version.h libopenmpt_la_SOURCES += common/AudioCriticalSection.cpp @@ -263,10 +263,10 @@ endif check_PROGRAMS += libopenmpttest -libopenmpttest_CPPFLAGS = -DLIBOPENMPT_BUILD -DLIBOPENMPT_BUILD_TEST -I$(srcdir)/build/svn_version -I$(srcdir)/ -I$(srcdir)/common $(ZLIB_CFLAGS) +libopenmpttest_CPPFLAGS = -DLIBOPENMPT_BUILD -DLIBOPENMPT_BUILD_TEST -I$(srcdir)/build/svn_version -I$(srcdir)/ -I$(srcdir)/common $(ZLIB_CFLAGS) $(LTDL_CPPFLAGS) libopenmpttest_CXXFLAGS = $(ZLIB_CFLAGS) libopenmpttest_CFLAGS = $(ZLIB_CFLAGS) -libopenmpttest_LDADD = $(ZLIB_LIBS) +libopenmpttest_LDADD = $(ZLIB_LIBS) $(LTDL_LIBS) libopenmpttest_SOURCES = libopenmpttest_SOURCES += libopenmpt/libopenmpt_test.cpp libopenmpttest_SOURCES += test/test.cpp Modified: trunk/OpenMPT/build/autotools/autoconfiscate.sh =================================================================== --- trunk/OpenMPT/build/autotools/autoconfiscate.sh 2014-10-27 19:20:44 UTC (rev 4511) +++ trunk/OpenMPT/build/autotools/autoconfiscate.sh 2014-10-27 19:31:59 UTC (rev 4512) @@ -93,7 +93,7 @@ cd test-tarball tar xvaf ../libopenmpt*.tar.gz cd libopenmpt* -./configure +./configure --enable-unmo3 make make check cd .. Modified: trunk/OpenMPT/build/autotools/configure.ac =================================================================== --- trunk/OpenMPT/build/autotools/configure.ac 2014-10-27 19:20:44 UTC (rev 4511) +++ trunk/OpenMPT/build/autotools/configure.ac 2014-10-27 19:31:59 UTC (rev 4512) @@ -26,6 +26,48 @@ # Required libopenmpt dependency: zlib PKG_CHECK_MODULES([ZLIB], [zlib], AC_DEFINE([MPT_WITH_ZLIB], [], [with libz])) +# Optional libopenmpt dependency: libltdl +AC_ARG_ENABLE([unmo3], AS_HELP_STRING([--enable-unmo3], [Enable the use of dynamically loaded libunmo3.])) +AS_IF([test "x$enable_unmo3" = "xyes"], + [ + AC_CHECK_HEADER([ltdl.h], + [ + AC_CHECK_LIB([ltdl], [lt_dlinit], + [ + have_ltdl=1 + ], + [ + have_ltdl=0 + ] + ) + ], + [ + have_ltdl=0 + ] + ) + AS_IF([test "x$have_ltdl" = "x0"], + [ + AC_MSG_ERROR([Unable to find libltdl.]) + ] + ) + ], + [ + have_ltdl=0 + ] +) +AS_IF([test "x$have_ltdl" = "x1"], + [ + LTDL_CPPFLAGS=-DMPT_WITH_MO3 + LTDL_LIBS=-lltdl + ], + [ + LTDL_CPPFLAGS= + LTDL_LIBS= + ] +) +AC_SUBST([LTDL_CPPFLAGS]) +AC_SUBST([LTDL_LIBS]) + # Optional openmpt123 dependency: PortAudio, try SDL if PortAudio is unavailable PKG_CHECK_MODULES([PORTAUDIO], [portaudio-2.0], [ Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-10-27 19:20:44 UTC (rev 4511) +++ trunk/OpenMPT/common/misc_util.cpp 2014-10-27 19:31:59 UTC (rev 4512) @@ -18,7 +18,7 @@ #if defined(MPT_WITH_DYNBIND) #if !MPT_OS_WINDOWS -#include <dlfcn.h> +#include <ltdl.h> #endif #endif @@ -912,39 +912,51 @@ private: - void * handle; + bool inited; + lt_dlhandle handle; public: LibraryHandle(const mpt::LibraryPath &path) - : handle(NULL) + : inited(false) + , handle(0) { - handle = dlopen(path.GetFileName().AsNative().c_str(), RTLD_NOW); + if(lt_dlinit() != 0) + { + return; + } + inited = true; + handle = lt_dlopenext(path.GetFileName().AsNative().c_str()); } ~LibraryHandle() { if(IsValid()) { - dlclose(handle); + lt_dlclose(handle); } - handle = NULL; + handle = 0; + if(inited) + { + lt_dlexit(); + inited = false; + } } public: bool IsValid() const { - return handle != NULL; + return handle != 0; } FuncPtr GetProcAddress(const std::string &symbol) const { if(!IsValid()) { - return NULL; + return nullptr; } - return reinterpret_cast<FuncPtr>(dlsym(handle, symbol.c_str())); + return reinterpret_cast<FuncPtr>(lt_dlsym(handle, symbol.c_str())); } }; @@ -979,26 +991,22 @@ mpt::PathString LibraryPath::GetDefaultPrefix() //--------------------------------------------- { -#if MPT_OS_WINDOWS - return MPT_PATHSTRING(""); -#elif MPT_OS_MACOSX_OR_IOS - return MPT_PATHSTRING("lib"); -#else - return MPT_PATHSTRING("lib"); -#endif + #if MPT_OS_WINDOWS + return MPT_PATHSTRING(""); + #else + return MPT_PATHSTRING("lib"); + #endif } mpt::PathString LibraryPath::GetDefaultSuffix() //--------------------------------------------- { -#if MPT_OS_WINDOWS - return MPT_PATHSTRING(".dll"); -#elif MPT_OS_MACOSX_OR_IOS - return MPT_PATHSTRING(".dylib"); -#else - return MPT_PATHSTRING(".so"); -#endif + #if MPT_OS_WINDOWS + return MPT_PATHSTRING(".dll"); + #else + return MPT_PATHSTRING(""); // handled by libltdl + #endif } Modified: trunk/OpenMPT/libopenmpt/dox/changelog.md =================================================================== --- trunk/OpenMPT/libopenmpt/dox/changelog.md 2014-10-27 19:20:44 UTC (rev 4511) +++ trunk/OpenMPT/libopenmpt/dox/changelog.md 2014-10-27 19:31:59 UTC (rev 4512) @@ -10,6 +10,7 @@ * xmp-openmpt / in_openmpt: libopenmpt_settings.dll no longer requires .NET 4 to be installed. * foo_openmpt: Settings are now accessable via foobar2000 advanced settings. + * Autotools based build now supports libunmo3. Specify --enable-unmo3. * [Bug] The -autotools tarballs were not working at all. Modified: trunk/OpenMPT/libopenmpt/dox/dependencies.md =================================================================== --- trunk/OpenMPT/libopenmpt/dox/dependencies.md 2014-10-27 19:20:44 UTC (rev 4511) +++ trunk/OpenMPT/libopenmpt/dox/dependencies.md 2014-10-27 19:31:59 UTC (rev 4512) @@ -20,6 +20,9 @@ * **J2B** support requires an inflate (deflate decompression) implementation: * **zlib** * **miniz** can be used internally if no zlib is available. + * **MO3** support requires: + * closed-source **libunmo3** from un4seen + * **libltdl** from libtool on Unix-like platforms * Building on Unix-like systems requires: * **GNU make** * **pkg-config** Modified: trunk/OpenMPT/libopenmpt/dox/quickstart.md =================================================================== --- trunk/OpenMPT/libopenmpt/dox/quickstart.md 2014-10-27 19:20:44 UTC (rev 4511) +++ trunk/OpenMPT/libopenmpt/dox/quickstart.md 2014-10-27 19:31:59 UTC (rev 4512) @@ -12,6 +12,7 @@ - **zlib** - **doxygen >= 1.8** 3. *Optional*: + - **libltdl** - **portaudio-v19** - **libSDL == 1.2.x** - **libFLAC** @@ -43,6 +44,7 @@ - **pkg-config** 2. *Optional*: - **zlib** + - **libltdl** - **portaudio-v19** - **libSDL == 1.2.x** - **doxygen >= 1.8** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-28 15:04:20
|
Revision: 4513 http://sourceforge.net/p/modplug/code/4513 Author: manxorist Date: 2014-10-28 15:03:57 +0000 (Tue, 28 Oct 2014) Log Message: ----------- [Imp] openmpt123: Support building with C++98/03-TR1 for older GCC and VS2008. [Mod] libopenmpt: Do not rely on a modern help2man if ANCIENT=1 is given to Makefile. Modified Paths: -------------- trunk/OpenMPT/Makefile trunk/OpenMPT/libopenmpt/libopenmpt_config.h trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123_config.hpp Modified: trunk/OpenMPT/Makefile =================================================================== --- trunk/OpenMPT/Makefile 2014-10-27 19:31:59 UTC (rev 4512) +++ trunk/OpenMPT/Makefile 2014-10-28 15:03:57 UTC (rev 4513) @@ -129,11 +129,7 @@ ONLY_TEST=0 ANCIENT=0 SOSUFFIX=.so -ifeq ($(ANCIENT),1) -OPENMPT123=0 -else OPENMPT123=1 -endif # get commandline or defaults @@ -251,9 +247,11 @@ ifeq ($(HOST),unix) +ifeq ($(ANCIENT),1) ifeq ($(shell help2man --version > /dev/null 2>&1 && echo yes ),yes) MPT_WITH_HELP2MAN := 1 endif +endif ifeq ($(shell doxygen --version > /dev/null 2>&1 && echo yes ),yes) MPT_WITH_DOXYGEN := 1 Modified: trunk/OpenMPT/libopenmpt/libopenmpt_config.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_config.h 2014-10-27 19:31:59 UTC (rev 4512) +++ trunk/OpenMPT/libopenmpt/libopenmpt_config.h 2014-10-28 15:03:57 UTC (rev 4513) @@ -111,14 +111,14 @@ #ifdef LIBOPENMPT_ANCIENT_COMPILER #include <stdint.h> namespace std { - typedef int8_t int8_t; - typedef int16_t int16_t; - typedef int32_t int32_t; - typedef int64_t int64_t; - typedef uint8_t uint8_t; - typedef uint16_t uint16_t; - typedef uint32_t uint32_t; - typedef uint64_t uint64_t; +typedef int8_t int8_t; +typedef int16_t int16_t; +typedef int32_t int32_t; +typedef int64_t int64_t; +typedef uint8_t uint8_t; +typedef uint16_t uint16_t; +typedef uint32_t uint32_t; +typedef uint64_t uint64_t; } #endif #endif Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-10-27 19:31:59 UTC (rev 4512) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-10-28 15:03:57 UTC (rev 4513) @@ -52,7 +52,9 @@ #include <vector> #include <cmath> +#if !defined(OPENMPT123_ANCIENT_COMPILER) #include <cstdint> +#endif #include <cstdio> #include <cstdlib> #include <cstring> @@ -169,7 +171,11 @@ : impl(0) { if ( !flags.force_overwrite ) { +#if defined(OPENMPT123_ANCIENT_COMPILER) + std::ifstream testfile( filename.c_str(), std::ios::binary ); +#else std::ifstream testfile( filename, std::ios::binary ); +#endif if ( testfile ) { throw exception( "file already exists" ); } @@ -1348,12 +1354,20 @@ file_stream.str( data ); filesize = data.length(); #elif defined(_MSC_VER) && defined(UNICODE) +#if defined(OPENMPT123_ANCIENT_COMPILER) + file_stream.open( utf8_to_wstring( filename ).c_str(), std::ios::binary ); +#else file_stream.open( utf8_to_wstring( filename ), std::ios::binary ); +#endif file_stream.seekg( 0, std::ios::end ); filesize = file_stream.tellg(); file_stream.seekg( 0, std::ios::beg ); #else +#if defined(OPENMPT123_ANCIENT_COMPILER) + file_stream.open( filename.c_str(), std::ios::binary ); +#else file_stream.open( filename, std::ios::binary ); +#endif file_stream.seekg( 0, std::ios::end ); filesize = file_stream.tellg(); file_stream.seekg( 0, std::ios::beg ); Modified: trunk/OpenMPT/openmpt123/openmpt123_config.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123_config.hpp 2014-10-27 19:31:59 UTC (rev 4512) +++ trunk/OpenMPT/openmpt123/openmpt123_config.hpp 2014-10-28 15:03:57 UTC (rev 4513) @@ -63,4 +63,30 @@ #define OPENMPT123_VERSION_STRING "0.2" +#if defined(_MSC_VER) +#if (_MSC_VER >= 1500) && (_MSC_VER < 1600) +#define OPENMPT123_ANCIENT_COMPILER +#endif +#endif + +#if defined(__GNUC__) && !defined(__clang__) +#if (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__*1 < 40300) +#define OPENMPT123_ANCIENT_COMPILER +#endif +#endif + +#ifdef OPENMPT123_ANCIENT_COMPILER +#include <stdint.h> +namespace std { +typedef int8_t int8_t; +typedef int16_t int16_t; +typedef int32_t int32_t; +typedef int64_t int64_t; +typedef uint8_t uint8_t; +typedef uint16_t uint16_t; +typedef uint32_t uint32_t; +typedef uint64_t uint64_t; +} +#endif + #endif // OPENMPT123_CONFIG_HPP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-29 11:59:52
|
Revision: 4516 http://sourceforge.net/p/modplug/code/4516 Author: manxorist Date: 2014-10-29 11:59:43 +0000 (Wed, 29 Oct 2014) Log Message: ----------- [Ref] Convert the AddToLog interface to mpt::ustring. Keep supporting std::string (for now). Modified Paths: -------------- trunk/OpenMPT/common/Logging.h trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2014-10-28 16:39:30 UTC (rev 4515) +++ trunk/OpenMPT/common/Logging.h 2014-10-29 11:59:43 UTC (rev 4516) @@ -39,8 +39,7 @@ class ILog { public: - virtual void AddToLog(const std::string &text) const { AddToLog(LogInformation, text); } - virtual void AddToLog(LogLevel level, const std::string &text) const = 0; + virtual void AddToLog(LogLevel level, const mpt::ustring &text) const = 0; }; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-10-28 16:39:30 UTC (rev 4515) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-10-29 11:59:43 UTC (rev 4516) @@ -191,8 +191,8 @@ return; } private: - void AddToLog( LogLevel level, const std::string & text ) const { - destination->log( mpt::ToCharset( mpt::CharsetUTF8, LogLevelToString( level ) ) + std::string(": ") + text ); + void AddToLog( LogLevel level, const mpt::ustring & text ) const { + destination->log( mpt::ToCharset( mpt::CharsetUTF8, LogLevelToString( level ) + MPT_USTRING(": ") + text ) ); } }; // class log_forwarder @@ -202,21 +202,21 @@ public: std::vector<std::pair<LogLevel,std::string> > GetMessages() const; private: - void AddToLog( LogLevel level, const std::string & text ) const; + void AddToLog( LogLevel level, const mpt::ustring & text ) const; }; // class loader_log std::vector<std::pair<LogLevel,std::string> > loader_log::GetMessages() const { return m_Messages; } -void loader_log::AddToLog( LogLevel level, const std::string & text ) const { - m_Messages.push_back( std::make_pair( level, text ) ); +void loader_log::AddToLog( LogLevel level, const mpt::ustring & text ) const { + m_Messages.push_back( std::make_pair( level, mpt::ToCharset( mpt::CharsetUTF8, text ) ) ); } void module_impl::PushToCSoundFileLog( const std::string & text ) const { - m_sndFile->AddToLog( LogError, text ); + m_sndFile->AddToLog( LogError, mpt::ToUnicode( mpt::CharsetUTF8, text ) ); } void module_impl::PushToCSoundFileLog( int loglevel, const std::string & text ) const { - m_sndFile->AddToLog( static_cast<LogLevel>( loglevel ), text ); + m_sndFile->AddToLog( static_cast<LogLevel>( loglevel ), mpt::ToUnicode( mpt::CharsetUTF8, text ) ); } static ResamplingMode filterlength_to_resamplingmode(std::int32_t length) { Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-28 16:39:30 UTC (rev 4515) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-29 11:59:43 UTC (rev 4516) @@ -853,8 +853,8 @@ } -void CModDoc::AddToLog(LogLevel level, const std::string &text) const -//------------------------------------------------------------------- +void CModDoc::AddToLog(LogLevel level, const mpt::ustring &text) const +//-------------------------------------------------------------------- { if(m_LogMode == LogModeGather) { @@ -863,24 +863,24 @@ { switch(level) { - case LogError: Reporting::Error(text.c_str()); break; - case LogWarning: Reporting::Warning(text.c_str()); break; - case LogInformation: Reporting::Information(text.c_str()); break; - case LogNotification: Reporting::Notification(text.c_str()); break; - default: Reporting::Information(text.c_str()); break; + case LogError: Reporting::Error(mpt::ToWide(text)); break; + case LogWarning: Reporting::Warning(mpt::ToWide(text)); break; + case LogInformation: Reporting::Information(mpt::ToWide(text)); break; + case LogNotification: Reporting::Notification(mpt::ToWide(text)); break; + default: Reporting::Information(mpt::ToWide(text)); break; } } } -std::string CModDoc::GetLogString() const +mpt::ustring CModDoc::GetLogString() const //--------------------------------------- { - std::string ret; + mpt::ustring ret; for(std::vector<LogEntry>::const_iterator i=m_Log.begin(); i!=m_Log.end(); ++i) { ret += (*i).message; - ret += "\r\n"; + ret += MPT_USTRING("\r\n"); } return ret; } @@ -918,15 +918,15 @@ if(!parent) parent = CMainFrame::GetMainFrame(); if(GetLog().size() > 0) { - std::wstring text = preamble + mpt::ToWide(mpt::CharsetLocale, GetLogString()); + std::wstring text = preamble + GetLogString(); std::wstring actualTitle = (title.length() == 0) ? MAINFRAME_TITLEW : title; switch(GetMaxLogLevel()) { - case LogError: Reporting::Error(text.c_str(), actualTitle.c_str(), parent); break; - case LogWarning: Reporting::Warning(text.c_str(), actualTitle.c_str(), parent); break; - case LogInformation: Reporting::Information(text.c_str(), actualTitle.c_str(), parent); break; - case LogNotification: Reporting::Notification(text.c_str(), actualTitle.c_str(), parent); break; - default: Reporting::Information(text.c_str(), actualTitle.c_str(), parent); break; + case LogError: Reporting::Error(text, actualTitle.c_str(), parent); break; + case LogWarning: Reporting::Warning(text, actualTitle.c_str(), parent); break; + case LogInformation: Reporting::Information(text, actualTitle.c_str(), parent); break; + case LogNotification: Reporting::Notification(text, actualTitle.c_str(), parent); break; + default: Reporting::Information(text, actualTitle.c_str(), parent); break; } return IDOK; } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2014-10-28 16:39:30 UTC (rev 4515) +++ trunk/OpenMPT/mptrack/Moddoc.h 2014-10-29 11:59:43 UTC (rev 4516) @@ -131,9 +131,9 @@ struct LogEntry { LogLevel level; - std::string message; + mpt::ustring message; LogEntry() : level(LogInformation) {} - LogEntry(LogLevel l, const std::string &m) : level(l), message(m) {} + LogEntry(LogLevel l, const mpt::ustring &m) : level(l), message(m) {} }; @@ -211,11 +211,11 @@ SAMPLEINDEX GetNumSamples() const { return m_SndFile.m_nSamples; } // Logging for general progress and error events. - void AddToLog(LogLevel level, const std::string &text) const; - void AddToLog(const std::string &text) const { AddToLog(LogInformation, text); } + void AddToLog(LogLevel level, const mpt::ustring &text) const; + /*MPT_DEPRECATED*/ void AddToLog(const std::string &text) const { AddToLog(LogInformation, mpt::ToUnicode(mpt::CharsetLocale, text)); } const std::vector<LogEntry> & GetLog() const { return m_Log; } - std::string GetLogString() const; + mpt::ustring GetLogString() const; LogLevel GetMaxLogLevel() const; protected: LogMode GetLogMode() const { return m_LogMode; } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-28 16:39:30 UTC (rev 4515) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-29 11:59:43 UTC (rev 4516) @@ -651,8 +651,8 @@ } -void CSoundFile::AddToLog(LogLevel level, const std::string &text) const -//---------------------------------------------------------------------- +void CSoundFile::AddToLog(LogLevel level, const mpt::ustring &text) const +//----------------------------------------------------------------------- { if(m_pCustomLog) { @@ -662,11 +662,7 @@ #ifdef MODPLUG_TRACKER if(GetpModDoc()) GetpModDoc()->AddToLog(level, text); #else - #ifdef MPT_WITH_CHARSET_LOCALE - Log(level, mpt::ToUnicode(mpt::CharsetLocale, text)); - #else - Log(level, mpt::ToUnicode(mpt::CharsetUTF8, text)); - #endif + Log(level, text); #endif } } @@ -1667,7 +1663,7 @@ { if(s_pTuningsSharedLocal->Serialize() != CTuningCollection::SERIALIZATION_SUCCESS) { - AddToLog(LogError, "Static tuning serialisation failed"); + AddToLog(LogError, MPT_USTRING("Static tuning serialisation failed")); return false; } return true; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-10-28 16:39:30 UTC (rev 4515) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-10-29 11:59:43 UTC (rev 4516) @@ -526,8 +526,12 @@ public: // logging and user interaction void SetCustomLog(ILog *pLog) { m_pCustomLog = pLog; } - void AddToLog(LogLevel level, const std::string &text) const; - void AddToLog(const std::string &text) const { AddToLog(LogInformation, text); } + void AddToLog(LogLevel level, const mpt::ustring &text) const; +#if defined(MPT_WITH_CHARSET_LOCALE) + /*MPT_DEPRECATED*/ void AddToLog(const std::string &text) const { AddToLog(LogInformation, mpt::ToUnicode(mpt::CharsetLocale, text)); } +#else + /*MPT_DEPRECATED*/ void AddToLog(const std::string &text) const { AddToLog(LogInformation, mpt::ToUnicode(mpt::CharsetUTF8, text)); } +#endif public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-29 12:50:54
|
Revision: 4517 http://sourceforge.net/p/modplug/code/4517 Author: manxorist Date: 2014-10-29 12:50:29 +0000 (Wed, 29 Oct 2014) Log Message: ----------- [Imp] libopenmpt: Log when a module uses external samples and libopenmpt is compiled without external samples support (currently always). [Imp] MT2 Loader: Log load failure of external samples. [Imp] openmpt123: Better handling of log messages during module loading. Modified Paths: -------------- trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-10-29 11:59:43 UTC (rev 4516) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-10-29 12:50:29 UTC (rev 4517) @@ -1257,6 +1257,7 @@ if ( flags.show_details ) { set_field( fields, "Filename" ).ostream() << get_filename( filename ); set_field( fields, "Size" ).ostream() << bytes_to_string( filesize ); + set_field( fields, "Warnings" ).ostream() << mod.get_metadata( "warnings" ); if ( !mod.get_metadata( "container" ).empty() ) { set_field( fields, "Container" ).ostream() << mod.get_metadata( "container" ) << " (" << mod.get_metadata( "container_long" ) << ")"; } @@ -1326,6 +1327,8 @@ log.writeout(); + std::ostringstream silentlog; + try { #if defined(WIN32) && defined(UNICODE) && !defined(_MSC_VER) @@ -1379,7 +1382,8 @@ } { - openmpt::module mod( data_stream ); + openmpt::module mod( data_stream, silentlog ); + silentlog.str( std::string() ); // clear, loader messages get stored to get_metadata( "warnings" ) by libopenmpt internally render_mod_file( flags, filename, filesize, mod, log, audio_stream ); } @@ -1390,8 +1394,18 @@ } catch ( silent_exit_exception & ) { throw; } catch ( std::exception & e ) { + if ( !silentlog.str().empty() ) { + log << "errors loading '" << filename << "': " << silentlog.str() << std::endl; + } else { + log << "errors loading '" << filename << "'" << std::endl; + } log << "error playing '" << filename << "': " << e.what() << std::endl; } catch ( ... ) { + if ( !silentlog.str().empty() ) { + log << "errors loading '" << filename << "': " << silentlog.str() << std::endl; + } else { + log << "errors loading '" << filename << "'" << std::endl; + } log << "unknown error playing '" << filename << "'" << std::endl; } Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-29 11:59:43 UTC (rev 4516) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-29 12:50:29 UTC (rev 4517) @@ -653,9 +653,9 @@ // External sample in MPTM file size_t strLen; file.ReadVarInt(strLen); -#ifdef MPT_EXTERNAL_SAMPLES std::string filenameU8; file.ReadString<mpt::String::maybeNullTerminated>(filenameU8, strLen); +#ifdef MPT_EXTERNAL_SAMPLES mpt::PathString filename = mpt::PathString::FromUTF8(filenameU8); if(!filename.empty()) @@ -669,14 +669,14 @@ } if(!LoadExternalSample(i + 1, filename)) { - AddToLog("Unable to load sample: " + filename.ToLocale()); + AddToLog(LogError, mpt::String::Print(MPT_USTRING("Unable to load sample %1: %2"), i, filename.ToUnicode())); } } else { sample.uFlags.reset(SMP_KEEPONDISK); } #else - file.Skip(strLen); + AddToLog(LogWarning, mpt::String::Print(MPT_USTRING("Loading external sample %1 ('%2') failed: External samples are not supported."), i, mpt::ToUnicode(mpt::CharsetUTF8, filenameU8))); #endif // MPT_EXTERNAL_SAMPLES } lastSampleOffset = std::max(lastSampleOffset, file.GetPosition()); Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-29 11:59:43 UTC (rev 4516) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-29 12:50:29 UTC (rev 4517) @@ -1080,7 +1080,16 @@ } path = path.RelativePathToAbsolute(mt2FileName.GetPath()); } - LoadExternalSample(i + 1, path); + if(!LoadExternalSample(i + 1, path)) + { + AddToLog(LogError, mpt::String::Print(MPT_USTRING("Unable to load sample %1: %2"), i, path.ToUnicode())); + } +#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))); + #else + AddToLog(LogWarning, mpt::String::Print(MPT_USTRING("Loading external sample %1 ('%2') failed: External samples are not supported."), i, mpt::ToUnicode(mpt::CharsetWindows1252, filename))); + #endif #endif // MPT_EXTERNAL_SAMPLES } mptSmp.nC5Speed = freq; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-30 09:30:37
|
Revision: 4519 http://sourceforge.net/p/modplug/code/4519 Author: manxorist Date: 2014-10-30 09:30:21 +0000 (Thu, 30 Oct 2014) Log Message: ----------- [Mod] in_openmpt: Expect the complete Winamp SDK in folder include/winamp/ instead of just the Winamp/ subfolder of the SDK. Modified Paths: -------------- trunk/OpenMPT/README.md trunk/OpenMPT/libopenmpt/in_openmpt.cpp Modified: trunk/OpenMPT/README.md =================================================================== --- trunk/OpenMPT/README.md 2014-10-29 20:27:35 UTC (rev 4518) +++ trunk/OpenMPT/README.md 2014-10-30 09:30:21 UTC (rev 4519) @@ -77,8 +77,8 @@ - Winamp 5 SDK: - To build libopenmpt as a winamp input plugin, copy the headers in - Winamp/ from `WA5.55_SDK.exe` to include/winamp/. + To build libopenmpt as a winamp input plugin, copy the contents of + `WA5.55_SDK.exe` to include/winamp/. Please visit [winamp.com](http://wiki.winamp.com/wiki/Plug-in_Developer) to Modified: trunk/OpenMPT/libopenmpt/in_openmpt.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/in_openmpt.cpp 2014-10-29 20:27:35 UTC (rev 4518) +++ trunk/OpenMPT/libopenmpt/in_openmpt.cpp 2014-10-30 09:30:21 UTC (rev 4519) @@ -34,8 +34,8 @@ #include <windows.h> #define UNICODE_INPUT_PLUGIN -#include "winamp/IN2.H" -#include "winamp/wa_ipc.h" +#include "winamp/Winamp/IN2.H" +#include "winamp/Winamp/wa_ipc.h" #include <algorithm> #include <fstream> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-31 18:30:03
|
Revision: 4523 http://sourceforge.net/p/modplug/code/4523 Author: manxorist Date: 2014-10-31 18:29:55 +0000 (Fri, 31 Oct 2014) Log Message: ----------- [Ref] Consolidate duplicate code in IAudioReadTarget implementations. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/soundlib/AudioReadTarget.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-30 10:21:50 UTC (rev 4522) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-31 18:29:55 UTC (rev 4523) @@ -687,71 +687,18 @@ //============================== class StereoVuMeterTargetWrapper //============================== - : public IAudioReadTarget + : public AudioReadTargetBufferInterleavedDynamic { -private: - const SampleFormat sampleFormat; - bool clipFloat; - Dither &dither; - void *buffer; public: - StereoVuMeterTargetWrapper(SampleFormat sampleFormat_, bool clipFloat_, Dither &dither_, void *buffer_) - : sampleFormat(sampleFormat_) - , clipFloat(clipFloat_) - , dither(dither_) - , buffer(buffer_) + StereoVuMeterTargetWrapper(SampleFormat sampleFormat, bool clipFloat, Dither &dither, void *buffer) + : AudioReadTargetBufferInterleavedDynamic(sampleFormat, clipFloat, dither, buffer) { - MPT_ASSERT_ALWAYS(sampleFormat.IsValid()); + return; } virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) { CMainFrame::CalcStereoVuMeters(MixSoundBuffer, countChunk, channels); - switch(sampleFormat.value) - { - case SampleFormatUnsigned8: - { - typedef SampleFormatToType<SampleFormatUnsigned8>::type Tsample; - AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); - target.DataCallback(MixSoundBuffer, channels, countChunk); - } - break; - case SampleFormatInt16: - { - typedef SampleFormatToType<SampleFormatInt16>::type Tsample; - AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); - target.DataCallback(MixSoundBuffer, channels, countChunk); - } - break; - case SampleFormatInt24: - { - typedef SampleFormatToType<SampleFormatInt24>::type Tsample; - AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); - target.DataCallback(MixSoundBuffer, channels, countChunk); - } - break; - case SampleFormatInt32: - { - typedef SampleFormatToType<SampleFormatInt32>::type Tsample; - AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); - target.DataCallback(MixSoundBuffer, channels, countChunk); - } - break; - case SampleFormatFloat32: - if(clipFloat) - { - typedef SampleFormatToType<SampleFormatFloat32>::type Tsample; - AudioReadTargetBuffer<Tsample, true> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); - target.DataCallback(MixSoundBuffer, channels, countChunk); - } else - { - typedef SampleFormatToType<SampleFormatFloat32>::type Tsample; - AudioReadTargetBuffer<Tsample, false> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); - target.DataCallback(MixSoundBuffer, channels, countChunk); - } - break; - } - // increment output buffer for potentially next callback - buffer = (char*)buffer + (sampleFormat.GetBitsPerSample()/8) * channels * countChunk; + AudioReadTargetBufferInterleavedDynamic::DataCallback(MixSoundBuffer, channels, countChunk); } }; Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-10-30 10:21:50 UTC (rev 4522) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-10-31 18:29:55 UTC (rev 4523) @@ -36,45 +36,8 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------------- { sndFile.ResetMixStat(); - switch(sampleFormat.value) - { - case SampleFormatUnsigned8: - { - typedef SampleFormatToType<SampleFormatUnsigned8>::type Tsample; - AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); - return sndFile.Read(count, target); - } - break; - case SampleFormatInt16: - { - typedef SampleFormatToType<SampleFormatInt16>::type Tsample; - AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); - return sndFile.Read(count, target); - } - break; - case SampleFormatInt24: - { - typedef SampleFormatToType<SampleFormatInt24>::type Tsample; - AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); - return sndFile.Read(count, target); - } - break; - case SampleFormatInt32: - { - typedef SampleFormatToType<SampleFormatInt32>::type Tsample; - AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); - return sndFile.Read(count, target); - } - break; - case SampleFormatFloat32: - { - typedef SampleFormatToType<SampleFormatFloat32>::type Tsample; - AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); - return sndFile.Read(count, target); - } - break; - } - return 0; + AudioReadTargetBufferInterleavedDynamic target(sampleFormat, false, dither, outputBuffer); + return sndFile.Read(count, target); } Modified: trunk/OpenMPT/soundlib/AudioReadTarget.h =================================================================== --- trunk/OpenMPT/soundlib/AudioReadTarget.h 2014-10-30 10:21:50 UTC (rev 4522) +++ trunk/OpenMPT/soundlib/AudioReadTarget.h 2014-10-31 18:29:55 UTC (rev 4523) @@ -71,6 +71,77 @@ }; +//=========================================== +class AudioReadTargetBufferInterleavedDynamic +//=========================================== + : public IAudioReadTarget +{ +private: + const SampleFormat sampleFormat; + bool clipFloat; + Dither &dither; + void *buffer; +public: + AudioReadTargetBufferInterleavedDynamic(SampleFormat sampleFormat_, bool clipFloat_, Dither &dither_, void *buffer_) + : sampleFormat(sampleFormat_) + , clipFloat(clipFloat_) + , dither(dither_) + , buffer(buffer_) + { + MPT_ASSERT_ALWAYS(sampleFormat.IsValid()); + } + virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) + { + switch(sampleFormat.value) + { + case SampleFormatUnsigned8: + { + typedef SampleFormatToType<SampleFormatUnsigned8>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + case SampleFormatInt16: + { + typedef SampleFormatToType<SampleFormatInt16>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + case SampleFormatInt24: + { + typedef SampleFormatToType<SampleFormatInt24>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + case SampleFormatInt32: + { + typedef SampleFormatToType<SampleFormatInt32>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + case SampleFormatFloat32: + if(clipFloat) + { + typedef SampleFormatToType<SampleFormatFloat32>::type Tsample; + AudioReadTargetBuffer<Tsample, true> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } else + { + typedef SampleFormatToType<SampleFormatFloat32>::type Tsample; + AudioReadTargetBuffer<Tsample, false> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + } + // increment output buffer for potentially next callback + buffer = reinterpret_cast<char*>(buffer) + (sampleFormat.GetBitsPerSample()/8) * channels * countChunk; + } +}; + + #ifndef MODPLUG_TRACKER template<typename Tsample> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-11-02 13:40:07
|
Revision: 4537 http://sourceforge.net/p/modplug/code/4537 Author: saga-games Date: 2014-11-02 13:39:57 +0000 (Sun, 02 Nov 2014) Log Message: ----------- [Ref] Silence warning in mpt::IO::WriteVarInt when writing 64-bit integers and add a test case for it. Modified Paths: -------------- trunk/OpenMPT/common/mptIO.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/mptIO.h =================================================================== --- trunk/OpenMPT/common/mptIO.h 2014-11-02 12:37:47 UTC (rev 4536) +++ trunk/OpenMPT/common/mptIO.h 2014-11-02 13:39:57 UTC (rev 4537) @@ -194,7 +194,7 @@ { byte = 0; if(!IO::ReadIntLE<uint8>(f, byte)) result = false; - v |= (static_cast<uint16>(byte) << (((i+1)*8) - 1)); + v |= (static_cast<uint16>(byte) << (((i+1)*8) - 1)); } return result; } @@ -214,7 +214,7 @@ { byte = 0; if(!IO::ReadIntLE<uint8>(f, byte)) result = false; - v |= (static_cast<uint32>(byte) << (((i+1)*8) - 2)); + v |= (static_cast<uint32>(byte) << (((i+1)*8) - 2)); } return result; } @@ -234,7 +234,7 @@ { byte = 0; if(!IO::ReadIntLE<uint8>(f, byte)) result = false; - v |= (static_cast<uint64>(byte) << (((i+1)*8) - 2)); + v |= (static_cast<uint64>(byte) << (((i+1)*8) - 2)); } return result; } @@ -262,7 +262,7 @@ } str.push_back(c); } - return true; + return true; } @@ -364,11 +364,14 @@ template <typename Tfile, typename T> bool WriteVarInt(Tfile & f, const T v, size_t *bytesWritten = nullptr) { + STATIC_ASSERT(std::numeric_limits<T>::is_integer); + STATIC_ASSERT(!std::numeric_limits<T>::is_signed); + uint8 out[(sizeof(T) * 8 + 6) / 7]; size_t numBytes = 0; for(uint32 n = (sizeof(T) * 8) / 7; n > 0; n--) { - if(v >= (1u << (n * 7u))) + if(v >= (static_cast<T>(1) << (n * 7u))) { out[numBytes++] = static_cast<uint8>(((v >> (n * 7u)) & 0x7F) | 0x80); } @@ -568,7 +571,7 @@ }; -#endif +#endif class FileDataContainerMemory Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-11-02 12:37:47 UTC (rev 4536) +++ trunk/OpenMPT/test/test.cpp 2014-11-02 13:39:57 UTC (rev 4537) @@ -98,7 +98,7 @@ #if MPT_OS_WINDOWS // prefix for test suite - std::wstring pathprefix = std::wstring(); + std::wstring pathprefix = std::wstring(); // set path prefix for test files (if provided) std::vector<WCHAR> buf(GetEnvironmentVariableW(L"srcdir", NULL, 0) + 1); @@ -199,7 +199,7 @@ } #ifdef MODPLUG_TRACKER - //Verify that the version obtained from the executable file is the same as + //Verify that the version obtained from the executable file is the same as //defined in MptVersion. { char szFullPath[MAX_PATH]; @@ -223,18 +223,19 @@ char* szVer = NULL; UINT uVerLength; - if (!(::GetFileVersionInfo((LPTSTR)szFullPath, (DWORD)dwVerHnd, - (DWORD)dwVerInfoSize, (LPVOID)pVersionInfo))) { + if (!(::GetFileVersionInfo((LPTSTR)szFullPath, (DWORD)dwVerHnd, + (DWORD)dwVerInfoSize, (LPVOID)pVersionInfo))) + { delete[] pVersionInfo; throw std::runtime_error("GetFileVersionInfo() returned false"); - } - if (!(::VerQueryValue(pVersionInfo, TEXT("\\StringFileInfo\\040904b0\\FileVersion"), + } + if (!(::VerQueryValue(pVersionInfo, TEXT("\\StringFileInfo\\040904b0\\FileVersion"), (LPVOID*)&szVer, &uVerLength))) { delete[] pVersionInfo; throw std::runtime_error("VerQueryValue() returned false"); } - std::string version = szVer; + std::string version = szVer; delete[] pVersionInfo; //version string should be like: 1,17,2,38 Change ',' to '.' to get format 1.17.2.38 @@ -602,7 +603,7 @@ VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int32>::max()), (uint32)std::numeric_limits<int32>::max() ); VERIFY_EQUAL( mpt::saturate_cast<uint64>(std::numeric_limits<int64>::min()), std::numeric_limits<uint64>::min() ); VERIFY_EQUAL( mpt::saturate_cast<uint64>(std::numeric_limits<int64>::max()), (uint64)std::numeric_limits<int64>::max() ); - + // overflow VERIFY_EQUAL( mpt::saturate_cast<int16>(std::numeric_limits<int16>::min() - 1), std::numeric_limits<int16>::min() ); VERIFY_EQUAL( mpt::saturate_cast<int16>(std::numeric_limits<int16>::max() + 1), std::numeric_limits<int16>::max() ); @@ -629,7 +630,7 @@ //Util::Round<std::string>(1.0); //Util::Round<int64>(1.0); //Util::Round<uint64>(1.0); - + // This should trigger assert in Round. //VERIFY_EQUAL( Util::Round<int8>(-129), 0 ); @@ -639,7 +640,7 @@ VERIFY_EQUAL(strlen(ModSpecs::Collection[i]->commands), (size_t)MAX_EFFECTS); VERIFY_EQUAL(strlen(ModSpecs::Collection[i]->volcommands), (size_t)MAX_VOLCMDS); } - + // UUID #ifdef MODPLUG_TRACKER VERIFY_EQUAL(Util::IsValid(Util::CreateGUID()), true); @@ -658,7 +659,7 @@ static noinline void TestCharsets() //--------------------------------- { - + // MPT_UTF8 version // Charset conversions (basic sanity checks) @@ -682,7 +683,7 @@ VERIFY_EQUAL(mpt::ToLocale(MPT_UTF8("a")), "a"); VERIFY_EQUAL(mpt::ToUnicode(mpt::CharsetLocale, "a"), MPT_UTF8("a")); #endif - + // Check that some character replacement is done (and not just empty strings or truncated strings are returned) // We test german umlaut-a (U+00E4) (\xC3\xA4) and CJK U+5BB6 (\xE5\xAE\xB6) @@ -744,7 +745,7 @@ // cp437 VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetCP437,MPT_UTF8("abc\xC3\xA4xyz")),"abc\x84xyz"); VERIFY_EQUAL(MPT_UTF8("abc\xC3\xA4xyz"),mpt::ToUnicode(mpt::CharsetCP437,"abc\x84xyz")); - + // iso8859 VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetISO8859_1,MPT_UTF8("abc\xC3\xA4xyz")),"abc\xE4xyz"); VERIFY_EQUAL(MPT_UTF8("abc\xC3\xA4xyz"),mpt::ToUnicode(mpt::CharsetISO8859_1,"abc\xE4xyz")); @@ -771,7 +772,7 @@ VERIFY_EQUAL(mpt::ToLocale(L"a"), "a"); VERIFY_EQUAL(mpt::ToWide(mpt::CharsetLocale, "a"), L"a"); #endif - + // Check that some character replacement is done (and not just empty strings or truncated strings are returned) // We test german umlaut-a (U+00E4) and CJK U+5BB6 @@ -833,7 +834,7 @@ // cp437 VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetCP437,L"abc\u00E4xyz"),"abc\x84xyz"); VERIFY_EQUAL(L"abc\u00E4xyz",mpt::ToWide(mpt::CharsetCP437,"abc\x84xyz")); - + // iso8859 VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetISO8859_1,L"abc\u00E4xyz"),"abc\xE4xyz"); VERIFY_EQUAL(L"abc\u00E4xyz",mpt::ToWide(mpt::CharsetISO8859_1,"abc\xE4xyz")); @@ -928,7 +929,7 @@ { DefaultSettingsContainer conf; - + int32 foobar = conf.Read("Test", "bar", 123, "foobar"); VERIFY_EQUAL(foobar, 43); conf.Write("Test", "bar", 88); @@ -983,7 +984,7 @@ //----------------------------------- { uint32 midiEvent; - + midiEvent = MIDIEvents::CC(MIDIEvents::MIDICC_Balance_Coarse, 13, 40); VERIFY_EQUAL_NONCONT(MIDIEvents::GetTypeFromEvent(midiEvent), MIDIEvents::evControllerChange); VERIFY_EQUAL_NONCONT(MIDIEvents::GetChannelFromEvent(midiEvent), 13); @@ -1244,7 +1245,7 @@ VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultRowsPerMeasure, 12); VERIFY_EQUAL_NONCONT(sndFile.m_dwCreatedWithVersion, MAKE_VERSION_NUMERIC(1, 19, 02, 05)); VERIFY_EQUAL_NONCONT(sndFile.m_nRestartPos, 1); - + // Edit history VERIFY_EQUAL_NONCONT(sndFile.GetFileHistory().size() > 0, true); const FileHistory &fh = sndFile.GetFileHistory().at(0); @@ -1325,7 +1326,7 @@ VERIFY_EQUAL_NONCONT(sample.GetSampleSizeInBytes(), 16 * 4); VERIFY_EQUAL_NONCONT(sample.GetSampleRate(MOD_TYPE_MPT), 16000); VERIFY_EQUAL_NONCONT(sample.uFlags, CHN_16BIT | CHN_STEREO | CHN_LOOP); - + // Sample Data (Stereo Interleaved) for(size_t i = 0; i < 7; i++) { @@ -1691,6 +1692,7 @@ return sndFile->GetrSoundFile(); } + static TSoundFileContainer CreateSoundFileContainer(const mpt::PathString &filename) { CModDoc *pModDoc = (CModDoc *)theApp.OpenDocumentFile(filename, FALSE); @@ -1732,12 +1734,12 @@ static mpt::PathString GetTestFilenameBase() { - return Test::GetPathPrefix() + MPT_PATHSTRING("./test/test."); + return Test::GetPathPrefix() + MPT_PATHSTRING("./test/test."); } static mpt::PathString GetTempFilenameBase() { - return MPT_PATHSTRING("./test."); + return MPT_PATHSTRING("./test."); } typedef MPT_SHARED_PTR<CSoundFile> TSoundFileContainer; @@ -1815,9 +1817,9 @@ TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + MPT_PATHSTRING("saved.mptm")); TestLoadMPTMFile(GetrSoundFile(sndFileContainer)); - + DestroySoundFileContainer(sndFileContainer); - + RemoveFile(filenameBase + MPT_PATHSTRING("saved.mptm")); } #endif @@ -1852,7 +1854,7 @@ TestLoadXMFile(GetrSoundFile(sndFileContainer)); DestroySoundFileContainer(sndFileContainer); - + RemoveFile(filenameBase + MPT_PATHSTRING("saved.xm")); } #endif @@ -1860,7 +1862,7 @@ // Test S3M file loading { TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBaseSrc + MPT_PATHSTRING("s3m")); - + TestLoadS3MFile(GetrSoundFile(sndFileContainer), false); #ifndef MODPLUG_NO_FILESAVE @@ -1879,7 +1881,7 @@ TestLoadS3MFile(GetrSoundFile(sndFileContainer), true); DestroySoundFileContainer(sndFileContainer); - + RemoveFile(filenameBase + MPT_PATHSTRING("saved.s3m")); } #endif @@ -1894,15 +1896,17 @@ mpt::IO::WriteVarInt(f, uint16(16383), &bytesWritten); VERIFY_EQUAL_NONCONT(bytesWritten, 2); mpt::IO::WriteVarInt(f, uint16(16384), &bytesWritten); VERIFY_EQUAL_NONCONT(bytesWritten, 3); mpt::IO::WriteVarInt(f, uint16(65535), &bytesWritten); VERIFY_EQUAL_NONCONT(bytesWritten, 3); + mpt::IO::WriteVarInt(f, uint64(0xFFFFFFFFFFFFFFFF), &bytesWritten); VERIFY_EQUAL_NONCONT(bytesWritten, 10); std::string data = f.str(); FileReader file(&data[0], data.size()); - uint16 v; + uint64 v; file.ReadVarInt(v); VERIFY_EQUAL_NONCONT(v, 0); file.ReadVarInt(v); VERIFY_EQUAL_NONCONT(v, 127); file.ReadVarInt(v); VERIFY_EQUAL_NONCONT(v, 128); file.ReadVarInt(v); VERIFY_EQUAL_NONCONT(v, 16383); file.ReadVarInt(v); VERIFY_EQUAL_NONCONT(v, 16384); file.ReadVarInt(v); VERIFY_EQUAL_NONCONT(v, 65535); + file.ReadVarInt(v); VERIFY_EQUAL_NONCONT(v, 0xFFFFFFFFFFFFFFFF); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-11-03 16:48:09
|
Revision: 4541 http://sourceforge.net/p/modplug/code/4541 Author: manxorist Date: 2014-11-03 16:47:58 +0000 (Mon, 03 Nov 2014) Log Message: ----------- [Mod] PortAudio: Build with DirectSound support. Modified Paths: -------------- trunk/OpenMPT/build/gen/portaudio.vcproj trunk/OpenMPT/build/gen/portaudio.vcxproj trunk/OpenMPT/build/gen/portaudio.vcxproj.filters trunk/OpenMPT/build/gen/portmidi.vcxproj.filters trunk/OpenMPT/include/portaudio.premake4.lua Modified: trunk/OpenMPT/build/gen/portaudio.vcproj =================================================================== --- trunk/OpenMPT/build/gen/portaudio.vcproj 2014-11-02 20:40:27 UTC (rev 4540) +++ trunk/OpenMPT/build/gen/portaudio.vcproj 2014-11-03 16:47:58 UTC (rev 4541) @@ -45,7 +45,7 @@ AdditionalOptions="/wd4018 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -61,7 +61,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -124,7 +124,7 @@ AdditionalOptions="/wd4018 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -140,7 +140,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -202,7 +202,7 @@ AdditionalOptions="/wd4018 /wd4267 /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -218,7 +218,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -281,7 +281,7 @@ AdditionalOptions="/wd4018 /wd4267 /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -297,7 +297,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -359,7 +359,7 @@ AdditionalOptions="/wd4018 /wd4267 /GL- /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -375,7 +375,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -438,7 +438,7 @@ AdditionalOptions="/wd4018 /wd4267 /GL- /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -454,7 +454,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -620,6 +620,23 @@ </File> </Filter> <Filter + Name="dsound" + Filter="" + > + <File + RelativePath="..\..\include\portaudio\src\hostapi\dsound\pa_win_ds.c" + > + </File> + <File + RelativePath="..\..\include\portaudio\src\hostapi\dsound\pa_win_ds_dynlink.c" + > + </File> + <File + RelativePath="..\..\include\portaudio\src\hostapi\dsound\pa_win_ds_dynlink.h" + > + </File> + </Filter> + <Filter Name="wasapi" Filter="" > Modified: trunk/OpenMPT/build/gen/portaudio.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/portaudio.vcxproj 2014-11-02 20:40:27 UTC (rev 4540) +++ trunk/OpenMPT/build/gen/portaudio.vcxproj 2014-11-03 16:47:58 UTC (rev 4541) @@ -114,7 +114,7 @@ <AdditionalOptions>/wd4018 /wd4267 %(AdditionalOptions)</AdditionalOptions> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> @@ -125,7 +125,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -142,7 +142,7 @@ <AdditionalOptions>/wd4018 /wd4267 %(AdditionalOptions)</AdditionalOptions> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> @@ -153,7 +153,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -170,7 +170,7 @@ <AdditionalOptions>/wd4018 /wd4267 /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>false</MinimalRebuild> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -182,7 +182,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -201,7 +201,7 @@ <AdditionalOptions>/wd4018 /wd4267 /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>false</MinimalRebuild> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -213,7 +213,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -232,7 +232,7 @@ <AdditionalOptions>/wd4018 /wd4267 /GL- /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>false</MinimalRebuild> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -244,7 +244,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -262,7 +262,7 @@ <AdditionalOptions>/wd4018 /wd4267 /GL- /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>false</MinimalRebuild> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -274,7 +274,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=1;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -302,6 +302,7 @@ <ClInclude Include="..\..\include\portaudio\src\common\pa_trace.h" /> <ClInclude Include="..\..\include\portaudio\src\common\pa_types.h" /> <ClInclude Include="..\..\include\portaudio\src\common\pa_util.h" /> + <ClInclude Include="..\..\include\portaudio\src\hostapi\dsound\pa_win_ds_dynlink.h" /> <ClInclude Include="..\..\include\portaudio\src\os\win\pa_win_coinitialize.h" /> <ClInclude Include="..\..\include\portaudio\src\os\win\pa_win_wdmks_utils.h" /> <ClInclude Include="..\..\include\portaudio\src\os\win\pa_x86_plain_converters.h" /> @@ -339,6 +340,10 @@ </ClCompile> <ClCompile Include="..\..\include\portaudio\src\hostapi\skeleton\pa_hostapi_skeleton.c"> </ClCompile> + <ClCompile Include="..\..\include\portaudio\src\hostapi\dsound\pa_win_ds.c"> + </ClCompile> + <ClCompile Include="..\..\include\portaudio\src\hostapi\dsound\pa_win_ds_dynlink.c"> + </ClCompile> <ClCompile Include="..\..\include\portaudio\src\hostapi\wasapi\pa_win_wasapi.c"> </ClCompile> <ClCompile Include="..\..\include\portaudio\src\hostapi\wdmks\pa_win_wdmks.c"> Modified: trunk/OpenMPT/build/gen/portaudio.vcxproj.filters =================================================================== --- trunk/OpenMPT/build/gen/portaudio.vcxproj.filters 2014-11-02 20:40:27 UTC (rev 4540) +++ trunk/OpenMPT/build/gen/portaudio.vcxproj.filters 2014-11-03 16:47:58 UTC (rev 4541) @@ -2,40 +2,43 @@ <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <Filter Include="include"> - <UniqueIdentifier>{0C38A521-FA8F-D842-A32E-4DD0EBE3C083}</UniqueIdentifier> + <UniqueIdentifier>{6EDF7ABE-3CE7-424F-9327-45FE6ED9D977}</UniqueIdentifier> </Filter> <Filter Include="include\portaudio"> - <UniqueIdentifier>{7A70F49A-78F1-C846-A302-550F294B1675}</UniqueIdentifier> + <UniqueIdentifier>{FC5DED3F-B9E0-AA44-9568-C5EAFE0D0C15}</UniqueIdentifier> </Filter> <Filter Include="include\portaudio\src"> - <UniqueIdentifier>{F19E6F07-F796-0943-9E85-7671424FB4C5}</UniqueIdentifier> + <UniqueIdentifier>{291C0623-52C3-2C4F-BEA4-55D5772B847E}</UniqueIdentifier> </Filter> <Filter Include="include\portaudio\src\common"> - <UniqueIdentifier>{2C635822-E363-AD49-8957-DF3D4FC5DBD5}</UniqueIdentifier> + <UniqueIdentifier>{CEF5B21C-1EDE-B04E-9189-C888FB4600EC}</UniqueIdentifier> </Filter> + <Filter Include="include\portaudio\src\hostapi"> + <UniqueIdentifier>{8B78EB0F-7CFD-9446-9D4C-B2B461F84372}</UniqueIdentifier> + </Filter> + <Filter Include="include\portaudio\src\hostapi\dsound"> + <UniqueIdentifier>{C895A7E7-55DA-3949-93DD-3931A420E487}</UniqueIdentifier> + </Filter> <Filter Include="include\portaudio\src\os"> - <UniqueIdentifier>{78E40326-679E-D14F-AD10-4043417F9BB0}</UniqueIdentifier> + <UniqueIdentifier>{253E9EB0-C6D6-1E4B-8478-E3FFC824C9A4}</UniqueIdentifier> </Filter> <Filter Include="include\portaudio\src\os\win"> - <UniqueIdentifier>{45C92B31-C66A-144A-861A-1A0F99EF1606}</UniqueIdentifier> + <UniqueIdentifier>{71CBAE4A-9E44-C84D-A11C-78D9E79BD961}</UniqueIdentifier> </Filter> <Filter Include="include\portaudio\include"> - <UniqueIdentifier>{86364D78-7177-0549-830C-BCA7EFC9F893}</UniqueIdentifier> + <UniqueIdentifier>{99B86E98-5394-1F44-BBE6-599E8BA69BCC}</UniqueIdentifier> </Filter> - <Filter Include="include\portaudio\src\hostapi"> - <UniqueIdentifier>{F9BD62C2-5924-BC4E-9333-06C57E4EC004}</UniqueIdentifier> - </Filter> <Filter Include="include\portaudio\src\hostapi\skeleton"> - <UniqueIdentifier>{C3975870-61EF-BB47-B32F-3A4F3D028019}</UniqueIdentifier> + <UniqueIdentifier>{CFA019AE-4182-C548-A5D9-1866F9A32C09}</UniqueIdentifier> </Filter> <Filter Include="include\portaudio\src\hostapi\wasapi"> - <UniqueIdentifier>{125165C0-1A1F-5F44-9C97-44CB3FCEFAEF}</UniqueIdentifier> + <UniqueIdentifier>{A81F58B8-9058-7C47-9A8E-7FBC2AEDC132}</UniqueIdentifier> </Filter> <Filter Include="include\portaudio\src\hostapi\wdmks"> - <UniqueIdentifier>{DEDCA2A0-74F2-2543-B8A8-C7CE3BBF9999}</UniqueIdentifier> + <UniqueIdentifier>{CFDC3205-4F06-FA47-86FF-3940442C1385}</UniqueIdentifier> </Filter> <Filter Include="include\portaudio\src\hostapi\wmme"> - <UniqueIdentifier>{B27501B5-9F84-734F-BA18-5EAB8D73F5D1}</UniqueIdentifier> + <UniqueIdentifier>{2B595720-10A2-EB40-85F1-DD19FDAC918A}</UniqueIdentifier> </Filter> </ItemGroup> <ItemGroup> @@ -81,6 +84,9 @@ <ClInclude Include="..\..\include\portaudio\src\common\pa_util.h"> <Filter>include\portaudio\src\common</Filter> </ClInclude> + <ClInclude Include="..\..\include\portaudio\src\hostapi\dsound\pa_win_ds_dynlink.h"> + <Filter>include\portaudio\src\hostapi\dsound</Filter> + </ClInclude> <ClInclude Include="..\..\include\portaudio\src\os\win\pa_win_coinitialize.h"> <Filter>include\portaudio\src\os\win</Filter> </ClInclude> @@ -155,6 +161,12 @@ <ClCompile Include="..\..\include\portaudio\src\hostapi\skeleton\pa_hostapi_skeleton.c"> <Filter>include\portaudio\src\hostapi\skeleton</Filter> </ClCompile> + <ClCompile Include="..\..\include\portaudio\src\hostapi\dsound\pa_win_ds.c"> + <Filter>include\portaudio\src\hostapi\dsound</Filter> + </ClCompile> + <ClCompile Include="..\..\include\portaudio\src\hostapi\dsound\pa_win_ds_dynlink.c"> + <Filter>include\portaudio\src\hostapi\dsound</Filter> + </ClCompile> <ClCompile Include="..\..\include\portaudio\src\hostapi\wasapi\pa_win_wasapi.c"> <Filter>include\portaudio\src\hostapi\wasapi</Filter> </ClCompile> Modified: trunk/OpenMPT/build/gen/portmidi.vcxproj.filters =================================================================== --- trunk/OpenMPT/build/gen/portmidi.vcxproj.filters 2014-11-02 20:40:27 UTC (rev 4540) +++ trunk/OpenMPT/build/gen/portmidi.vcxproj.filters 2014-11-03 16:47:58 UTC (rev 4541) @@ -2,19 +2,19 @@ <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <Filter Include="include"> - <UniqueIdentifier>{C27BC0E9-DCCD-FD4C-8C7C-FB49784B4F55}</UniqueIdentifier> + <UniqueIdentifier>{0D903532-12B6-2045-8607-F91EC26BCFD0}</UniqueIdentifier> </Filter> <Filter Include="include\portmidi"> - <UniqueIdentifier>{6D40500A-6BB2-514A-8B91-F3E4607C4BF3}</UniqueIdentifier> + <UniqueIdentifier>{543DCC1C-EA4C-EB4D-8D0A-E360C2BDF725}</UniqueIdentifier> </Filter> <Filter Include="include\portmidi\porttime"> - <UniqueIdentifier>{EBBED6AB-18CD-3F4C-AF01-827C37F2E525}</UniqueIdentifier> + <UniqueIdentifier>{7045E620-920F-BE40-A815-C28615046FE1}</UniqueIdentifier> </Filter> <Filter Include="include\portmidi\pm_common"> - <UniqueIdentifier>{284EAE59-DFFA-EB43-8DFF-EAEE7582DE17}</UniqueIdentifier> + <UniqueIdentifier>{91D2D715-A0A8-FD4D-A348-54B73DA75F36}</UniqueIdentifier> </Filter> <Filter Include="include\portmidi\pm_win"> - <UniqueIdentifier>{955326E8-4777-C641-8F60-F3B33A7AC339}</UniqueIdentifier> + <UniqueIdentifier>{D399173C-BD41-3F42-BD50-C408005F5548}</UniqueIdentifier> </Filter> </ItemGroup> <ItemGroup> Modified: trunk/OpenMPT/include/portaudio.premake4.lua =================================================================== --- trunk/OpenMPT/include/portaudio.premake4.lua 2014-11-02 20:40:27 UTC (rev 4540) +++ trunk/OpenMPT/include/portaudio.premake4.lua 2014-11-03 16:47:58 UTC (rev 4541) @@ -9,7 +9,7 @@ "PAWIN_USE_WDMKS_DEVICE_INFO", "PA_WDMKS_NO_KSGUID_LIB", "PA_USE_ASIO=0", - "PA_USE_DS=0", + "PA_USE_DS=1", "PA_USE_WMME=1", "PA_USE_WASAPI=1", "PA_USE_WDMKS=1", @@ -40,6 +40,9 @@ "../include/portaudio/src/common/pa_types.h", "../include/portaudio/src/common/pa_util.h", "../include/portaudio/src/hostapi/skeleton/pa_hostapi_skeleton.c", + "../include/portaudio/src/hostapi/dsound/pa_win_ds.c", + "../include/portaudio/src/hostapi/dsound/pa_win_ds_dynlink.c", + "../include/portaudio/src/hostapi/dsound/pa_win_ds_dynlink.h", "../include/portaudio/src/hostapi/wasapi/pa_win_wasapi.c", "../include/portaudio/src/hostapi/wdmks/pa_win_wdmks.c", "../include/portaudio/src/hostapi/wmme/pa_win_wmme.c", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-11-03 18:04:05
|
Revision: 4543 http://sourceforge.net/p/modplug/code/4543 Author: manxorist Date: 2014-11-03 18:03:46 +0000 (Mon, 03 Nov 2014) Log Message: ----------- [Ref] sounddev: Remove superfluous functions from SoundDevice::IBase. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-11-03 17:39:54 UTC (rev 4542) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-11-03 18:03:46 UTC (rev 4543) @@ -767,7 +767,7 @@ return false; } const SoundDevice::Identifier deviceIdentifier = TrackerSettings::Instance().GetSoundDeviceIdentifier(); - if(gpSoundDevice && (gpSoundDevice->GetDeviceIdentifier() != deviceIdentifier)) + if(gpSoundDevice && (gpSoundDevice->GetDeviceInfo().GetIdentifier() != deviceIdentifier)) { gpSoundDevice->Stop(); gpSoundDevice->Close(); Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-11-03 17:39:54 UTC (rev 4542) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-11-03 18:03:46 UTC (rev 4543) @@ -628,7 +628,7 @@ //---------------------------------------------------------------------------------------------------------------------------------------------------------- { bool result = false; - if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceIdentifier() == identifier)) + if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceInfo().GetIdentifier() == identifier)) { result = currentSoundDevice->OpenDriverSettings(); } else @@ -650,7 +650,7 @@ { if(m_DeviceCaps.find(identifier) == m_DeviceCaps.end()) { - if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceIdentifier() == identifier)) + if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceInfo().GetIdentifier() == identifier)) { m_DeviceCaps[identifier] = currentSoundDevice->GetDeviceCaps(); } else @@ -675,7 +675,7 @@ { if((m_DeviceDynamicCaps.find(identifier) == m_DeviceDynamicCaps.end()) || update) { - if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceIdentifier() == identifier)) + if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceInfo().GetIdentifier() == identifier)) { m_DeviceDynamicCaps[identifier] = currentSoundDevice->GetDeviceDynamicCaps(baseSampleRates); if(!currentSoundDevice->IsAvailable()) Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-11-03 17:39:54 UTC (rev 4542) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-11-03 18:03:46 UTC (rev 4543) @@ -474,11 +474,6 @@ virtual SoundDevice::IMessageReceiver *GetMessageReceiver() const = 0; virtual SoundDevice::Info GetDeviceInfo() const = 0; - virtual SoundDevice::ID GetDeviceID() const = 0; - virtual SoundDevice::Type GetDeviceType() const = 0; - virtual SoundDevice::Index GetDeviceIndex() const = 0; - virtual std::wstring GetDeviceInternalID() const = 0; - virtual SoundDevice::Identifier GetDeviceIdentifier() const = 0; virtual SoundDevice::Caps GetDeviceCaps() const = 0; virtual SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates) = 0; @@ -559,6 +554,12 @@ protected: + SoundDevice::ID GetDeviceID() const { return m_Info.id; } + SoundDevice::Type GetDeviceType() const { return m_Info.id.GetType(); } + SoundDevice::Index GetDeviceIndex() const { return m_Info.id.GetIndex(); } + std::wstring GetDeviceInternalID() const { return m_Info.internalID; } + SoundDevice::Identifier GetDeviceIdentifier() const { return m_Info.GetIdentifier(); } + virtual void InternalFillAudioBuffer() = 0; void FillAudioBuffer(); @@ -610,11 +611,6 @@ SoundDevice::IMessageReceiver *GetMessageReceiver() const { return m_MessageReceiver; } SoundDevice::Info GetDeviceInfo() const { return m_Info; } - SoundDevice::ID GetDeviceID() const { return m_Info.id; } - SoundDevice::Type GetDeviceType() const { return m_Info.id.GetType(); } - SoundDevice::Index GetDeviceIndex() const { return m_Info.id.GetIndex(); } - std::wstring GetDeviceInternalID() const { return m_Info.internalID; } - SoundDevice::Identifier GetDeviceIdentifier() const { return m_Info.GetIdentifier(); } SoundDevice::Caps GetDeviceCaps() const { return m_Caps; } virtual SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-11-03 20:14:48
|
Revision: 4546 http://sourceforge.net/p/modplug/code/4546 Author: manxorist Date: 2014-11-03 20:14:36 +0000 (Mon, 03 Nov 2014) Log Message: ----------- [Ref] sounddev: Convert from std::wstring to mpt::ustring. Modified Paths: -------------- trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.h trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -598,17 +598,17 @@ StoredSoundDeviceSettings(SettingsContainer &conf, const SoundDevice::Info & deviceInfo, const SoundDevice::Settings & defaults) : conf(conf) , deviceInfo(deviceInfo) - , LatencyUS(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"Latency", Util::Round<int32>(defaults.Latency * 1000000.0)) - , UpdateIntervalUS(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"UpdateInterval", Util::Round<int32>(defaults.UpdateInterval * 1000000.0)) - , Samplerate(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"SampleRate", defaults.Samplerate) - , Channels(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"Channels", defaults.Channels) - , sampleFormat(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"SampleFormat", defaults.sampleFormat) - , ExclusiveMode(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"ExclusiveMode", defaults.ExclusiveMode) - , BoostThreadPriority(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"BoostThreadPriority", defaults.BoostThreadPriority) - , KeepDeviceRunning(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"KeepDeviceRunning", defaults.KeepDeviceRunning) - , UseHardwareTiming(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"UseHardwareTiming", defaults.UseHardwareTiming) - , DitherType(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"DitherType", defaults.DitherType) - , ChannelMapping(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"ChannelMapping", defaults.ChannelMapping) + , LatencyUS(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"Latency", Util::Round<int32>(defaults.Latency * 1000000.0)) + , UpdateIntervalUS(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"UpdateInterval", Util::Round<int32>(defaults.UpdateInterval * 1000000.0)) + , Samplerate(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"SampleRate", defaults.Samplerate) + , Channels(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"Channels", defaults.Channels) + , sampleFormat(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"SampleFormat", defaults.sampleFormat) + , ExclusiveMode(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"ExclusiveMode", defaults.ExclusiveMode) + , BoostThreadPriority(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"BoostThreadPriority", defaults.BoostThreadPriority) + , KeepDeviceRunning(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"KeepDeviceRunning", defaults.KeepDeviceRunning) + , UseHardwareTiming(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"UseHardwareTiming", defaults.UseHardwareTiming) + , DitherType(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"DitherType", defaults.DitherType) + , ChannelMapping(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"ChannelMapping", defaults.ChannelMapping) { if(ChannelMapping.Get().GetNumHostChannels() != Channels) { @@ -616,10 +616,10 @@ ChannelMapping = SoundDevice::ChannelMapping(Channels); } // store informational data (not read back, just to allow the user to mock with the raw ini file) - conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"ID", deviceInfo.id); - conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"InternalID", deviceInfo.internalID); - conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"API", deviceInfo.apiName); - conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"Name", deviceInfo.name); + conf.Write(L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"ID", deviceInfo.id); + conf.Write(L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"InternalID", deviceInfo.internalID); + conf.Write(L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"API", deviceInfo.apiName); + conf.Write(L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"Name", deviceInfo.name); } StoredSoundDeviceSettings & operator = (const SoundDevice::Settings &settings) Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -33,21 +33,21 @@ namespace SoundDevice { -std::wstring TypeToString(SoundDevice::Type type) +mpt::ustring TypeToString(SoundDevice::Type type) //----------------------------------------------- { switch(type) { - case TypeWAVEOUT: return L"WaveOut"; break; - case TypeDSOUND: return L"DirectSound"; break; - case TypeASIO: return L"ASIO"; break; - case TypePORTAUDIO_WASAPI: return L"WASAPI"; break; - case TypePORTAUDIO_WDMKS: return L"WDM-KS"; break; - case TypePORTAUDIO_WMME: return L"MME"; break; - case TypePORTAUDIO_DS: return L"DS"; break; - case TypePORTAUDIO_ASIO: return L"ASIO"; break; + case TypeWAVEOUT: return MPT_USTRING("WaveOut"); break; + case TypeDSOUND: return MPT_USTRING("DirectSound"); break; + case TypeASIO: return MPT_USTRING("ASIO"); break; + case TypePORTAUDIO_WASAPI: return MPT_USTRING("WASAPI"); break; + case TypePORTAUDIO_WDMKS: return MPT_USTRING("WDM-KS"); break; + case TypePORTAUDIO_WMME: return MPT_USTRING("MME"); break; + case TypePORTAUDIO_DS: return MPT_USTRING("DS"); break; + case TypePORTAUDIO_ASIO: return MPT_USTRING("ASIO"); break; } - return std::wstring(); + return mpt::ustring(); } @@ -551,7 +551,7 @@ { for(int i = 0; i < TypeNUM_DEVTYPES; ++i) { - const std::wstring api = SoundDevice::TypeToString(static_cast<SoundDevice::Type>(i)); + const mpt::ustring api = SoundDevice::TypeToString(static_cast<SoundDevice::Type>(i)); if(identifier.find(api) == 0) { return static_cast<SoundDevice::Type>(i); Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-11-03 20:14:36 UTC (rev 4546) @@ -95,7 +95,7 @@ TypeNUM_DEVTYPES }; -std::wstring TypeToString(SoundDevice::Type type); +mpt::ustring TypeToString(SoundDevice::Type type); typedef uint8 Index; @@ -154,7 +154,7 @@ }; -typedef std::wstring Identifier; +typedef mpt::ustring Identifier; SoundDevice::Type ParseType(const SoundDevice::Identifier &identifier); @@ -162,12 +162,12 @@ struct Info { SoundDevice::ID id; - std::wstring name; - std::wstring apiName; - std::wstring internalID; + mpt::ustring name; + mpt::ustring apiName; + mpt::ustring internalID; bool isDefault; Info() : id(TypeINVALID, 0), isDefault(false) { } - Info(SoundDevice::ID id, const std::wstring &name, const std::wstring &apiName, const std::wstring &internalID = std::wstring()) + Info(SoundDevice::ID id, const mpt::ustring &name, const mpt::ustring &apiName, const mpt::ustring &internalID = mpt::ustring()) : id(id) , name(name) , apiName(apiName) @@ -184,10 +184,10 @@ { if(!IsValid()) { - return std::wstring(); + return mpt::ustring(); } - std::wstring result = apiName; - result += L"_"; + mpt::ustring result = apiName; + result += MPT_USTRING("_"); if(!internalID.empty()) { result += internalID; // safe to not contain special characters @@ -196,11 +196,11 @@ // UTF8-encode the name and convert the utf8 to hex. // This ensures that no special characters are contained in the configuration key. std::string utf8String = mpt::ToCharset(mpt::CharsetUTF8, name); - std::wstring hexString = Util::BinToHex(std::vector<char>(utf8String.begin(), utf8String.end())); + mpt::ustring hexString = mpt::ToUnicode(Util::BinToHex(std::vector<char>(utf8String.begin(), utf8String.end()))); result += hexString; } else { - result += mpt::ToWString(id.GetIndex()); + result += mpt::ufmt::dec(id.GetIndex()); } return result; } @@ -385,7 +385,7 @@ bool CanChannelMapping; bool CanDriverPanel; bool HasInternalDither; - std::wstring ExclusiveModeDescription; + mpt::ustring ExclusiveModeDescription; double LatencyMin; double LatencyMax; double UpdateIntervalMin; @@ -402,7 +402,7 @@ , CanChannelMapping(false) , CanDriverPanel(false) , HasInternalDither(false) - , ExclusiveModeDescription(L"Use device exclusively") + , ExclusiveModeDescription(MPT_USTRING("Use device exclusively")) , LatencyMin(0.002) // 2ms , LatencyMax(0.5) // 500ms , UpdateIntervalMin(0.001) // 1ms @@ -418,7 +418,7 @@ uint32 currentSampleRate; std::vector<uint32> supportedSampleRates; std::vector<uint32> supportedExclusiveSampleRates; - std::vector<std::wstring> channelNames; + std::vector<mpt::ustring> channelNames; DynamicCaps() : currentSampleRate(0) { @@ -557,7 +557,7 @@ SoundDevice::ID GetDeviceID() const { return m_Info.id; } SoundDevice::Type GetDeviceType() const { return m_Info.id.GetType(); } SoundDevice::Index GetDeviceIndex() const { return m_Info.id.GetIndex(); } - std::wstring GetDeviceInternalID() const { return m_Info.internalID; } + mpt::ustring GetDeviceInternalID() const { return m_Info.internalID; } SoundDevice::Identifier GetDeviceIdentifier() const { return m_Info.GetIdentifier(); } virtual void InternalFillAudioBuffer() = 0; Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -139,14 +139,14 @@ WCHAR descriptionBuf[ASIO_MAXDRVNAMELEN]; DWORD datatype = REG_SZ; DWORD datasize = sizeof(descriptionBuf); - std::wstring description; + mpt::ustring description; if(ERROR_SUCCESS == RegQueryValueExW(hksub, L"Description", 0, &datatype, (LPBYTE)descriptionBuf, &datasize)) { Log(mpt::String::Print("ASIO: description='%1'", mpt::ToLocale(description))); - description = descriptionBuf; + description = mpt::ToUnicode(descriptionBuf); } else { - description = keyname; + description = mpt::ToUnicode(keyname); } WCHAR idBuf[256]; @@ -154,8 +154,8 @@ datasize = sizeof(idBuf); if(ERROR_SUCCESS == RegQueryValueExW(hksub, L"CLSID", 0, &datatype, (LPBYTE)idBuf, &datasize)) { - const std::wstring internalID = idBuf; - if(Util::IsCLSID(internalID)) + const mpt::ustring internalID = mpt::ToUnicode(idBuf); + if(Util::IsCLSID(mpt::ToWide(internalID))) { Log(mpt::String::Print("ASIO: clsid=%1", mpt::ToLocale(internalID))); if(SoundDevice::IndexIsValid(devices.size())) @@ -669,7 +669,7 @@ { return; } - CLSID clsid = Util::StringToCLSID(GetDeviceInternalID()); + CLSID clsid = Util::StringToCLSID(mpt::ToWide(GetDeviceInternalID())); try { if(CoCreateInstance(clsid,0,CLSCTX_INPROC_SERVER, clsid, (void **)&m_pAsioDrv) != S_OK) @@ -1434,12 +1434,12 @@ MemsetZero(channelInfo); channelInfo.channel = i; channelInfo.isInput = ASIOFalse; - std::wstring name = mpt::ToWString(i); + mpt::ustring name = mpt::ufmt::dec(i); try { asioCall(getChannelInfo(&channelInfo)); mpt::String::SetNullTerminator(channelInfo.name); - name = mpt::ToWide(mpt::CharsetLocale, channelInfo.name); + name = mpt::ToUnicode(mpt::CharsetLocale, channelInfo.name); } catch(...) { // continue Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -53,11 +53,11 @@ } SoundDevice::Info info; info.id = SoundDevice::ID(TypeDSOUND, static_cast<SoundDevice::Index>(devices.size())); - info.name = lpstrDescription; + info.name = mpt::ToUnicode(lpstrDescription); info.apiName = SoundDevice::TypeToString(TypeDSOUND); if(lpGuid) { - info.internalID = Util::GUIDToString(*lpGuid); + info.internalID = mpt::ToUnicode(Util::GUIDToString(*lpGuid)); } devices.push_back(info); return TRUE; @@ -107,7 +107,7 @@ caps.CanUseHardwareTiming = false; caps.CanChannelMapping = false; caps.CanDriverPanel = false; - caps.ExclusiveModeDescription = L"Use primary buffer"; + caps.ExclusiveModeDescription = MPT_USTRING("Use primary buffer"); caps.DefaultSettings.sampleFormat = SampleFormatInt16; IDirectSound *dummy = nullptr; IDirectSound *ds = nullptr; @@ -116,8 +116,8 @@ ds = m_piDS; } else { - const std::wstring internalID = GetDeviceInternalID(); - GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(internalID); + const mpt::ustring internalID = GetDeviceInternalID(); + GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(mpt::ToWide(internalID)); if(DirectSoundCreate(internalID.empty() ? NULL : &guid, &dummy, NULL) != DS_OK) { return caps; @@ -159,8 +159,8 @@ ds = m_piDS; } else { - const std::wstring internalID = GetDeviceInternalID(); - GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(internalID); + const mpt::ustring internalID = GetDeviceInternalID(); + GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(mpt::ToWide(internalID)); if(DirectSoundCreate(internalID.empty() ? NULL : &guid, &dummy, NULL) != DS_OK) { return caps; @@ -214,8 +214,8 @@ DSBCAPS dsc; if(m_piDS) return true; - const std::wstring internalID = GetDeviceInternalID(); - GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(internalID); + const mpt::ustring internalID = GetDeviceInternalID(); + GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(mpt::ToWide(internalID)); if(DirectSoundCreate(internalID.empty() ? NULL : &guid, &m_piDS, NULL) != DS_OK) return false; if(!m_piDS) return false; if(m_piDS->SetCooperativeLevel(m_Settings.hWnd, m_Settings.ExclusiveMode ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY) != DS_OK) Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -426,13 +426,13 @@ } -std::wstring CPortaudioDevice::HostApiToString(PaHostApiIndex hostapi) +mpt::ustring CPortaudioDevice::HostApiToString(PaHostApiIndex hostapi) //-------------------------------------------------------------------- { SoundDevice::Type type = HostApiToSndDevType(hostapi); if(type == TypeINVALID) { - return L"PortAudio"; + return MPT_USTRING("PortAudio"); } return SoundDevice::TypeToString(type); } @@ -448,7 +448,7 @@ if(!Pa_GetDeviceInfo(dev)) return false; result.id = SoundDevice::ID(HostApiToSndDevType(hostapi), index); - result.name = mpt::ToWide(mpt::CharsetUTF8, Pa_GetDeviceInfo(dev)->name); + result.name = mpt::ToUnicode(mpt::CharsetUTF8, Pa_GetDeviceInfo(dev)->name); result.apiName = HostApiToString(Pa_GetDeviceInfo(dev)->hostApi); result.isDefault = (Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->defaultOutputDevice == (PaDeviceIndex)dev); PALOG(mpt::String::Print("PortAudio: %1, %2, %3, %4", result.id.GetIdRaw(), mpt::ToLocale(result.name), mpt::ToLocale(result.apiName), result.isDefault)); Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2014-11-03 20:14:36 UTC (rev 4546) @@ -77,7 +77,7 @@ void *userData ); - static std::wstring HostApiToString(PaHostApiIndex hostapi); + static mpt::ustring HostApiToString(PaHostApiIndex hostapi); static PaDeviceIndex HostApiOutputIndexToGlobalDeviceIndex(int hostapioutputdeviceindex, PaHostApiIndex hostapi); static SoundDevice::Type HostApiToSndDevType(PaHostApiIndex hostapi); Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -75,7 +75,7 @@ caps.CanChannelMapping = false; caps.CanDriverPanel = false; caps.HasInternalDither = false; - caps.ExclusiveModeDescription = L"Use direct mode"; + caps.ExclusiveModeDescription = MPT_USTRING("Use direct mode"); if(mpt::Windows::Version::IsWine()) { caps.DefaultSettings.sampleFormat = SampleFormatInt16; @@ -327,17 +327,17 @@ { if(waveOutGetDevCapsW(WAVE_MAPPER, &woc, sizeof(woc)) == MMSYSERR_NOERROR) { - info.name = woc.szPname; + info.name = mpt::ToUnicode(woc.szPname); } else { - info.name = L"Auto (Wave Mapper)"; + info.name = MPT_USTRING("Auto (Wave Mapper)"); } info.isDefault = true; } else { if(waveOutGetDevCapsW(index-1, &woc, sizeof(woc)) == MMSYSERR_NOERROR) { - info.name = woc.szPname; + info.name = mpt::ToUnicode(woc.szPname); } } devices.push_back(info); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-11-04 18:49:54
|
Revision: 4548 http://sourceforge.net/p/modplug/code/4548 Author: saga-games Date: 2014-11-04 18:49:38 +0000 (Tue, 04 Nov 2014) Log Message: ----------- [Fix] Sample tab: The sample transpose range has always been too small to cover the whole XM transpose range. Extend it to the full range and invert it the transpose behaviour (can now be understood as "C-5 is being played like note x". [Mod] OpenMPT: Version is now 1.24.00.15 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-11-04 18:46:56 UTC (rev 4547) +++ trunk/OpenMPT/common/versionNumber.h 2014-11-04 18:49:38 UTC (rev 4548) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 14 +#define VER_MINORMINOR 15 //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/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-11-04 18:46:56 UTC (rev 4547) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-11-04 18:49:38 UTC (rev 4548) @@ -66,8 +66,8 @@ } -#define BASENOTE_MIN (1*12) // C-1 -#define BASENOTE_MAX (9*12) // C-9 +#define BASENOTE_MIN (1*12) // C-1 +#define BASENOTE_MAX (10*12+11) // B-10 BEGIN_MESSAGE_MAP(CCtrlSamples, CModControlDlg) //{{AFX_MSG_MAP(CCtrlSamples) @@ -240,11 +240,11 @@ m_SpinVolume.SetRange(0, 64); m_SpinGlobalVol.SetRange(0, 64); - for (UINT i = BASENOTE_MIN; i < BASENOTE_MAX; i++) + for (int i = BASENOTE_MIN; i <= BASENOTE_MAX; i++) { - CHAR s[32]; + CHAR s[16]; wsprintf(s, "%s%u", szNoteNames[i%12], i/12); - m_CbnBaseNote.AddString(s); + m_CbnBaseNote.SetItemData(m_CbnBaseNote.AddString(s), i - (NOTE_MIDDLEC - NOTE_MIN)); } @@ -270,7 +270,8 @@ if(combo) { // Allow pitch from -12 (1 octave down) to +12 (1 octave up) - for(int i = -12 ; i <= 12 ; i++){ + for(int i = -12 ; i <= 12 ; i++) + { if(i == 0) wsprintf(str,"none"); else wsprintf(str,i < 0 ? " %d" : "+%d",i); combo->SetItemData(combo->AddString(str), i+12); @@ -706,8 +707,8 @@ SetDlgItemInt(IDC_EDIT5, ftune); transp = (int)sample.RelativeTone; } - int basenote = 60 - transp; - Limit(basenote, BASENOTE_MIN, BASENOTE_MAX - 1); + int basenote = (NOTE_MIDDLEC - NOTE_MIN) + transp; + Limit(basenote, BASENOTE_MIN, BASENOTE_MAX); basenote -= BASENOTE_MIN; if (basenote != m_CbnBaseNote.GetCurSel()) m_CbnBaseNote.SetCurSel(basenote); @@ -2457,9 +2458,8 @@ { m_sndFile.GetSample(m_nSample).nC5Speed = n; int transp = ModSample::FrequencyToTranspose(n) >> 7; - int basenote = 60 - transp; - if (basenote < BASENOTE_MIN) basenote = BASENOTE_MIN; - if (basenote >= BASENOTE_MAX) basenote = BASENOTE_MAX-1; + int basenote = (NOTE_MIDDLEC - NOTE_MIN) + transp; + Clamp(basenote, BASENOTE_MIN, BASENOTE_MAX); basenote -= BASENOTE_MIN; if (basenote != m_CbnBaseNote.GetCurSel()) { @@ -2487,7 +2487,7 @@ //------------------------------------- { if (IsLocked()) return; - int n = (NOTE_MIDDLEC - NOTE_MIN) - (m_CbnBaseNote.GetCurSel() + BASENOTE_MIN); + int n = static_cast<int>(m_CbnBaseNote.GetItemData(m_CbnBaseNote.GetCurSel())); ModSample &sample = m_sndFile.GetSample(m_nSample); m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Transpose"); @@ -2933,9 +2933,8 @@ d += (pos * TrackerSettings::Instance().m_nFinetuneStep); sample.nC5Speed = Clamp(d, 1u, 9999999u); // 9999999 is max. in Impulse Tracker int transp = ModSample::FrequencyToTranspose(sample.nC5Speed) >> 7; - int basenote = 60 - transp; - if (basenote < BASENOTE_MIN) basenote = BASENOTE_MIN; - if (basenote >= BASENOTE_MAX) basenote = BASENOTE_MAX-1; + int basenote = (NOTE_MIDDLEC - NOTE_MIN) + transp; + Clamp(basenote, BASENOTE_MIN, BASENOTE_MAX); basenote -= BASENOTE_MIN; if (basenote != m_CbnBaseNote.GetCurSel()) m_CbnBaseNote.SetCurSel(basenote); wsprintf(s, "%lu", sample.nC5Speed); @@ -3019,7 +3018,7 @@ { if(m_CbnBaseNote.IsWindowEnabled()) { - int sel = Clamp(m_CbnBaseNote.GetCurSel() - transpose, 0, m_CbnBaseNote.GetCount() - 1); + int sel = Clamp(m_CbnBaseNote.GetCurSel() + transpose, 0, m_CbnBaseNote.GetCount() - 1); if(sel != m_CbnBaseNote.GetCurSel()) { m_CbnBaseNote.SetCurSel(sel); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-11-05 10:56:08
|
Revision: 4551 http://sourceforge.net/p/modplug/code/4551 Author: manxorist Date: 2014-11-05 10:55:56 +0000 (Wed, 05 Nov 2014) Log Message: ----------- [Imp] build: Reduce 'make CONFIG=generic' dependency on GCC-specific command line options. Modified Paths: -------------- trunk/OpenMPT/Makefile trunk/OpenMPT/build/make/Makefile.config.clang trunk/OpenMPT/build/make/Makefile.config.generic Modified: trunk/OpenMPT/Makefile =================================================================== --- trunk/OpenMPT/Makefile 2014-11-05 00:07:46 UTC (rev 4550) +++ trunk/OpenMPT/Makefile 2014-11-05 10:55:56 UTC (rev 4551) @@ -220,6 +220,30 @@ INSTALL_MAKE_DIR += -m 0755 CPPFLAGS += -Icommon -I. -Iinclude/modplug/include -Iinclude + +ifeq ($(MPT_COMPILER_GENERIC),1) + +CXXFLAGS += +CFLAGS += +LDFLAGS += +LDLIBS += +ARFLAGS += + +ifeq ($(DEBUG),1) +CXXFLAGS += -g +CFLAGS += -g +else +ifeq ($(OPTIMIZE),1) +CXXFLAGS += -O +CFLAGS += -O +endif +endif + +CXXFLAGS += -W +CFLAGS += -W + +else + CXXFLAGS += -fvisibility=hidden CFLAGS += -fvisibility=hidden LDFLAGS += @@ -239,6 +263,8 @@ CXXFLAGS += -Wall -Wextra -Wcast-align $(CXXFLAGS_WARNINGS) CFLAGS += -Wall -Wextra -Wcast-align $(CFLAGS_WARNINGS) +endif + ifeq ($(DYNLINK),1) LDFLAGS_RPATH += -Wl,-rpath,./bin LDFLAGS_LIBOPENMPT += -Lbin Modified: trunk/OpenMPT/build/make/Makefile.config.clang =================================================================== --- trunk/OpenMPT/build/make/Makefile.config.clang 2014-11-05 00:07:46 UTC (rev 4550) +++ trunk/OpenMPT/build/make/Makefile.config.clang 2014-11-05 10:55:56 UTC (rev 4551) @@ -4,7 +4,6 @@ LD = clang++ AR = ar -#CPPFLAGS += -DMPT_COMPILER_GENERIC CPPFLAGS += CXXFLAGS += -std=c++0x -fPIC CFLAGS += -std=c99 -fPIC Modified: trunk/OpenMPT/build/make/Makefile.config.generic =================================================================== --- trunk/OpenMPT/build/make/Makefile.config.generic 2014-11-05 00:07:46 UTC (rev 4550) +++ trunk/OpenMPT/build/make/Makefile.config.generic 2014-11-05 10:55:56 UTC (rev 4551) @@ -5,11 +5,15 @@ AR = ar #CPPFLAGS += -DMPT_COMPILER_GENERIC -CXXFLAGS += -std=c++11 -fPIC -CFLAGS += -std=c99 -fPIC +CXXFLAGS += -std=c++11 +CFLAGS += -std=c99 LDFLAGS += -LDLIBS += -lm +LDLIBS += ARFLAGS := rcs +MPT_COMPILER_GENERIC=1 +SHARED_LIB=0 +DYNLINK=0 + EXESUFFIX= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-11-06 20:49:11
|
Revision: 4555 http://sourceforge.net/p/modplug/code/4555 Author: saga-games Date: 2014-11-06 20:48:55 +0000 (Thu, 06 Nov 2014) Log Message: ----------- [Mod] Re-implemented stereo separation to be applied on the mix buffer. This has the following advantages: - It works with stereo samples - It also affects plugins The only drawback is that the setting is now limited to a 0...100% range, i.e. stereo widening is no longer possible. [Mod] Improve stereo separation slider granularity (http://bugs.openmpt.org/view.php?id=604) [Ref] Introduce mul32to64 and mul32to64_unsigned (used by stereo separation and muldiv code so far) to efficiently compute 32bit * 32bit to 64bit multiplication with MSVC, as the compiler often fails to replace such multipications with the x86 imul instructions and instead calls the way less efficient _allmul function. [Mod] OpenMPT: Version is now 1.24.00.16 Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/soundlib/MixerSettings.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2014-11-06 20:35:47 UTC (rev 4554) +++ trunk/OpenMPT/common/misc_util.h 2014-11-06 20:48:55 UTC (rev 4555) @@ -422,24 +422,44 @@ namespace Util { + // Multiply two 32-bit integers, receive 64-bit result. + // MSVC generates unnecessarily complicated code for the unoptimized variant using _allmul. + inline int64 mul32to64(int32 a, int32 b) + { +#if MPT_COMPILER_MSVC + return __emul(a, b); +#else + return static_cast<int64>(a) * b; +#endif + } + + inline uint64 mul32to64_unsigned(uint32 a, uint32 b) + { +#if MPT_COMPILER_MSVC + return __emulu(a, b); +#else + return static_cast<uint64>(a) * b; +#endif + } + inline int32 muldiv(int32 a, int32 b, int32 c) { - return static_cast<int32>( ( static_cast<int64>(a) * b ) / c ); + return static_cast<int32>( mul32to64( a, b ) / c ); } inline int32 muldivr(int32 a, int32 b, int32 c) { - return static_cast<int32>( ( static_cast<int64>(a) * b + ( c / 2 ) ) / c ); + return static_cast<int32>( ( mul32to64( a, b ) + ( c / 2 ) ) / c ); } // Do not use overloading because catching unsigned version by accident results in slower X86 code. inline uint32 muldiv_unsigned(uint32 a, uint32 b, uint32 c) { - return static_cast<uint32>( ( static_cast<uint64>(a) * b ) / c ); + return static_cast<uint32>( mul32to64_unsigned( a, b ) / c ); } inline uint32 muldivr_unsigned(uint32 a, uint32 b, uint32 c) { - return static_cast<uint32>( ( static_cast<uint64>(a) * b + ( c / 2 ) ) / c ); + return static_cast<uint32>( ( mul32to64_unsigned( a, b ) + ( c / 2 ) ) / c ); } inline int32 muldivrfloor(int64 a, uint32 b, uint32 c) @@ -449,6 +469,7 @@ return (a >= 0) ? mpt::saturate_cast<int32>(a / c) : mpt::saturate_cast<int32>((a - (c - 1)) / c); } + // 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 2014-11-06 20:35:47 UTC (rev 4554) +++ trunk/OpenMPT/common/versionNumber.h 2014-11-06 20:48:55 UTC (rev 4555) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 15 +#define VER_MINORMINOR 16 //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/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-11-06 20:35:47 UTC (rev 4554) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-11-06 20:48:55 UTC (rev 4555) @@ -1010,11 +1010,11 @@ // Stereo Separation { - m_SliderStereoSep.SetRange(0, 4); - m_SliderStereoSep.SetPos(2); - for (int n=0; n<=4; n++) + m_SliderStereoSep.SetRange(0, 16); + m_SliderStereoSep.SetPos(16); + for (int n = 0; n <= 16; n++) { - if ((int)TrackerSettings::Instance().MixerStereoSeparation <= (int)(32 << n)) + if ((int)TrackerSettings::Instance().MixerStereoSeparation <= 8 * n) { m_SliderStereoSep.SetPos(n); break; @@ -1126,10 +1126,11 @@ { MPT_UNREFERENCED_PARAMETER(n); MPT_UNREFERENCED_PARAMETER(pos); - MPT_UNREFERENCED_PARAMETER(p); // stereo sep + if(p == (CScrollBar *)&m_SliderStereoSep) { UpdateStereoSep(); + OnSettingsChanged(); } } @@ -1154,7 +1155,7 @@ //----------------------------------- { CString s; - s.Format("%d%%", ((32 << m_SliderStereoSep.GetPos()) * 100) / 128); + s.Format(_T("%d%%"), ((8 * m_SliderStereoSep.GetPos()) * 100) / 128); SetDlgItemText(IDC_TEXT_STEREOSEP, s); } @@ -1218,7 +1219,7 @@ // stereo sep { - TrackerSettings::Instance().MixerStereoSeparation = 32 << m_SliderStereoSep.GetPos(); + TrackerSettings::Instance().MixerStereoSeparation = 8 * m_SliderStereoSep.GetPos(); } // soft pan Modified: trunk/OpenMPT/soundlib/MixerSettings.h =================================================================== --- trunk/OpenMPT/soundlib/MixerSettings.h 2014-11-06 20:35:47 UTC (rev 4554) +++ trunk/OpenMPT/soundlib/MixerSettings.h 2014-11-06 20:48:55 UTC (rev 4555) @@ -16,7 +16,7 @@ struct MixerSettings { - UINT m_nStereoSeparation; + int32 m_nStereoSeparation; UINT m_nMaxMixChannels; DWORD DSPMask; DWORD MixerFlags; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-06 20:35:47 UTC (rev 4554) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-06 20:48:55 UTC (rev 4555) @@ -127,6 +127,34 @@ } +// Apply stereo separation factor on an interleaved stereo/quad stream. +// count = Number of stereo sample pairs to process +// separation = 0...128 +static void ApplyStereoSeparation(mixsample_t *mixBuf, CSoundFile::samplecount_t count, int32 separation) +//------------------------------------------------------------------------------------------------------- +{ +#ifdef MPT_INTMIXER + const mixsample_t fac1 = 64 + separation / 2, fac2 = 64 - separation / 2; + for(CSoundFile::samplecount_t i = 0; i < count; i++) + { + mixsample_t l = mixBuf[0], r = mixBuf[1]; + mixBuf[0] = static_cast<mixsample_t>((Util::mul32to64(l, fac1) + Util::mul32to64(r, fac2)) >> 7); + mixBuf[1] = static_cast<mixsample_t>((Util::mul32to64(l, fac2) + Util::mul32to64(r, fac1)) >> 7); + mixBuf += 2; + } +#else + const mixsample_t fac1 = static_cast<mixsample_t>(64 + separation / 2), fac2 = static_cast<mixsample_t>(64 - separation / 2); + for(CSoundFile::samplecount_t i = 0; i < count; i++) + { + mixsample_t l = mixBuf[0], r = mixBuf[1]; + mixBuf[0] = (l * fac1 + r * fac2) / mixsample_t(128); + mixBuf[1] = (l * fac2 + r * fac1) / mixsample_t(128); + mixBuf += 2; + } +#endif +} + + CSoundFile::samplecount_t CSoundFile::Read(samplecount_t count, IAudioReadTarget &target) //--------------------------------------------------------------------------------------- { @@ -236,6 +264,12 @@ InterleaveFrontRear(MixSoundBuffer, MixRearBuffer, countChunk); } + if(m_MixerSettings.m_nStereoSeparation < 128 && m_MixerSettings.gnChannels >= 2) + { + // Apply stereo separation + ApplyStereoSeparation(MixSoundBuffer, count * m_MixerSettings.gnChannels / 2, m_MixerSettings.m_nStereoSeparation); + } + target.DataCallback(MixSoundBuffer, m_MixerSettings.gnChannels, countChunk); // Buffer ready @@ -1984,10 +2018,7 @@ // Adjusting volumes if (m_MixerSettings.gnChannels >= 2) { - int pan = ((int)pChn->nRealPan) - 128; - pan *= (int)m_MixerSettings.m_nStereoSeparation; - pan /= 128; - pan += 128; + int32 pan = pChn->nRealPan; Limit(pan, 0, 256); LONG realvol; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-11-08 17:21:09
|
Revision: 4560 http://sourceforge.net/p/modplug/code/4560 Author: manxorist Date: 2014-11-08 17:21:00 +0000 (Sat, 08 Nov 2014) Log Message: ----------- [Ref] Add AnyString (and related) types. The AnyString types are meant to be used as function argument types only, and only during the transition phase to all-unicode strings in the whole codebase. Using an AnyString type as a function argument avoids the need to overload the function for all the different string types that we currently have (in particular, when taking multiple strings, this avoids the need to overload all possible permutations). [Ref] Add mpt::IsUTF8 heuristic function. [Ref] Convert logging to AnyString. [Ref] Convert class Reporting to AnyString. [Fix] mpt::ToUnicode(std::wstring) should depend on MPT_WSTRING_CONVERT. [Ref] Provide const wchar_t * overloads for string conversion functions even in non-MFC builds, because we handle nullptr there which would otherwise just crash in the std::wstring constructor. Modified Paths: -------------- trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/common/Logging.h trunk/OpenMPT/common/mptPathString.cpp trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/mptString.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Reporting.cpp trunk/OpenMPT/mptrack/Reporting.h Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2014-11-08 00:26:16 UTC (rev 4559) +++ trunk/OpenMPT/common/Logging.cpp 2014-11-08 17:21:00 UTC (rev 4560) @@ -163,8 +163,8 @@ DoLog(context, LogLevelToString(level) + MPT_USTRING(": ") + text); } -void Logger::operator () (const mpt::ustring &text) -//------------------------------------------------- +void Logger::operator () (const AnyStringLocale &text) +//---------------------------------------------------- { DoLog(context, text); } @@ -178,25 +178,7 @@ va_end(va); } -void Logger::operator () (const std::string &text) -//------------------------------------------------ -{ -#if defined(MPT_WITH_CHARSET_LOCALE) - DoLog(context, mpt::ToUnicode(mpt::CharsetLocale, text)); -#else - DoLog(context, mpt::ToUnicode(mpt::CharsetUTF8, text)); -#endif -} -#if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) -void Logger::operator () (const std::wstring &text) -//------------------------------------------------- -{ - DoLog(context, mpt::ToUnicode(text)); -} -#endif - - #endif // !NO_LOGGING Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2014-11-08 00:26:16 UTC (rev 4559) +++ trunk/OpenMPT/common/Logging.h 2014-11-08 17:21:00 UTC (rev 4560) @@ -84,11 +84,7 @@ Logger(const Context &context) : context(context) {} void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...); void operator () (LogLevel level, const mpt::ustring &text); - void operator () (const mpt::ustring &text); - void operator () (const std::string &text); -#if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) - void operator () (const std::wstring &text); -#endif + void operator () (const AnyStringLocale &text); }; #define Log mpt::log::Logger(MPT_LOG_CURRENTCONTEXT()) @@ -100,11 +96,7 @@ public: inline void MPT_PRINTF_FUNC(2,3) operator () (const char * /*format*/, ...) {} inline void operator () (LogLevel /*level*/ , const mpt::ustring & /*text*/ ) {} - inline void operator () (const mpt::ustring & /*text*/ ) {} - inline void operator () (const std::string & /*text*/ ) {} -#if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) - inline void operator () (const std::wstring & /*text*/ ) {} -#endif + inline void operator () (const AnyStringLocale & /*text*/ ) {} }; #define Log if(true) {} else mpt::log::Logger() // completely compile out arguments to Log() so that they do not even get evaluated Modified: trunk/OpenMPT/common/mptPathString.cpp =================================================================== --- trunk/OpenMPT/common/mptPathString.cpp 2014-11-08 00:26:16 UTC (rev 4559) +++ trunk/OpenMPT/common/mptPathString.cpp 2014-11-08 17:21:00 UTC (rev 4560) @@ -174,7 +174,7 @@ // that filenames we get from MFC are always encoded in our hacked UTF8-in-CString encoding. // Instead, we use a rough heuristic: if the string is parseable as UTF8, we assume it is. // This fails for CP_ACP strings, that are also valid UTF8. That's the trade-off here. - if(mpt::ToCharset(mpt::CharsetUTF8, mpt::ToWide(mpt::CharsetUTF8, path.GetString())) == path.GetString()) + if(mpt::IsUTF8(path.GetString())) { // utf8 return mpt::PathString::FromUTF8(path.GetString()); Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2014-11-08 00:26:16 UTC (rev 4559) +++ trunk/OpenMPT/common/mptString.cpp 2014-11-08 17:21:00 UTC (rev 4560) @@ -1010,6 +1010,13 @@ } // namespace String +bool IsUTF8(const std::string &str) +//--------------------------------- +{ + return (str == String::EncodeImpl<std::string>(mpt::CharsetUTF8, String::DecodeImpl<std::string>(mpt::CharsetUTF8, str))); +} + + #if MPT_WSTRING_CONVERT std::wstring ToWide(Charset from, const std::string &str) { @@ -1103,10 +1110,12 @@ #if MPT_USTRING_MODE_WIDE // inline #else // !MPT_USTRING_MODE_WIDE +#if MPT_WSTRING_CONVERT mpt::ustring ToUnicode(const std::wstring &str) { return String::EncodeImpl<mpt::ustring>(mpt::CharsetUTF8, str); } +#endif mpt::ustring ToUnicode(Charset from, const std::string &str) { return String::ConvertImpl<mpt::ustring>(mpt::CharsetUTF8, from, str); Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2014-11-08 00:26:16 UTC (rev 4559) +++ trunk/OpenMPT/common/mptString.h 2014-11-08 17:21:00 UTC (rev 4560) @@ -150,6 +150,16 @@ }; +// Checks if the std::string represents an UTF8 string. +// This is currently implemented as converting to std::wstring and back assuming UTF8 both ways, +// and comparing the result to the original string. +// Caveats: +// - can give false negatives because of possible unicode normalization during conversion +// - can give false positives if the 8bit encoding contains high-ascii only in valid utf8 groups +// - slow because of double conversion +bool IsUTF8(const std::string &str); + + #define MPT_CHAR_TYPE char #define MPT_CHAR(x) x #define MPT_LITERAL(x) x @@ -199,6 +209,7 @@ // If str does not contain any invalid characters, this conversion is lossless. // Invalid source bytes will be replaced by some replacement character or string. static inline std::wstring ToWide(const std::wstring &str) { return str; } +static inline std::wstring ToWide(const wchar_t * str) { return (str ? std::wstring(str) : std::wstring()); } std::wstring ToWide(Charset from, const std::string &str); #endif @@ -210,6 +221,7 @@ // destination charset will be replaced by some replacement character or string. #if MPT_WSTRING_CONVERT std::string ToCharset(Charset to, const std::wstring &str); +static inline std::string ToCharset(Charset to, const wchar_t * str) { return ToCharset(to, str ? std::wstring(str) : std::wstring()); } #endif std::string ToCharset(Charset to, Charset from, const std::string &str); @@ -224,6 +236,7 @@ // If UNICODE is defined, this is a completely lossless operation. static inline CString ToCString(const CString &str) { return str; } CString ToCString(const std::wstring &str); +static inline CString ToCString(const wchar_t * str) { return ToCString(str ? std::wstring(str) : std::wstring()); } CString ToCString(Charset from, const std::string &str); // Convert from a MFC CString. The CString encoding depends on UNICODE. @@ -232,11 +245,6 @@ std::wstring ToWide(const CString &str); std::string ToCharset(Charset to, const CString &str); -// Provide un-ambiguous conversion from wide string literal. -static inline std::wstring ToWide(const wchar_t * str) { return ToWide(str ? std::wstring(str) : std::wstring()); } -static inline std::string ToCharset(Charset to, const wchar_t * str) { return ToCharset(to, str ? std::wstring(str) : std::wstring()); } -static inline CString ToCString(const wchar_t * str) { return ToCString(str ? std::wstring(str) : std::wstring()); } - #ifdef UNICODE MPT_DEPRECATED static inline CString ToCStringW(const CString &str) { return ToCString(str); } MPT_DEPRECATED static inline CString ToCStringW(const std::wstring &str) { return ToCString(str); } @@ -320,21 +328,23 @@ #error "MPT_USTRING_MODE_WIDE depends on MPT_WSTRING_CONVERT)" #endif static inline mpt::ustring ToUnicode(const std::wstring &str) { return str; } +static inline mpt::ustring ToUnicode(const wchar_t * str) { return (str ? std::wstring(str) : std::wstring()); } static inline mpt::ustring ToUnicode(Charset from, const std::string &str) { return ToWide(from, str); } #if defined(_MFC_VER) static inline mpt::ustring ToUnicode(const CString &str) { return ToWide(str); } -static inline mpt::ustring ToUnicode(const wchar_t * str) { return ToUnicode(str ? std::wstring(str) : std::wstring()); } #ifndef UNICODE static inline mpt::ustring ToUnicode(const CStringW &str) { return ToWide(str); } #endif // !UNICODE #endif // MFC #else // !MPT_USTRING_MODE_WIDE static inline mpt::ustring ToUnicode(const mpt::ustring &str) { return str; } +#if MPT_WSTRING_CONVERT mpt::ustring ToUnicode(const std::wstring &str); +static inline mpt::ustring ToUnicode(const wchar_t * str) { return ToUnicode(str ? std::wstring(str) : std::wstring()); } +#endif mpt::ustring ToUnicode(Charset from, const std::string &str); #if defined(_MFC_VER) mpt::ustring ToUnicode(const CString &str); -static inline mpt::ustring ToUnicode(const wchar_t * str) { return ToUnicode(str ? std::wstring(str) : std::wstring()); } #ifndef UNICODE mpt::ustring ToUnicode(const CStringW &str); #endif // !UNICODE @@ -374,6 +384,137 @@ +// The AnyString types are meant to be used as function argument types only, +// and only during the transition phase to all-unicode strings in the whole codebase. +// Using an AnyString type as function argument avoids the need to overload a function for all the +// different string types that we currently have. +// Warning: These types will silently do charset conversions. Only use them when this can be tolerated. + +// BasicAnyString is convertable to mpt::ustring and constructable from any string at all. +template <mpt::Charset charset = mpt::CharsetUTF8, bool tryUTF8 = true> +class BasicAnyString : public mpt::ustring +{ + +private: + + static mpt::ustring From8bit(const std::string &str) + { + if(charset == mpt::CharsetUTF8) + { + return mpt::ToUnicode(mpt::CharsetUTF8, str); + } + // auto utf8 detection + if(tryUTF8 && mpt::IsUTF8(str)) + { + return mpt::ToUnicode(mpt::CharsetUTF8, str); + } else + { + return mpt::ToUnicode(charset, str); + } + } + +public: + + // 8 bit + BasicAnyString(const char *str) : mpt::ustring(str ? mpt::ToUnicode(charset, str) : mpt::ustring()) { } + BasicAnyString(const std::string str) : mpt::ustring(mpt::ToUnicode(charset, str)) { } + + // unicode + BasicAnyString(const mpt::ustring &str) : mpt::ustring(str) { } +#if MPT_COMPILER_HAS_RVALUE_REF + BasicAnyString(mpt::ustring &&str) : mpt::ustring(std::move(str)) { } +#endif +#if MPT_USTRING_MODE_UTF8 && MPT_WSTRING_CONVERT + BasicAnyString(const std::wstring &str) : mpt::ustring(mpt::ToUnicode(str)) { } +#endif +#if MPT_WSTRING_CONVERT + BasicAnyString(const wchar_t *str) : mpt::ustring(str ? mpt::ToUnicode(str) : mpt::ustring()) { } +#endif + + // mfc +#if defined(_MFC_VER) + BasicAnyString(const CString &str) : mpt::ustring(mpt::ToUnicode(str)) { } +#ifndef UNICODE + BasicAnyString(const CStringW &str) : mpt::ustring(mpt::ToUnicode(str)) { } +#endif +#endif + + // fallback for custom string types + template <typename Tstring> BasicAnyString(const Tstring &str) : mpt::ustring(mpt::ToUnicode(str)) { } +#if MPT_COMPILER_HAS_RVALUE_REF + template <typename Tstring> BasicAnyString(Tstring &&str) : mpt::ustring(mpt::ToUnicode(std::forward<Tstring>(str))) { } +#endif + +}; + +// AnyUnicodeString is convertable to mpt::ustring and constructable from any unicode string, +class AnyUnicodeString : public mpt::ustring +{ + +public: + + // unicode + AnyUnicodeString(const mpt::ustring &str) : mpt::ustring(str) { } +#if MPT_COMPILER_HAS_RVALUE_REF + AnyUnicodeString(mpt::ustring &&str) : mpt::ustring(std::move(str)) { } +#endif +#if MPT_USTRING_MODE_UTF8 && MPT_WSTRING_CONVERT + AnyUnicodeString(const std::wstring &str) : mpt::ustring(mpt::ToUnicode(str)) { } +#endif +#if MPT_WSTRING_CONVERT + AnyUnicodeString(const wchar_t *str) : mpt::ustring(str ? mpt::ToUnicode(str) : mpt::ustring()) { } +#endif + + // mfc +#if defined(_MFC_VER) + AnyUnicodeString(const CString &str) : mpt::ustring(mpt::ToUnicode(str)) { } +#ifndef UNICODE + AnyUnicodeString(const CStringW &str) : mpt::ustring(mpt::ToUnicode(str)) { } +#endif +#endif + + // fallback for custom string types + template <typename Tstring> AnyUnicodeString(const Tstring &str) : mpt::ustring(mpt::ToUnicode(str)) { } +#if MPT_COMPILER_HAS_RVALUE_REF + template <typename Tstring> AnyUnicodeString(Tstring &&str) : mpt::ustring(mpt::ToUnicode(std::forward<Tstring>(str))) { } +#endif + +}; + +// AnyString +// Try to do the smartest auto-magic we can do. +#if defined(MPT_WITH_CHARSET_LOCALE) +typedef BasicAnyString<mpt::CharsetLocale, true> AnyString; +#elif MPT_OS_WINDOWS +typedef BasicAnyString<mpt::CharsetWindows1252, true> AnyString; +#else +typedef BasicAnyString<mpt::CharsetISO8859_1, true> AnyString; +#endif + +// AnyStringLocale +// char-based strings are assumed to be in locale encoding. +#if defined(MPT_WITH_CHARSET_LOCALE) +typedef BasicAnyString<mpt::CharsetLocale, false> AnyStringLocale; +#else +typedef BasicAnyString<mpt::CharsetUTF8, false> AnyStringLocale; +#endif + +// AnyStringUTF8orLocale +// char-based strings are tried in UTF8 first, if this fails, locale is used. +#if defined(MPT_WITH_CHARSET_LOCALE) +typedef BasicAnyString<mpt::CharsetLocale, true> AnyStringUTF8orLocale; +#else +typedef BasicAnyString<mpt::CharsetUTF8, false> AnyStringUTF8orLocale; +#endif + +// AnyStringUTF8 +// char-based strings are assumed to be in UTF8. +typedef BasicAnyString<mpt::CharsetUTF8, false> AnyStringUTF8; + + + + + // The following section demands a rationale. // 1. ToString(), ToWString() an ToUString() mimic the semantics of c++11 std::to_string() and std::to_wstring(). // There is an important difference though. The c++11 versions are specified in terms of sprintf formatting which in turn Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-08 00:26:16 UTC (rev 4559) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-08 17:21:00 UTC (rev 4560) @@ -863,11 +863,11 @@ { switch(level) { - case LogError: Reporting::Error(mpt::ToWide(text)); break; - case LogWarning: Reporting::Warning(mpt::ToWide(text)); break; - case LogInformation: Reporting::Information(mpt::ToWide(text)); break; - case LogNotification: Reporting::Notification(mpt::ToWide(text)); break; - default: Reporting::Information(mpt::ToWide(text)); break; + case LogError: Reporting::Error(text); break; + case LogWarning: Reporting::Warning(text); break; + case LogInformation: Reporting::Information(text); break; + case LogNotification: Reporting::Notification(text); break; + default: Reporting::Information(text); break; } } } @@ -922,11 +922,11 @@ std::wstring actualTitle = (title.length() == 0) ? MAINFRAME_TITLEW : title; switch(GetMaxLogLevel()) { - case LogError: Reporting::Error(text, actualTitle.c_str(), parent); break; - case LogWarning: Reporting::Warning(text, actualTitle.c_str(), parent); break; - case LogInformation: Reporting::Information(text, actualTitle.c_str(), parent); break; - case LogNotification: Reporting::Notification(text, actualTitle.c_str(), parent); break; - default: Reporting::Information(text, actualTitle.c_str(), parent); break; + case LogError: Reporting::Error(text, actualTitle, parent); break; + case LogWarning: Reporting::Warning(text, actualTitle, parent); break; + case LogInformation: Reporting::Information(text, actualTitle, parent); break; + case LogNotification: Reporting::Notification(text, actualTitle, parent); break; + default: Reporting::Information(text, actualTitle, parent); break; } return IDOK; } Modified: trunk/OpenMPT/mptrack/Reporting.cpp =================================================================== --- trunk/OpenMPT/mptrack/Reporting.cpp 2014-11-08 00:26:16 UTC (rev 4559) +++ trunk/OpenMPT/mptrack/Reporting.cpp 2014-11-08 17:21:00 UTC (rev 4560) @@ -17,32 +17,59 @@ OPENMPT_NAMESPACE_BEGIN -UINT Reporting::ShowNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) -//----------------------------------------------------------------------------------------------------- +static inline UINT LogLevelToFlags(LogLevel level) +//------------------------------------------------ { - CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - - if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) + switch(level) { - pMainFrm->GetInputHandler()->Bypass(true); + case LogNotification: return MB_OK; break; + case LogInformation: return MB_OK | MB_ICONINFORMATION; break; + case LogWarning: return MB_OK | MB_ICONWARNING; break; + case LogError: return MB_OK | MB_ICONERROR; break; } + return MB_OK; +} - if(parent == nullptr) + +static std::wstring GetTitle() +//---------------------------- +{ + return MAINFRAME_TITLEW; +} + + +static std::wstring FillEmptyCaption(const std::wstring &caption, LogLevel level) +//------------------------------------------------------------------------------- +{ + std::wstring result = mpt::ToWide(caption); + if(result.empty()) { - parent = pMainFrm; + result = GetTitle() + std::wstring(L" - "); + switch(level) + { + case LogNotification: result += L"Notification"; break; + case LogInformation: result += L"Information"; break; + case LogWarning: result += L"Warning"; break; + case LogError: result += L"Error"; break; + } } - UINT result = ::MessageBoxA((parent ? parent->m_hWnd : NULL), text, caption, flags); + return result; +} - if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) + +static std::wstring FillEmptyCaption(const std::wstring &caption) +//--------------------------------------------------------------- +{ + std::wstring result = mpt::ToWide(caption); + if(result.empty()) { - pMainFrm->GetInputHandler()->Bypass(false); + result = GetTitle(); } - return result; } -UINT Reporting::ShowNotification(const std::wstring &text, const std::wstring &caption, UINT flags, const CWnd *parent) +static UINT ShowNotificationImpl(const std::wstring &text, const std::wstring &caption, UINT flags, const CWnd *parent) //--------------------------------------------------------------------------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); @@ -56,7 +83,7 @@ { parent = pMainFrm; } - UINT result = ::MessageBoxW((parent ? parent->m_hWnd : NULL), text.c_str(), caption.c_str(), flags); + UINT result = ::MessageBoxW((parent ? parent->m_hWnd : NULL), text.c_str(), caption.empty() ? MAINFRAME_TITLEW : caption.c_str(), flags); if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) { @@ -67,175 +94,72 @@ } -void Reporting::Notification(const char *text, const CWnd *parent) -//---------------------------------------------------------------- +UINT Reporting::CustomNotification(const AnyStringLocale &text, const AnyStringLocale &caption, UINT flags, const CWnd *parent) +//----------------------------------------------------------------------------------------------------------------------------- { - Notification(text, MAINFRAME_TITLE, parent); + return ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(mpt::ToWide(caption)), flags, parent); } -void Reporting::Notification(const char *text, const char *caption, const CWnd *parent) -//------------------------------------------------------------------------------------- +void Reporting::Notification(const AnyStringLocale &text, const CWnd *parent) +//--------------------------------------------------------------------------- { - ShowNotification(text, caption, MB_OK, parent); + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(std::wstring(), LogNotification), LogLevelToFlags(LogNotification), parent); } - - -void Reporting::Information(const char *text, const CWnd *parent) -//--------------------------------------------------------------- +void Reporting::Notification(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent) +//----------------------------------------------------------------------------------------------------------- { - Information(text, MAINFRAME_TITLE, parent); + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(mpt::ToWide(caption), LogNotification), LogLevelToFlags(LogNotification), parent); } -void Reporting::Information(const char *text, const char *caption, const CWnd *parent) -//------------------------------------------------------------------------------------ +void Reporting::Information(const AnyStringLocale &text, const CWnd *parent) +//-------------------------------------------------------------------------- { - ShowNotification(text, caption, MB_OK | MB_ICONINFORMATION, parent); + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(std::wstring(), LogInformation), LogLevelToFlags(LogInformation), parent); } - - -void Reporting::Warning(const char *text, const CWnd *parent) -//----------------------------------------------------------- +void Reporting::Information(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent) +//---------------------------------------------------------------------------------------------------------- { - Warning(text, MAINFRAME_TITLE " - Warning", parent); + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(mpt::ToWide(caption), LogInformation), LogLevelToFlags(LogInformation), parent); } -void Reporting::Warning(const char *text, const char *caption, const CWnd *parent) -//-------------------------------------------------------------------------------- -{ - ShowNotification(text, caption, MB_OK | MB_ICONWARNING, parent); -} - - -void Reporting::Error(const char *text, const CWnd *parent) -//--------------------------------------------------------- -{ - Error(text, MAINFRAME_TITLE " - Error", parent); -} - - -void Reporting::Error(const char *text, const char *caption, const CWnd *parent) -//------------------------------------------------------------------------------ -{ - ShowNotification(text, caption, MB_OK | MB_ICONERROR, parent); -} - - -ConfirmAnswer Reporting::Confirm(const char *text, bool showCancel, bool defaultNo, const CWnd *parent) -//----------------------------------------------------------------------------------------------------- -{ - return Confirm(text, MAINFRAME_TITLE " - Confirmation", showCancel, defaultNo, parent); -} - - -ConfirmAnswer Reporting::Confirm(const char *text, const char *caption, bool showCancel, bool defaultNo, const CWnd *parent) -//-------------------------------------------------------------------------------------------------------------------------- -{ - UINT result = ShowNotification(text, caption, (showCancel ? MB_YESNOCANCEL : MB_YESNO) | MB_ICONQUESTION | (defaultNo ? MB_DEFBUTTON2 : 0), parent); - switch(result) - { - case IDYES: - return cnfYes; - case IDNO: - return cnfNo; - default: - case IDCANCEL: - return cnfCancel; - } -} - - -RetryAnswer Reporting::RetryCancel(const char *text, const CWnd *parent) +void Reporting::Warning(const AnyStringLocale &text, const CWnd *parent) //---------------------------------------------------------------------- { - return RetryCancel(text, MAINFRAME_TITLE, parent); + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(std::wstring(), LogWarning), LogLevelToFlags(LogWarning), parent); } - - -RetryAnswer Reporting::RetryCancel(const char *text, const char *caption, const CWnd *parent) -//------------------------------------------------------------------------------------------- +void Reporting::Warning(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent) +//------------------------------------------------------------------------------------------------------ { - UINT result = ShowNotification(text, caption, MB_RETRYCANCEL, parent); - switch(result) - { - case IDRETRY: - return rtyRetry; - default: - case IDCANCEL: - return rtyCancel; - } + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(mpt::ToWide(caption), LogWarning), LogLevelToFlags(LogWarning), parent); } -void Reporting::Notification(const std::wstring &text, const CWnd *parent) -//------------------------------------------------------------------------ +void Reporting::Error(const AnyStringLocale &text, const CWnd *parent) +//-------------------------------------------------------------------- { - Notification(text, MAINFRAME_TITLEW, parent); + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(std::wstring(), LogError), LogLevelToFlags(LogError), parent); } - - -void Reporting::Notification(const std::wstring &text, const std::wstring &caption, const CWnd *parent) -//----------------------------------------------------------------------------------------------------- -{ - ShowNotification(text, caption, MB_OK, parent); -} - - -void Reporting::Information(const std::wstring &text, const CWnd *parent) -//----------------------------------------------------------------------- -{ - Information(text, MAINFRAME_TITLEW, parent); -} - - -void Reporting::Information(const std::wstring &text, const std::wstring &caption, const CWnd *parent) +void Reporting::Error(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent) //---------------------------------------------------------------------------------------------------- { - ShowNotification(text, caption, MB_OK | MB_ICONINFORMATION, parent); + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(mpt::ToWide(caption), LogError), LogLevelToFlags(LogError), parent); } -void Reporting::Warning(const std::wstring &text, const CWnd *parent) -//----------------------------------------------------------- +ConfirmAnswer Reporting::Confirm(const AnyStringLocale &text, bool showCancel, bool defaultNo, const CWnd *parent) +//---------------------------------------------------------------------------------------------------------------- { - Warning(text, MAINFRAME_TITLEW L" - Warning", parent); + return Confirm(mpt::ToWide(text), GetTitle() + L" - Confirmation", showCancel, defaultNo, parent); } -void Reporting::Warning(const std::wstring &text, const std::wstring &caption, const CWnd *parent) -//------------------------------------------------------------------------------------------------ +ConfirmAnswer Reporting::Confirm(const AnyStringLocale &text, const AnyStringLocale &caption, bool showCancel, bool defaultNo, const CWnd *parent) +//------------------------------------------------------------------------------------------------------------------------------------------------ { - ShowNotification(text, caption, MB_OK | MB_ICONWARNING, parent); -} - - -void Reporting::Error(const std::wstring &text, const CWnd *parent) -//--------------------------------------------------------- -{ - Error(text, MAINFRAME_TITLEW L" - Error", parent); -} - - -void Reporting::Error(const std::wstring &text, const std::wstring &caption, const CWnd *parent) -//---------------------------------------------------------------------------------------------- -{ - ShowNotification(text, caption, MB_OK | MB_ICONERROR, parent); -} - - -ConfirmAnswer Reporting::Confirm(const std::wstring &text, bool showCancel, bool defaultNo, const CWnd *parent) -//------------------------------------------------------------------------------------------------------------- -{ - return Confirm(text, MAINFRAME_TITLEW L" - Confirmation", showCancel, defaultNo, parent); -} - - -ConfirmAnswer Reporting::Confirm(const std::wstring &text, const std::wstring &caption, bool showCancel, bool defaultNo, const CWnd *parent) -//------------------------------------------------------------------------------------------------------------------------------------------ -{ - UINT result = ShowNotification(text, caption, (showCancel ? MB_YESNOCANCEL : MB_YESNO) | MB_ICONQUESTION | (defaultNo ? MB_DEFBUTTON2 : 0), parent); + UINT result = ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(mpt::ToWide(caption)), (showCancel ? MB_YESNOCANCEL : MB_YESNO) | MB_ICONQUESTION | (defaultNo ? MB_DEFBUTTON2 : 0), parent); switch(result) { case IDYES: @@ -249,17 +173,17 @@ } -RetryAnswer Reporting::RetryCancel(const std::wstring &text, const CWnd *parent) -//------------------------------------------------------------------------------ +RetryAnswer Reporting::RetryCancel(const AnyStringLocale &text, const CWnd *parent) +//--------------------------------------------------------------------------------- { - return RetryCancel(text, MAINFRAME_TITLEW, parent); + return RetryCancel(mpt::ToWide(text), GetTitle(), parent); } -RetryAnswer Reporting::RetryCancel(const std::wstring &text, const std::wstring &caption, const CWnd *parent) -//----------------------------------------------------------------------------------------------------------- +RetryAnswer Reporting::RetryCancel(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent) +//----------------------------------------------------------------------------------------------------------------- { - UINT result = ShowNotification(text, caption, MB_RETRYCANCEL, parent); + UINT result = ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(mpt::ToWide(caption)), MB_RETRYCANCEL, parent); switch(result) { case IDRETRY: Modified: trunk/OpenMPT/mptrack/Reporting.h =================================================================== --- trunk/OpenMPT/mptrack/Reporting.h 2014-11-08 00:26:16 UTC (rev 4559) +++ trunk/OpenMPT/mptrack/Reporting.h 2014-11-08 17:21:00 UTC (rev 4560) @@ -34,52 +34,34 @@ //============= { -protected: - - static UINT ShowNotification(const char *text, const char *caption, UINT flags, const CWnd *parent); - static UINT ShowNotification(const std::wstring &text, const std::wstring &caption, UINT flags, const CWnd *parent); - public: // TODO Quick'n'dirty workaround for MsgBox(). Shouldn't be public. - static UINT CustomNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) { return ShowNotification(text, caption, flags, parent); }; - static UINT CustomNotification(const std::wstring &text, const std::wstring &caption, UINT flags, const CWnd *parent) { return ShowNotification(text, caption, flags, parent); }; + static UINT CustomNotification(const AnyStringLocale &text, const AnyStringLocale &caption, UINT flags, const CWnd *parent); // Show a simple notification - static void Notification(const char *text, const CWnd *parent = nullptr); - static void Notification(const char *text, const char *caption, const CWnd *parent = nullptr); - static void Notification(const std::wstring &text, const CWnd *parent = nullptr); - static void Notification(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); + static void Notification(const AnyStringLocale &text, const CWnd *parent = nullptr); + static void Notification(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent = nullptr); // Show a simple information - static void Information(const char *text, const CWnd *parent = nullptr); - static void Information(const char *text, const char *caption, const CWnd *parent = nullptr); - static void Information(const std::wstring &text, const CWnd *parent = nullptr); - static void Information(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); + static void Information(const AnyStringLocale &text, const CWnd *parent = nullptr); + static void Information(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent = nullptr); // Show a simple warning - static void Warning(const char *text, const CWnd *parent = nullptr); - static void Warning(const char *text, const char *caption, const CWnd *parent = nullptr); - static void Warning(const std::wstring &text, const CWnd *parent = nullptr); - static void Warning(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); + static void Warning(const AnyStringLocale &text, const CWnd *parent = nullptr); + static void Warning(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent = nullptr); // Show an error box. - static void Error(const char *text, const CWnd *parent = nullptr); - static void Error(const char *text, const char *caption, const CWnd *parent = nullptr); - static void Error(const std::wstring &text, const CWnd *parent = nullptr); - static void Error(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); + static void Error(const AnyStringLocale &text, const CWnd *parent = nullptr); + static void Error(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent = nullptr); // Show a confirmation dialog. - static ConfirmAnswer Confirm(const char *text, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); - static ConfirmAnswer Confirm(const char *text, const char *caption, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); - static ConfirmAnswer Confirm(const std::wstring &text, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); - static ConfirmAnswer Confirm(const std::wstring &text, const std::wstring &caption, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); + static ConfirmAnswer Confirm(const AnyStringLocale &text, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); + static ConfirmAnswer Confirm(const AnyStringLocale &text, const AnyStringLocale &caption, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); // Show a confirmation dialog. - static RetryAnswer RetryCancel(const char *text, const CWnd *parent = nullptr); - static RetryAnswer RetryCancel(const char *text, const char *caption, const CWnd *parent = nullptr); - static RetryAnswer RetryCancel(const std::wstring &text, const CWnd *parent = nullptr); - static RetryAnswer RetryCancel(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); + static RetryAnswer RetryCancel(const AnyStringLocale &text, const CWnd *parent = nullptr); + static RetryAnswer RetryCancel(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent = nullptr); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-11-08 17:56:55
|
Revision: 4561 http://sourceforge.net/p/modplug/code/4561 Author: saga-games Date: 2014-11-08 17:56:49 +0000 (Sat, 08 Nov 2014) Log Message: ----------- [Imp] Song length estimation reports length for all sub songs in the current order list instead of just the first. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-11-08 17:21:00 UTC (rev 4560) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-11-08 17:56:49 UTC (rev 4561) @@ -691,7 +691,7 @@ double module_impl::get_duration_seconds() const { - return m_sndFile->GetLength( eNoAdjust ).duration; + return m_sndFile->GetLength( eNoAdjust ).back().duration; } void module_impl::select_subsong( std::int32_t subsong ) { if ( subsong < -1 || subsong >= m_sndFile->Order.GetNumSequences() ) { @@ -714,12 +714,12 @@ return m_currentPositionSeconds; } double module_impl::set_position_seconds( double seconds ) { - GetLengthType t = m_sndFile->GetLength( eNoAdjust, GetLengthTarget( seconds ) ); + GetLengthType t = m_sndFile->GetLength( eNoAdjust, GetLengthTarget( seconds ) ).back(); m_sndFile->InitializeVisitedRows(); m_sndFile->m_PlayState.m_nCurrentOrder = t.lastOrder; m_sndFile->SetCurrentOrder( t.lastOrder ); m_sndFile->m_PlayState.m_nNextRow = t.lastRow; - m_currentPositionSeconds = m_sndFile->GetLength( eAdjust, GetLengthTarget( t.lastOrder, t.lastRow ) ).duration; + m_currentPositionSeconds = m_sndFile->GetLength( eAdjust, GetLengthTarget( t.lastOrder, t.lastRow ) ).back().duration; return m_currentPositionSeconds; } double module_impl::set_position_order_row( std::int32_t order, std::int32_t row ) { @@ -738,7 +738,7 @@ m_sndFile->m_PlayState.m_nCurrentOrder = order; m_sndFile->SetCurrentOrder( order ); m_sndFile->m_PlayState.m_nNextRow = row; - m_currentPositionSeconds = m_sndFile->GetLength( eAdjust, GetLengthTarget( order, row ) ).duration; + m_currentPositionSeconds = m_sndFile->GetLength( eAdjust, GetLengthTarget( order, row ) ).back().duration; return m_currentPositionSeconds; } std::vector<std::string> module_impl::get_metadata_keys() const { Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-08 17:21:00 UTC (rev 4560) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-08 17:56:49 UTC (rev 4561) @@ -2222,16 +2222,25 @@ void CModDoc::OnEstimateSongLength() //---------------------------------- { - CString s; - double songLength = m_SndFile.GetSongTime(); - if(songLength != std::numeric_limits<double>::infinity()) + CString s = _T("Approximate song length: "); + std::vector<GetLengthType> lengths = m_SndFile.GetLength(eNoAdjust, GetLengthTarget(true)); + for(size_t i = 0; i < lengths.size(); i++) { - songLength = Util::Round(songLength); - s.Format("Approximate song length: %.0fmn%02.0fs", std::floor(songLength / 60.0), fmod(songLength, 60.0)); - } else - { - s = "Song too long!"; + if(lengths.size() > 1) + { + s.AppendFormat(_T("\nSong %u, starting at order %u: "), i, lengths[i].startOrder); + } + double songLength = lengths[i].duration; + if(songLength != std::numeric_limits<double>::infinity()) + { + songLength = Util::Round(songLength); + s.AppendFormat("%.0fmn%02.0fs", std::floor(songLength / 60.0), std::fmod(songLength, 60.0)); + } else + { + s += "Song too long!"; + } } + Reporting::Information(s); } Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2014-11-08 17:21:00 UTC (rev 4560) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2014-11-08 17:56:49 UTC (rev 4561) @@ -1172,10 +1172,13 @@ //--------------------------------- { bool result = false; - GetLengthType length = m_SndFile.GetLength(eNoAdjust); - if(length.endOrder != ORDERINDEX_INVALID && length.endRow != ROWINDEX_INVALID) + std::vector<GetLengthType> length = m_SndFile.GetLength(eNoAdjust, GetLengthTarget(true)); + for(size_t i = 0; i < length.size(); i++) { - result = m_SndFile.Patterns[m_SndFile.Order[length.endOrder]].WriteEffect(EffectWriter(CMD_POSITIONJUMP, m_SndFile.m_nRestartPos).Row(length.endRow).Retry(EffectWriter::rmTryNextRow)); + if(length[i].endOrder != ORDERINDEX_INVALID && length[i].endRow != ROWINDEX_INVALID) + { + result = m_SndFile.Patterns[m_SndFile.Order[length[i].endOrder]].WriteEffect(EffectWriter(CMD_POSITIONJUMP, m_SndFile.m_nRestartPos).Row(length[i].endRow).Retry(EffectWriter::rmTryNextRow)); + } } m_SndFile.m_nRestartPos = 0; return result; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-08 17:21:00 UTC (rev 4560) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-08 17:56:49 UTC (rev 4561) @@ -105,14 +105,11 @@ // [out] lastRow: last parsed row (dito) // [out] endOrder: last order before module loops (UNDEFINED if a target is specified) // [out] endRow: last row before module loops (dito) -GetLengthType CSoundFile::GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target) -//------------------------------------------------------------------------------------------- +std::vector<GetLengthType> CSoundFile::GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target) +//------------------------------------------------------------------------------------------------------------ { + std::vector<GetLengthType> results; GetLengthType retval; - retval.duration = 0.0; - retval.targetReached = false; - retval.lastOrder = retval.endOrder = ORDERINDEX_INVALID; - retval.lastRow = retval.endRow = ROWINDEX_INVALID; // Are we trying to reach a certain pattern position? const bool hasSearchTarget = target.mode != GetLengthTarget::NoTarget; @@ -199,7 +196,12 @@ } else { // 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; memory.Reset(); + nRow = nNextRow; nCurrentOrder = nNextOrder; nPattern = Order[nCurrentOrder]; @@ -220,6 +222,10 @@ } else { // 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; memory.Reset(); continue; } @@ -248,6 +254,10 @@ } else { // 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; memory.Reset(); continue; } @@ -814,6 +824,7 @@ retval.lastRow = nRow; } retval.duration = memory.elapsedTime; + results.push_back(retval); // Store final variables if((adjustMode & eAdjust)) @@ -852,7 +863,7 @@ visitedSongRows.Set(visitedRows); } - return retval; + return results; } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-08 17:21:00 UTC (rev 4560) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-08 17:56:49 UTC (rev 4561) @@ -1848,7 +1848,7 @@ double CSoundFile::GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row, bool updateVars, bool updateSamplePos) //------------------------------------------------------------------------------------------------------- { - const GetLengthType t = GetLength(updateVars ? (updateSamplePos ? eAdjustSamplePositions : eAdjust) : eNoAdjust, GetLengthTarget(ord, row)); + const GetLengthType t = GetLength(updateVars ? (updateSamplePos ? eAdjustSamplePositions : eAdjust) : eNoAdjust, GetLengthTarget(ord, row)).back(); if(t.targetReached) return t.duration; else return -1; //Given position not found from play sequence. } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-11-08 17:21:00 UTC (rev 4560) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-11-08 17:56:49 UTC (rev 4561) @@ -97,11 +97,19 @@ struct GetLengthType { double duration; // total time in seconds - ROWINDEX lastRow; // last parsed row (dito) - ROWINDEX endRow; // last row before module loops (dito) + ROWINDEX lastRow; // last parsed row (see lastOrder remark) + ROWINDEX endRow; // last row before module loops (see endOrder remark) + ROWINDEX startRow; // first row of parsed subsong ORDERINDEX lastOrder; // last parsed order (if no target is specified, this is the first order that is parsed twice, i.e. not the *last* played order) ORDERINDEX endOrder; // last order before module loops (UNDEFINED if a target is specified) + ORDERINDEX startOrder; // first order of parsed subsong bool targetReached; // true if the specified order/row combination has been reached while going through the module + + GetLengthType() + : duration(0.0) + , lastRow(ROWINDEX_INVALID), endRow(ROWINDEX_INVALID), startRow(0) + , lastOrder(ORDERINDEX_INVALID), endOrder(ORDERINDEX_INVALID), startOrder(0) + , targetReached(false) { } }; @@ -120,15 +128,16 @@ enum Mode { - NoTarget, // Don't seek, i.e. return complete module length. + NoTarget, // Don't seek, i.e. return complete length of the first subsong. + GetAllSubsongs, // Same as NoTarget (i.e. get complete length), but returns the length of all sub songs SeekPosition, // Seek to given pattern position. SeekSeconds, // Seek to given time. } mode; // Don't seek, i.e. return complete module length. - GetLengthTarget() + GetLengthTarget(bool allSongs = false) { - mode = NoTarget; + mode = allSongs ? GetAllSubsongs : NoTarget; } // Seek to given pattern position if position is valid. @@ -600,13 +609,13 @@ //Get modlength in various cases: total length, length to //specific order&row etc. Return value is in seconds. - GetLengthType GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target = GetLengthTarget()); + std::vector<GetLengthType> GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target = GetLengthTarget()); void InitializeVisitedRows() { visitedSongRows.Initialize(true); } public: //Returns song length in seconds. - double GetSongTime() { return GetLength(eNoAdjust).duration; } + double GetSongTime() { return GetLength(eNoAdjust).back().duration; } void RecalculateSamplesPerTick(); double GetRowDuration(UINT tempo, UINT speed) const; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-08 17:21:00 UTC (rev 4560) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-08 17:56:49 UTC (rev 4561) @@ -492,7 +492,7 @@ // Let's check again if this really is the end of the song. // The visited rows vector might have been screwed up while editing... // This is of course not possible during rendering to WAV, so we ignore that case. - GetLengthType t = GetLength(eNoAdjust); + GetLengthType t = GetLength(eNoAdjust).back(); if(IsRenderingToDisc() || (t.lastOrder == m_PlayState.m_nCurrentOrder && t.lastRow == m_PlayState.m_nRow)) #else if(1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-11-08 23:30:42
|
Revision: 4566 http://sourceforge.net/p/modplug/code/4566 Author: saga-games Date: 2014-11-08 23:30:27 +0000 (Sat, 08 Nov 2014) Log Message: ----------- [Imp] libopenmpt: Add support for hidden subsongs. They are added completely transparently to the already existing subsong functionality. [Imp] xmp-openmpt: Added subsong support. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/libopenmpt/xmp-openmpt.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/RowVisitor.cpp trunk/OpenMPT/soundlib/RowVisitor.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2014-11-08 22:49:49 UTC (rev 4565) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2014-11-08 23:30:27 UTC (rev 4566) @@ -196,7 +196,7 @@ RENDER_VOLUMERAMPING_STRENGTH = 4 }; - //! Parameter index to use with get_pattern_row_channel_command, format_pattern_row_channel_command and highlight_pattern_row_channel_command + //! Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format_pattern_row_channel_command and openmpt::module::highlight_pattern_row_channel_command enum command_index { command_note = 0, command_instrument = 1, @@ -317,7 +317,7 @@ //! Get approximate song duration /*! - \return Approximate song duration in seconds. + \return Approximate duration of current subsong in seconds. */ double get_duration_seconds() const; @@ -328,9 +328,9 @@ \sa openmpt::module::get_position_seconds */ double set_position_seconds( double seconds ); - //! Get approximate current song position + //! Get current song position /*! - \return Approximate current song position in seconds. + \return Current song position in seconds. \sa openmpt::module::set_position_seconds */ double get_position_seconds() const; @@ -593,7 +593,7 @@ //! Get the number of rows in a pattern /*! - \param order The pattern whose row count should be retrieved. + \param pattern The pattern whose row count should be retrieved. \return The number of rows in the given pattern. If the pattern does not exist, 0 is returned. */ std::int32_t get_pattern_num_rows( std::int32_t pattern ) const; @@ -603,9 +603,8 @@ \param pattern The pattern whose data should be retrieved. \param row The row from which the data should be retrieved. \param channel The channel from which the data should be retrieved. - \param command The cell index at which the data should be retrieved. + \param command The cell index at which the data should be retrieved. See openmpt::module::command_index \return The internal, raw pattern data at the given pattern position. - \sa openmpt::module::command_index */ std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; @@ -615,8 +614,8 @@ \param row The row from which the data should be retrieved. \param channel The channel from which the data should be retrieved. \param command The cell index at which the data should be retrieved. - \return The formatted pattern data at the given pattern position. - \sa openmpt::module::command_index + \return The formatted pattern data at the given pattern position. See openmpt::module::command_index + \sa openmpt::module::highlight_pattern_row_channel_command */ std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; @@ -625,7 +624,7 @@ \param pattern The pattern whose data should be retrieved. \param row The row from which the data should be retrieved. \param channel The channel from which the data should be retrieved. - \param command The cell index at which the data should be retrieved. + \param command The cell index at which the data should be retrieved. See openmpt::module::command_index \return The highlighting string for the formatted pattern data as retrived by openmpt::module::get_pattern_row_channel_command at the given pattern position. \remarks The returned string will map each character position of the string returned by openmpt::module::get_pattern_row_channel_command to a highlighting instruction. Possible highlighting characters are: @@ -638,7 +637,7 @@ - "v" : generic volume column parameter - "e" : generic effect column effect - "f" : generic effect column parameter - \sa openmpt::module::command_index + \sa openmpt::module::get_pattern_row_channel_command */ std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; @@ -650,6 +649,7 @@ \param width The maximum number of characters the string should contain. 0 means no limit. \param pad If true, the string will be resized to the exact length provided in the width parameter. \return The formatted pattern data at the given pattern position. + \sa openmpt::module::highlight_pattern_row_channel */ std::string format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; //! Get highlighting information for formatted pattern content @@ -660,7 +660,7 @@ \param width The maximum number of characters the string should contain. 0 means no limit. \param pad If true, the string will be resized to the exact length provided in the width parameter. \return The highlighting string for the formatted pattern data as retrived by openmpt::module::format_pattern_row_channel at the given pattern position. - \sa openmpt::module::format_pattern_row_channel_command + \sa openmpt::module::format_pattern_row_channel */ std::string highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; @@ -673,9 +673,9 @@ - seek.sync_samples: Set to "1" to sync sample playback when using openmpt::module::set_position_seconds or openmpt::module::set_position_order_row. - dither: Set the dither algorithm that is used for the 16 bit versions of openmpt::module::read. Supported values are: - 0: No dithering. - - 1: Default mode. Chosen by OpenMPT code, might change. - - 2: Rectangular, 0.5 bit depth, no noise shaping (original ModPlug Tracker). - - 3: Rectangular, 1 bit depth, simple 1st order noise shaping + - 1: Default mode. Chosen by OpenMPT code, might change. + - 2: Rectangular, 0.5 bit depth, no noise shaping (original ModPlug Tracker). + - 3: Rectangular, 1 bit depth, simple 1st order noise shaping */ std::vector<std::string> get_ctls() const; @@ -689,7 +689,7 @@ //! Set ctl value /*! \param ctl The ctl key whose value should be set. - \param The value that should be set. + \param value The value that should be set. \sa openmpt::module::get_ctls */ void ctl_set( const std::string & ctl, const std::string & value ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-11-08 22:49:49 UTC (rev 4565) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-11-08 23:30:27 UTC (rev 4566) @@ -325,6 +325,8 @@ m_ctl_load_skip_samples = false; m_ctl_load_skip_patterns = false; m_ctl_seek_sync_samples = false; + m_current_subsong = 0; + m_sndFile->Order.SetSequence( 0 ); for ( std::map< std::string, std::string >::const_iterator i = ctls.begin(); i != ctls.end(); ++i ) { ctl_set( i->first, i->second ); } @@ -692,18 +694,26 @@ double module_impl::get_duration_seconds() const { + cache_subsongs(); + if ( m_current_subsong >= 0 && m_current_subsong < static_cast<std::int32_t>( m_subsongs.size() ) ) { + return m_subsongs[m_current_subsong].duration; + } return m_sndFile->GetLength( eNoAdjust ).back().duration; } void module_impl::select_subsong( std::int32_t subsong ) { - if ( subsong < -1 || subsong >= m_sndFile->Order.GetNumSequences() ) { + cache_subsongs(); + if ( subsong < -1 || subsong >= static_cast<std::int32_t>( m_subsongs.size() ) ) { return; } if ( subsong == -1 ) { // default subsong - m_sndFile->Order.SetSequence( 0 ); - return; + subsong = 0; } - m_sndFile->Order.SetSequence( subsong ); + + m_current_subsong = subsong; + m_sndFile->Order.SetSequence( static_cast<SEQUENCEINDEX>( m_subsongs[subsong].sequence ) ); + set_position_order_row( m_subsongs[subsong].start_order, m_subsongs[subsong].start_row ); + } void module_impl::set_repeat_count( std::int32_t repeat_count ) { m_sndFile->SetRepeatCount( repeat_count ); @@ -715,12 +725,13 @@ return m_currentPositionSeconds; } double module_impl::set_position_seconds( double seconds ) { - GetLengthType t = m_sndFile->GetLength( eNoAdjust, GetLengthTarget( seconds ) ).back(); + const subsong_data &subsong = m_subsongs[m_current_subsong]; + GetLengthType t = m_sndFile->GetLength( eNoAdjust, GetLengthTarget( seconds ).StartPos( subsong.sequence, subsong.start_order, subsong.start_row ) ).back(); m_sndFile->InitializeVisitedRows(); m_sndFile->m_PlayState.m_nCurrentOrder = t.lastOrder; m_sndFile->SetCurrentOrder( t.lastOrder ); m_sndFile->m_PlayState.m_nNextRow = t.lastRow; - m_currentPositionSeconds = m_sndFile->GetLength( m_ctl_seek_sync_samples ? eAdjustSamplePositions : eAdjust, GetLengthTarget( t.lastOrder, t.lastRow ) ).back().duration; + m_currentPositionSeconds = m_sndFile->GetLength( m_ctl_seek_sync_samples ? eAdjustSamplePositions : eAdjust, GetLengthTarget( t.lastOrder, t.lastRow ).StartPos( subsong.sequence, subsong.start_order, subsong.start_row ) ).back().duration; return m_currentPositionSeconds; } double module_impl::set_position_order_row( std::int32_t order, std::int32_t row ) { @@ -885,7 +896,8 @@ } std::int32_t module_impl::get_num_subsongs() const { - return m_sndFile->Order.GetNumSequences(); + cache_subsongs(); + return static_cast<std::int32_t>( m_subsongs.size() ); } std::int32_t module_impl::get_num_channels() const { return m_sndFile->GetNumChannels(); @@ -904,9 +916,10 @@ } std::vector<std::string> module_impl::get_subsong_names() const { + cache_subsongs(); std::vector<std::string> retval; - for ( SEQUENCEINDEX i = 0; i < m_sndFile->Order.GetNumSequences(); ++i ) { - retval.push_back( mod_string_to_utf8( m_sndFile->Order.GetSequence( i ).GetName() ) ); + for ( std::size_t i = 0; i < m_subsongs.size(); ++i ) { + retval.push_back( mod_string_to_utf8( m_sndFile->Order.GetSequence( m_subsongs[i].sequence ).GetName() ) ); } return retval; } @@ -1177,4 +1190,19 @@ } } +void module_impl::cache_subsongs() const { + if ( !m_subsongs.empty() ) { + return; + } + + m_subsongs.reserve( m_sndFile->Order.GetNumSequences() ); + + for ( SEQUENCEINDEX seq = 0; seq < m_sndFile->Order.GetNumSequences(); ++seq ) { + const std::vector<GetLengthType> lengths = m_sndFile->GetLength( eNoAdjust, GetLengthTarget( true ).StartPos( seq, 0, 0 ) ); + for ( std::vector<GetLengthType>::const_iterator l = lengths.begin(); l != lengths.end(); ++l ) { + m_subsongs.push_back( subsong_data( l->duration, l->startRow, l->startOrder, seq ) ); + } + } +} + } // namespace openmpt Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2014-11-08 22:49:49 UTC (rev 4565) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2014-11-08 23:30:27 UTC (rev 4566) @@ -57,6 +57,16 @@ class log_forwarder; +class subsong_data { +public: + double duration; + std::int32_t start_row; + std::int32_t start_order; + std::int32_t sequence; + + subsong_data( double duration, std::int32_t start_row, std::int32_t start_order, std::int32_t sequence ) : duration(duration), start_row(start_row), start_order(start_order), sequence(sequence) { } +}; + class module_impl { protected: #ifdef LIBOPENMPT_ANCIENT_COMPILER @@ -85,6 +95,8 @@ bool m_ctl_load_skip_patterns; bool m_ctl_seek_sync_samples; std::vector<std::string> m_loaderMessages; + mutable std::vector<subsong_data> m_subsongs; + std::int32_t m_current_subsong; public: void PushToCSoundFileLog( const std::string & text ) const; void PushToCSoundFileLog( int loglevel, const std::string & text ) const; @@ -101,6 +113,7 @@ std::size_t read_interleaved_wrapper( std::size_t count, std::size_t channels, float * interleaved ); std::pair< std::string, std::string > format_and_highlight_pattern_row_channel_command( std::int32_t p, std::int32_t r, std::int32_t c, int command ) const; std::pair< std::string, std::string > format_and_highlight_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const; + void cache_subsongs() const; public: static std::vector<std::string> get_supported_extensions(); static bool is_extension_supported( const std::string & extension ); Modified: trunk/OpenMPT/libopenmpt/xmp-openmpt.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/xmp-openmpt.cpp 2014-11-08 22:49:49 UTC (rev 4565) +++ trunk/OpenMPT/libopenmpt/xmp-openmpt.cpp 2014-11-08 23:30:27 UTC (rev 4566) @@ -97,6 +97,7 @@ static void apply_and_save_options(); struct self_xmplay_t { + std::vector<float> subsong_lengths; std::size_t samplerate; std::size_t num_channels; openmpt::settings::settings settings; @@ -161,6 +162,21 @@ return &decoded_string[0]; } +static std::string seconds_to_string( float time ) { + std::int64_t time_ms = static_cast<std::int64_t>( time * 1000 ); + std::int64_t seconds = ( time_ms / 1000 ) % 60; + std::int64_t minutes = ( time_ms / ( 1000 * 60 ) ) % 60; + std::int64_t hours = ( time_ms / ( 1000 * 60 * 60 ) ); + std::ostringstream str; + if ( hours > 0 ) { + str << hours << ":"; + } + str << std::setfill('0') << std::setw(2) << minutes; + str << ":"; + str << std::setfill('0') << std::setw(2) << seconds; + return str.str(); +} + static void save_settings_to_map( std::map<std::string,int> & result, const openmpt::settings::settings & s ) { result.clear(); result[ "Samplerate_Hz" ] = s.samplerate; @@ -763,7 +779,16 @@ apply_options(); self->samplerate = self->settings.samplerate; self->num_channels = self->settings.channels; - xmpfin->SetLength( static_cast<float>( self->mod->get_duration_seconds() ), TRUE ); + + std::int32_t num_subsongs = self->mod->get_num_subsongs(); + self->subsong_lengths.resize( num_subsongs ); + for ( std::int32_t i = 0; i < num_subsongs; ++i ) { + self->mod->select_subsong( i ); + self->subsong_lengths[i] = static_cast<float>( self->mod->get_duration_seconds() ); + } + self->mod->select_subsong( -1 ); + + xmpfin->SetLength( self->subsong_lengths[0], TRUE ); return 2; } catch ( ... ) { self->delete_mod(); @@ -898,7 +923,17 @@ << "Orders" << "\t" << self->mod->get_num_orders() << "\r" << "Patterns" << "\t" << self->mod->get_num_patterns() << "\r" << "Instruments" << "\t" << self->mod->get_num_instruments() << "\r" - << "Samples" << "\t" << self->mod->get_num_samples() << "\r" + << "Samples" << "\t" << self->mod->get_num_samples() << "\r"; + + if( self->subsong_lengths.size() > 1 ) { + std::vector<std::string> names = self->mod->get_subsong_names(); + + for ( std::size_t i = 0; i < self->subsong_lengths.size(); ++i ) { + str << ( i == 0 ? "Subsongs\t" : "\t" ) << (i + 1) << ". " << seconds_to_string( self->subsong_lengths[i]) << " " << names[i] << "\r"; + } + } + + str << "\r" << "Tracker" << "\t" << sanitize_xmplay_info_string( self->mod->get_metadata("tracker") ) << "\r" << "Player" << "\t" << "xmp-openmpt" << " version " << openmpt::string::get( openmpt::string::library_version ) << "\r" @@ -927,6 +962,14 @@ if ( !self->mod ) { return -1.0; } + + if ( pos & XMPIN_POS_SUBSONG ) { + self->mod->select_subsong( pos & 0xffff ); + xmpfin->SetLength( self->subsong_lengths[pos & 0xffff], TRUE ); + reset_timeinfos( 0 ); + return 0.0; + } + double new_position = self->mod->set_position_seconds( static_cast<double>( pos ) * 0.001 ); reset_timeinfos( new_position ); return new_position; @@ -1016,6 +1059,15 @@ write_xmplay_string( buf, str.str() ); } +static DWORD WINAPI openmpt_GetSubSongs( float * length ) { + *length = 0.0; + for ( std::size_t i = 0; i < self->subsong_lengths.size(); ++i ) { + *length += self->subsong_lengths[i]; + } + + return static_cast<DWORD>( self->subsong_lengths.size() ); +} + #ifdef EXPERIMENTAL_VIS enum ColorIndex @@ -1432,7 +1484,7 @@ openmpt_Process, NULL, // WriteFile openmpt_GetSamples, - NULL, // GetSubSongs + openmpt_GetSubSongs, // GetSubSongs NULL, // GetCues NULL, // GetDownloaded Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-08 22:49:49 UTC (rev 4565) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-08 23:30:27 UTC (rev 4566) @@ -2228,16 +2228,16 @@ { if(lengths.size() > 1) { - s.AppendFormat(_T("\nSong %u, starting at order %u: "), i, lengths[i].startOrder); + s.AppendFormat(_T("\nSong %u, starting at order %u: "), i + 1, lengths[i].startOrder); } double songLength = lengths[i].duration; if(songLength != std::numeric_limits<double>::infinity()) { songLength = Util::Round(songLength); - s.AppendFormat("%.0fmn%02.0fs", std::floor(songLength / 60.0), std::fmod(songLength, 60.0)); + s.AppendFormat(_T("%.0fmn%02.0fs"), std::floor(songLength / 60.0), std::fmod(songLength, 60.0)); } else { - s += "Song too long!"; + s += _T("Song too long!"); } } Modified: trunk/OpenMPT/soundlib/RowVisitor.cpp =================================================================== --- trunk/OpenMPT/soundlib/RowVisitor.cpp 2014-11-08 22:49:49 UTC (rev 4565) +++ trunk/OpenMPT/soundlib/RowVisitor.cpp 2014-11-08 23:30:27 UTC (rev 4566) @@ -28,10 +28,15 @@ // Resize / Clear the row vector. // If reset is true, the vector is not only resized to the required dimensions, but also completely cleared (i.e. all visited rows are unset). -void RowVisitor::Initialize(bool reset) -//------------------------------------- +void RowVisitor::Initialize(bool reset, SEQUENCEINDEX sequence) +//------------------------------------------------------------- { - const ORDERINDEX endOrder = sndFile.Order.GetLengthTailTrimmed(); + if(sequence < sndFile.Order.GetNumSequences()) + Order = &sndFile.Order.GetSequence(sequence); + else + Order = &sndFile.Order; + + const ORDERINDEX endOrder = Order->GetLengthTailTrimmed(); visitedRows.resize(endOrder); if(reset) { @@ -41,7 +46,7 @@ for(ORDERINDEX order = 0; order < endOrder; order++) { VisitedRowsBaseType &row = visitedRows[order]; - const size_t size = GetVisitedRowsVectorSize(sndFile.Order[order]); + const size_t size = GetVisitedRowsVectorSize(Order->At(order)); if(reset) { // If we want to reset the vectors completely, we overwrite existing items with false. @@ -60,8 +65,8 @@ void RowVisitor::SetVisited(ORDERINDEX order, ROWINDEX row, bool visited) //----------------------------------------------------------------------- { - const ORDERINDEX endOrder = sndFile.Order.GetLengthTailTrimmed(); - if(order >= endOrder || row >= GetVisitedRowsVectorSize(sndFile.Order[order])) + const ORDERINDEX endOrder = Order->GetLengthTailTrimmed(); + if(order >= endOrder || row >= GetVisitedRowsVectorSize(Order->At(order))) { return; } @@ -86,7 +91,7 @@ bool RowVisitor::IsVisited(ORDERINDEX order, ROWINDEX row, bool autoSet) //---------------------------------------------------------------------- { - const ORDERINDEX endOrder = sndFile.Order.GetLengthTailTrimmed(); + const ORDERINDEX endOrder = Order->GetLengthTailTrimmed(); if(order >= endOrder) { return false; @@ -138,10 +143,10 @@ bool RowVisitor::GetFirstUnvisitedRow(ORDERINDEX &order, ROWINDEX &row, bool fastSearch) const //-------------------------------------------------------------------------------------------- { - const ORDERINDEX endOrder = sndFile.Order.GetLengthTailTrimmed(); + const ORDERINDEX endOrder = Order->GetLengthTailTrimmed(); for(order = 0; order < endOrder; order++) { - const PATTERNINDEX pattern = sndFile.Order[order]; + const PATTERNINDEX pattern = Order->At(order); if(!sndFile.Patterns.IsValidPat(pattern)) { continue; @@ -197,7 +202,7 @@ { // We're in a new pattern! Forget about which rows we previously visited... visitOrder.clear(); - visitOrder.reserve(GetVisitedRowsVectorSize(sndFile.Order[order])); + visitOrder.reserve(GetVisitedRowsVectorSize(Order->At(order))); currentOrder = order; } // And now add the played row to our memory. Modified: trunk/OpenMPT/soundlib/RowVisitor.h =================================================================== --- trunk/OpenMPT/soundlib/RowVisitor.h 2014-11-08 22:49:49 UTC (rev 4565) +++ trunk/OpenMPT/soundlib/RowVisitor.h 2014-11-08 23:30:27 UTC (rev 4566) @@ -16,6 +16,7 @@ OPENMPT_NAMESPACE_BEGIN class CSoundFile; +class ModSequence; //============== class RowVisitor @@ -28,6 +29,7 @@ typedef std::vector<VisitedRowsBaseType> VisitedRowsType; const CSoundFile &sndFile; + const ModSequence *Order; // Memory for every row in the module if it has been visited or not. VisitedRowsType visitedRows; @@ -37,16 +39,16 @@ public: - RowVisitor(const CSoundFile &sf) : sndFile(sf), currentOrder(0) + RowVisitor(const CSoundFile &sf, SEQUENCEINDEX sequence = SEQUENCEINDEX_INVALID) : sndFile(sf), currentOrder(0) { - Initialize(true); + Initialize(true, sequence); }; - RowVisitor(const RowVisitor &other) : sndFile(other.sndFile), visitedRows(other.visitedRows), visitOrder(other.visitOrder), currentOrder(other.currentOrder) { }; + RowVisitor(const RowVisitor &other) : sndFile(other.sndFile), Order(other.Order), visitedRows(other.visitedRows), visitOrder(other.visitOrder), currentOrder(other.currentOrder) { }; // Resize / Clear the row vector. // If reset is true, the vector is not only resized to the required dimensions, but also completely cleared (i.e. all visited rows are unset). - void Initialize(bool reset); + void Initialize(bool reset, SEQUENCEINDEX sequence = SEQUENCEINDEX_INVALID); // Mark a row as visited. void Visit(ORDERINDEX order, ROWINDEX row) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-08 22:49:49 UTC (rev 4565) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-08 23:30:27 UTC (rev 4566) @@ -106,29 +106,35 @@ // [out] endOrder: last order before module loops (UNDEFINED if a target is specified) // [out] endRow: last row before module loops (dito) std::vector<GetLengthType> CSoundFile::GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target) -//------------------------------------------------------------------------------------------------------------ +//-------------------------------------------------------------------------------------------------------- { std::vector<GetLengthType> results; GetLengthType retval; + retval.startOrder = target.startOrder; + retval.startRow = target.startRow; // Are we trying to reach a certain pattern position? const bool hasSearchTarget = target.mode != GetLengthTarget::NoTarget; const bool adjustSamplePos = (adjustMode & eAdjustSamplePositions) == eAdjustSamplePositions; - ROWINDEX nRow = 0, nNextRow = 0; + ROWINDEX nRow = target.startRow, nNextRow = nRow; ROWINDEX nNextPatStartRow = 0; // FT2 E60 bug - ORDERINDEX nCurrentOrder = 0, nNextOrder = 0; + ORDERINDEX nCurrentOrder = target.startOrder, nNextOrder = nCurrentOrder; + SEQUENCEINDEX sequence = target.sequence; + if(sequence > Order.GetNumSequences()) sequence = Order.GetCurrentSequenceIndex(); + const ModSequence &orderList = Order.GetSequence(sequence); + GetLengthMemory memory(*this); // 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); + RowVisitor visitedRows(*this, sequence); // Optimize away channels for which it's pointless to adjust sample positions std::vector<bool> adjustSampleChn(GetNumChannels(), true); if(adjustSamplePos && target.mode == GetLengthTarget::SeekPosition) { PATTERNINDEX seekPat = PATTERNINDEX_INVALID; - if(target.pos.order < Order.GetLength()) seekPat = Order[target.pos.order]; + if(target.pos.order < orderList.GetLength()) seekPat = orderList[target.pos.order]; if(!Patterns.IsValidPat(seekPat) || !Patterns[seekPat].IsValidRow(target.pos.row)) seekPat = PATTERNINDEX_INVALID; for(CHANNELINDEX i = 0; i < GetNumChannels(); i++) @@ -156,16 +162,16 @@ nRow = nNextRow; nCurrentOrder = nNextOrder; - if(nCurrentOrder >= Order.size()) + if(nCurrentOrder >= orderList.size()) break; // Check if pattern is valid - PATTERNINDEX nPattern = Order[nCurrentOrder]; + PATTERNINDEX nPattern = orderList[nCurrentOrder]; bool positionJumpOnThisRow = false; bool patternBreakOnThisRow = false; bool patternLoopEndedOnThisRow = false, patternLoopStartedOnThisRow = false; - if(nPattern == Order.GetIgnoreIndex() && target.mode == GetLengthTarget::SeekPosition && nCurrentOrder == target.pos.order) + if(nPattern == orderList.GetIgnoreIndex() && target.mode == GetLengthTarget::SeekPosition && nCurrentOrder == target.pos.order) { // Early test: Target is inside +++ pattern retval.targetReached = true; @@ -175,7 +181,7 @@ while(nPattern >= Patterns.Size()) { // End of song? - if((nPattern == Order.GetInvalidPatIndex()) || (nCurrentOrder >= Order.size())) + if((nPattern == orderList.GetInvalidPatIndex()) || (nCurrentOrder >= orderList.size())) { if(nCurrentOrder == m_nRestartPos) break; @@ -185,7 +191,7 @@ { nCurrentOrder++; } - nPattern = (nCurrentOrder < Order.size()) ? Order[nCurrentOrder] : Order.GetInvalidPatIndex(); + nPattern = (nCurrentOrder < orderList.size()) ? orderList[nCurrentOrder] : orderList.GetInvalidPatIndex(); nNextOrder = nCurrentOrder; if((!Patterns.IsValidPat(nPattern)) && visitedRows.IsVisited(nCurrentOrder, 0, true)) { @@ -204,7 +210,7 @@ nRow = nNextRow; nCurrentOrder = nNextOrder; - nPattern = Order[nCurrentOrder]; + nPattern = orderList[nCurrentOrder]; break; } } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-11-08 22:49:49 UTC (rev 4565) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-11-08 23:30:27 UTC (rev 4566) @@ -116,6 +116,10 @@ // Target seek mode for GetLength() struct GetLengthTarget { + ROWINDEX startRow; + ORDERINDEX startOrder; + SEQUENCEINDEX sequence; + union { double time; @@ -138,12 +142,18 @@ GetLengthTarget(bool allSongs = false) { mode = allSongs ? GetAllSubsongs : NoTarget; + sequence = SEQUENCEINDEX_INVALID; + startOrder = 0; + startRow = 0; } // Seek to given pattern position if position is valid. GetLengthTarget(ORDERINDEX order, ROWINDEX row) { mode = NoTarget; + sequence = SEQUENCEINDEX_INVALID; + startOrder = 0; + startRow = 0; if(order != ORDERINDEX_INVALID && row != ROWINDEX_INVALID) { mode = SeekPosition; @@ -156,12 +166,24 @@ GetLengthTarget(double t) { mode = NoTarget; + sequence = SEQUENCEINDEX_INVALID; + startOrder = 0; + startRow = 0; if(t >= 0.0) { mode = SeekSeconds; time = t; } } + + // Set start position from which seeking should begin. + GetLengthTarget &StartPos(SEQUENCEINDEX seq, ORDERINDEX order, ROWINDEX row) + { + sequence = seq; + startOrder = order; + startRow = row; + return *this; + } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-11-09 00:22:10
|
Revision: 4568 http://sourceforge.net/p/modplug/code/4568 Author: saga-games Date: 2014-11-09 00:21:59 +0000 (Sun, 09 Nov 2014) Log Message: ----------- [Ref] Lots of small oneliner changes in various files - no functional changes. Modified Paths: -------------- trunk/OpenMPT/README.md trunk/OpenMPT/mptrack/AboutDialog.cpp trunk/OpenMPT/mptrack/CImageListEx.cpp trunk/OpenMPT/mptrack/Childfrm.h trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Globals.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.h trunk/OpenMPT/mptrack/MIDIMapping.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/ITCompression.cpp trunk/OpenMPT/soundlib/ITCompression.h trunk/OpenMPT/soundlib/Load_dmf.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Load_stm.cpp trunk/OpenMPT/soundlib/MIDIMacros.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/S3MTools.cpp trunk/OpenMPT/soundlib/SampleIO.cpp trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/Tables.cpp trunk/OpenMPT/soundlib/mod_specifications.cpp trunk/OpenMPT/soundlib/mod_specifications.h trunk/OpenMPT/test/test.cpp trunk/OpenMPT/unarchiver/unrar.cpp trunk/OpenMPT/unarchiver/unzip.cpp Modified: trunk/OpenMPT/README.md =================================================================== --- trunk/OpenMPT/README.md 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/README.md 2014-11-09 00:21:59 UTC (rev 4568) @@ -55,7 +55,8 @@ this, uncomment `#define NO_DSOUND` in the file `common/BuildSettings.h`. - To compile the project, open `mptrack/MPTRACK_08.SLN` (if you're using - VS2008) or `mptrack/MPTRACK_10.SLN` (VS2010) and hit the compile button! :) + VS2008) or `mptrack/MPTRACK_10.SLN` (VS2010 or later) and hit the compile + button! :) ### libopenmpt and openmpt123 Modified: trunk/OpenMPT/mptrack/AboutDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/AboutDialog.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/AboutDialog.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -136,11 +136,11 @@ { // Were there any pixels being moved in the last frame? if(!activity) - return FALSE; + return false; DWORD now = timeGetTime(); if(now - lastFrame < 15) - return TRUE; + return true; lastFrame = now; activity = false; Modified: trunk/OpenMPT/mptrack/CImageListEx.cpp =================================================================== --- trunk/OpenMPT/mptrack/CImageListEx.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/CImageListEx.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -89,7 +89,7 @@ { // 32-bit image on modern system - // Make fully transparent pixels use the maks color. This should hopefully make the icons look "somewhat" okay + // Make fully transparent pixels use the mask color. This should hopefully make the icons look "somewhat" okay // on system where the alpha channel is magically missing in 32-bit mode (http://bugs.openmpt.org/view.php?id=520) PNG::Pixel *pixel = bitmap->GetPixels(); for(size_t i = bitmap->GetNumPixels(); i != 0; i--, pixel++) Modified: trunk/OpenMPT/mptrack/Childfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Childfrm.h 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/Childfrm.h 2014-11-09 00:21:59 UTC (rev 4568) @@ -38,10 +38,10 @@ typedef struct SAMPLEVIEWSTATE { - DWORD dwScrollPos; - DWORD dwBeginSel; - DWORD dwEndSel; - UINT nSample; + SmpLength dwScrollPos; + SmpLength dwBeginSel; + SmpLength dwEndSel; + SAMPLEINDEX nSample; } SAMPLEVIEWSTATE; Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/CommandSet.h 2014-11-09 00:21:59 UTC (rev 4568) @@ -1306,7 +1306,7 @@ //Communication KeyCombination GetKey(CommandID cmd, UINT key) const { return commands[cmd].kcList[key]; } bool isHidden(UINT c) const { return commands[c].isHidden; } - int GetKeyListSize(CommandID cmd) const { return commands[cmd].kcList.size(); } + int GetKeyListSize(CommandID cmd) const { return (int)commands[cmd].kcList.size(); } CString GetCommandText(CommandID cmd) const { return commands[cmd].Message; } CString GetKeyTextFromCommand(CommandID c, UINT key); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -2498,11 +2498,9 @@ const uint32 newTrans = Util::Round<uint32>(sample.nC5Speed * pow(2.0, (n - oldTransp) / 12.0)); if (newTrans > 0 && newTrans <= (m_sndFile.GetType() == MOD_TYPE_S3M ? 65535u : 9999999u) && newTrans != sample.nC5Speed) { - CHAR s[32]; sample.nC5Speed = newTrans; - wsprintf(s, "%lu", newTrans); LockControls(); - m_EditFineTune.SetWindowText(s); + SetDlgItemInt(IDC_EDIT5, newTrans, FALSE); UnlockControls(); SetModified(HINT_SAMPLEINFO, false, false); } @@ -2733,7 +2731,7 @@ UINT pinc = 1; ModSample &sample = m_sndFile.GetSample(m_nSample); const uint8 *pSample = static_cast<const uint8 *>(sample.pSample); - short int pos; + int pos; bool redraw = false; LockControls(); @@ -2745,7 +2743,7 @@ } if (sample.uFlags[CHN_STEREO]) pinc *= 2; // Loop Start - if ((pos = (short int)m_SpinLoopStart.GetPos()) != 0) + if ((pos = m_SpinLoopStart.GetPos32()) != 0) { bool bOk = false; const uint8 *p = pSample + sample.nLoopStart * pinc; @@ -2789,7 +2787,7 @@ m_SpinLoopStart.SetPos(0); } // Loop End - pos = (short int)m_SpinLoopEnd.GetPos(); + pos = m_SpinLoopEnd.GetPos32(); if ((pos) && (sample.nLoopEnd)) { bool bOk = false; @@ -2833,7 +2831,7 @@ m_SpinLoopEnd.SetPos(0); } // Sustain Loop Start - pos = (short int)m_SpinSustainStart.GetPos(); + pos = m_SpinSustainStart.GetPos32(); if ((pos) && (sample.nSustainEnd)) { bool bOk = false; @@ -2878,7 +2876,7 @@ m_SpinSustainStart.SetPos(0); } // Sustain Loop End - pos = (short int)m_SpinSustainEnd.GetPos(); + pos = m_SpinSustainEnd.GetPos32(); if (pos) { bool bOk = false; @@ -2923,7 +2921,7 @@ } NoSample: // FineTune / C-5 Speed - if ((pos = (short int)m_SpinFineTune.GetPos()) != 0) + if ((pos = m_SpinFineTune.GetPos32()) != 0) { if (m_sndFile.m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) { @@ -2937,8 +2935,7 @@ Clamp(basenote, BASENOTE_MIN, BASENOTE_MAX); basenote -= BASENOTE_MIN; if (basenote != m_CbnBaseNote.GetCurSel()) m_CbnBaseNote.SetCurSel(basenote); - wsprintf(s, "%lu", sample.nC5Speed); - m_EditFineTune.SetWindowText(s); + SetDlgItemInt(IDC_EDIT5, sample.nC5Speed, FALSE); } else { int ftune = (int)sample.nFineTune; @@ -2947,8 +2944,7 @@ { ftune = Clamp((ftune >> 4) + pos, -8, 7); sample.nFineTune = MOD2XMFineTune((signed char)ftune); - } - else + } else { ftune = Clamp(ftune + pos, -128, 127); sample.nFineTune = (signed char)ftune; @@ -3004,9 +3000,9 @@ int transpose = 0; switch(wParam) { - case kcSampleLoad: OnSampleOpen(); return wParam; - case kcSampleSave: OnSampleSave(); return wParam; - case kcSampleNew: OnSampleNew(); return wParam; + case kcSampleLoad: OnSampleOpen(); return wParam; + case kcSampleSave: OnSampleSave(); return wParam; + case kcSampleNew: OnSampleNew(); return wParam; case kcSampleTransposeUp: transpose = 1; break; case kcSampleTransposeDown: transpose = -1; break; Modified: trunk/OpenMPT/mptrack/Globals.h =================================================================== --- trunk/OpenMPT/mptrack/Globals.h 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/Globals.h 2014-11-09 00:21:59 UTC (rev 4568) @@ -24,7 +24,6 @@ class CModControlView; class CModControlBar; -class CImageListEx; //======================================= class CModControlBar: public CToolBarCtrl Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -687,35 +687,6 @@ //----------------------------------------------------------- -void COptionsKeyboard::OnHotKeyChanged() -//-------------------------------------- -{ -/* if ((m_nCurKeyboard == KEYBOARD_CUSTOM) && (m_nCurHotKey >= 0) && (m_nCurHotKey < MAX_MPTHOTKEYS)) - { - BOOL bChanged = FALSE; - WORD wVk=0, wMod=0; - - m_HotKey.GetHotKey(wVk, wMod); - DWORD dwHk = ((DWORD)wVk) | (((DWORD)wMod) << 16); - for (UINT i = 0; i<MAX_MPTHOTKEYS; i++) if (i != (UINT)m_nCurHotKey) - { - if (CustomKeys[i] == dwHk) - { - CustomKeys[i] = 0; - bChanged = TRUE; - } - } - if (dwHk != CustomKeys[m_nCurHotKey]) - { - CustomKeys[m_nCurHotKey] = dwHk; - bChanged = TRUE; - } - if (bChanged) OnSettingsChanged(); - } - */ -} - - void COptionsKeyboard::OnRestoreKeyChoice() //----------------------------------------- { @@ -770,8 +741,7 @@ CommandID cmd = (CommandID)m_nCurHotKey; if (cmd<0) { - CString error = "Invalid slot."; - Reporting::Warning(error, "Invalid key data", this); + Reporting::Warning("Invalid slot.", "Invalid key data", this); return; } @@ -826,7 +796,6 @@ //Update log m_eReport.GetWindowText(reportHistory); - //reportHistory = reportHistory.Mid(6,reportHistory.GetLength()-1); m_eReport.SetWindowText(report + reportHistory); ForceUpdateGUI(); } @@ -870,7 +839,6 @@ m_sFullPathName = dlg.GetFirstFile(); plocalCmdSet->LoadFile(m_sFullPathName); ForceUpdateGUI(); - //TentativeSetToDefaultFile(m_sFullPathName); } @@ -886,7 +854,6 @@ m_sFullPathName = dlg.GetFirstFile(); plocalCmdSet->SaveFile(m_sFullPathName); - //TentativeSetToDefaultFile(m_sFullPathName); } Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.h =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.h 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.h 2014-11-09 00:21:59 UTC (rev 4568) @@ -115,7 +115,6 @@ afx_msg void OnCategorySelChanged(); afx_msg void OnSearchTermChanged(); afx_msg void OnChordWaitTimeChanged(); //rewbs.autochord - afx_msg void OnHotKeyChanged(); afx_msg void OnSettingsChanged() { SetModified(TRUE); } afx_msg void OnCheck() { OnSetKeyChoice(); }; afx_msg void OnNotesRepeat(); Modified: trunk/OpenMPT/mptrack/MIDIMapping.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.h 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/MIDIMapping.h 2014-11-09 00:21:59 UTC (rev 4568) @@ -39,14 +39,14 @@ //Note: In these functions, channel value is in range [1,16], //GetChannel() returns 0 on 'any channel'. - void SetChannel(const int c){if(c < 1 || c > 16) m_AnyChannel = true; else {m_ChnEvent &= ~0xF; m_ChnEvent |= c-1; m_AnyChannel = false;}} - BYTE GetChannel() const {return (m_AnyChannel) ? 0 : (m_ChnEvent & 0xF) + 1;} + void SetChannel(const int c){ if(c < 1 || c > 16) m_AnyChannel = true; else { m_ChnEvent &= ~0x0F; m_ChnEvent |= c - 1; m_AnyChannel = false; } } + uint8 GetChannel() const {return (m_AnyChannel) ? 0 : (m_ChnEvent & 0xF) + 1;} - void SetEvent(BYTE e) {if(e > 15) e = 15; m_ChnEvent &= ~0xF0; m_ChnEvent |= (e << 4);} - BYTE GetEvent() const {return static_cast<BYTE>((m_ChnEvent >> 4) & 0xF);} + void SetEvent(uint8 e) {if(e > 15) e = 15; m_ChnEvent &= ~0xF0; m_ChnEvent |= (e << 4);} + uint8 GetEvent() const {return (m_ChnEvent >> 4) & 0x0F;} - void SetController(int controller) {if(controller > 127) controller = 127; m_MIDIByte1 = static_cast<BYTE>(controller);} - BYTE GetController() const {return m_MIDIByte1;} + void SetController(int controller) {if(controller > 127) controller = 127; m_MIDIByte1 = static_cast<uint8>(controller);} + uint8 GetController() const {return m_MIDIByte1;} //Note: Plug index starts from 1. void SetPlugIndex(const int i) {m_PluginIndex = static_cast<PLUGINDEX>(i);} @@ -60,12 +60,12 @@ bool operator==(const CMIDIMappingDirective &other) const { return memcmp(this, &other, sizeof(*this)) == 0; } bool operator<(const CMIDIMappingDirective &other) const { return GetController() < other.GetController(); } - BYTE GetChnEvent() const {return m_ChnEvent;} + uint8 GetChnEvent() const {return m_ChnEvent;} private: uint32 m_Parameter; PLUGINDEX m_PluginIndex; - BYTE m_MIDIByte1; + uint8 m_MIDIByte1; uint8 m_ChnEvent; //0-3 channel, 4-7 event bool m_Active : 1; bool m_CaptureMIDI : 1; //When true, MIDI data should not be processed beyond this directive Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -322,7 +322,7 @@ } // Now, create new sample list. - m_SndFile.m_nSamples = newNumSamples; + m_SndFile.m_nSamples = std::max(m_SndFile.m_nSamples, newNumSamples); // Avoid assertions when using GetSample()... for(SAMPLEINDEX i = 0; i < newNumSamples; i++) { const SAMPLEINDEX origSlot = newOrder[i]; @@ -375,6 +375,8 @@ } } + m_SndFile.m_nSamples = newNumSamples; + if(m_SndFile.GetNumInstruments()) { // Instrument mode: Update sample maps. Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -286,8 +286,8 @@ TrackerDirectories::Instance().SetDefaultDirectory(path, static_cast<Directory>(i), false); } m_szKbdFile = conf.Read<mpt::PathString>("Paths", "Key_Config_File", mpt::PathString()); + conf.Forget("Paths", "Key_Config_File"); - // init old and messy stuff: // Default chords @@ -1041,7 +1041,7 @@ if(stripFilename) { - path = filenameFrom.GetDrive() + filenameFrom.GetDir(); + path = filenameFrom.GetPath(); } else { path = filenameFrom; Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -713,7 +713,7 @@ fin.close(); if (pT) { - if (m_TempTunings.AddTuning(pT) == true) + if (m_TempTunings.AddTuning(pT)) { delete pT; pT = nullptr; if (m_TempTunings.GetNumTunings() >= CTuningCollection::s_nMaxTuningCount) @@ -722,16 +722,14 @@ } else // Case: Can't add tuning to tuning collection for unknown reason. { - sLoadReport += L"-Unable to import file \"" + fileNameExt + L"\": unknown reason.\n"; + sLoadReport += L"-Unable to import file \"" + fileNameExt + L"\": unknown reason.\n"; } } - } - else // pT == nullptr + } else // pT == nullptr { - sLoadReport += L"-Unable to import file \"" + fileNameExt + L"\": unrecognized file.\n"; + sLoadReport += L"-Unable to import file \"" + fileNameExt + L"\": unrecognized file.\n"; } - } - else // scl import. + } else // scl import. { EnSclImport a = ImportScl(files[counter], fileName.ToCString()); if (a != enSclImportOk) @@ -990,7 +988,7 @@ } void CTuningDialog::OnNMRclickTreeTuning(NMHDR *, LRESULT *pResult) -//----------------------------------------------------------------------- +//----------------------------------------------------------------- { *pResult = 0; @@ -1483,36 +1481,36 @@ CTuningDialog::EnSclImport CTuningDialog::ImportScl(std::istream& iStrm, LPCTSTR pszName) //--------------------------------------------------------------------------------------- { - std::string str; - SkipCommentLines(iStrm, str); + std::string str; + SkipCommentLines(iStrm, str); // str should now contain comment line. - SkipCommentLines(iStrm, str); + SkipCommentLines(iStrm, str); // str should now contain number of notes. const size_t nNotes = 1 + ConvertStrTo<size_t>(str.c_str()); - if (nNotes > s_nSclImportMaxNoteCount) - return enSclImportFailTooManyNotes; + if (nNotes > s_nSclImportMaxNoteCount) + return enSclImportFailTooManyNotes; std::vector<CTuningRTI::RATIOTYPE> fRatios; fRatios.reserve(nNotes); - fRatios.push_back(1); + fRatios.push_back(1); - char buffer[128]; + char buffer[128]; MemsetZero(buffer); - while (iStrm.getline(buffer, sizeof(buffer))) - { - LPSTR psz = buffer; - LPSTR const pEnd = psz + strlen(buffer); + while (iStrm.getline(buffer, sizeof(buffer))) + { + LPSTR psz = buffer; + LPSTR const pEnd = psz + strlen(buffer); - // Skip tabs and spaces. - while(psz != pEnd && (*psz == ' ' || *psz == '\t')) - psz++; + // Skip tabs and spaces. + while(psz != pEnd && (*psz == ' ' || *psz == '\t')) + psz++; - // Skip empty lines, comment lines and non-text. - if (*psz == 0 || *psz == '!' || *psz < 32) - continue; + // Skip empty lines, comment lines and non-text. + if (*psz == 0 || *psz == '!' || *psz < 32) + continue; - char* pNonDigit = pEnd; + char* pNonDigit = pEnd; // Check type of first non digit. This tells whether to read cent, ratio or plain number. for (pNonDigit = psz; pNonDigit != pEnd; pNonDigit++) @@ -1521,39 +1519,39 @@ break; } - if (*pNonDigit == '.') // Reading cents - { - SclFloat fCent = ConvertStrTo<SclFloat>(psz); + if (*pNonDigit == '.') // Reading cents + { + SclFloat fCent = ConvertStrTo<SclFloat>(psz); fRatios.push_back(static_cast<CTuningRTI::RATIOTYPE>(CentToRatio(fCent))); - } - else if (*pNonDigit == '/') // Reading ratios - { - *pNonDigit = 0; // Replace '/' with null. - int64 nNum = ConvertStrTo<int64>(psz); - psz = pNonDigit + 1; - int64 nDenom = ConvertStrTo<int64>(psz); + } + else if (*pNonDigit == '/') // Reading ratios + { + *pNonDigit = 0; // Replace '/' with null. + int64 nNum = ConvertStrTo<int64>(psz); + psz = pNonDigit + 1; + int64 nDenom = ConvertStrTo<int64>(psz); - if (nNum > int32_max || nDenom > int32_max) - return enSclImportFailTooLargeNumDenomIntegers; - if (nDenom == 0) - return enSclImportFailZeroDenominator; + if (nNum > int32_max || nDenom > int32_max) + return enSclImportFailTooLargeNumDenomIntegers; + if (nDenom == 0) + return enSclImportFailZeroDenominator; - fRatios.push_back(static_cast<CTuningRTI::RATIOTYPE>((SclFloat)nNum / (SclFloat)nDenom)); - } - else // Plain numbers. + fRatios.push_back(static_cast<CTuningRTI::RATIOTYPE>((SclFloat)nNum / (SclFloat)nDenom)); + } + else // Plain numbers. fRatios.push_back(static_cast<CTuningRTI::RATIOTYPE>(ConvertStrTo<int32>(psz))); - } + } - if (nNotes != fRatios.size()) - return enSclImportLineCountMismatch; + if (nNotes != fRatios.size()) + return enSclImportLineCountMismatch; - for(size_t i = 0; i < fRatios.size(); i++) - { - if (fRatios[i] < 0) - return enSclImportFailNegativeRatio; - } + for(size_t i = 0; i < fRatios.size(); i++) + { + if (fRatios[i] < 0) + return enSclImportFailNegativeRatio; + } - CTuning* pT = new CTuningRTI; + CTuning* pT = new CTuningRTI; if (pT->CreateGroupGeometric(fRatios, 1, pT->GetValidityRange(), 0) != false) { delete pT; @@ -1568,7 +1566,7 @@ pT->SetName(pszName); - return enSclImportOk; + return enSclImportOk; } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -985,8 +985,8 @@ char rawname[MAX(kVstMaxProgNameLen + 1, 256)] = ""; // kVstMaxProgNameLen is 24... Dispatch(effGetProgramName, 0, 0, rawname, 0); + mpt::String::SetNullTerminator(rawname); SanitizeFilename(rawname); - mpt::String::SetNullTerminator(rawname); FileDialog dlg = SaveFileDialog() .DefaultExtension("fxb") @@ -1419,8 +1419,8 @@ void CVstPlugin::SetDryRatio(UINT param) //-------------------------------------- { - param = MIN(param, 127); - m_pMixStruct->fDryRatio = static_cast<float>(1.0-(static_cast<double>(param)/127.0)); + param = std::min(param, UINT(127)); + m_pMixStruct->fDryRatio = 1.0f - (param / 127.0f); } Modified: trunk/OpenMPT/soundlib/ITCompression.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITCompression.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/ITCompression.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -10,10 +10,11 @@ #include <stdafx.h> +#include <ostream> #include "ITCompression.h" #include "../common/misc_util.h" -#include <ostream> #include "../common/mptIO.h" +#include "ModSample.h" OPENMPT_NAMESPACE_BEGIN Modified: trunk/OpenMPT/soundlib/ITCompression.h =================================================================== --- trunk/OpenMPT/soundlib/ITCompression.h 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/ITCompression.h 2014-11-09 00:21:59 UTC (rev 4568) @@ -10,15 +10,15 @@ #pragma once +#include <vector> +#include <iosfwd> #include "Snd_defs.h" -#include <vector> -#include "ModSample.h" #include "FileReader.h" -#include <iosfwd> OPENMPT_NAMESPACE_BEGIN +struct ModSample; //================= class ITCompression @@ -34,7 +34,7 @@ protected: std::vector<int> bwt; // Bit width table uint8 *packedData; // Compressed data for current sample block - std::ostream *file; // File to which compressed data will be written (can be nullptr if you only want to find out the sample size) + std::ostream *file; // File to which compressed data will be written (can be nullptr if you only want to find out the sample size) void *sampleData; // Pre-processed sample data for currently compressed sample block const ModSample &mptSample; // Sample that is being processed size_t packedLength; // Size of currently compressed sample block Modified: trunk/OpenMPT/soundlib/Load_dmf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -48,7 +48,7 @@ idPATT = MAGIC4LE('P','A','T','T'), // Patterns idSMPI = MAGIC4LE('S','M','P','I'), // Sample headers idSMPD = MAGIC4LE('S','M','P','D'), // Sample data - idSMPJ = MAGIC4LE('S','M','P','J'), // Sample jump table (XTrakcker 32 only) + idSMPJ = MAGIC4LE('S','M','P','J'), // Sample jump table (XTracker 32 only) idENDE = MAGIC4LE('E','N','D','E'), // Last four bytes of DMF file idSETT = MAGIC4LE('S','E','T','T'), // Probably contains GUI settings }; @@ -222,7 +222,7 @@ noteBuffer = lastNote = NOTE_NONE; vibratoType = 8; tremoloType = 4; - highOffset = 0; + highOffset = 6; playDir = false; } }; Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -383,11 +383,11 @@ interpretModPlugMade = true; } else if(fileHeader.cwtv == 0x0217 && fileHeader.cmwt == 0x0200 && !memcmp(fileHeader.reserved, "\0\0\0\0", 4)) { - if(memchr(fileHeader.chnpan, 0xFF, sizeof(fileHeader.chnpan)) != NULL) + if(memchr(fileHeader.chnpan, 0xFF, sizeof(fileHeader.chnpan)) != nullptr) { // ModPlug Tracker 1.16 (semi-raped IT format) m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 16, 00, 00); - madeWithTracker = "ModPlug tracker 1.09 - 1.16"; + madeWithTracker = "ModPlug Tracker 1.09 - 1.16"; } else { // OpenMPT 1.17 disguised as this in compatible mode, @@ -400,7 +400,7 @@ { // ModPlug Tracker b3.3 - 1.09, instruments 557 bytes apart m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 09, 00, 00); - madeWithTracker = "ModPlug tracker b3.3 - 1.09"; + madeWithTracker = "ModPlug Tracker b3.3 - 1.09"; interpretModPlugMade = true; } } else // case: type == MOD_TYPE_MPT @@ -477,26 +477,17 @@ uint32 minPtr = Util::MaxValueOfType(minPtr); for(uint16 n = 0; n < fileHeader.insnum; n++) { - if(insPos[n] > 0) - { - minPtr = std::min(minPtr, insPos[n]); - } + if(insPos[n] > 0) minPtr = std::min(minPtr, insPos[n]); } for(uint16 n = 0; n < fileHeader.smpnum; n++) { - if(smpPos[n] > 0) - { - minPtr = std::min(minPtr, smpPos[n]); - } + if(smpPos[n] > 0) minPtr = std::min(minPtr, smpPos[n]); } for(uint16 n = 0; n < fileHeader.patnum; n++) { - if(patPos[n] > 0) - { - minPtr = std::min(minPtr, patPos[n]); - } + if(patPos[n] > 0) minPtr = std::min(minPtr, patPos[n]); } if(fileHeader.special & ITFileHeader::embedSongMessage) @@ -508,7 +499,7 @@ // This is only supposed to be present if bit 1 of the special flags is set. // However, old versions of Schism and probably other trackers always set this bit // even if they don't write the edit history count. So we have to filter this out... - // This is done by looking at the parapointers. If the history data end after + // This is done by looking at the parapointers. If the history data ends after // the first parapointer, we assume that it's actually no history data. if(fileHeader.special & ITFileHeader::embedEditHistory) { @@ -556,11 +547,6 @@ m_SongFlags.set(SONG_EMBEDMIDICFG); } - if(file.ReadMagic("MODU")) - { - madeWithTracker = "BeRoTracker"; - } - // Read pattern names: "PNAM" FileReader patNames; if(file.ReadMagic("PNAM")) @@ -1946,6 +1932,9 @@ } //end rewbs.modularPlugData } + } else if(!memcmp(code, "MODU", 4)) + { + madeWithTracker = "BeRoTracker"; } else if(!memcmp(code, "XTPM", 4)) { // Read too far, chicken out... Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -1069,16 +1069,16 @@ mptSmp.uFlags.reset(); if(flags & PSM16SampleHeader::smp16Bit) { - mptSmp.uFlags |= CHN_16BIT; + mptSmp.uFlags.set(CHN_16BIT); mptSmp.nLength /= 2; } if(flags & PSM16SampleHeader::smpPingPong) { - mptSmp.uFlags |= CHN_PINGPONGLOOP; + mptSmp.uFlags.set(CHN_PINGPONGLOOP); } if(flags & PSM16SampleHeader::smpLoop) { - mptSmp.uFlags |= CHN_LOOP; + mptSmp.uFlags.set(CHN_LOOP); } } Modified: trunk/OpenMPT/soundlib/Load_stm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_stm.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/Load_stm.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -123,10 +123,6 @@ struct PACKED STMPatternData { STMPatternEntry entry[64 * 4]; - void ConvertEndianness() - { - // nothing - } }; STATIC_ASSERT(sizeof(STMPatternData) == 4*64*4); @@ -204,7 +200,7 @@ { STMPatternData patternData; - if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, 64) || !file.ReadConvertEndianness(patternData)) + if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, 64) || !file.ReadStruct(patternData)) { file.Skip(sizeof(patternData)); continue; Modified: trunk/OpenMPT/soundlib/MIDIMacros.cpp =================================================================== --- trunk/OpenMPT/soundlib/MIDIMacros.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/MIDIMacros.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -476,11 +476,11 @@ } -// Remove blanks and other unwanted characters from macro strings for internal usage. +// Normalize by removing blanks and other unwanted characters from macro strings for internal usage. std::string MIDIMacroConfig::GetSafeMacro(const char *macro) const //---------------------------------------------------------------- { - std::string sanitizedMacro = std::string(macro); + std::string sanitizedMacro = macro; std::string::size_type pos; while((pos = sanitizedMacro.find_first_not_of("0123456789ABCDEFabpcnuvxyz")) != std::string::npos) Modified: trunk/OpenMPT/soundlib/ModSequence.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/ModSequence.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -264,7 +264,7 @@ //------------------------------------------------------------------------------------ { if (nPos >= m_sndFile.GetModSpecifications().ordersMax || nCount == 0) - return (nCount = 0); + return 0; const ORDERINDEX nLengthTt = GetLengthTailTrimmed(); // Limit number of orders to be inserted. LimitMax(nCount, ORDERINDEX(m_sndFile.GetModSpecifications().ordersMax - nPos)); Modified: trunk/OpenMPT/soundlib/S3MTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/S3MTools.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/S3MTools.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -97,12 +97,12 @@ smpLength = length; - flags = (mptSmp.uFlags & CHN_LOOP) ? smpLoop : 0; - if(mptSmp.uFlags & CHN_16BIT) + flags = (mptSmp.uFlags[CHN_LOOP] ? smpLoop : 0); + if(mptSmp.uFlags[CHN_16BIT]) { flags |= smp16Bit; } - if(mptSmp.uFlags & CHN_STEREO) + if(mptSmp.uFlags[CHN_STEREO]) { flags |= smpStereo; } Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -593,25 +593,29 @@ size_t SampleIO::WriteSample(FILE *f, const ModSample &sample, SmpLength maxSamples) const //---------------------------------------------------------------------------------------- { + if(!sample.HasSampleData()) return 0; + size_t len = 0, bufcount = 0; - int8 buffer8[4096]; - int16 buffer16[4096]; + union + { + int8 buffer8[4096]; + int16 buffer16[4096]; + }; const void *const pSampleVoid = sample.pSample; const int8 *const pSample8 = sample.pSample8; const int16 *const pSample16 = sample.pSample16; SmpLength numSamples = sample.nLength; if(maxSamples && numSamples > maxSamples) numSamples = maxSamples; - if(!sample.HasSampleData()) return 0; if(GetBitDepth() == 16 && GetChannelFormat() == mono && GetEndianness() == littleEndian && (GetEncoding() == signedPCM || GetEncoding() == unsignedPCM || GetEncoding() == deltaPCM)) { // 16-bit little-endian mono samples const int16 *p = pSample16; - int s_old = 0, s_ofs; + int s_old = 0; len = numSamples * 2; - s_ofs = (GetEncoding() == unsignedPCM) ? 0x8000 : 0; + const int s_ofs = (GetEncoding() == unsignedPCM) ? 0x8000 : 0; for(SmpLength j = 0; j < numSamples; j++) { int s_new = *p; @@ -644,7 +648,7 @@ (GetEncoding() == signedPCM || GetEncoding() == unsignedPCM || GetEncoding() == deltaPCM)) { // 8-bit Stereo samples (not interleaved) - int s_ofs = (GetEncoding() == unsignedPCM) ? 0x80 : 0; + const int s_ofs = (GetEncoding() == unsignedPCM) ? 0x80 : 0; for (UINT iCh=0; iCh<2; iCh++) { const int8 *p = pSample8 + iCh; @@ -678,14 +682,14 @@ (GetEncoding() == signedPCM || GetEncoding() == unsignedPCM || GetEncoding() == deltaPCM)) { // 16-bit little-endian Stereo samples (not interleaved) - int s_ofs = (GetEncoding() == unsignedPCM) ? 0x8000 : 0; + const int s_ofs = (GetEncoding() == unsignedPCM) ? 0x8000 : 0; for (UINT iCh=0; iCh<2; iCh++) { const int16 *p = pSample16 + iCh; int s_old = 0; bufcount = 0; - for (UINT j=0; j<numSamples; j++) + for (SmpLength j=0; j<numSamples; j++) { int s_new = *p; p += 2; @@ -711,7 +715,7 @@ else if((GetBitDepth() == 8 || (GetBitDepth() == 16 && GetEndianness() == littleEndian)) && GetChannelFormat() == stereoInterleaved && GetEncoding() == signedPCM) { - // Stereo signed interleaved + // Stereo signed interleaved len = sample.GetSampleSizeInBytes(); if(f) fwrite(pSampleVoid, 1, len, f); } @@ -722,7 +726,7 @@ len = numSamples * 2; for(SmpLength j = 0; j < len; j++) { - buffer8[bufcount] = (int8)(uint8)((uint8)(pSample8[j]) + 0x80); + buffer8[bufcount] = (int8)((uint8)(pSample8[j]) + 0x80); bufcount++; if(bufcount >= CountOf(buffer8)) { @@ -747,10 +751,11 @@ len = numSamples; const int8 *p = pSample8; int sinc = (sample.uFlags & CHN_16BIT) ? 2 : 1; - int s_old = 0, s_ofs = (GetEncoding() == unsignedPCM) ? 0x80 : 0; + int s_old = 0; + const int s_ofs = (GetEncoding() == unsignedPCM) ? 0x80 : 0; if (sample.uFlags & CHN_16BIT) p++; - for (UINT j=0; j<len; j++) + for (SmpLength j=0; j<len; j++) { int s_new = (int8)(*p); p += sinc; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -129,7 +129,7 @@ // Apply stereo separation factor on an interleaved stereo/quad stream. // count = Number of stereo sample pairs to process -// separation = 0...128 +// separation = -128...128 (negative values = swap L/R, 0 = mono) static void ApplyStereoSeparation(mixsample_t *mixBuf, CSoundFile::samplecount_t count, int32 separation) //------------------------------------------------------------------------------------------------------- { @@ -258,7 +258,7 @@ InterleaveFrontRear(MixSoundBuffer, MixRearBuffer, countChunk); } - if(m_MixerSettings.m_nStereoSeparation < 128 && m_MixerSettings.gnChannels >= 2) + if(m_MixerSettings.m_nStereoSeparation >= -128 && m_MixerSettings.m_nStereoSeparation < 128 && m_MixerSettings.gnChannels >= 2) { // Apply stereo separation ApplyStereoSeparation(MixSoundBuffer, count * m_MixerSettings.gnChannels / 2, m_MixerSettings.m_nStereoSeparation); Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2014-11-09 00:04:15 UTC (rev 4567) +++ trunk/OpenMPT/soundlib/Tables.cpp 2014-11-09 00:21:59 UTC (rev 4568) @@ -324,7 +324,7 @@ }; -const uint16 ProTrackerTunedPeriods[16*12] = +const uint16 ProTrackerTunedPeriods[16*12] = { 1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907, 1700,1604,1514,1430,1348,1274,1202,1134,1070,1010,954,900, @@ -341,7 +341,7 @@ 1762,1664,1570,1482,1398,1320,1246,1176,1110,1048,988,934, 1750,1652,1558,1472,1388,1310,1238,1168,1102,1040,982,926, 1736,1640,1548,1460,1378,1302,1228,1160,1094,1032,974,920, - 1724,1628,1536,1450,1368,1292,1220,1150,1086,1026,968,914 + 1724,1628,1536,1450,1368,1292,1220,1150,1086,1026,968,914 }; // Table for Invert Loop and Funk Repeat effects (EFx, .MOD only) @@ -349,10 +349,10 @@ { 0, 5, 6, 7, 8, 10, 11, 13, 16, 19, 22, 26, 32, 43, 64, 128 -}; +}; // S3M C-4 periods -const uint16 FreqS3MTable[16] = +const uint16 FreqS3MTable[16] = { 1712,1616,1524,1440,1356,1280, 1208,1140,1076,1016,960,907, @@ -360,7 +360,7 @@ }; // S3M FineTune frequencies -const uint16 S3MFineTuneTable[16] = +const uint16 S3MFineTuneTable[16] = { 7895,7941,7985,8046,8107,8169,8232,8280, 8363,8413,8463,8529,8581,8651,8723,8757, // 8363*2^((i-8)/(12*8)) @@ -449,7 +449,7 @@ -const uint16 XMPeriodTable[104] = +const uint16 XMPeriodTable[104] = { 907,900,894,887,881,875,868,862,856,850,844,838,832,826,820,814, 808,802,796,791,785,779,774,768,762,757,752,746,741,736,730,725, @@ -464,7 +464,7 @@ // floor(8363 * 64 * 2**(-n/768)) // 768 = 64 period steps for 12 notes // Table is for highest possible octave -const uint32 XMLinearTable[768] = +const uint32 XMLinearTable[768] = { 535232,534749,534266,533784,533303,532822,532341,531861, 531381,530902,530423,529944,529466,528988,528511,528034, @@ -561,11 +561,11 @@ 275457,275209,274960,274712,274465,274217,273970,273722, 273476,273229,272982,272736,272490,272244,271999,271753, 271508,271263,271018,270774,270530,270286,270042,269798, - 269555,269312,269069,268826,268583,268341,268099,267857 + 269555,269312,269069,268826,268583,268341,268099,267857 }; -const int8 ft2VibratoTable[256] = +const int8 ft2VibratoTable[256] = { 0,-2,-3,-5,-6,-8,-9,-11,-12,-14,-16,-17,-19,-20,-22,-23, -24,-26,-27,-29,-30,-32,-33,-34,-36,-37,-38,-39,-41,-42, @@ -582,7 +582,7 @@ 63,63,64,64,64,64,64,64,64,64,64,64,64,63,63,63,62,62, 62,61,61,60,60,59,59,58,57,56,56,55,54,53,52,51,50,49, 48,47,46,45,44,43,42,41,39,38,37,36,34,33,32,30,29,27, - 26,24,23,22,20,19,17,16,14,12,11,9,8,6,5,3,2 + 26,24,23,22,20,19,17,16,14,12,11,9,8,6,5,3,2 }; @@ -616,38 +616,38 @@ // Table content is in 16.16 format const uint32 LinearSlideUpTable[256] = { - 65536, 65773, 66010, 66249, 66489, 66729, 66971, 67213, - 67456, 67700, 67945, 68190, 68437, 68685, 68933, 69182, - 69432, 69684, 69936, 70189, 70442, 70697, 70953, 71209, - 71467, 71725, 71985, 72245, 72507, 72769, 73032, 73296, - 73561, 73827, 74094, 74362, 74631, 74901, 75172, 75444, - 75717, 75991, 76265, 76541, 76818, 77096, 77375, 77655, - 77935, 78217, 78500, 78784, 79069, 79355, 79642, 79930, - 80219, 80509, 80800, 81093, 81386, 81680, 81976, 82272, - 82570, 82868, 83168, 83469, 83771, 84074, 84378, 84683, - 84989, 85297, 85605, 85915, 86225, 86537, 86850, 87164, - 87480, 87796, 88113, 88432, 88752, 89073, 89395, 89718, - 90043, 90369, 90695, 91023, 91353, 91683, 92015, 92347, - 92681, 93017, 93353, 93691, 94029, 94370, 94711, 95053, - 95397, 95742, 96088, 96436, 96785, 97135, 97486, 97839, - 98193, 98548, 98904, 99262, 99621, 99981, 100343, 100706, - 101070, 101435, 101802, 102170, 102540, 102911, 103283, 103657, - 104031, 104408, 104785, 105164, 105545, 105926, 106309, 106694, - 107080, 107467, 107856, 108246, 108637, 109030, 109425, 109820, - 110217, 110616, 111016, 111418, 111821, 112225, 112631, 113038, - 113447, 113857, 114269, 114682, 115097, 115514, 115931, 116351, - 116771, 117194, 117618, 118043, 118470, 118898, 119328, 119760, - 120193, 120628, 121064, 121502, 121941, 122382, 122825, 123269, - 123715, 124162, 124611, 125062, 125514, 125968, 126424, 126881, - 127340, 127801, 128263, 128727, 129192, 129660, 130129, 130599, - 131072, 131546, 132021, 132499, 132978, 133459, 133942, 134426, - 134912, 135400, 135890, 136381, 136875, 137370, 137866, 138365, - 138865, 139368, 139872, 140378, 140885, 141395, 141906, 142419, - 142935, 143451, 143970, 144491, 145014, 145538, 146064, 146593, - 147123, 147655, 148189, 148725, 149263, 149803, 150344, 150888, - 151434, 151982, 152531, 153083, 153637, 154192, 154750, 155310, - 155871, 156435, 157001, 157569, 158138, 158710, 159284, 159860, - 160439, 161019, 161601, 162186, 162772, 163361, 163952, 164545, + 65536, 65773, 66010, 66249, 66489, 66729, 66971, 67213, + 67456, 67700, 67945, 68190, 68437, 68685, 68933, 69182, + 69432, 69684, 69936, 70189, 70442, 70697, 70953, 71209, + 71467, 71725, 71985, 72245, 72507, 72769, 73032, 73296, + 73561, 73827, 74094, 74362, 74631, 74901, 75172, 75444, + 75717, 75991, 76265, 76541, 76818, 77096, 77375, 77655, + 77935, 78217, 78500, 78784, 79069, 79355, 79642, 79930, + 80219, 80509, 80800, 81093, 81386, 81680, 81976, 82272, + 82570, 82868, 83168, 83469, 83771, 84074, 84378, 84683, + 84989, 85297, 85605, 85915, 86225, 86537, 86850, 87164, + 87480, 87796, 88113, 88432, 88752, 89073, 89395, 89718, + 90043, 90369, 90695, 91023, 91353, 91683, 92015, 92347, + 92681, 93017, 93353, 93691, 94029, 94370, 94711, 95053, + 95397, 95742, 96088, 96436, 96785, 97135, 97486, 97839, + 98193, 98548, 98904, 99262, 99621, 99981, 100343, 100706, + 101070, 101435, 101802, 102170, 102540, 102911, 103283, 103657, + 104031, 104408, 104785, 105164, 105545, 105926, 106309, 106694, + 107080, 107467, 107856, 108246, 108637, 109030, 109425, 109820, + 110217, 110616, 111016, 111418, 111821, 112225, 112631, 113038, + 113447, 113857, 114269, 114682, 115097, 115514, 115931, 116351, + 116771, 117194, 117618, 118043, 118470, 118898, 119328, 119760, + 120193, 120628, 121064, 121502, 121941, 122382, 122825, 123269, + 123715, 124162, 124611, 125062, 125514, 125968, 126424, 126881, + 127340, 127801, 128263, 128727, 129192, 129660, 130129, 130599, + 131072, 131546, 132021, 132499, 132978, 133459, 133942, 134426, + 134912, 135400, 135890, 136381, 136875, 137370, 137866, 138365, + 138865, 139368, 139872, 140378, 140885, 141395, 141906, 142419, + 142935, 143451, 143970, 144491, 145014, 145538, 146064, 146593, + 147123, 147655, 148189, 148725, 149263, 149803, 150344, 150888, + 151434, 151982, 152531, 153083, 153637, 154192, 154750, 155310, + 155871, 156435, 157001, 157569, 158138, 158710, 159284, 159860, + 160439, 161019, 161601, 162186, 162772, 163361, 163952, 164545, }; @@ -656,38 +656,38 @@ // Table content is in 16.16 format const uint32 LinearSlideDownTable[256] = { - 65536, 65299, 65064, 64830, 64596, 64363, 64131, 63900, - 63670, 63440, 63212, 62984, 62757, 62531, 62305, 62081, - 61857, 61634, 61412, 61191, 60970, 60751, 60532, 60314, - 60096, 59880, 59664, 59449, 59235, 59021, 58809, 58597, - 58385, 58175, 57965, 57757, 57548, 57341, 57134, 56928, - 56723, 56519, 56315, 56112, 55910, 55709, 55508, 55308, - 55108, 54910, 54712, 54515, 54318, 54123, 53928, 53733, - 53540, 53347, 53154, 52963, 52772, 52582, 52392, 52204, - 52015, 51828, 51641, 51455, 51270, 51085, 50901, 50717, - 50535, 50353, 50171, 49990, 49810, 49631, 49452, 49274, - 49096, 48919, 48743, 48567, 48392, 48218, 48044, 47871, - 47698, 47526, 47355, 47185, 47014, 46845, 46676, 46508, - 46340, 46173, 46007, 45841, 45676, 45511, 45347, 45184, - 45021, 44859, 44697, 44536, 44376, 44216, 44056, 43898, - 43740, 43582, 43425, 43268, 43112, 42957, 42802, 42648, - 42494, 42341, 42189, 42037, 41885, 41734, 41584, 41434, - 41285, 41136, 40988, 40840, 40693, 40546, 40400, 40254, - 40109, 39965, 39821, 39677, 39534, 39392, 39250, 39108, - 38967, 38827, 38687, 38548, 38409, 38270, 38132, 37995, - 37858, 37722, 37586, 37450, 37315, 37181, 37047, 36913, - 36780, 36648, 36516, 36384, 36253, 36122, 35992, 35862, - 35733, 35604, 35476, 35348, 35221, 35094, 34968, 34842, - 34716, 34591, 34466, 34342, 34218, 34095, 33972, 33850, - 33728, 33606, 33485, 33364, 33244, 33124, 33005, 32886, - 32768, 32649, 32532, 32415, 32298, 32181, 32065, 31950, - 31835, 31720, 31606, 31492, 31378, 31265, 31152, 31040, - 30928, 30817, 30706, 30595, 30485, 30375, 30266, 30157, - 30048, 29940, 29832, 29724, 29617, 29510, 29404, 29298, - 29192, 29087, 28982, 28878, 28774, 28670, 28567, 28464, - 28361, 28259, 28157, 28056, 27955, 27854, 27754, 27654, - 27554, 27455, 27356, 27257, 27159, 27061, 26964, 26866, - 26770, 26673, 26577, 26481, 26386, 26291, 26196, 26102, + 65536, 65299, 65064, 64830, 64596, 64363, 64131, 63900, + 63670, 63440, 63212, 62984, 62757, 62531, 62305, 62081, + 61857, 61634, 61412, 61191, 60970, 60751, 60532, 60314, + 60096, 59880, 59664, 59449, 59235, 59021, 58809, 58597, + 58385, 58175, 57965, 57757, 57548, 57341, 57134, 56928, + 56723, 56519, 56315, 56112, 55910, 55709, 55508, 55308, + 55108, 54910, 54712, 54515, 54318, 54123, 53928, 53733, + 53540, 53347, 53154, 52963, 52772, 52582, 52392, 52204, + 52015, 51828, 51641, 51455, 51270, 51085, 50901, 50717, + 50535, 50353, 50171, 49990, 49810, 49631, 49452, 49274, + 49096, 48919, 48743, 48567, 48392, 48218, 48044, 47871, + 47698, 47526, 47355, 47185, 47014, 46845, 46676, 46508, + 46340, 46173, 46007, 45841, 45676, 45511, 45347, 45184, + 45021, 44859, 44697, 44536, 44376, 44216, 44056, 43898, + 43740, 43582, 43425, 43268, 43112, 42957, 42802, 42648, + 42494, 42341, 42189, 42037, 41885, 41734, 41584, 41434, + 41285, 41136, 40988, 40840, 40693, 40546, 40400, 40254, + 40109, 39965, 39821, 39677, 39534, 39392, 39250, 39108, + 38967, 38827, 38687, 38548, 38409, 38270, 38132, 37995, + 37858, 37722, 37586, 37450, 37315, 37181, 37047, 36913, + 36780, 36648, 36516, 36384, 36253, 36122, 35992, 35862, + 35733, 35604, 35476, 35348, 35221, 35094, 34968, 34842, + 34716, 34591, 34466, 34342, 34218, 34095, 33972, 33850, + 33728, 33606, 33485, 33364, 33244, 33124, 33005, 32886, + 32768, 32649, 32532, 32415, 32298, 32181, 32065, 31950, + 31835, 31720, 31606, 31492, 31378, 31265, 31152, 31040, + 30928, 30817, 30706, 30595, 30485, 30375, 30266, 30157, + 30048, 29940, 29832, 29724, 29617, 29510, 29404, 29298, + 29192, 29087, 28982, 28878, 28774, 28670, 28567, 28464, + 28361, 28259, 28157, 28056, 27955, 27854, 27754, 27654, + 27554, 27455, 27356, 27257, 27159, 27061, 26964, 26866, + 26770, 26673, 26577, 26481, 26386, 26291, 26196, 26102, }; @@ -755,70 +755,70 @@ // Reversed sinc coefficients for 4x256 taps polyphase FIR resampling filter (SchismTracker's lutgen.c should generate a very similar table, but it's more precise) const int16 CResampler::FastSincTable[256*4] = { // Cubic Spline - 0, 16384, 0, 0, -31, 16383, 32, 0, -63, 16381, 65, 0, -93, 16378, 100, -1, - -124, 16374, 135, -1, -153, 16368, 172, -3, -183, 16361, 209, -4, -211, 16353, 247, -5, - -240, 16344, 287, -7, -268, 16334, 327, -9, -295, 16322, 368, -12, -322, 16310, 410, -14, - -348, 16296, 453, -17, -374, 16281, 497, -20, -400, 16265, 541, -23, -425, 16248, 587, -26, - -450, 16230, 634, -30, -474, 16210, 681, -33, -497, 16190, 729, -37, -521, 16168, 778, -41, - -543, 16145, 828, -46, -566, 16121, 878, -50, -588, 16097, 930, -55, -609, 16071, 982, -60, - -630, 16044, 1035, -65, -651, 16016, 1089, -70, -671, 15987, 1144, -75, -691, 15957, 1199, -81, - -710, 15926, 1255, -87, -729, 15894, 1312, -93, -748, 15861, 1370, -99, -766, 15827, 1428, -105, - -784, 15792, 1488, -112, -801, 15756, 1547, -118, -818, 15719, 1608, -125, -834, 15681, 1669, -132, - -850, 15642, 1731, -139, -866, 15602, 1794, -146, -881, 15561, 1857, -153, -896, 15520, 1921, -161, - -911, 15477, 1986, -168, -925, 15434, 2051, -176, -939, 15390, 2117, -184, -952, 15344, 2184, -192, - -965, 15298, 2251, -200, -978, 15251, 2319, -208, -990, 15204, 2387, -216, -1002, 15155, 2456, -225, --1014, 15106, 2526, -234, -1025, 15055, 2596, -242, -1036, 15004, 2666, -251, -1046, 14952, 2738, -260, --1056, 14899, 2810, -269, -1066, 14846, 2882, -278, -1075, 14792, 2955, -287, -1084, 14737, 3028, -296, --1093, 14681, 3102, -306, -1102, 14624, 3177, -315, -1110, 14567, 3252, -325, -1118, 14509, 3327, -334, --1125, 14450, 3403, -344, -1132, 14390, 3480, -354, -1139, 14330, 3556, -364, -1145, 14269, 3634, -374, --1152, 14208, 3712, -384, -1157, 14145, 3790, -394, -1163, 14082, 3868, -404, -1168, 14018, 3947, -414, --1173, 13954, 4027, -424, -1178, 13889, 4107, -434, -1182, 13823, 4187, -445, -1186, 13757, 4268, -455, --1190, 13690, 4349, -465, -1193, 13623, 4430, -476, -1196, 13555, 4512, -486, -1199, 13486, 4594, -497, --1202, 13417, 4676, -507, -1204, 13347, 4759, -518, -1206, 13276, 4842, -528, -1208, 13205, 4926, -539, --1210, 13134, 5010, -550, -1211, 13061, 5094, -560, -1212, 12989, 5178, -571, -1212, 12915, 5262, -581, --1213, 12842, 5347, -592, -1213, 12767, 5432, -603, -1213, 12693, 5518, -613, -1213, 12617, 5603, -624, --1212, 12542, 5689, -635, -1211, 12466, 5775, -645, -1210, 12389, 5862, -656, -1209, 12312, 5948, -667, --1208, 12234, 6035, -677, -1206, 12156, 6122, -688, -1204, 12078, 6209, -698, -1202, 11999, 6296, -709, --1200, 11920, 6384, -720, -1197, 11840, 6471, -730, -1194, 11760, 6559, -740, -1191, 11679, 6647, -751, --1188, 11598, 6735, -761, -1184, 11517, 6823, -772, -1181, 11436, 6911, -782, -1177, 11354, 6999, -792, --1173, 11271, 7088, -802, -1168, 11189, 7176, -812, -1164, 11106, 7265, -822, -1159, 11022, 7354, -832, --1155, 10939, 7442, -842, -1150, 10855, 7531, -852, -1144, 10771, 7620, -862, -1139, 10686, 7709, -872, --1134, 10602, 7798, -882, -1128, 10516, 7886, -891, -1122, 10431, 7975, -901, -1116, 10346, 8064, -910, --1110, 10260, 8153, -919, -1103, 10174, 8242, -929, -1097, 10088, 8331, -938, -1090, 10001, 8420, -947, --1083, 9915, 8508, -956, -1076, 9828, 8597, -965, -1069, 9741, 8686, -973, -1062, 9654, 8774, -982, --1054, 9566, 8863, -991, -1047, 9479, 8951, -999, -1039, 9391, 9039, -1007, -1031, 9303, 9127, -1015, --1024, 9216, 9216, -1024, -1015, 9127, 9303, -1031, -1007, 9039, 9391, -1039, -999, 8951, 9479, -1047, - -991, 8863, 9566, -1054, -982, 8774, 9654, -1062, -973, 8686, 9741, -1069, -965, 8597, 9828, -1076, - -956, 8508, 9915, -1083, -947, 8420, 10001, -1090, -938, 8331, 10088, -1097, -929, 8242, 10174, -1103, - -919, 8153, 10260, -1110, -910, 8064, 10346, -1116, -901, 7975, 10431, -1122, -891, 7886, 10516, -1128, - -882, 7798, 10602, -1134, -872, 7709, 10686, -1139, -862, 7620, 10771, -1144, -852, 7531, 10855, -1150, - -842, 7442, 10939, -1155, -832, 7354, 11022, -1159, -822, 7265, 11106, -1164, -812, 7176, 11189, -1168, - -802, 7088, 11271, -1173, -792, 6999, 11354, -1177, -782, 6911, 11436, -1181, -772, 6823, 11517, -1184, - -761, 6735, 11598, -1188, -751, 6647, 11679, -1191, -740, 6559, 11760, -1194, -730, 6471, 11840, -1197, - -720, 6384, 11920, -1200, -709, 6296, 11999, -1202, -698, 6209, 12078, -1204, -688, 6122, 12156, -1206, - -677, 6035, 12234, -1208, -667, 5948, 12312, -1209, -656, 5862, 12389, -1210, -645, 5775, 12466, -1211, - -635, 5689, 12542, -1212, -624, 5603, 12617, -1213, -613, 5518, 12693, -1213, -603, 5432, 12767, -1213, - -592, 5347, 12842, -1213, -581, 5262, 12915, -1212, -571, 5178, 12989, -1212, -560, 5094, 13061, -1211, - -550, 5010, 13134, -1210, -539, 4926, 13205, -1208, -528, 4842, 13276, -1206, -518, 4759, 13347, -1204, - -507, 4676, 13417, -1202, -497, 4594, 13486, -1199, -486, 4512, 13555, -1196, -476, 4430, 13623, -1193, - -465, 4349, 13690, -1190, -455, 4268, 13757, -1186, -445, 4187, 13823, -1182, -434, 4107, 13889, -1178, - -424, 4027, 13954, -1173, -414, 3947, 14018, -1168, -404, 3868, 14082, -1163, -394, 3790, 14145, -1157, - -384, 3712, 14208, -1152, -374, 3634, 14269, -1145, -364, 3556, 14330, -1139, -354, 3480, 14390, -1132, - -344, 3403, 14450, -1125, -334, 3327, 14509, -1118, -325, 3252, 14567, -1110, -315, 3177, 14624, -1102, - -306, 3102, 14681, -1093, -296, 3028, 14737, -1084, -287, 2955, 14792, -1075, -278, 2882, 14846, -1066, - -269, 2810, 14899, -1056, -260, 2738, 14952, -1046, -251, 2666, 15004, -1036, -242, 2596, 15055, -1025, - -234, 2526, 15106, -1014, -225, 2456, 15155, -1002, -216, 2387, 15204, -990, -208, 2319, 15251, -978, - -200, 2251, 15298, -965, -192, 2184, 15344, -952, -184, 2117, 15390, -939, -176, 2051, 15434, -925, - -168, 1986, 15477, -911, -161, 1921, 15520, -896, -153, 1857, 15561, -881, -146, 1794, 15602, -866, - -139, 1731, 15642, -850, -132, 1669, 15681, -834, -125, 1608, 15719, -818, -118, 1547, 15756, -801, - -112, 1488, 15792, -784, -105, 1428, 15827, -766, -99, 1370, 15861, -748, -93, 1312, 15894, -729, - -87, 1255, 15926, -710, -81, 1199, 15957, -691, -75, 1144, 15987, -671, -70, 1089, 16016, -651, - -65, 1035, 16044, -630, -60, 982, 16071, -609, -55, 930, 16097, -588, -50, 878, 16121, -566, - -46, 828, 16145, -543, -41, 778, 16168, -521, -37, 729, 16190, -497, -33, 681, 16210, -474, - -30, 634, 16230, -450, -26, 587, 16248, -425, -23, 541, 16265, -400, -20, 497, 16281, -374, - -17, 453, 16296, -348, -14, 410, 16310, -322, -12, 368, 16322, -295, -9, 327, 16334, -268, - -7, 287, 16344, -240, -5, 247, 16353, -211, -4, 209, 16361, -183, -3, 172, 16368, -153, - -1, 135, 16374, -124, -1, 100, 16378, -93, 0, 65, 16381, -63, 0, 32, 16383, -31, + 0, 16384, 0, 0, -31, 16383, 32, 0, -63, 16381, 65, 0, -93, 16378, 100, -1, + -124, 16374, 135, -1, -153, 16368, 172, -3, -183, 16361, 209, -4, -211, 16353, 247, -5, + -240, 16344, 287, -7, -268, 16334, 327, -9, -295, 16322, 368, -12, -322, 16310, 410, -14, + -348, 16296, 453, -17, -374, 16281, 497, -20, -400, 16265, 541, -23, -425, 16248, 587, -26, + -450, 16230, 634, -30, -474, 16210, 681, -33, -497, 16190, 729, -37, -521, 16168, 778, -41, + -543, 16145, 828, -46, -566, 16121, 878, -50, -588, 16097, 930, -55, -609, 16071, 982, -60, + -630, 16044, 1035, -65, -651, 16016, 1089, -70, -671, 15987, 1144, -75, -691, 15957, 1199, -81, + -710, 15926, 1255, -87, -729, 15894, 1312, -93, -748, 15861, 1370, -99, -766, 15827, 1428, -105, + -784, 15792, 1488, -112, -801, 15756, 1547, -118, -818, 15719, 1608, -125, -834, 15681, 1669, -132, + -850, 15642, 1731, -139, -866, 15602, 1794, -146, -881, 15561, 1857, -153, -896, 15520, 1921, -161, + -911, 15477, 1986, -168, -925, 15434, 2051, -176, -939, 15390, 2117, -184, -952, 15344, 2184, -192, + -965, 15298, 2251, -200, -978, 15251, 2319, -208, -990, 15204, 2387, -216, -1002, 15155, 2456, -225, +-1014, 15106, 2526, -234, -1025, 15055, 2596, -242, -1036, 15004, 2666, -251, -1046, 14952, 2738, -260, +-1056, 14899, 2810, -269, -1066, 14846, 2882, -278, -1075, 14792, 2955, -287, -1084, 14737, 3028, -296, +-1093, 14681, 3102, -306, -1102, 14624, 3177, -315, -1110, 14567, 3252, -325, -1118, 14509, 3327, -334, +-1125, 14450, 3403, -344, -1132, 14390, 3480, -354, -1139, 14330, 3556, -364, -1145, 14269, 3634, -374, +-1152, 14208, 3712, -384, -1157, 14145, 3790, -394, -1163, 14082, 3868, -404, -1168, 14018, 3947, -414, +-1173, 13954, 4027, -424, -1178, 13889, 4107, -434, -1182, 13823, 4187, -445, -1186, 13757, 4268, -455, +-1190, 13690, 4349, -465, -1193, 13623, 4430, -476, -1196, 13555, 4512, -486, -1199, 13486, 4594, -497, +-1202, 13417, 4676, -507, -1204, 13347, 4759, -518, -1206, 13276, 4842, -528, -1208, 13205, 4926, -539, +-1210, 13134, 5010, -550, -1211, 13061, 5094, -560, -1212, 12989, 5178, -571, -1212, 12915, 5262, -581, +-1213, 12842, 5347, -592, -1213, 12767, 5432, -603, -1213, 12693, 5518, -613, -1213, 12617, 5603, -624, +-1212, 12542, 5689, -635, -1211, 12466, 5775, -645, -1210, 12389, 5862, -656, -1209, 12312, 5948, -667, +-1208, 12234, 6035, -677, -1206, 12156, 6122, -688, -1204, 12078, 6209, -698, -1202, 11999, 6296, -709, +-1200, 11920, 6384, -720, -1197, 11840, 6471, -730, -1194, 11760, 6559, -740, -1191, 11679, 6647, -751, +-1188, 11598, 6735, -761, -1184, 11517, 6823, -772, -1181, 11436, 6911, -782, -1177, 11354, 6999, -792, +-1173, 11271, 7088, -802, -1168, 11189, 7176, -812, -1164, 11106, 7265, -822, -1159, 11022, 7354, -832, +-1155, 10939, 7442, -842, -1150, 10855, 7531, -852, -1144, 10771, 7620, -862, -1139, 10686, 7709, -872, +-1134, 10602, 7798, -882, -1128, 10516, 7886, -891, -1122, 10431, 7975, -901, -1116, 10346, 8064, -910, +-1110, 10260, 8153, -919, -1103, 10174, 8242, -929, -1097, 10088, 8331, -938, -1090, 10001, 8420, -947, +-1083, 9915, 8508, -956, -1076, 9828, 8597, -965, -1069, 9741, 8686, -973, -1062, 9654, 8774, -982, +-1054, 9566, 8863, -991, -1047, 9479, 8951, -999, -1039, 9391, 9039, -1007, -1031, 9303, 9127, -1015, +-1024, 9216, 9216, -1024, -1015, 9127, 9303, -1031, -1007, 9039, 9391, -1039, -999, 8951, 9479, -1047, + -991, 8863, 9566, -1054, -982, 8774, 9654, -1062, -973, 8686, 9741, -1069, -965, 8597, 9828, -1076, + -956, 8508, 9915, -1083, -947, 8420, 10001, -1090, -938, 8331, 10088, -1097, -929, 8242, 10174, -1103, + -919, 8153, 10260, -1110, -910, 8064, 10346, -1116, -901, 7975, 10431, -1122, -891, 7886, 10516, -1128, + -882, 7798, 10602, -1134, -872, 7709, 10686, -1139, -862, 7620, 10771, -1144, -852, 7531, 10855, -1150, + -842, 7442, 10939, -1155, -832, 7354, 11022, -1159, -822, 7265, 11106, -1164, -812, 7176, 11189, -1168, + -802, 7088, 11271, -1173, -792, 6999, 11354, -1177, -782, 6911, 11436, -1181, -772, 6823, 11517, -1184, + -761, 6735, 11598, -1188, -751, 6647, 11679, -1191, -740, 6559, 11760, -1194, -730, 6471, 11840, -1197, + -720, 6384, 11920, -1200, -709, 6296, 11999, -1202, -698, 6209, 12078, -1204, -688, 6122, 12156, -1206, + -677, 6035, 12234, -1208, -667, 5948, 12312, -1209, -656, 5862, 12389, -1210, -645, 5775, 12466, -1211, + -635, 5689, 12542, -1212, -624, 5603, 12617, -1213, -613, 5518, 12693, -1213, -603, 5432, 12767, -1213, + -592, 5347, 12842, -1213, -581, 5262, 12915, -1212, -571, 5178, 12989, -1212, -560, 5094, 13061, -1211, + -550, 5010, 13134, -1210, -539, 4926, 13205, -1208, -528, 4842, 13276, -1206, -518, 4759, 13347, -1204, + -507, 4676, 13417, -1202, -497, 4594, 13486, -1199, -486, 4512, 13555, -1196, -476, 4430, 13623, -1193, + -465, 4349, 13690, -1190, -455, 4268, 13757, -1186, -445, 4187, 13823, -1182, -434, 4107, 13889, -1178, + -424, 4027, 13954, -1173, -414, 3947, 14018, -1168, -404, 3868, 14082, -1163, -394, 3790, 14145, -1157, + -384, 3712, 14208, -1152, -374, 3634, 14269, -1145, -364, 3556, 14330, -1139, -354, 3480, 14390, -1132, + -344, 3403, 14450, -1125, -334, 3327, 14509, -1118, -325, 3252, 14567, -1110, -315, 3177, 14624, -1102, + -306, 3102, 14681, -1093, -296, 3028, 14737, -1084, -287, 2955, 14792, -1075, -278, 2882, 14846, -1066, + -269, 2810, 14899, -1056, -260, 2738, 14952, -1046, -251, 2666, 15004, -1036, -242, 2596, 15055, -1025, + -234, 2526, 15106, -1014, -225, 2456, 15155, -1002, -216, 2387, 15204, -990, -208, 2319, 15251, -978, + -200, 2251, 15298, -965, -192, 2184, 15344, -952, -184, 2117, 15390, -939, -176, 2051, 15434, -925, + -168, 1986, 15477, -911, -161, 1921, 15520, -896, -153, 1857, 15561, -881, -146, 1794, 15602, -866, + -139, 1731, 15642, -850, -132, 1669, 15681, -834, -125, 1608, 15719, -818, -118, 1547, 15756, -801, + -112, 1488, 15792, -784, -105, 1428, 15827, -766, -99, 1370, 15861, -748, -93, 1312, 15894, -729, + -87, 1255, 15926, -710, -81, 1199, 15957, -691, -75, 1144, 15987, -671, -70, 1089, 16016, -651, + -65, 1035, 16044, -630, -60, 982, 16071, -609, -55, 930, 16097, -588, -50, 878, 16121, -566, + -46, 828, 16145, -543, -41, 778, 16168, -521, -37, 729, 16190, -497, -33, 681, 16210, -474, + -30, 634, 16230, -450, -26, 587, 16248, -425, -23, 541, 16265, -400, -20, 497, 16281, -374, + -17, 453, 16296, -348, -14, 410, 16310, -322, -12, 368, 16322, -295, -9, 327, 16334, -268, + -7, 287, 16344, -240, -5, 247, 16353, -211, -4, 209, 16361, -183, -3, 172, 16368, -153, + -1, 135, 16374, -124, -1, 100, 16378, -93, 0, 65, 16381, -63, 0, 32, 16383, -31, }; Modified: trunk/OpenM... [truncated message content] |
From: <sag...@us...> - 2014-11-09 00:24:41
|
Revision: 4569 http://sourceforge.net/p/modplug/code/4569 Author: saga-games Date: 2014-11-09 00:24:35 +0000 (Sun, 09 Nov 2014) Log Message: ----------- [Fix] Instrument tab: When loading an instrument, force all sample views to be updated completely. [Mod] Export dialog: Only show the slow render warning once per session. [Mod] Plugin bridge: Be a bit more verbose when something bad happens during loading. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-11-09 00:21:59 UTC (rev 4568) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-11-09 00:24:35 UTC (rev 4569) @@ -1464,7 +1464,7 @@ } SetCurrentInstrument(m_nInstrument); - SetModified(HINT_INSTRUMENT | HINT_ENVELOPE | HINT_INSNAMES | HINT_SMPNAMES, true); + SetModified(HINT_INSTRUMENT | HINT_ENVELOPE | HINT_INSNAMES | HINT_SMPNAMES | HINT_SAMPLEINFO | HINT_SAMPLEDATA, true); } else bOk = FALSE; } if (bFirst) m_modDoc.UpdateAllViews(NULL, HINT_MODTYPE | HINT_INSNAMES | HINT_SMPNAMES); @@ -2100,7 +2100,7 @@ { // No plugin in this slot yet: Ask user to add one. #ifndef NO_VST - CSelectPluginDlg dlg(&m_modDoc, nPlug - 1, this); + CSelectPluginDlg dlg(&m_modDoc, nPlug - 1, this); if (dlg.DoModal() == IDOK) { if(m_sndFile.GetModSpecifications().supportsPlugins) @@ -2116,7 +2116,7 @@ if(plugin.pMixPlugin != nullptr) { - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_INSVIEWPLG), true); + GetDlgItem(IDC_INSVIEWPLG)->EnableWindow(true); if(active && plugin.pMixPlugin->isInstrument()) { @@ -2179,12 +2179,13 @@ } } -// -> CODE#0027 -// -> DESC="per-instrument volume ramping setup (refered as attack)" + void CCtrlInstruments::OnAttackChanged() +//-------------------------------------- { ModInstrument *pIns = m_sndFile.Instruments[m_nInstrument]; - if(!IsLocked() && pIns){ + if(!IsLocked() && pIns) + { int n = GetDlgItemInt(IDC_EDIT2); if(n < 0) n = 0; if(n > MAX_ATTACK_VALUE) n = MAX_ATTACK_VALUE; @@ -2203,7 +2204,6 @@ UnlockControls(); } } -// -! NEW_FEATURE#0027 void CCtrlInstruments::OnPPCChanged() @@ -2414,9 +2414,9 @@ } // Update channels - if (filterChanger == true) + if (filterChanger) { - for (UINT i=0; i<MAX_CHANNELS; i++) + for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { if (m_sndFile.m_PlayState.Chn[i].pModInstrument == pIns) { @@ -2819,8 +2819,7 @@ void CCtrlInstruments::BuildTuningComboBox() //------------------------------------------ { - while(m_ComboTuning.GetCount() > 0) - m_ComboTuning.DeleteString(0); + m_ComboTuning.ResetContent(); m_ComboTuning.AddString("OMPT IT behavior"); //<-> Instrument pTuning pointer == NULL for(size_t i = 0; i<CSoundFile::GetBuiltInTunings().GetNumTunings(); i++) Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-11-09 00:21:59 UTC (rev 4568) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-11-09 00:24:35 UTC (rev 4569) @@ -676,12 +676,14 @@ m_bGivePlugsIdleTime = IsDlgButtonChecked(IDC_GIVEPLUGSIDLETIME) != BST_UNCHECKED; if (m_bGivePlugsIdleTime) { - if (Reporting::Confirm("You only need slow render if you are experiencing dropped notes with a Kontakt based sampler with Direct-From-Disk enabled.\nIt will make rendering *very* slow.\n\nAre you sure you want to enable slow render?", + static bool showWarning = true; + if(showWarning && Reporting::Confirm("You only need slow render if you are experiencing dropped notes with a Kontakt based sampler with Direct-From-Disk enabled, or buggy plugins that use the system time for parameter automation.\nIt will make rendering *very* slow.\n\nAre you sure you want to enable slow render?", "Really enable slow render?") == cnfNo) { CheckDlgButton(IDC_GIVEPLUGSIDLETIME, BST_UNCHECKED); return; } + showWarning = false; } m_bChannelMode = IsDlgButtonChecked(IDC_CHECK4) != BST_UNCHECKED; Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-11-09 00:21:59 UTC (rev 4568) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-11-09 00:24:35 UTC (rev 4569) @@ -148,7 +148,7 @@ HKEY hkEnum; WCHAR keyname[128]; - LONG cr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\classes\\DirectShow\\MediaObjects\\Categories\\f3602b3f-0592-48df-a4cd-674721e7ebeb", 0, KEY_READ, &hkEnum); + LONG cr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("software\\classes\\DirectShow\\MediaObjects\\Categories\\f3602b3f-0592-48df-a4cd-674721e7ebeb"), 0, KEY_READ, &hkEnum); DWORD index = 0; while (cr == ERROR_SUCCESS) { @@ -223,7 +223,9 @@ // If there was some error, don't try normal loading as well... unless the user really wants it. if(isNative) { - if(Reporting::Confirm((std::string(e.what()) + "\n\nDo you want to try to load the plugin natively?").c_str(), "OpenMPT Plugin Bridge", false, true) == cnfNo) + const std::wstring msg = L"The following error occured while trying to load\n" + plugin.dllPath.ToWide() + L"\n\n" + mpt::ToWide(mpt::CharsetLocale, e.what()) + + L"\n\nDo you want to try to load the plugin natively?"; + if(Reporting::Confirm(msg, L"OpenMPT Plugin Bridge", false, true) == cnfNo) { return nullptr; } @@ -639,12 +641,6 @@ #ifdef VST_LOG Log(cBuf); #endif - - //Stop song - TODO: figure out why this causes a kernel hang from IASIO->release(); -/* - CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm) pMainFrm->StopMod(); -*/ va_end(va); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-11-09 16:49:59
|
Revision: 4572 http://sourceforge.net/p/modplug/code/4572 Author: manxorist Date: 2014-11-09 16:49:43 +0000 (Sun, 09 Nov 2014) Log Message: ----------- [Ref] Convert SettingPath to mpt::ustring using AnyStringLocale. [Ref] Convert SettingValue to mpt::ustring. [Ref] Convert BinToHex and HexToBin to mpt::ustring. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/mptrack/Settings.h trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-11-09 10:18:46 UTC (rev 4571) +++ trunk/OpenMPT/common/misc_util.cpp 2014-11-09 16:49:43 UTC (rev 4572) @@ -560,33 +560,37 @@ { -static const wchar_t EncodeNibble[16] = { L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F' }; +static const MPT_UCHAR_TYPE EncodeNibble[16] = { + MPT_UCHAR('0'), MPT_UCHAR('1'), MPT_UCHAR('2'), MPT_UCHAR('3'), + MPT_UCHAR('4'), MPT_UCHAR('5'), MPT_UCHAR('6'), MPT_UCHAR('7'), + MPT_UCHAR('8'), MPT_UCHAR('9'), MPT_UCHAR('A'), MPT_UCHAR('B'), + MPT_UCHAR('C'), MPT_UCHAR('D'), MPT_UCHAR('E'), MPT_UCHAR('F') }; -static inline bool DecodeByte(uint8 &byte, wchar_t c1, wchar_t c2) +static inline bool DecodeByte(uint8 &byte, MPT_UCHAR_TYPE c1, MPT_UCHAR_TYPE c2) { byte = 0; - if(L'0' <= c1 && c1 <= L'9') + if(MPT_UCHAR('0') <= c1 && c1 <= MPT_UCHAR('9')) { - byte += static_cast<uint8>((c1 - L'0') << 4); - } else if(L'A' <= c1 && c1 <= L'F') + byte += static_cast<uint8>((c1 - MPT_UCHAR('0')) << 4); + } else if(MPT_UCHAR('A') <= c1 && c1 <= MPT_UCHAR('F')) { - byte += static_cast<uint8>((c1 - L'A' + 10) << 4); - } else if(L'a' <= c1 && c1 <= L'f') + byte += static_cast<uint8>((c1 - MPT_UCHAR('A') + 10) << 4); + } else if(MPT_UCHAR('a') <= c1 && c1 <= MPT_UCHAR('f')) { - byte += static_cast<uint8>((c1 - L'a' + 10) << 4); + byte += static_cast<uint8>((c1 - MPT_UCHAR('a') + 10) << 4); } else { return false; } - if(L'0' <= c2 && c2 <= L'9') + if(MPT_UCHAR('0') <= c2 && c2 <= MPT_UCHAR('9')) { - byte += static_cast<uint8>(c2 - L'0'); - } else if(L'A' <= c2 && c2 <= L'F') + byte += static_cast<uint8>(c2 - MPT_UCHAR('0')); + } else if(MPT_UCHAR('A') <= c2 && c2 <= MPT_UCHAR('F')) { - byte += static_cast<uint8>(c2 - L'A' + 10); - } else if(L'a' <= c2 && c2 <= L'f') + byte += static_cast<uint8>(c2 - MPT_UCHAR('A') + 10); + } else if(MPT_UCHAR('a') <= c2 && c2 <= MPT_UCHAR('f')) { - byte += static_cast<uint8>(c2 - L'a' + 10); + byte += static_cast<uint8>(c2 - MPT_UCHAR('a') + 10); } else { return false; @@ -594,9 +598,9 @@ return true; } -std::wstring BinToHex(const std::vector<char> &src) +mpt::ustring BinToHex(const std::vector<char> &src) { - std::wstring result; + mpt::ustring result; for(std::size_t i = 0; i < src.size(); ++i) { uint8 byte = src[i]; @@ -606,7 +610,7 @@ return result; } -std::vector<char> HexToBin(const std::wstring &src) +std::vector<char> HexToBin(const mpt::ustring &src) { std::vector<char> result; for(std::size_t i = 0; i+1 < src.size(); i += 2) Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2014-11-09 10:18:46 UTC (rev 4571) +++ trunk/OpenMPT/common/misc_util.h 2014-11-09 16:49:43 UTC (rev 4572) @@ -111,7 +111,15 @@ } #endif +#if MPT_USTRING_MODE_UTF8 +template<typename T> +inline ConvertStrTo(const mpt::ustring &str) +{ + return ConvertStrTo<T>(mpt::ToCharset(mpt::CharsetUTF8, str)); +} +#endif + namespace mpt { namespace String { // Combine a vector of values into a string, separated with the given separator. @@ -703,8 +711,8 @@ namespace Util { -std::wstring BinToHex(const std::vector<char> &src); -std::vector<char> HexToBin(const std::wstring &src); +mpt::ustring BinToHex(const std::vector<char> &src); +std::vector<char> HexToBin(const mpt::ustring &src); } // namespace Util Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2014-11-09 10:18:46 UTC (rev 4571) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2014-11-09 16:49:43 UTC (rev 4572) @@ -828,7 +828,7 @@ static CString FormatSetting(const SettingPath &path, const SettingValue &val) //---------------------------------------------------------------------------- { - return mpt::ToCString(path.FormatAsString() + L" = " + val.FormatAsString()); + return mpt::ToCString(path.FormatAsString() + MPT_USTRING(" = ") + val.FormatAsString()); } @@ -918,7 +918,7 @@ { return; } - val.SetFromString(mpt::ToWide(inputDlg.resultString)); + val.SetFromString(inputDlg.resultString); } theApp.GetSettings().Write(path, val); m_List.DeleteString(index); Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2014-11-09 10:18:46 UTC (rev 4571) +++ trunk/OpenMPT/mptrack/Settings.cpp 2014-11-09 16:49:43 UTC (rev 4572) @@ -26,55 +26,55 @@ OPENMPT_NAMESPACE_BEGIN -std::wstring SettingValue::FormatTypeAsString() const +mpt::ustring SettingValue::FormatTypeAsString() const { if(GetType() == SettingTypeNone) { - return L"nil"; + return MPT_USTRING("nil"); } - std::wstring result; + mpt::ustring result; switch(GetType()) { case SettingTypeBool: - result += L"bool"; + result += MPT_USTRING("bool"); break; case SettingTypeInt: - result += L"int"; + result += MPT_USTRING("int"); break; case SettingTypeFloat: - result += L"float"; + result += MPT_USTRING("float"); break; case SettingTypeString: - result += L"string"; + result += MPT_USTRING("string"); break; case SettingTypeBinary: - result += L"binary"; + result += MPT_USTRING("binary"); break; case SettingTypeNone: default: - result += L"nil"; + result += MPT_USTRING("nil"); break; } if(HasTypeTag() && !GetTypeTag().empty()) { - result += L":" + mpt::ToWide(mpt::CharsetASCII, GetTypeTag()); + result += MPT_USTRING(":") + mpt::ToUnicode(mpt::CharsetASCII, GetTypeTag()); } return result; } -std::wstring SettingValue::FormatValueAsString() const +mpt::ustring SettingValue::FormatValueAsString() const { switch(GetType()) { case SettingTypeBool: - return StringifyW(valueBool); + return mpt::ToUString(valueBool); break; case SettingTypeInt: - return StringifyW(valueInt); + return mpt::ToUString(valueInt); break; case SettingTypeFloat: - return StringifyW(valueFloat); + return mpt::ToUString(valueFloat); break; case SettingTypeString: return valueString; @@ -84,19 +84,19 @@ break; case SettingTypeNone: default: - return std::wstring(); + return mpt::ustring(); break; } } -std::wstring SettingValue::FormatAsString() const +mpt::ustring SettingValue::FormatAsString() const { - return L"(" + FormatTypeAsString() + L")" + FormatValueAsString(); + return MPT_USTRING("(") + FormatTypeAsString() + MPT_USTRING(")") + FormatValueAsString(); } -void SettingValue::SetFromString(const std::wstring &newVal) +void SettingValue::SetFromString(const AnyStringLocale &newVal) { switch(GetType()) { @@ -373,11 +373,11 @@ std::wstring IniFileSettingsBackend::GetSection(const SettingPath &path) { - return path.GetSection(); + return mpt::ToWide(path.GetSection()); } std::wstring IniFileSettingsBackend::GetKey(const SettingPath &path) { - return path.GetKey(); + return mpt::ToWide(path.GetKey()); } Modified: trunk/OpenMPT/mptrack/Settings.h =================================================================== --- trunk/OpenMPT/mptrack/Settings.h 2014-11-09 10:18:46 UTC (rev 4571) +++ trunk/OpenMPT/mptrack/Settings.h 2014-11-09 16:49:43 UTC (rev 4572) @@ -44,7 +44,7 @@ bool valueBool; int32 valueInt; double valueFloat; - std::wstring valueString; + mpt::ustring valueString; std::vector<char> valueBinary; SettingType type; std::string typeTag; @@ -53,7 +53,7 @@ valueBool = false; valueInt = 0; valueFloat = 0.0; - valueString = std::wstring(); + valueString = mpt::ustring(); valueBinary.clear(); type = SettingTypeNone; typeTag = std::string(); @@ -121,32 +121,32 @@ { Init(); type = SettingTypeString; - valueString = mpt::ToWide(mpt::CharsetLocale, val); + valueString = mpt::ToUnicode(mpt::CharsetLocale, val); } SettingValue(const std::string &val) { Init(); type = SettingTypeString; - valueString = mpt::ToWide(mpt::CharsetLocale, val); + valueString = mpt::ToUnicode(mpt::CharsetLocale, val); } SettingValue(const wchar_t *val) { Init(); type = SettingTypeString; - valueString = val; + valueString = mpt::ToUnicode(val); } SettingValue(const std::wstring &val) { Init(); type = SettingTypeString; - valueString = val; + valueString = mpt::ToUnicode(val); } #if MPT_USTRING_MODE_UTF8 SettingValue(const mpt::ustring &val) { Init(); type = SettingTypeString; - valueString = mpt::ToWide(val); + valueString = val; } #endif SettingValue(const std::vector<char> &val) @@ -181,28 +181,28 @@ Init(); type = SettingTypeString; typeTag = typeTag_; - valueString = mpt::ToWide(mpt::CharsetLocale, val); + valueString = mpt::ToUnicode(mpt::CharsetLocale, val); } SettingValue(const std::string &val, const std::string &typeTag_) { Init(); type = SettingTypeString; typeTag = typeTag_; - valueString = mpt::ToWide(mpt::CharsetLocale, val); + valueString = mpt::ToUnicode(mpt::CharsetLocale, val); } SettingValue(const wchar_t *val, const std::string &typeTag_) { Init(); type = SettingTypeString; typeTag = typeTag_; - valueString = val; + valueString = mpt::ToUnicode(val); } SettingValue(const std::wstring &val, const std::string &typeTag_) { Init(); type = SettingTypeString; typeTag = typeTag_; - valueString = val; + valueString = mpt::ToUnicode(val); } #if MPT_USTRING_MODE_UTF8 SettingValue(const mpt::ustring &val, const std::string &typeTag_) @@ -210,7 +210,7 @@ Init(); type = SettingTypeString; typeTag = typeTag_; - valueString = mpt::ToWide(val); + valueString = val; } #endif SettingValue(const std::vector<char> &val, const std::string &typeTag_) @@ -260,13 +260,13 @@ operator std::wstring () const { ASSERT(type == SettingTypeString); - return valueString; + return mpt::ToWide(valueString); } #if MPT_USTRING_MODE_UTF8 operator mpt::ustring () const { ASSERT(type == SettingTypeString); - return mpt::ToUnicode(valueString); + return valueString; } #endif operator std::vector<char> () const @@ -274,10 +274,10 @@ ASSERT(type == SettingTypeBinary); return valueBinary; } - std::wstring FormatTypeAsString() const; - std::wstring FormatValueAsString() const; - std::wstring FormatAsString() const; - void SetFromString(const std::wstring &newVal); + mpt::ustring FormatTypeAsString() const; + mpt::ustring FormatValueAsString() const; + mpt::ustring FormatAsString() const; + void SetFromString(const AnyStringLocale &newVal); }; @@ -411,30 +411,24 @@ class SettingPath { private: - std::wstring section; - std::wstring key; + mpt::ustring section; + mpt::ustring key; public: SettingPath() { return; } - SettingPath(const std::wstring §ion_, const std::wstring &key_) + SettingPath(const AnyStringLocale §ion_, const AnyStringLocale &key_) : section(section_) , key(key_) { return; } - SettingPath(const std::string §ion_, const std::string &key_) - : section(mpt::ToWide(mpt::CharsetLocale, section_)) - , key(mpt::ToWide(mpt::CharsetLocale, key_)) + mpt::ustring GetSection() const { - return; - } - std::wstring GetSection() const - { return section; } - std::wstring GetKey() const + mpt::ustring GetKey() const { return key; } @@ -448,9 +442,9 @@ int cmp_key = key.compare(other.key); return cmp_key; } - std::wstring FormatAsString() const + mpt::ustring FormatAsString() const { - return section + L"." + key; + return section + MPT_USTRING(".") + key; } }; @@ -473,10 +467,9 @@ struct SettingMetadata { - std::string description; + mpt::ustring description; SettingMetadata() {} - template<typename T1> - SettingMetadata(const T1 &description) + SettingMetadata(const AnyStringLocale &description) : description(description) { return; @@ -546,54 +539,36 @@ return FromSettingValue<T>(ReadSetting(path, ToSettingValue<T>(def), metadata)); } template <typename T> - T Read(const std::wstring §ion, const std::wstring &key, const T &def = T(), const SettingMetadata &metadata = SettingMetadata()) const + T Read(const AnyStringLocale §ion, const AnyStringLocale &key, const T &def = T(), const SettingMetadata &metadata = SettingMetadata()) const { return FromSettingValue<T>(ReadSetting(SettingPath(section, key), ToSettingValue<T>(def), metadata)); } template <typename T> - T Read(const std::string §ion, const std::string &key, const T &def = T(), const SettingMetadata &metadata = SettingMetadata()) const - { - return FromSettingValue<T>(ReadSetting(SettingPath(section, key), ToSettingValue<T>(def), metadata)); - } - template <typename T> void Write(const SettingPath &path, const T &val, SettingFlushMode flushMode = SettingWriteBack) { WriteSetting(path, ToSettingValue<T>(val), flushMode); } template <typename T> - void Write(const std::wstring §ion, const std::wstring &key, const T &val, SettingFlushMode flushMode = SettingWriteBack) + void Write(const AnyStringLocale §ion, const AnyStringLocale &key, const T &val, SettingFlushMode flushMode = SettingWriteBack) { WriteSetting(SettingPath(section, key), ToSettingValue<T>(val), flushMode); } - template <typename T> - void Write(const std::string §ion, const std::string &key, const T &val, SettingFlushMode flushMode = SettingWriteBack) - { - WriteSetting(SettingPath(section, key), ToSettingValue<T>(val), flushMode); - } void Forget(const SettingPath &path) { ForgetSetting(path); } - void Forget(const std::wstring §ion, const std::wstring &key) + void Forget(const AnyStringLocale §ion, const AnyStringLocale &key) { ForgetSetting(SettingPath(section, key)); } - void Forget(const std::string §ion, const std::string &key) - { - ForgetSetting(SettingPath(section, key)); - } void Remove(const SettingPath &path) { RemoveSetting(path); } - void Remove(const std::wstring §ion, const std::wstring &key) + void Remove(const AnyStringLocale §ion, const AnyStringLocale &key) { RemoveSetting(SettingPath(section, key)); } - void Remove(const std::string §ion, const std::string &key) - { - RemoveSetting(SettingPath(section, key)); - } void Flush(); ~SettingsContainer(); @@ -642,18 +617,12 @@ return; } public: - Setting(SettingsContainer &conf_, const std::string §ion, const std::string &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) + Setting(SettingsContainer &conf_, const AnyStringLocale §ion, const AnyStringLocale &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) : conf(conf_) , path(section, key) { conf.Read(path, def, metadata); // set default value } - Setting(SettingsContainer &conf_, const std::wstring §ion, const std::wstring &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) - : conf(conf_) - , path(section, key) - { - conf.Read(path, def, metadata); // set default value - } Setting(SettingsContainer &conf_, const SettingPath &path_, const T&def, const SettingMetadata &metadata = SettingMetadata()) : conf(conf_) , path(path_) @@ -704,7 +673,7 @@ conf.Register(this, path); } public: - CachedSetting(SettingsContainer &conf_, const std::string §ion, const std::string &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) + CachedSetting(SettingsContainer &conf_, const AnyStringLocale §ion, const AnyStringLocale &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) : value(def) , conf(conf_) , path(section, key) @@ -712,14 +681,6 @@ value = conf.Read(path, def, metadata); conf.Register(this, path); } - CachedSetting(SettingsContainer &conf_, const std::wstring §ion, const std::wstring &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) - : value(def) - , conf(conf_) - , path(section, key) - { - value = conf.Read(path, def, metadata); - conf.Register(this, path); - } CachedSetting(SettingsContainer &conf_, const SettingPath &path_, const T&def, const SettingMetadata &metadata = SettingMetadata()) : value(def) , conf(conf_) @@ -788,20 +749,13 @@ return; } public: - Setting(SettingsContainer &conf_, const std::string §ion, const std::string &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) + Setting(SettingsContainer &conf_, const AnyStringLocale §ion, const AnyStringLocale &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) : value(def) , conf(conf_) , path(section, key) { value = conf.Read(path, def, metadata); } - Setting(SettingsContainer &conf_, const std::wstring §ion, const std::wstring &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) - : value(def) - , conf(conf_) - , path(section, key) - { - value = conf.Read(path, def, metadata); - } Setting(SettingsContainer &conf_, const SettingPath &path_, const T&def, const SettingMetadata &metadata = SettingMetadata()) : value(def) , conf(conf_) Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-11-09 10:18:46 UTC (rev 4571) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-11-09 16:49:43 UTC (rev 4572) @@ -196,7 +196,7 @@ // UTF8-encode the name and convert the utf8 to hex. // This ensures that no special characters are contained in the configuration key. std::string utf8String = mpt::ToCharset(mpt::CharsetUTF8, name); - mpt::ustring hexString = mpt::ToUnicode(Util::BinToHex(std::vector<char>(utf8String.begin(), utf8String.end()))); + mpt::ustring hexString = Util::BinToHex(std::vector<char>(utf8String.begin(), utf8String.end())); result += hexString; } else { Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-11-09 10:18:46 UTC (rev 4571) +++ trunk/OpenMPT/test/test.cpp 2014-11-09 16:49:43 UTC (rev 4572) @@ -912,7 +912,7 @@ { DefaultSettingsContainer conf; - int32 foobar = conf.Read("Test", "bar", 23, "foobar"); + int32 foobar = conf.Read("Test", "bar", 23, SettingMetadata("foobar")); conf.Write("Test", "bar", 64); conf.Write("Test", "bar", 42); conf.Read("Test", "baz", 4711); @@ -922,7 +922,7 @@ { DefaultSettingsContainer conf; - int32 foobar = conf.Read("Test", "bar", 28, "foobar"); + int32 foobar = conf.Read("Test", "bar", 28, SettingMetadata("foobar")); VERIFY_EQUAL(foobar, 42); conf.Write("Test", "bar", 43); } @@ -930,7 +930,7 @@ { DefaultSettingsContainer conf; - int32 foobar = conf.Read("Test", "bar", 123, "foobar"); + int32 foobar = conf.Read("Test", "bar", 123, SettingMetadata("foobar")); VERIFY_EQUAL(foobar, 43); conf.Write("Test", "bar", 88); } @@ -938,7 +938,7 @@ { DefaultSettingsContainer conf; - Setting<int> foo(conf, "Test", "bar", 99, "something"); + Setting<int> foo(conf, "Test", "bar", 99, SettingMetadata("something")); VERIFY_EQUAL(foo, 88); @@ -948,7 +948,7 @@ { DefaultSettingsContainer conf; - Setting<int> foo(conf, "Test", "bar", 99, "something"); + Setting<int> foo(conf, "Test", "bar", 99, SettingMetadata("something")); VERIFY_EQUAL(foo, 7); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-11-09 18:23:38
|
Revision: 4575 http://sourceforge.net/p/modplug/code/4575 Author: saga-games Date: 2014-11-09 18:23:21 +0000 (Sun, 09 Nov 2014) Log Message: ----------- [New] libopenmpt: Added the possibility to play all subsongs consecutively by calling openmpt::module::select_subsong with value -1. [Imp] openmpt123: Play all subsongs consecutively. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/dox/changelog.md trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/libopenmpt/dox/changelog.md =================================================================== --- trunk/OpenMPT/libopenmpt/dox/changelog.md 2014-11-09 17:46:22 UTC (rev 4574) +++ trunk/OpenMPT/libopenmpt/dox/changelog.md 2014-11-09 18:23:21 UTC (rev 4575) @@ -20,6 +20,12 @@ * [Bug] The -autotools tarballs were not working at all. * Vastly improved MT2 loader. + * Support for "hidden" subsongs has been added. + They are accessible through the same interface as ordinary subsongs, i.e. + use openmpt::module::select_subsong to switch between any kind of subsongs. + * All subsongs can now be played consecutively by passing -1 as the subsong + index in openmpt::module::select_subsong. + * Added documentation for a couple of more functions. ### 2014-09-07 - libopenmpt 0.2-beta7 Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2014-11-09 17:46:22 UTC (rev 4574) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2014-11-09 18:23:21 UTC (rev 4575) @@ -221,7 +221,7 @@ /*! \param stream Input stream from which the module is loaded. After the constructor has finished successfully, the input position of stream is set to the byte after the last byte that has been read. If the constructor fails, the state of the input position of stream is undefined. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. - \param ctls A map of initial ctl values, see openmpt::modules::get_ctls. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ @@ -229,7 +229,7 @@ /*! \param data Data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. - \param ctls A map of initial ctl values, see openmpt::modules::get_ctls. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ @@ -238,7 +238,7 @@ \param beg Begin of data to load the module from. \param end End of data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. - \param ctls A map of initial ctl values, see openmpt::modules::get_ctls. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ @@ -247,7 +247,7 @@ \param data Data to load the module from. \param size Amount of data available. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. - \param ctls A map of initial ctl values, see openmpt::modules::get_ctls. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ @@ -255,7 +255,7 @@ /*! \param data Data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. - \param ctls A map of initial ctl values, see openmpt::modules::get_ctls. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ @@ -264,7 +264,7 @@ \param beg Begin of data to load the module from. \param end End of data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. - \param ctls A map of initial ctl values, see openmpt::modules::get_ctls. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ @@ -273,7 +273,7 @@ \param data Data to load the module from. \param size Amount of data available. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. - \param ctls A map of initial ctl values, see openmpt::modules::get_ctls. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ @@ -282,7 +282,7 @@ \param data Data to load the module from. \param size Amount of data available. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. - \param ctls A map of initial ctl values, see openmpt::modules::get_ctls. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ @@ -292,8 +292,8 @@ //! Select a subsong from a multi-song module /*! - \param subsong Index of the subsong. - \return Throws an exception derived from openmpt::exception if subsong is not in range [0,openmpt::module::get_num_subsongs()] + \param subsong Index of the subsong. -1 plays all subsongs consecutively. + \return Throws an exception derived from openmpt::exception if subsong is not in range [-1,openmpt::module::get_num_subsongs()[ */ void select_subsong( std::int32_t subsong ); //! Set Repeat Count Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-11-09 17:46:22 UTC (rev 4574) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-11-09 18:23:21 UTC (rev 4575) @@ -219,6 +219,15 @@ m_sndFile->AddToLog( static_cast<LogLevel>( loglevel ), mpt::ToUnicode( mpt::CharsetUTF8, text ) ); } +module_impl::subsong_data::subsong_data( double duration, std::int32_t start_row, std::int32_t start_order, std::int32_t sequence ) + : duration(duration) + , start_row(start_row) + , start_order(start_order) + , sequence(sequence) +{ + return; +} + static ResamplingMode filterlength_to_resamplingmode(std::int32_t length) { if ( length == 0 ) { return SRCMODE_POLYPHASE; @@ -302,6 +311,7 @@ } void module_impl::apply_libopenmpt_defaults() { set_render_param( module::RENDER_STEREOSEPARATION_PERCENT, 100 ); + m_sndFile->Order.SetSequence( 0 ); } void module_impl::init( const std::map< std::string, std::string > & ctls ) { #ifdef LIBOPENMPT_ANCIENT_COMPILER @@ -326,7 +336,6 @@ m_ctl_load_skip_patterns = false; m_ctl_seek_sync_samples = false; m_current_subsong = 0; - m_sndFile->Order.SetSequence( 0 ); for ( std::map< std::string, std::string >::const_iterator i = ctls.begin(); i != ctls.end(); ++i ) { ctl_set( i->first, i->second ); } @@ -697,22 +706,30 @@ cache_subsongs(); if ( m_current_subsong >= 0 && m_current_subsong < static_cast<std::int32_t>( m_subsongs.size() ) ) { return m_subsongs[m_current_subsong].duration; + } else if ( m_current_subsong == all_subsongs ) { + // Play all subsongs consecutively. + double total_duration = 0.0; + for ( std::size_t i = 0; i < m_subsongs.size(); ++i ) { + total_duration += m_subsongs[i].duration; + } + return total_duration; } return m_sndFile->GetLength( eNoAdjust ).back().duration; } void module_impl::select_subsong( std::int32_t subsong ) { cache_subsongs(); - if ( subsong < -1 || subsong >= static_cast<std::int32_t>( m_subsongs.size() ) ) { - return; + if ( ( subsong < 0 || subsong >= static_cast<std::int32_t>( m_subsongs.size() ) ) && subsong != all_subsongs ) { + throw openmpt::exception("invalid subsong"); } + m_current_subsong = subsong; + m_sndFile->m_SongFlags.set( SONG_PLAYALLSONGS, subsong == all_subsongs ); if ( subsong == -1 ) { - // default subsong subsong = 0; } - m_current_subsong = subsong; m_sndFile->Order.SetSequence( static_cast<SEQUENCEINDEX>( m_subsongs[subsong].sequence ) ); set_position_order_row( m_subsongs[subsong].start_order, m_subsongs[subsong].start_row ); + m_currentPositionSeconds = 0.0; } void module_impl::set_repeat_count( std::int32_t repeat_count ) { @@ -725,13 +742,28 @@ return m_currentPositionSeconds; } double module_impl::set_position_seconds( double seconds ) { - const subsong_data &subsong = m_subsongs[m_current_subsong]; - GetLengthType t = m_sndFile->GetLength( eNoAdjust, GetLengthTarget( seconds ).StartPos( subsong.sequence, subsong.start_order, subsong.start_row ) ).back(); - m_sndFile->InitializeVisitedRows(); + const subsong_data *subsong; + double base_seconds = 0.0; + if ( m_current_subsong == all_subsongs ) { + // When playing all subsongs, find out which subsong this time would belong to. + for ( std::size_t i = 0; i < m_subsongs.size(); ++i ) { + subsong = &m_subsongs[i]; + if ( base_seconds + subsong->duration > seconds ) { + break; + } + base_seconds += subsong->duration; + } + seconds -= base_seconds; + } else + { + subsong = &m_subsongs[m_current_subsong]; + } + + GetLengthType t = m_sndFile->GetLength( eNoAdjust, GetLengthTarget( seconds ).StartPos( subsong->sequence, subsong->start_order, subsong->start_row ) ).back(); m_sndFile->m_PlayState.m_nCurrentOrder = t.lastOrder; m_sndFile->SetCurrentOrder( t.lastOrder ); m_sndFile->m_PlayState.m_nNextRow = t.lastRow; - m_currentPositionSeconds = m_sndFile->GetLength( m_ctl_seek_sync_samples ? eAdjustSamplePositions : eAdjust, GetLengthTarget( t.lastOrder, t.lastRow ).StartPos( subsong.sequence, subsong.start_order, subsong.start_row ) ).back().duration; + m_currentPositionSeconds = base_seconds + m_sndFile->GetLength( m_ctl_seek_sync_samples ? eAdjustSamplePositions : eAdjust, GetLengthTarget( t.lastOrder, t.lastRow ).StartPos( subsong->sequence, subsong->start_order, subsong->start_row ) ).back().duration; return m_currentPositionSeconds; } double module_impl::set_position_order_row( std::int32_t order, std::int32_t row ) { @@ -746,7 +778,6 @@ } else { row = 0; } - m_sndFile->InitializeVisitedRows(); m_sndFile->m_PlayState.m_nCurrentOrder = order; m_sndFile->SetCurrentOrder( order ); m_sndFile->m_PlayState.m_nNextRow = row; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2014-11-09 17:46:22 UTC (rev 4574) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2014-11-09 18:23:21 UTC (rev 4575) @@ -57,18 +57,17 @@ class log_forwarder; -class subsong_data { -public: - double duration; - std::int32_t start_row; - std::int32_t start_order; - std::int32_t sequence; - - subsong_data( double duration, std::int32_t start_row, std::int32_t start_order, std::int32_t sequence ) : duration(duration), start_row(start_row), start_order(start_order), sequence(sequence) { } -}; - class module_impl { protected: + struct subsong_data { + double duration; + std::int32_t start_row; + std::int32_t start_order; + std::int32_t sequence; + subsong_data( double duration, std::int32_t start_row, std::int32_t start_order, std::int32_t sequence ); + }; // struct subsong_data + static const std::int32_t all_subsongs = -1; + #ifdef LIBOPENMPT_ANCIENT_COMPILER std::tr1::shared_ptr<log_interface> m_Log; #else Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-11-09 17:46:22 UTC (rev 4574) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-11-09 18:23:21 UTC (rev 4575) @@ -1397,6 +1397,7 @@ { openmpt::module mod( data_stream, silentlog, flags.ctls ); + mod.select_subsong( -1 ); // play all subsongs consecutively silentlog.str( std::string() ); // clear, loader messages get stored to get_metadata( "warnings" ) by libopenmpt internally render_mod_file( flags, filename, filesize, mod, log, audio_stream ); } Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2014-11-09 17:46:22 UTC (rev 4574) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2014-11-09 18:23:21 UTC (rev 4575) @@ -277,6 +277,7 @@ SONG_BREAKTOROW = 0x80000, // Break to row command encountered (internal flag, do not touch) SONG_POSJUMP = 0x100000, // Position jump encountered (internal flag, do not touch) SONG_PT1XMODE = 0x200000, // ProTracker 1/2 playback mode + SONG_PLAYALLSONGS = 0x400000, // Play all subsongs consecutively (libopenmpt) }; DECLARE_FLAGSET(SongFlags) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-09 17:46:22 UTC (rev 4574) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-09 18:23:21 UTC (rev 4575) @@ -158,6 +158,13 @@ for (;;) { + // Time target reached. + if(target.mode == GetLengthTarget::SeekSeconds && memory.elapsedTime >= target.time) + { + retval.targetReached = true; + break; + } + uint32 rowDelay = 0, tickDelay = 0; nRow = nNextRow; nCurrentOrder = nNextOrder; @@ -244,8 +251,7 @@ nRow = 0; // Check whether target was reached. - if((target.mode == GetLengthTarget::SeekPosition && nCurrentOrder == target.pos.order && nRow == target.pos.row) - || (target.mode == GetLengthTarget::SeekSeconds && memory.elapsedTime >= target.time)) + if(target.mode == GetLengthTarget::SeekPosition && nCurrentOrder == target.pos.order && nRow == target.pos.row) { retval.targetReached = true; break; @@ -866,6 +872,10 @@ m_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume; } // When adjusting the playback status, we will also want to update the visited rows vector according to the current position. + if(sequence != Order.GetCurrentSequenceIndex()) + { + Order.SetSequence(sequence); + } visitedSongRows.Set(visitedRows); } Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-09 17:46:22 UTC (rev 4574) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-09 18:23:21 UTC (rev 4575) @@ -494,9 +494,6 @@ // This is of course not possible during rendering to WAV, so we ignore that case. GetLengthType t = GetLength(eNoAdjust).back(); if(IsRenderingToDisc() || (t.lastOrder == m_PlayState.m_nCurrentOrder && t.lastRow == m_PlayState.m_nRow)) -#else - if(1) -#endif // MODPLUG_TRACKER { // This is really the song's end! visitedSongRows.Initialize(true); @@ -506,6 +503,44 @@ // Ok, this is really dirty, but we have to update the visited rows vector... GetLength(eAdjustOnSuccess, GetLengthTarget(m_PlayState.m_nCurrentOrder, m_PlayState.m_nRow)); } +#else + if(m_SongFlags[SONG_PLAYALLSONGS]) + { + // When playing all subsongs consecutively, first search for any hidden subsongs... + if(!visitedSongRows.GetFirstUnvisitedRow(m_PlayState.m_nCurrentOrder, m_PlayState.m_nRow, true)) + { + // ...and then try the next sequence. + m_PlayState.m_nNextOrder = m_PlayState.m_nCurrentOrder = 0; + m_PlayState.m_nNextRow = m_PlayState.m_nRow = 0; + if(Order.GetCurrentSequenceIndex() >= Order.GetNumSequences() - 1) + { + Order.SetSequence(0); + visitedSongRows.Initialize(true); + return false; + } + Order.SetSequence(Order.GetCurrentSequenceIndex() + 1); + visitedSongRows.Initialize(true); + } + // When jumping to the next subsong, stop all playing notes from the previous song... + for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) + m_PlayState.Chn[i].Reset(ModChannel::resetSetPosFull, *this, i); + StopAllVsti(); + // ...and the global playback information. + m_PlayState.m_nMusicSpeed = m_nDefaultSpeed; + m_PlayState.m_nMusicTempo = m_nDefaultTempo; + m_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume; + + m_PlayState.m_nNextOrder = m_PlayState.m_nCurrentOrder; + m_PlayState.m_nNextRow = m_PlayState.m_nRow; + if(Order.size() > m_PlayState.m_nCurrentOrder) + m_PlayState.m_nPattern = Order[m_PlayState.m_nCurrentOrder]; + visitedSongRows.Visit(m_PlayState.m_nCurrentOrder, m_PlayState.m_nRow); + } else + { + visitedSongRows.Initialize(true); + return false; + } +#endif // MODPLUG_TRACKER } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-11-10 00:02:03
|
Revision: 4578 http://sourceforge.net/p/modplug/code/4578 Author: saga-games Date: 2014-11-10 00:01:55 +0000 (Mon, 10 Nov 2014) Log Message: ----------- [New] libopenmpt: Added openmpt::ext::interactive, which adds a whole bunch of new functionality to change playback in some way or another. The interface may still change within the next few days. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_ext.cpp trunk/OpenMPT/libopenmpt/libopenmpt_ext.hpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -222,7 +222,7 @@ \param stream Input stream from which the module is loaded. After the constructor has finished successfully, the input position of stream is set to the byte after the last byte that has been read. If the constructor fails, the state of the input position of stream is undefined. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -230,7 +230,7 @@ \param data Data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const std::vector<std::uint8_t> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -239,7 +239,7 @@ \param end End of data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const std::uint8_t * beg, const std::uint8_t * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -248,7 +248,7 @@ \param size Amount of data available. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -256,7 +256,7 @@ \param data Data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -265,7 +265,7 @@ \param end End of data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -274,7 +274,7 @@ \param size Amount of data available. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -283,7 +283,7 @@ \param size Amount of data available. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -293,7 +293,7 @@ //! Select a subsong from a multi-song module /*! \param subsong Index of the subsong. -1 plays all subsongs consecutively. - \return Throws an exception derived from openmpt::exception if subsong is not in range [-1,openmpt::module::get_num_subsongs()[ + \throws openmpt::exception Throws an exception derived from openmpt::exception if subsong is not in range [-1,openmpt::module::get_num_subsongs()[ */ void select_subsong( std::int32_t subsong ); //! Set Repeat Count @@ -349,7 +349,8 @@ //! Get render parameter /*! \param param Parameter to query. See openmpt::module::render_param. - \return The current value of the parameter. Throws an exception derived from openmpt::exception if param is invalid. + \return The current value of the parameter. + \throws openmpt::exception Throws an exception derived from openmpt::exception if param is invalid. \sa openmpt::module::render_param \sa openmpt::module::set_render_param */ @@ -358,7 +359,7 @@ /*! \param param Parameter to set. See openmpt::module::render_param. \param value The value to set param to. - \return Throws an exception derived from openmpt::exception if param is invalid or value is out of range. + \throws openmpt::exception Throws an exception derived from openmpt::exception if param is invalid or value is out of range. \sa openmpt::module::render_param \sa openmpt::module::get_render_param */ Modified: trunk/OpenMPT/libopenmpt/libopenmpt_ext.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_ext.cpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/libopenmpt/libopenmpt_ext.cpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -20,6 +20,7 @@ class module_ext_impl : public module_impl , public ext::pattern_vis + , public ext::interactive @@ -97,6 +98,8 @@ return 0; } else if ( interface_id == ext::pattern_vis_id ) { return dynamic_cast< ext::pattern_vis * >( this ); + } else if ( interface_id == ext::interactive_id ) { + return dynamic_cast< ext::interactive * >( this ); @@ -135,8 +138,179 @@ } } + // interactive + virtual void set_current_speed( std::int32_t speed ) { + if ( speed < 1 || speed > 65535 ) { + throw openmpt::exception("invalid tick count"); + } + m_sndFile->m_PlayState.m_nMusicSpeed = speed; + } + virtual void set_current_tempo( std::int32_t tempo ) { + if ( tempo < 32 || tempo > 512 ) { + throw openmpt::exception("invalid tempo"); + } + m_sndFile->m_PlayState.m_nMusicTempo = tempo; + } + + virtual void set_tempo_factor( double factor ) { + if ( factor <= 0.0 || factor > 4.0 ) { + throw openmpt::exception("invalid tempo factor"); + } + m_sndFile->m_nTempoFactor = Util::Round<uint32_t>( 65536.0 / factor ); + m_sndFile->RecalculateSamplesPerTick(); + } + + virtual double get_tempo_factor( ) const { + return 65536.0 / m_sndFile->m_nTempoFactor; + } + + virtual void set_pitch_factor( double factor ) { + if ( factor <= 0.0 || factor > 4.0 ) { + throw openmpt::exception("invalid pitch factor"); + } + m_sndFile->m_nFreqFactor = Util::Round<uint32_t>( 65536.0 * factor ); + m_sndFile->RecalculateSamplesPerTick(); + } + + virtual double get_pitch_factor( ) const { + return m_sndFile->m_nFreqFactor / 65536.0; + } + + virtual void set_global_volume( double volume ) { + if ( volume < 0.0 || volume > 1.0 ) { + throw openmpt::exception("invalid global volume"); + } + m_sndFile->m_PlayState.m_nGlobalVolume = Util::Round<uint32_t>( volume * MAX_GLOBAL_VOLUME ); + } + + virtual double get_global_volume( ) const { + return m_sndFile->m_PlayState.m_nGlobalVolume / static_cast<double>( MAX_GLOBAL_VOLUME ); + } + + virtual void set_channel_volume( std::int32_t channel, double volume ) { + if ( channel < 0 || channel >= get_num_channels() ) { + throw openmpt::exception("invalid channel"); + } + if ( volume < 0.0 || volume > 1.0 ) { + throw openmpt::exception("invalid global volume"); + } + m_sndFile->m_PlayState.Chn[channel].nGlobalVol = Util::Round<std::int32_t>(volume * 64.0); + } + + virtual double get_channel_volume( std::int32_t channel ) const { + if ( channel < 0 || channel >= get_num_channels() ) { + throw openmpt::exception("invalid channel"); + } + return m_sndFile->m_PlayState.Chn[channel].nGlobalVol / 64.0; + } + + virtual void set_channel_mute_status( std::int32_t channel, bool mute ) { + if ( channel < 0 || channel >= get_num_channels() ) { + throw openmpt::exception("invalid channel"); + } + m_sndFile->ChnSettings[channel].dwFlags.set( CHN_MUTE | CHN_SYNCMUTE , mute ); + m_sndFile->m_PlayState.Chn[channel].dwFlags.set( CHN_MUTE | CHN_SYNCMUTE , mute ); + + // Also update NNA channels + for ( CHANNELINDEX i = m_sndFile->GetNumChannels(); i < MAX_CHANNELS; i++) + { + if ( m_sndFile->m_PlayState.Chn[i].nMasterChn == channel + 1) + { + m_sndFile->m_PlayState.Chn[i].dwFlags.set( CHN_MUTE | CHN_SYNCMUTE, mute ); + } + } + } + + virtual bool get_channel_mute_status( std::int32_t channel ) const { + if ( channel < 0 || channel >= get_num_channels() ) { + throw openmpt::exception("invalid channel"); + } + return m_sndFile->m_PlayState.Chn[channel].dwFlags[CHN_MUTE]; + } + + virtual void set_instrument_mute_status( std::int32_t instrument, bool mute ) { + const bool instrument_mode = get_num_instruments() != 0; + const int32_t max_instrument = instrument_mode ? get_num_instruments() : get_num_samples(); + if ( instrument < 0 || instrument >= max_instrument ) { + throw openmpt::exception("invalid instrument"); + } + if ( instrument_mode ) { + if ( m_sndFile->Instruments[instrument + 1] != nullptr ) { + m_sndFile->Instruments[instrument + 1]->dwFlags.set( INS_MUTE, mute ); + } + } else { + m_sndFile->GetSample( static_cast<OpenMPT::SAMPLEINDEX>( instrument + 1 ) ).uFlags.set( CHN_MUTE, mute ) ; + } + } + + virtual bool get_instrument_mute_status( std::int32_t instrument ) const { + const bool instrument_mode = get_num_instruments() != 0; + const int32_t max_instrument = instrument_mode ? get_num_instruments() : get_num_samples(); + if ( instrument < 0 || instrument >= max_instrument ) { + throw openmpt::exception("invalid instrument"); + } + if ( instrument_mode ) { + if ( m_sndFile->Instruments[instrument + 1] != nullptr ) { + return m_sndFile->Instruments[instrument + 1]->dwFlags[INS_MUTE]; + } + return true; + } else { + return m_sndFile->GetSample( static_cast<OpenMPT::SAMPLEINDEX>( instrument + 1 ) ).uFlags[CHN_MUTE]; + } + } + + virtual std::int32_t play_note( std::int32_t instrument, std::int32_t note, double volume, double panning ) { + const bool instrument_mode = get_num_instruments() != 0; + const int32_t max_instrument = instrument_mode ? get_num_instruments() : get_num_samples(); + if ( instrument < 0 || instrument >= max_instrument ) { + throw openmpt::exception("invalid instrument"); + } + note += NOTE_MIN; + if ( note < NOTE_MIN || note > NOTE_MAX ) { + throw openmpt::exception("invalid note"); + } + + // Find a free channel + CHANNELINDEX free_channel = MAX_CHANNELS - 1; + // Search for available channel + for(CHANNELINDEX i = MAX_CHANNELS - 1; i >= get_num_channels(); i--) + { + const ModChannel &chn = m_sndFile->m_PlayState.Chn[i]; + if ( chn.nLength == 0 ) { + free_channel = i; + break; + } else if ( chn.dwFlags[CHN_NOTEFADE] ) { + // We can probably still do better than this. + free_channel = i; + } + } + + ModChannel &chn = m_sndFile->m_PlayState.Chn[free_channel]; + chn.Reset(ModChannel::resetTotal, *m_sndFile, CHANNELINDEX_INVALID); + chn.nMasterChn = 0; // remove NNA association + chn.nNewNote = chn.nLastNote = static_cast<uint8>(note); + chn.ResetEnvelopes(); + m_sndFile->InstrumentChange(&chn, instrument + 1); + chn.nFadeOutVol = 0x10000; + m_sndFile->NoteChange(&chn, note, false, true, true); + chn.nPan = Util::Round<int32_t>( Clamp( panning * 128.0, -128.0, 128.0 ) + 128.0 ); + chn.nVolume = Util::Round<int32_t>( Clamp( volume * 256.0, 0.0, 256.0 ) ); + + return free_channel; + } + + virtual void stop_note( std::int32_t channel ) { + if ( channel < 0 || channel >= MAX_CHANNELS ) { + throw openmpt::exception("invalid channel"); + } + ModChannel &chn = m_sndFile->m_PlayState.Chn[channel]; + chn.nLength = 0; + chn.pCurrentSample = nullptr; + } + + /* add stuff here */ Modified: trunk/OpenMPT/libopenmpt/libopenmpt_ext.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_ext.hpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/libopenmpt/libopenmpt_ext.hpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -65,6 +65,7 @@ LIBOPENMPT_EXT_INTERFACE(pattern_vis) + //! Pattern command type enum effect_type { effect_unknown = 0, @@ -76,14 +77,179 @@ }; // enum effect_type + //! Get pattern command type for pattern highlighting + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \return The command type in the effect column at the given pattern position (see openmpt::ext::pattern_vis::effect_type) + \sa openmpt::ext::pattern_vis::get_pattern_row_channel_effect_type + */ virtual effect_type get_pattern_row_channel_volume_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0; + //! Get pattern command type for pattern highlighting + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \return The command type in the volume column at the given pattern position (see openmpt::ext::pattern_vis::effect_type) + \sa openmpt::ext::pattern_vis::get_pattern_row_channel_volume_effect_type + */ virtual effect_type get_pattern_row_channel_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0; }; // class pattern_vis +LIBOPENMPT_DECLARE_EXT_INTERFACE(interactive) +class interactive { + + LIBOPENMPT_EXT_INTERFACE(interactive) + + //! Set the current ticks per row (speed) + /*! + \param speed The new tick count in range [1, 65535]. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the speed is outside the specified range. + \remarks The tick count may be reset by pattern commands at any time. + \sa openmpt::module::get_current_speed + */ + virtual void set_current_speed( std::int32_t speed ) = 0; + + //! Set the current module tempo + /*! + \param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the tempo is outside the specified range. + \remarks The tempo may be reset by pattern commands at any time. Use openmpt::ext:interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands. + \sa openmpt::module::get_current_tempo + */ + virtual void set_current_tempo( std::int32_t tempo ) = 0; + + //! Set the current module tempo factor without affecting playback pitch + /*! + \param factor The new tempo factor in range ]0.0, 4.0] - 1.0 means unmodified tempo. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range. + \remarks Modifying the tempo without applying the same pitch factor using openmpt::ext::interactive::set_pitch_factor may cause rhythmic samples (e.g. drum loops) to go out of sync. + \sa openmpt::ext::interactive::get_tempo_factor + */ + virtual void set_tempo_factor( double factor ) = 0; + + //! Gets the current module tempo factor + /*! + \return The current tempo factor. + \sa openmpt::ext::interactive::set_tempo_factor + */ + virtual double get_tempo_factor( ) const = 0; + + //! Set the current module pitch factor without affecting playback speed + /*! + \param factor The new pitch factor in range ]0.0, 4.0] - 1.0 means unmodified pitch. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range. + \remarks Modifying the pitch without applying the the same tempo factor openmpt::ext::interactive::set_tempo_factor may cause rhythmic samples (e.g. drum loops) to go out of sync. + \sa openmpt::ext::interactive::get_pitch_factor + */ + virtual void set_pitch_factor( double factor ) = 0; + + //! Gets the current module pitch factor + /*! + \return The current pitch factor. + \sa openmpt::ext::interactive::set_pitch_factor + */ + virtual double get_pitch_factor( ) const = 0; + + //! Set the current global volume + /*! + \param volume The new global volume in range [0.0, 1.0] + \throws openmpt::exception Throws an exception derived from openmpt::exception if the volume is outside the specified range. + \remarks The global volume may be reset by pattern commands at any time. Use openmpt::module:set_render_param to apply a global overall volume factor that is independent of pattern commands. + \sa openmpt::ext::interactive::get_global_volume + */ + virtual void set_global_volume( double volume ) = 0; + + //! Get the current global volume + /*! + \return The current global volume in range [0.0, 1.0] + \sa openmpt::ext::interactive::set_global_volume + */ + virtual double get_global_volume( ) const = 0; + + //! Set the current channel volume for a channel + /*! + \param channel The channel whose volume should be set, in range [0, openmpt::module::get_num_channels()[ + \param volume The new channel volume in range [0.0, 1.0] + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel or volume is outside the specified range. + \remarks The channel volume may be reset by pattern commands at any time. + \sa openmpt::ext::interactive::get_channel_volume + */ + virtual void set_channel_volume( std::int32_t channel, double volume ) = 0; + + //! Get the current channel volume for a channel + /*! + \param channel The channel whose volume should be retrieved, in range [0, openmpt::module::get_num_channels()[ + \return The current channel volume in range [0.0, 1.0] + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive::set_channel_volume + */ + virtual double get_channel_volume( std::int32_t channel ) const = 0; + + //! Set the current mute status for a channel + /*! + \param channel The channel whose mute status should be set, in range [0, openmpt::module::get_num_channels()[ + \param mute The new mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive::get_channel_mute_status + */ + virtual void set_channel_mute_status( std::int32_t channel, bool mute ) = 0; + + //! Get the current mute status for a channel + /*! + \param channel The channel whose mute status should be retrieved, in range [0, openmpt::module::get_num_channels()[ + \return The current channel mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive::set_channel_mute_status + */ + virtual bool get_channel_mute_status( std::int32_t channel ) const = 0; + + //! Set the current mute status for an instrument + /*! + \param instrument The instrument whose mute status should be set, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[ + \param mute The new mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range. + \sa openmpt::ext::interactive::get_instrument_mute_status + */ + virtual void set_instrument_mute_status( std::int32_t instrument, bool mute ) = 0; + + //! Get the current mute status for an instrument + /*! + \param instrument The instrument whose mute status should be retrieved, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[ + \return The current channel mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range. + \sa openmpt::ext::interactive::set_instrument_mute_status + */ + virtual bool get_instrument_mute_status( std::int32_t instrument ) const = 0; + + //! Play a note using the specified instrument + /*! + \param instrument The instrument that should be played, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[ + \param note The note to play, in rage [0, 119]. 60 is the middle C. + \param volume The volume at which the note should be triggered, in range [0.0, 1.0] + \param panning The panning position at which the note should be triggered, in range [-1.0, 1.0], 0.0 is center. + \return The channel on which the note is played. This can pe be passed to openmpt::ext::interactive::stop_note to stop the note. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument or note is outside the specified range. + \sa openmpt::ext::interactive::stop_note + */ + virtual std::int32_t play_note( std::int32_t instrument, std::int32_t note, double volume, double panning ) = 0; + + //! Stop the note playing on the specified channel + /*! + \param channel The channel on which the note should be stopped. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid. + \sa openmpt::ext::interactive::play_note + */ + virtual void stop_note( std::int32_t channel ) = 0; + +}; // class interactive + + /* add stuff here */ Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -598,7 +598,7 @@ m_nSamples = 0; m_nInstruments = 0; #ifndef MODPLUG_TRACKER - m_nFreqFactor = m_nTempoFactor = 128; + m_nFreqFactor = m_nTempoFactor = 65536; #endif m_nMinPeriod = MIN_PERIOD; m_nMaxPeriod = 0x7FFF; @@ -725,7 +725,7 @@ m_nMixChannels = 0; #ifndef MODPLUG_TRACKER - m_nFreqFactor = m_nTempoFactor = 128; + m_nFreqFactor = m_nTempoFactor = 65536; #endif m_PlayState.m_nGlobalVolume = MAX_GLOBAL_VOLUME; @@ -1877,7 +1877,7 @@ break; } #ifndef MODPLUG_TRACKER - m_PlayState.m_nSamplesPerTick = Util::muldivr(m_PlayState.m_nSamplesPerTick, m_nTempoFactor, 128); + m_PlayState.m_nSamplesPerTick = Util::muldivr(m_PlayState.m_nSamplesPerTick, m_nTempoFactor, 65536); #endif // !MODPLUG_TRACKER } @@ -1923,7 +1923,7 @@ } #ifndef MODPLUG_TRACKER // when the user modifies the tempo, we do not really care about accurate tempo error accumulation - retval = Util::muldivr(retval, m_nTempoFactor, 128); + retval = Util::muldivr(retval, m_nTempoFactor, 65536); #endif // !MODPLUG_TRACKER return retval; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-11-10 00:01:55 UTC (rev 4578) @@ -421,8 +421,8 @@ UINT m_nSamplePreAmp, m_nVSTiVolume; bool IsGlobalVolumeUnset() const { return IsFirstTick(); } #ifndef MODPLUG_TRACKER - UINT m_nFreqFactor; // Pitch shift factor (128 = no pitch shifting). Interesting ModPlug Player relict, but unused in OpenMPT. - UINT m_nTempoFactor; // Tempo factor (128 = no tempo adjustment). Interesting ModPlug Player relict, but unused in OpenMPT. + 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 int32 m_nRepeatCount; // -1 means repeat infinitely. Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -1986,7 +1986,7 @@ uint32 ninc = GetChannelIncrement(pChn, period, nPeriodFrac); #ifndef MODPLUG_TRACKER - ninc = Util::muldivr(ninc, m_nFreqFactor, 128); + ninc = Util::muldivr(ninc, m_nFreqFactor, 65536); #endif // !MODPLUG_TRACKER if(ninc == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-11-10 00:27:58
|
Revision: 4579 http://sourceforge.net/p/modplug/code/4579 Author: saga-games Date: 2014-11-10 00:27:49 +0000 (Mon, 10 Nov 2014) Log Message: ----------- [New] openmpt123: Added possibility to change playback tempo and pitch through openmpt::ext::interactive. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/dox/changelog.md trunk/OpenMPT/openmpt123/openmpt123.cpp Modified: trunk/OpenMPT/libopenmpt/dox/changelog.md =================================================================== --- trunk/OpenMPT/libopenmpt/dox/changelog.md 2014-11-10 00:01:55 UTC (rev 4578) +++ trunk/OpenMPT/libopenmpt/dox/changelog.md 2014-11-10 00:27:49 UTC (rev 4579) @@ -20,6 +20,8 @@ * [Bug] The -autotools tarballs were not working at all. * Vastly improved MT2 loader. + * Added openmpt::ext::interactive, an extension which adds a whole bunch of + new functionality to change playback in some way or another. * Added possibility to sync sample playback when using openmpt::module::set_position_* by setting the ctl value seek.sync_samples=1 * Support for "hidden" subsongs has been added. Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-11-10 00:01:55 UTC (rev 4578) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-11-10 00:27:49 UTC (rev 4579) @@ -81,7 +81,9 @@ #include <sys/types.h> #endif +#define LIBOPENMPT_EXT_IS_EXPERIMENTAL #include <libopenmpt/libopenmpt.hpp> +#include <libopenmpt/libopenmpt_ext.hpp> #include "openmpt123.hpp" @@ -547,6 +549,8 @@ log << " [j] seek 1 seconds backward" << std::endl; log << " [k] seek 1 seconds forward" << std::endl; log << " [l] seek 10 seconds forward" << std::endl; + log << " [u]|[i] +/- tempo" << std::endl; + log << " [o]|[p] +/- pitch" << std::endl; log << " [3]|[4] +/- gain" << std::endl; log << " [5]|[6] +/- stereo separation" << std::endl; log << " [7]|[8] +/- filter taps" << std::endl; @@ -577,6 +581,7 @@ template < typename Tmod > static bool handle_keypress( int c, commandlineflags & flags, Tmod & mod, write_buffers_interface & audio_stream ) { + openmpt::ext::interactive *interactive = static_cast<openmpt::ext::interactive*>( mod.get_interface( openmpt::ext::interactive_id ) ); switch ( c ) { case 'q': throw silent_exit_exception(); break; case 'N': throw prev_file(10); break; @@ -592,6 +597,10 @@ case 'L': mod.set_position_order_row( mod.get_current_order() + 1, 0 ); break; case 'm': throw next_file(1); break; case 'M': throw next_file(10); break; + case 'u': interactive->set_tempo_factor( std::max( 0.00001, interactive->get_tempo_factor() * std::pow( 2.0, -1.0 / 24.0 ) ) ); break; + case 'i': interactive->set_tempo_factor( std::min( 4.0, interactive->get_tempo_factor() * std::pow( 2.0, 1.0 / 24.0 ) ) ); break; + case 'o': interactive->set_pitch_factor( std::max( 0.00001, interactive->get_pitch_factor() * std::pow( 2.0, -1.0 / 24.0 ) ) ); break; + case 'p': interactive->set_pitch_factor( std::min( 4.0, interactive->get_pitch_factor() * std::pow( 2.0, 1.0 / 24.0 ) ) ); break; case '3': flags.gain -=100; apply_mod_settings( flags, mod ); break; case '4': flags.gain +=100; apply_mod_settings( flags, mod ); break; case '5': flags.separation -= 5; apply_mod_settings( flags, mod ); break; @@ -1396,7 +1405,7 @@ } { - openmpt::module mod( data_stream, silentlog, flags.ctls ); + openmpt::module_ext mod( data_stream, silentlog, flags.ctls ); mod.select_subsong( -1 ); // play all subsongs consecutively silentlog.str( std::string() ); // clear, loader messages get stored to get_metadata( "warnings" ) by libopenmpt internally render_mod_file( flags, filename, filesize, mod, log, audio_stream ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-11-10 08:56:10
|
Revision: 4580 http://sourceforge.net/p/modplug/code/4580 Author: manxorist Date: 2014-11-10 08:55:41 +0000 (Mon, 10 Nov 2014) Log Message: ----------- [Imp] libopenmpt: Add ctl interface for tempo and pitch factor. [Fix] openmpt123: Do not depend on libopenmpt_ext. [Fix] openmpt123: Avoid cumulative rounding errors when changing pitch and tempo. [New] openmpt123: Add --tempo and --pitch command line options. [Mod] openmpt123: Retain tempo and pitch factors across module change. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123.hpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-11-10 00:27:49 UTC (rev 4579) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-11-10 08:55:41 UTC (rev 4580) @@ -1187,6 +1187,8 @@ retval.push_back( "load.skip_samples" ); retval.push_back( "load.skip_patterns" ); retval.push_back( "seek.sync_samples" ); + retval.push_back( "play.tempo_factor" ); + retval.push_back( "play.pitch_factor" ); retval.push_back( "dither" ); return retval; } @@ -1199,6 +1201,10 @@ return mpt::ToString( m_ctl_load_skip_patterns ); } else if ( ctl == "seek.sync_samples" ) { return mpt::ToString( m_ctl_seek_sync_samples ); + } else if ( ctl == "play.tempo_factor" ) { + return mpt::ToString( 65536.0 / m_sndFile->m_nTempoFactor ); + } else if ( ctl == "play.pitch_factor" ) { + return mpt::ToString( m_sndFile->m_nFreqFactor / 65536.0 ); } else if ( ctl == "dither" ) { return mpt::ToString( static_cast<int>( m_Dither->GetMode() ) ); } else { @@ -1214,6 +1220,20 @@ m_ctl_load_skip_patterns = ConvertStrTo<bool>( value ); } else if ( ctl == "seek.sync_samples" ) { m_ctl_seek_sync_samples = ConvertStrTo<bool>( value ); + } else if ( ctl == "play.tempo_factor" ) { + double factor = ConvertStrTo<double>( value ); + if ( factor <= 0.0 || factor > 4.0 ) { + throw openmpt::exception("invalid tempo factor"); + } + m_sndFile->m_nTempoFactor = Util::Round<uint32_t>( 65536.0 / factor ); + m_sndFile->RecalculateSamplesPerTick(); + } else if ( ctl == "play.pitch_factor" ) { + double factor = ConvertStrTo<double>( value ); + if ( factor <= 0.0 || factor > 4.0 ) { + throw openmpt::exception("invalid pitch factor"); + } + m_sndFile->m_nFreqFactor = Util::Round<uint32_t>( 65536.0 * factor ); + m_sndFile->RecalculateSamplesPerTick(); } else if ( ctl == "dither" ) { m_Dither->SetMode( static_cast<DitherMode>( ConvertStrTo<int>( value ) ) ); } else { Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-11-10 00:27:49 UTC (rev 4579) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-11-10 08:55:41 UTC (rev 4580) @@ -81,9 +81,7 @@ #include <sys/types.h> #endif -#define LIBOPENMPT_EXT_IS_EXPERIMENTAL #include <libopenmpt/libopenmpt.hpp> -#include <libopenmpt/libopenmpt_ext.hpp> #include "openmpt123.hpp" @@ -234,6 +232,30 @@ return result; } +static double tempo_flag_to_double( std::int32_t tempo ) { + return std::pow( 2.0, tempo / 24.0 ); +} + +static double pitch_flag_to_double( std::int32_t pitch ) { + return std::pow( 2.0, pitch / 24.0 ); +} + +static double my_round( double val ) { + if ( val >= 0.0 ) { + return std::floor( val + 0.5 ); + } else { + return std::ceil( val - 0.5 ); + } +} + +static std::int32_t double_to_tempo_flag( double factor ) { + return static_cast<std::int32_t>( my_round( std::log( factor ) / std::log( 2.0 ) * 24.0 ) ); +} + +static std::int32_t double_to_pitch_flag( double factor ) { + return static_cast<std::int32_t>( my_round( std::log( factor ) / std::log( 2.0 ) * 24.0 ) ); +} + static std::ostream & operator << ( std::ostream & s, const commandlineflags & flags ) { s << "Quiet: " << flags.quiet << std::endl; s << "Verbose: " << flags.verbose << std::endl; @@ -254,6 +276,8 @@ s << "Stereo separation: " << flags.separation << std::endl; s << "Interpolation filter taps: " << flags.filtertaps << std::endl; s << "Volume ramping strength: " << flags.ramping << std::endl; + s << "Tempo: " << tempo_flag_to_double( flags.tempo ) << std::endl; + s << "Pitch: " << pitch_flag_to_double( flags.pitch ) << std::endl; s << "Output dithering: " << flags.dither << std::endl; s << "Repeat count: " << flags.repeatcount << std::endl; s << "Seek target: " << flags.seek_target << std::endl; @@ -488,6 +512,8 @@ log << " --stereo n Set stereo separation to n % [default: " << commandlineflags().separation << "]" << std::endl; log << " --filter n Set interpolation filter taps to n [1,2,4,8] [default: " << commandlineflags().filtertaps << "]" << std::endl; log << " --ramping n Set volume ramping strength n [0..5] [default: " << commandlineflags().ramping << "]" << std::endl; + log << " --tempo f Set tempo factor f [default: " << tempo_flag_to_double( commandlineflags().tempo ) << "]" << std::endl; + log << " --pitch f Set pitch factor f [default: " << pitch_flag_to_double( commandlineflags().pitch ) << "]" << std::endl; log << " --dither n Dither type to use (if applicable for selected output format): [0=off,1=auto,2=0.5bit,3=1bit] [default: " << commandlineflags().dither << "]" << std::endl; log << std::endl; log << " --[no-]shuffle Shuffle playlist [default: " << commandlineflags().shuffle << "]" << std::endl; @@ -559,6 +585,34 @@ log.writeout(); } + +template < typename T, typename Tmod > +T ctl_get( Tmod & mod, const std::string & ctl ) { + T result = T(); + try { + std::istringstream str; + str.imbue( std::locale::classic() ); + str.str( mod.ctl_get( ctl ) ); + str >> std::fixed >> std::setprecision(16) >> result; + } catch ( const openmpt::exception & ) { + // ignore + } + return result; +} + +template < typename T, typename Tmod > +void ctl_set( Tmod & mod, const std::string & ctl, const T & val ) { + try { + std::ostringstream str; + str.imbue( std::locale::classic() ); + str << std::fixed << std::setprecision(16) << val; + mod.ctl_set( ctl, str.str() ); + } catch ( const openmpt::exception & ) { + // ignore + } + return; +} + template < typename Tmod > static void apply_mod_settings( commandlineflags & flags, Tmod & mod ) { flags.separation = std::max( flags.separation, 0 ); @@ -566,10 +620,16 @@ flags.filtertaps = std::min( flags.filtertaps, 8 ); flags.ramping = std::max( flags.ramping, -1 ); flags.ramping = std::min( flags.ramping, 10 ); + flags.tempo = std::max( flags.tempo, -48 ); + flags.tempo = std::min( flags.tempo, 48 ); + flags.pitch = std::max( flags.pitch, -48 ); + flags.pitch = std::min( flags.pitch, 48 ); mod.set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, flags.gain ); mod.set_render_param( openmpt::module::RENDER_STEREOSEPARATION_PERCENT, flags.separation ); mod.set_render_param( openmpt::module::RENDER_INTERPOLATIONFILTER_LENGTH, flags.filtertaps ); mod.set_render_param( openmpt::module::RENDER_VOLUMERAMPING_STRENGTH, flags.ramping ); + ctl_set( mod, "play.tempo_factor", tempo_flag_to_double( flags.tempo ) ); + ctl_set( mod, "play.pitch_factor", pitch_flag_to_double( flags.pitch ) ); std::ostringstream dither_str; dither_str.imbue( std::locale::classic() ); dither_str << flags.dither; @@ -581,7 +641,6 @@ template < typename Tmod > static bool handle_keypress( int c, commandlineflags & flags, Tmod & mod, write_buffers_interface & audio_stream ) { - openmpt::ext::interactive *interactive = static_cast<openmpt::ext::interactive*>( mod.get_interface( openmpt::ext::interactive_id ) ); switch ( c ) { case 'q': throw silent_exit_exception(); break; case 'N': throw prev_file(10); break; @@ -597,10 +656,10 @@ case 'L': mod.set_position_order_row( mod.get_current_order() + 1, 0 ); break; case 'm': throw next_file(1); break; case 'M': throw next_file(10); break; - case 'u': interactive->set_tempo_factor( std::max( 0.00001, interactive->get_tempo_factor() * std::pow( 2.0, -1.0 / 24.0 ) ) ); break; - case 'i': interactive->set_tempo_factor( std::min( 4.0, interactive->get_tempo_factor() * std::pow( 2.0, 1.0 / 24.0 ) ) ); break; - case 'o': interactive->set_pitch_factor( std::max( 0.00001, interactive->get_pitch_factor() * std::pow( 2.0, -1.0 / 24.0 ) ) ); break; - case 'p': interactive->set_pitch_factor( std::min( 4.0, interactive->get_pitch_factor() * std::pow( 2.0, 1.0 / 24.0 ) ) ); break; + case 'u': flags.tempo -= 1; apply_mod_settings( flags, mod ); break; + case 'i': flags.tempo += 1; apply_mod_settings( flags, mod ); break; + case 'o': flags.pitch -= 1; apply_mod_settings( flags, mod ); break; + case 'p': flags.pitch += 1; apply_mod_settings( flags, mod ); break; case '3': flags.gain -=100; apply_mod_settings( flags, mod ); break; case '4': flags.gain +=100; apply_mod_settings( flags, mod ); break; case '5': flags.separation -= 5; apply_mod_settings( flags, mod ); break; @@ -1405,7 +1464,7 @@ } { - openmpt::module_ext mod( data_stream, silentlog, flags.ctls ); + openmpt::module mod( data_stream, silentlog, flags.ctls ); mod.select_subsong( -1 ); // play all subsongs consecutively silentlog.str( std::string() ); // clear, loader messages get stored to get_metadata( "warnings" ) by libopenmpt internally render_mod_file( flags, filename, filesize, mod, log, audio_stream ); @@ -1652,6 +1711,18 @@ std::istringstream istr( nextarg ); istr >> flags.ramping; ++i; + } else if ( arg == "--tempo" && nextarg != "" ) { + std::istringstream istr( nextarg ); + double tmp = 1.0; + istr >> tmp; + flags.tempo = double_to_tempo_flag( tmp ); + ++i; + } else if ( arg == "--pitch" && nextarg != "" ) { + std::istringstream istr( nextarg ); + double tmp = 1.0; + istr >> tmp; + flags.pitch = double_to_pitch_flag( tmp ); + ++i; } else if ( arg == "--dither" && nextarg != "" ) { std::istringstream istr( nextarg ); istr >> flags.dither; Modified: trunk/OpenMPT/openmpt123/openmpt123.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.hpp 2014-11-10 00:27:49 UTC (rev 4579) +++ trunk/OpenMPT/openmpt123/openmpt123.hpp 2014-11-10 08:55:41 UTC (rev 4580) @@ -251,6 +251,8 @@ std::int32_t separation; std::int32_t filtertaps; std::int32_t ramping; // ramping strength : -1:default 0:off 1 2 3 4 5 // roughly milliseconds + std::int32_t tempo; + std::int32_t pitch; std::int32_t dither; std::int32_t repeatcount; std::map<std::string, std::string> ctls; @@ -306,6 +308,8 @@ separation = 100; filtertaps = 8; ramping = -1; + tempo = 0; + pitch = 0; dither = 1; repeatcount = 0; seek_target = 0.0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-11-10 12:39:48
|
Revision: 4585 http://sourceforge.net/p/modplug/code/4585 Author: manxorist Date: 2014-11-10 12:39:42 +0000 (Mon, 10 Nov 2014) Log Message: ----------- [Mod] build: Remove EXPERIMENTAL_LIBOPENMPT_EXT option from Makefile again. libopenmpt_ext is already included in Visual Studio as well as in Autotools and Android builds. There is no point in not including it in Makefile builds by default. [Mod] build: Distribute libopenmpt_ext.hpp in autotools and windows packages. Modified Paths: -------------- trunk/OpenMPT/Makefile trunk/OpenMPT/build/auto/package_libopenmpt_win32.cmd trunk/OpenMPT/build/auto/package_libopenmpt_win64.cmd trunk/OpenMPT/build/autotools/Makefile.am trunk/OpenMPT/libopenmpt/dox/changelog.md Modified: trunk/OpenMPT/Makefile =================================================================== --- trunk/OpenMPT/Makefile 2014-11-10 11:39:10 UTC (rev 4584) +++ trunk/OpenMPT/Makefile 2014-11-10 12:39:42 UTC (rev 4585) @@ -49,10 +49,6 @@ # ANCIENT=0 Use a pre-C++0x compiler (i.e. GCC before 4.3) # # -# Experimental features (need to be enabled explicitely): -# EXPERIMENTAL_LIBOPENMPT_EXT=1 Include libopenmpt_ext interface. -# -# # Build flags for libopenmpt (provide on each `make` invocation) # (defaults are 0): # @@ -135,9 +131,7 @@ SOSUFFIX=.so OPENMPT123=1 -EXPERIMENTAL_LIBOPENMPT_EXT=0 - # get commandline or defaults CPPFLAGS := $(CPPFLAGS) @@ -438,10 +432,8 @@ libopenmpt/libopenmpt_c.cpp \ libopenmpt/libopenmpt_cxx.cpp \ libopenmpt/libopenmpt_impl.cpp \ + libopenmpt/libopenmpt_ext.cpp \ -ifeq ($(EXPERIMENTAL_LIBOPENMPT_EXT),1) -LIBOPENMPT_CXX_SOURCES += libopenmpt/libopenmpt_ext.cpp -endif ifeq ($(NO_ZLIB),1) LIBOPENMPT_C_SOURCES += include/miniz/miniz.c endif @@ -637,9 +629,7 @@ $(INSTALL_DATA) libopenmpt/libopenmpt_stream_callbacks_fd.h $(DESTDIR)$(PREFIX)/include/libopenmpt/libopenmpt_stream_callbacks_fd.h $(INSTALL_DATA) libopenmpt/libopenmpt_stream_callbacks_file.h $(DESTDIR)$(PREFIX)/include/libopenmpt/libopenmpt_stream_callbacks_file.h $(INSTALL_DATA) libopenmpt/libopenmpt.hpp $(DESTDIR)$(PREFIX)/include/libopenmpt/libopenmpt.hpp -ifeq ($(EXPERIMENTAL_LIBOPENMPT_EXT),1) $(INSTALL_DATA) libopenmpt/libopenmpt_ext.hpp $(DESTDIR)$(PREFIX)/include/libopenmpt/libopenmpt_ext.hpp -endif $(INSTALL_MAKE_DIR) $(DESTDIR)$(PREFIX)/lib/pkgconfig $(INSTALL_DATA) bin/libopenmpt.pc $(DESTDIR)$(PREFIX)/lib/pkgconfig/libopenmpt.pc ifeq ($(SHARED_LIB),1) Modified: trunk/OpenMPT/build/auto/package_libopenmpt_win32.cmd =================================================================== --- trunk/OpenMPT/build/auto/package_libopenmpt_win32.cmd 2014-11-10 11:39:10 UTC (rev 4584) +++ trunk/OpenMPT/build/auto/package_libopenmpt_win32.cmd 2014-11-10 12:39:42 UTC (rev 4585) @@ -18,6 +18,7 @@ copy /y ..\..\libopenmpt\libopenmpt.hpp inc\libopenmpt\ || goto error copy /y ..\..\libopenmpt\libopenmpt_config.h inc\libopenmpt\ || goto error copy /y ..\..\libopenmpt\libopenmpt_version.h inc\libopenmpt\ || goto error +copy /y ..\..\libopenmpt\libopenmpt_ext.hpp inc\libopenmpt\ || goto error copy /y libopenmpt.lib lib\Win32\ || goto error copy /y libopenmpt.dll bin\Win32\ || goto error copy /y ..\..\libopenmpt\doc\in_openmpt.txt .\ || goto error Modified: trunk/OpenMPT/build/auto/package_libopenmpt_win64.cmd =================================================================== --- trunk/OpenMPT/build/auto/package_libopenmpt_win64.cmd 2014-11-10 11:39:10 UTC (rev 4584) +++ trunk/OpenMPT/build/auto/package_libopenmpt_win64.cmd 2014-11-10 12:39:42 UTC (rev 4585) @@ -18,6 +18,7 @@ copy /y ..\..\libopenmpt\libopenmpt.hpp inc\libopenmpt\ || goto error copy /y ..\..\libopenmpt\libopenmpt_config.h inc\libopenmpt\ || goto error copy /y ..\..\libopenmpt\libopenmpt_version.h inc\libopenmpt\ || goto error +copy /y ..\..\libopenmpt\libopenmpt_ext.hpp inc\libopenmpt\ || goto error copy /y libopenmpt.lib lib\x64\ || goto error copy /y libopenmpt.dll bin\x64\ || goto error copy /y ..\..\LICENSE .\ || goto error Modified: trunk/OpenMPT/build/autotools/Makefile.am =================================================================== --- trunk/OpenMPT/build/autotools/Makefile.am 2014-11-10 11:39:10 UTC (rev 4584) +++ trunk/OpenMPT/build/autotools/Makefile.am 2014-11-10 12:39:42 UTC (rev 4585) @@ -67,7 +67,7 @@ pkgconfig_DATA += libopenmpt/libopenmpt.pc lib_LTLIBRARIES += libopenmpt.la libopenmpt_la_LDFLAGS = -version-info 0:7:0 -nobase_include_HEADERS += libopenmpt/libopenmpt.h libopenmpt/libopenmpt.hpp libopenmpt/libopenmpt_version.h libopenmpt/libopenmpt_config.h libopenmpt/libopenmpt_stream_callbacks_fd.h libopenmpt/libopenmpt_stream_callbacks_file.h +nobase_include_HEADERS += libopenmpt/libopenmpt.h libopenmpt/libopenmpt.hpp libopenmpt/libopenmpt_version.h libopenmpt/libopenmpt_config.h libopenmpt/libopenmpt_stream_callbacks_fd.h libopenmpt/libopenmpt_stream_callbacks_file.h libopenmpt/libopenmpt_ext.hpp libopenmpt_la_CPPFLAGS = -DLIBOPENMPT_BUILD -I$(srcdir)/build/svn_version -I$(srcdir)/ -I$(srcdir)/common $(ZLIB_CFLAGS) $(LTDL_CPPFLAGS) libopenmpt_la_CXXFLAGS = $(ZLIB_CFLAGS) libopenmpt_la_CFLAGS = $(ZLIB_CFLAGS) Modified: trunk/OpenMPT/libopenmpt/dox/changelog.md =================================================================== --- trunk/OpenMPT/libopenmpt/dox/changelog.md 2014-11-10 11:39:10 UTC (rev 4584) +++ trunk/OpenMPT/libopenmpt/dox/changelog.md 2014-11-10 12:39:42 UTC (rev 4585) @@ -16,6 +16,8 @@ * GCC 4.1.x to 4.3.x (use `make ANCIENT=1`) * Microsoft Visual Studio 2008 (with latest Service Pack) (see `build/vs2008`) + * libopenmpt_ext.hpp is now distributed by default. The API is still + considered experimental and not guaranteed to stay API or ABI compatible. * [Bug] The -autotools tarballs were not working at all. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |