From: <sag...@us...> - 2011-10-03 16:52:55
|
Revision: 1078 http://modplug.svn.sourceforge.net/modplug/?rev=1078&view=rev Author: saga-games Date: 2011-10-03 16:52:48 +0000 (Mon, 03 Oct 2011) Log Message: ----------- [New] Sample Editor: Experimental feature: Autotune sample to the closest C. [Fix] Sample Editor: X-Fade shortcut was broken. [Mod] OpenMPT: Version is now 1.20.00.36 Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack.vcproj trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/mptrack/res/patterns.bmp trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.h Added Paths: ----------- trunk/OpenMPT/mptrack/Autotune.cpp trunk/OpenMPT/mptrack/Autotune.h Added: trunk/OpenMPT/mptrack/Autotune.cpp =================================================================== --- trunk/OpenMPT/mptrack/Autotune.cpp (rev 0) +++ trunk/OpenMPT/mptrack/Autotune.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -0,0 +1,243 @@ +/* + * Autotune.cpp + * ------------- + * Purpose: Class for tuning a sample to the next C automatically. + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + + +#include "stdafx.h" +#include <math.h> +#include "../common/misc_util.h" +#include "../soundlib/Sndfile.h" +#include "Autotune.h" + + +// The more bins, the more autocorrelations are done and the more precise the result is. +#define BINS_PER_NOTE 32 +#define MIN_SAMPLE_LENGTH 2 + + +double Autotune::FrequencyToNote(double freq) const +//------------------------------------------------- +{ + return ((12.0 * (log(freq / (440.0 / 2.0)) / log(2.0))) + 57.0); +} + + +double Autotune::NoteToFrequency(double note) const +//------------------------------------------------- +{ + return 440.0 * pow(2.0, (note - 69.0) / 12.0); +} + + +// Calculate the amount of samples for autocorrelation shifting for a given note +SmpLength Autotune::NoteToShift(uint32 sampleFreq, int note) const +//------------------------------------------------------------------- +{ + const double fundamentalFrequency = NoteToFrequency((double)note / BINS_PER_NOTE); + return (SmpLength)max(Util::Round((double)sampleFreq / fundamentalFrequency), 1); +} + + +// Create an 8-Bit sample buffer with loop unrolling and mono conversion for autocorrelation. +template <class T> +void Autotune::CopySamples(const T* origSample, SmpLength sampleLoopStart, SmpLength sampleLoopEnd) +//------------------------------------------------------------------------------------------------- +{ + const uint8 channels = sample.GetNumChannels(); + sampleLoopStart *= channels; + sampleLoopEnd *= channels; + + for(SmpLength i = 0, pos = 0; i < sampleLength; i++, pos += channels) + { + if(pos >= sampleLoopEnd) + { + pos = sampleLoopStart; + } + + const T* sample = origSample + pos; + + int16 data = 0; // Enough for 256 channels... :) + for(uint8 chn = 0; chn < channels; chn++) + { + // We only want the MSB. + data += static_cast<int16>(sample[chn] >> ((sizeof(T) - 1) * 8)); + } + + data /= channels; + + sampleData[i] = static_cast<int8>(data); + } +} + + +// Prepare a sample buffer for autocorrelation +bool Autotune::PrepareSample(SmpLength maxShift) +//---------------------------------------------- +{ + + // Determine which parts of the sample should be examined. + SmpLength sampleOffset = 0, sampleLoopStart = 0, sampleLoopEnd = sample.nLength; + if(selectionEnd >= sampleLoopStart + MIN_SAMPLE_LENGTH) + { + // A selection has been specified: Examine selection + sampleOffset = selectionStart; + sampleLoopStart = 0; + sampleLoopEnd = selectionEnd - selectionStart; + } else if((sample.uFlags & CHN_SUSTAINLOOP) && sample.nSustainEnd >= sample.nSustainStart + MIN_SAMPLE_LENGTH) + { + // A sustain loop is set: Examine sample up to sustain loop and, if necessary, execute the loop several times + sampleOffset = 0; + sampleLoopStart = sample.nSustainStart; + sampleLoopEnd = sample.nSustainEnd; + } else if((sample.uFlags & CHN_LOOP) && sample.nLoopEnd >= sample.nLoopStart + MIN_SAMPLE_LENGTH) + { + // A normal loop is set: Examine sample up to loop and, if necessary, execute the loop several times + sampleOffset = 0; + sampleLoopStart = sample.nLoopStart; + sampleLoopEnd = sample.nLoopEnd; + } + + // We should analyse at least a one second (= GetSampleRate() samples) long sample. + sampleLength = max(sampleLoopEnd, sample.GetSampleRate(modType)) + maxShift; + + if(sampleData != nullptr) + { + delete[] sampleData; + } + try + { + sampleData = new int8[sampleLength]; + } catch(MPTMemoryException) + { + return false; + } + + // Copy sample over. + switch(sample.GetElementarySampleSize()) + { + case 1: + CopySamples(reinterpret_cast<int8 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); + return true; + + case 2: + CopySamples(reinterpret_cast<int16 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); + return true; + } + + return false; + +} + + +bool Autotune::CanApply() const + //----------------------------- +{ + return (sample.pSample != nullptr && sample.nLength >= MIN_SAMPLE_LENGTH); +} + + +bool Autotune::Apply() +//-------------------- +{ + if(!CanApply()) + { + return false; + } + + const int autocorrStartNote = 24 * BINS_PER_NOTE; // C-2 + const int autocorrEndNote = 96 * BINS_PER_NOTE; // C-8 + const int historyBins = 12 * BINS_PER_NOTE; // One octave + + const uint32 sampleFreq = sample.GetSampleRate(modType); + // At the lowest frequency, we get the highest autocorrelation shift amount. + const SmpLength maxShift = NoteToShift(sampleFreq, autocorrStartNote); + if(!PrepareSample(maxShift)) + { + return false; + } + // We don't process the autocorrelation overhead. + const SmpLength processLength = sampleLength - maxShift; + + // Histogram for all notes. + vector<uint64> autocorrHistogram(historyBins, 0); + + // Do autocorrelation and save results in a note histogram (restriced to one octave). + for(int note = autocorrStartNote, noteBin = note; note < autocorrEndNote; note++, noteBin++) + { + + if(noteBin >= historyBins) + { + noteBin %= historyBins; + } + + const SmpLength autocorrShift = NoteToShift(sampleFreq, note); + + uint64 autocorrSum = 0; + const int8 *normalData = sampleData; + const int8 *shiftedData = sampleData + autocorrShift; + // Add up squared differences of all values + for(SmpLength i = processLength; i > 0; i--, normalData++, shiftedData++) + { + autocorrSum += (*normalData - *shiftedData) * (*normalData - *shiftedData); + } + autocorrHistogram[noteBin] += autocorrSum; + + } + + // Interpolate the histogram... + vector<uint64> interpolatedHistogram(historyBins, 0); + for(int i = 0; i < historyBins; i++) + { + const int kernelWidth = 4; + for(int ki = kernelWidth; ki >= 0; ki--) + { + // Choose bins to interpolate with + int left = (int)i - ki; + if(left < 0) left += historyBins; + int right = (int)i + ki; + if(right >= historyBins) right -= historyBins; + + interpolatedHistogram[i] = interpolatedHistogram[i] / 2 + (autocorrHistogram[left] + autocorrHistogram[right]) / 2; + } + } + + // ...and find global minimum + int minimumBin = 0; + //bool decrease = false; + for(int i = 0; i < historyBins; i++) + { + const int prev = (i > 0) ? (i - 1) : (historyBins - 1); + // Are we at a minimum? + //if(interpolatedHistogram[i] > interpolatedHistogram[prev] && decrease) + { + // Are we at the global minimum? + if(interpolatedHistogram[prev] < interpolatedHistogram[minimumBin]) + { + minimumBin = prev; + } + } + //decrease = (interpolatedHistogram[i] < interpolatedHistogram[prev]); + + } + + // Center around C + if(minimumBin >= 6 * BINS_PER_NOTE) minimumBin -= 12 * BINS_PER_NOTE; + const double newFundamentalFreq = NoteToFrequency(69.0 + (double)minimumBin / BINS_PER_NOTE); + + sample.nC5Speed = (UINT)Util::Round(sample.nC5Speed * 440.0 / newFundamentalFreq); + + if((modType & (MOD_TYPE_XM | MOD_TYPE_MOD)) != 0) + { + CSoundFile::FrequencyToTranspose(&sample); + if((modType & MOD_TYPE_MOD) != 0) + { + sample.RelativeTone = 0; + } + } + + return true; +} Added: trunk/OpenMPT/mptrack/Autotune.h =================================================================== --- trunk/OpenMPT/mptrack/Autotune.h (rev 0) +++ trunk/OpenMPT/mptrack/Autotune.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -0,0 +1,56 @@ +/* + * Autotune.h + * ---------- + * Purpose: Header file for sample auto tuning + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + + +#pragma once +#ifndef AUTOTUNE_H +#define AUTOTUNE_H + +#include "../soundlib/Snd_defs.h" + +//============ +class Autotune +//============ +{ +protected: + MODSAMPLE &sample; + MODTYPE modType; + + SmpLength selectionStart, selectionEnd; + + int8 *sampleData; + SmpLength sampleLength; + +public: + Autotune(MODSAMPLE &smp, MODTYPE type, SmpLength selStart, SmpLength selEnd) : sample(smp), modType(type), selectionStart(selStart), selectionEnd(selEnd) + { + sampleData = 0; + sampleLength = 0; + }; + + ~Autotune() + { + delete[] sampleData; + } + + bool CanApply() const; + bool Apply(); + +protected: + double FrequencyToNote(double freq) const; + double NoteToFrequency(double note) const; + SmpLength NoteToShift(uint32 sampleFreq, int note) const; + + template <class T> + void CopySamples(const T* origSample, SmpLength sampleLoopStart, SmpLength sampleLoopEnd); + + bool PrepareSample(SmpLength maxShift); + +}; + +#endif // AUTOTUNE_H Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -609,6 +609,7 @@ DefineKeyCommand(kcFileSaveTemplate, 1860, _T("File/Save As Template")); DefineKeyCommand(kcIncreaseSpacing, 1861, _T("Increase row spacing")); DefineKeyCommand(kcDecreaseSpacing, 1862, _T("Decrease row spacing")); + DefineKeyCommand(kcSampleAutotune, 1863, _T("Autotune sample to C")); // Add new key commands here. #ifdef _DEBUG Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/CommandSet.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -618,7 +618,8 @@ kcSampleRemoveDCOffset, kcSampleQuickFade, kcSampleXFade, - kcEndSampleEditing=kcSampleXFade, + kcSampleAutotune, + kcEndSampleEditing=kcSampleAutotune, //kcSampStartNotes to kcInsNoteMapEndNoteStops must be contiguous. kcSampStartNotes, Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -16,6 +16,7 @@ #include "smbPitchShift.cpp" #pragma warning(default:4244) //"conversion from 'type1' to 'type2', possible loss of data" #include "modsmp_ctrl.h" +#include "Autotune.h" #include "../common/StringFixer.h" #include <Shlwapi.h> @@ -72,6 +73,7 @@ ON_COMMAND(IDC_SAMPLE_SIGN_UNSIGN, OnSignUnSign) ON_COMMAND(IDC_SAMPLE_DCOFFSET, OnRemoveDCOffset) ON_COMMAND(IDC_SAMPLE_XFADE, OnXFade) + ON_COMMAND(IDC_SAMPLE_AUTOTUNE, OnAutotune) ON_COMMAND(IDC_CHECK1, OnSetPanningChanged) ON_COMMAND(ID_PREVINSTRUMENT, OnPrevInstrument) ON_COMMAND(ID_NEXTINSTRUMENT, OnNextInstrument) @@ -215,6 +217,7 @@ m_ToolBar2.AddButton(IDC_SAMPLE_INVERT, TIMAGE_SAMPLE_INVERT); m_ToolBar2.AddButton(IDC_SAMPLE_SIGN_UNSIGN, TIMAGE_SAMPLE_UNSIGN); m_ToolBar2.AddButton(IDC_SAMPLE_XFADE, TIMAGE_SAMPLE_FIXLOOP); + m_ToolBar2.AddButton(IDC_SAMPLE_AUTOTUNE, TIMAGE_SAMPLE_AUTOTUNE); // Setup Controls m_SpinVolume.SetRange(0, 64); m_SpinGlobalVol.SetRange(0, 64); @@ -469,7 +472,12 @@ case IDC_SAMPLE_XFADE: OnXFade(); + break; + case IDC_SAMPLE_AUTOTUNE: + OnAutotune(); + break; + case IDC_SAMPLE_SIGN_UNSIGN: OnSignUnSign(); break; @@ -3179,3 +3187,24 @@ } } + +void CCtrlSamples::OnAutotune() +//----------------------------- +{ + SELECTIONPOINTS selection = GetSelectionPoints(); + if(!selection.bSelected) + { + selection.nStart = selection.nEnd = 0; + } + + Autotune at(m_pSndFile->GetSample(m_nSample), m_pSndFile->GetType(), selection.nStart, selection.nEnd); + if(at.CanApply()) + { + BeginWaitCursor(); + m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_none); + at.Apply(); + m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO, NULL); + m_pModDoc->SetModified(); + EndWaitCursor(); + } +} Modified: trunk/OpenMPT/mptrack/Ctrl_smp.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/Ctrl_smp.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -90,6 +90,7 @@ afx_msg void OnSilence(); afx_msg void OnInvert(); afx_msg void OnSignUnSign(); + afx_msg void OnAutotune(); afx_msg void OnNameChanged(); afx_msg void OnFileNameChanged(); afx_msg void OnVolumeChanged(); Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -289,6 +289,7 @@ TIMAGE_SAMPLE_DCOFFSET, TIMAGE_PATTERN_OVERFLOWPASTE, TIMAGE_SAMPLE_FIXLOOP, + TIMAGE_SAMPLE_AUTOTUNE, }; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -2514,7 +2514,7 @@ CAddSilenceDlg dlg(this, 32, sample.nLength); if (dlg.DoModal() != IDOK) return; - const ctrlSmp::SmpLength nOldLength = sample.nLength; + const SmpLength nOldLength = sample.nLength; if(MAX_SAMPLE_LENGTH - nOldLength < dlg.m_nSamples) { @@ -2672,6 +2672,7 @@ case kcSampleSignUnsign: PostCtrlMessage(IDC_SAMPLE_SIGN_UNSIGN); return wParam; case kcSampleRemoveDCOffset: PostCtrlMessage(IDC_SAMPLE_DCOFFSET); return wParam; case kcSampleXFade: PostCtrlMessage(IDC_SAMPLE_XFADE); return wParam; + case kcSampleAutotune: PostCtrlMessage(IDC_SAMPLE_AUTOTUNE); return wParam; case kcSampleQuickFade: PostCtrlMessage(IDC_SAMPLE_QUICKFADE); return wParam; // Those don't seem to work. Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-10-03 16:52:48 UTC (rev 1078) @@ -2546,6 +2546,7 @@ STRINGTABLE BEGIN IDC_SAMPLE_XFADE "Crossfade Loop Points\nCrossfade between loop start and loop end to create seamless sample loops." + IDC_SAMPLE_AUTOTUNE "Autotune sample to C\nTune the sample to the closest C." END #endif // English (United States) resources Modified: trunk/OpenMPT/mptrack/mptrack.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack.vcproj 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack.vcproj 2011-10-03 16:52:48 UTC (rev 1078) @@ -187,6 +187,9 @@ RelativePath=".\AutoSaver.cpp"> </File> <File + RelativePath=".\Autotune.cpp"> + </File> + <File RelativePath=".\ChannelManagerDlg.cpp"> </File> <File @@ -678,6 +681,9 @@ RelativePath=".\AutoSaver.h"> </File> <File + RelativePath=".\Autotune.h"> + </File> + <File RelativePath=".\ChannelManagerDlg.h"> </File> <File Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-10-03 16:52:48 UTC (rev 1078) @@ -253,6 +253,10 @@ > </File> <File + RelativePath=".\Autotune.cpp" + > + </File> + <File RelativePath=".\ChannelManagerDlg.cpp" > </File> @@ -899,6 +903,10 @@ > </File> <File + RelativePath=".\Autotune.h" + > + </File> + <File RelativePath=".\ChannelManagerDlg.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-10-03 16:52:48 UTC (rev 1078) @@ -171,6 +171,7 @@ <ClCompile Include="ACMConvert.cpp" /> <ClCompile Include="ArrayUtils.cpp" /> <ClCompile Include="AutoSaver.cpp" /> + <ClCompile Include="Autotune.cpp" /> <ClCompile Include="ChannelManagerDlg.cpp" /> <ClCompile Include="ChildFrm.cpp" /> <ClCompile Include="CleanupSong.cpp" /> @@ -323,6 +324,7 @@ <ClInclude Include="..\common\StringFixer.h" /> <ClInclude Include="..\common\typedefs.h" /> <ClInclude Include="ACMConvert.h" /> + <ClInclude Include="Autotune.h" /> <ClInclude Include="ExceptionHandler.h" /> <ClInclude Include="PatternRandomizer.h" /> <ClInclude Include="PatternRandomizerGUI.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-10-03 16:52:48 UTC (rev 1078) @@ -430,6 +430,9 @@ <ClCompile Include="MIDIMappingDialog.cpp"> <Filter>Source Files\Dialogs</Filter> </ClCompile> + <ClCompile Include="Autotune.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="AbstractVstEditor.h"> @@ -753,6 +756,9 @@ <ClInclude Include="MIDIMappingDialog.h"> <Filter>Header Files\Dialogs</Filter> </ClInclude> + <ClInclude Include="Autotune.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/mptrack/res/patterns.bmp =================================================================== (Binary files differ) Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/resource.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -946,6 +946,7 @@ #define IDC_SAMPLE_XFADE 2434 #define IDC_LASTUPDATE 2435 #define IDC_RESTORE_KEYMAP 2436 +#define IDC_SAMPLE_AUTOTUNE 2437 #define ID_FILE_NEWMOD 32771 #define ID_FILE_NEWXM 32772 #define ID_FILE_NEWS3M 32773 @@ -1214,7 +1215,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 531 #define _APS_NEXT_COMMAND_VALUE 44462 -#define _APS_NEXT_CONTROL_VALUE 2437 +#define _APS_NEXT_CONTROL_VALUE 2438 #define _APS_NEXT_SYMED_VALUE 901 #endif #endif Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/version.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 35 +#define VER_MINORMINOR 36 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -41,6 +41,8 @@ const SEQUENCEINDEX SEQUENCEINDEX_INVALID = SEQUENCEINDEX_MAX; typedef uint32 MODTYPE; +typedef uintptr_t SmpLength; + #define MAX_PATTERN_ROWS 1024 // -> CODE#0008 -> DESC="#define to set pattern size" -! BEHAVIOUR_CHANGE#0008 Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -579,7 +579,7 @@ void ReplaceSample( MODCHANNEL (&Chn)[MAX_CHANNELS], LPCSTR pOldSample, LPSTR pNewSample, - const ctrlSmp::SmpLength nNewLength, + const SmpLength nNewLength, DWORD orFlags /* = 0*/, DWORD andFlags /* = MAXDWORD*/) { Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.h =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -10,8 +10,6 @@ namespace ctrlSmp { -typedef uintptr_t SmpLength; - enum ResetFlag { SmpResetCompo = 1, @@ -33,7 +31,7 @@ // If valid CSoundFile pointer is given, the sample will be replaced also from the sounds channels. void ReplaceSample(MODSAMPLE &smp, const LPSTR pNewSample, const SmpLength nNewLength, CSoundFile* pSndFile); -bool AdjustEndOfSample(MODSAMPLE &smp, CSoundFile* pSndFile = 0); +bool AdjustEndOfSample(MODSAMPLE &smp, CSoundFile *pSndFile = nullptr); // Returns the number of bytes allocated(at least) for sample data. // Note: Currently the return value is based on the sample length and the actual @@ -77,7 +75,7 @@ void ReplaceSample( MODCHANNEL (&Chn)[MAX_CHANNELS], LPCSTR pOldSample, LPSTR pNewSample, - const ctrlSmp::SmpLength nNewLength, + const SmpLength nNewLength, DWORD orFlags = 0, DWORD andFlags = MAXDWORD); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |