|
From: <rel...@us...> - 2008-08-24 20:33:39
|
Revision: 222
http://modplug.svn.sourceforge.net/modplug/?rev=222&view=rev
Author: relabsoluness
Date: 2008-08-24 20:33:31 +0000 (Sun, 24 Aug 2008)
Log Message:
-----------
[Mod] Moved HasNote-inquiries from CSoundFile to CModSpecifications along with related changes to CModSpecifications. Adds additional restrictions to entering notes to pattern (e.g. for MOD: notes below C-3, which don't get saved to file, won't be recorded to pattern).
Modified Paths:
--------------
branches/devBranch_1_17_03/mptrack/View_pat.cpp
branches/devBranch_1_17_03/mptrack/dlg_misc.cpp
branches/devBranch_1_17_03/mptrack/mptrack.vcproj
branches/devBranch_1_17_03/mptrack/test/test.cpp
branches/devBranch_1_17_03/soundlib/Load_it.cpp
branches/devBranch_1_17_03/soundlib/OrderToPatternTable.cpp
branches/devBranch_1_17_03/soundlib/Sndfile.cpp
branches/devBranch_1_17_03/soundlib/Sndfile.h
branches/devBranch_1_17_03/soundlib/modspecifications.h
Added Paths:
-----------
branches/devBranch_1_17_03/soundlib/modspecifications.cpp
Modified: branches/devBranch_1_17_03/mptrack/View_pat.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/View_pat.cpp 2008-08-22 18:08:38 UTC (rev 221)
+++ branches/devBranch_1_17_03/mptrack/View_pat.cpp 2008-08-24 20:33:31 UTC (rev 222)
@@ -4017,8 +4017,13 @@
UINT nRow = m_nRow;
CSoundFile *pSndFile = pModDoc->GetSoundFile();
+ if(note > pSndFile->GetModSpecifications().noteMax && note < NOTE_MIN_SPECIAL)
+ note = pSndFile->GetModSpecifications().noteMax;
+ else if( note < pSndFile->GetModSpecifications().noteMin)
+ note = pSndFile->GetModSpecifications().noteMin;
+
// Check whether the module format supports the note.
- if( pSndFile->HasNote(note) == false )
+ if( pSndFile->GetModSpecifications().HasNote(note) == false )
return;
UINT nChn = GetChanFromCursor(m_dwCursor);
@@ -4037,8 +4042,6 @@
return;
}
- if (note > NOTE_MAX && note<254) note = NOTE_MAX;
-
bool usePlaybackPosition = (m_dwStatus & PATSTATUS_FOLLOWSONG) && // work out whether we should use
(pMainFrm->GetFollowSong(pModDoc) == m_hWnd) && // player engine position or
!(pSndFile->IsPaused()) && // edit cursor position
Modified: branches/devBranch_1_17_03/mptrack/dlg_misc.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/dlg_misc.cpp 2008-08-22 18:08:38 UTC (rev 221)
+++ branches/devBranch_1_17_03/mptrack/dlg_misc.cpp 2008-08-24 20:33:31 UTC (rev 222)
@@ -632,7 +632,7 @@
{
combo->SetItemData(combo->AddString("any"), findAny);
}
- AppendNotesToControl(*combo, pSndFile);
+ AppendNotesToControl(*combo);
UINT ncount = combo->GetCount();
for (UINT i=0; i<ncount; i++) if (m_nNote == combo->GetItemData(i))
@@ -2713,7 +2713,9 @@
void AppendNotesToControl(CComboBox& combobox, const CSoundFile* const pSndFile)
//----------------------------------------------------------------------------------
{
- for(MODCOMMAND::NOTE nNote=1; nNote<=NOTE_MAX; nNote++)
+ const MODCOMMAND::NOTE noteStart = (pSndFile != nullptr) ? pSndFile->GetModSpecifications().noteMin : 1;
+ const MODCOMMAND::NOTE noteEnd = (pSndFile != nullptr) ? pSndFile->GetModSpecifications().noteMax : NOTE_MAX;
+ for(MODCOMMAND::NOTE nNote = noteStart; nNote <= noteEnd; nNote++)
{
combobox.SetItemData(combobox.AddString(szDefaultNoteNames[nNote-1]), nNote);
}
@@ -2721,7 +2723,7 @@
{
if(pSndFile != 0)
{
- if(pSndFile->HasSpecialNote(nNote) == true)
+ if(pSndFile->GetModSpecifications().HasNote(nNote) == true)
{
int k = combobox.AddString(szSpecialNoteNames[nNote-NOTE_MIN_SPECIAL]);
combobox.SetItemData(k, nNote);
@@ -2736,14 +2738,16 @@
void AppendNotesToControl(CComboBox& combobox, const CSoundFile& rSndFile, const INSTRUMENTINDEX iInstr)
//----------------------------------------------------------------------------------------------------------
{
- for (MODCOMMAND::NOTE i=1; i<=NOTE_MAX; i++)
+ const MODCOMMAND::NOTE noteStart = rSndFile.GetModSpecifications().noteMin;
+ const MODCOMMAND::NOTE noteEnd = rSndFile.GetModSpecifications().noteMax;
+ for(MODCOMMAND::NOTE note = noteStart; note <= noteEnd; note++)
{
- combobox.SetItemData(combobox.AddString(rSndFile.GetNoteName(i, iInstr).c_str()), i);
+ combobox.SetItemData(combobox.AddString(rSndFile.GetNoteName(note, iInstr).c_str()), note);
}
for(MODCOMMAND::NOTE note = NOTE_MIN_SPECIAL-1; note++ < NOTE_MAX_SPECIAL;)
{
- if(rSndFile.HasSpecialNote(note) == true)
+ if(rSndFile.GetModSpecifications().HasNote(note) == true)
{
combobox.SetItemData(combobox.AddString(szSpecialNoteShortDesc[note-NOTE_MIN_SPECIAL]), note);
}
Modified: branches/devBranch_1_17_03/mptrack/mptrack.vcproj
===================================================================
--- branches/devBranch_1_17_03/mptrack/mptrack.vcproj 2008-08-22 18:08:38 UTC (rev 221)
+++ branches/devBranch_1_17_03/mptrack/mptrack.vcproj 2008-08-24 20:33:31 UTC (rev 222)
@@ -350,6 +350,9 @@
RelativePath=".\modedit.cpp">
</File>
<File
+ RelativePath="..\soundlib\modspecifications.cpp">
+ </File>
+ <File
RelativePath=".\Moptions.cpp">
</File>
<File
Modified: branches/devBranch_1_17_03/mptrack/test/test.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/test/test.cpp 2008-08-22 18:08:38 UTC (rev 221)
+++ branches/devBranch_1_17_03/mptrack/test/test.cpp 2008-08-24 20:33:31 UTC (rev 222)
@@ -10,8 +10,6 @@
#include "../misc_util.h"
-STATIC_ASSERT(sizeof(MODCOMMAND_ORIGINAL) == 6);
-
#ifdef ENABLE_TESTS
namespace MptTest
@@ -60,11 +58,13 @@
void TestMisc()
+//-------------
{
STATIC_ASSERT(SMP_16BIT == CHN_16BIT);
STATIC_ASSERT(SMP_STEREO == CHN_STEREO);
+ STATIC_ASSERT(sizeof(MODCOMMAND_ORIGINAL) == 6);
STATIC_ASSERT( sizeof(SNDMIXPLUGININFO) == 128 ); //Comment right after the struct said: "Size should be 128"
- VERIFY_EQUAL( (MAX_BASECHANNELS >= MPTM_SPECS.channelsMax), true );
+ VERIFY_EQUAL( (MAX_BASECHANNELS >= ModSpecs::mptm.channelsMax), true );
}
void TestVersion()
Modified: branches/devBranch_1_17_03/soundlib/Load_it.cpp
===================================================================
--- branches/devBranch_1_17_03/soundlib/Load_it.cpp 2008-08-22 18:08:38 UTC (rev 221)
+++ branches/devBranch_1_17_03/soundlib/Load_it.cpp 2008-08-24 20:33:31 UTC (rev 222)
@@ -1133,7 +1133,7 @@
UINT len = *((WORD *)(lpStream+patpos[patchk]));
UINT rows = *((WORD *)(lpStream+patpos[patchk]+2));
- if(rows <= IT_MPTEXT_SPECS.patternRowsMax && rows > IT_STD_SPECS.patternRowsMax)
+ if(rows <= ModSpecs::it_ext.patternRowsMax && rows > ModSpecs::it.patternRowsMax)
{
interpretModplugmade = true;
hasModplugExtensions = true;
Modified: branches/devBranch_1_17_03/soundlib/OrderToPatternTable.cpp
===================================================================
--- branches/devBranch_1_17_03/soundlib/OrderToPatternTable.cpp 2008-08-22 18:08:38 UTC (rev 221)
+++ branches/devBranch_1_17_03/soundlib/OrderToPatternTable.cpp 2008-08-24 20:33:31 UTC (rev 222)
@@ -163,7 +163,7 @@
{
uint16 size;
istrm.read(reinterpret_cast<char*>(&size), 2);
- if(size > MPTM_SPECS.ordersMax) size = MPTM_SPECS.ordersMax;
+ if(size > ModSpecs::mptm.ordersMax) size = ModSpecs::mptm.ordersMax;
m_rOrders.resize(size);
if(size == 0) {m_rOrders.assign(MAX_ORDERS, m_rOrders.GetInvalidPatIndex()); return;}
Modified: branches/devBranch_1_17_03/soundlib/Sndfile.cpp
===================================================================
--- branches/devBranch_1_17_03/soundlib/Sndfile.cpp 2008-08-22 18:08:38 UTC (rev 221)
+++ branches/devBranch_1_17_03/soundlib/Sndfile.cpp 2008-08-24 20:33:31 UTC (rev 222)
@@ -391,7 +391,7 @@
PatternSize(*this), Patterns(*this),
Order(*this),
m_PlaybackEventer(*this),
- m_pModSpecs(&IT_MPTEXT_SPECS),
+ m_pModSpecs(&ModSpecs::it_ext),
m_MIDIMapper(*this)
//----------------------
{
@@ -2867,24 +2867,24 @@
switch(type)
{
case MOD_TYPE_MPT:
- pModSpecs = &MPTM_SPECS;
+ pModSpecs = &ModSpecs::mptm;
break;
case MOD_TYPE_IT:
- pModSpecs = &IT_MPTEXT_SPECS;
+ pModSpecs = &ModSpecs::it_ext;
break;
case MOD_TYPE_XM:
- pModSpecs = &XM_MPTEXT_SPECS;
+ pModSpecs = &ModSpecs::xm_ext;
break;
case MOD_TYPE_S3M:
- pModSpecs = &S3M_MPTEXT_SPECS;
+ pModSpecs = &ModSpecs::s3m_ext;
break;
case MOD_TYPE_MOD:
default:
- pModSpecs = &MOD_MPTEXT_SPECS;
+ pModSpecs = &ModSpecs::mod_ext;
break;
}
}
@@ -2956,36 +2956,3 @@
return *p;
}
-
-bool CSoundFile::HasNote(MODCOMMAND::NOTE note) const
-//----------------------------------------------
-{
- // TOFIX: This note range is not valid for all modtypes.
- if(note >= 1 && note <= NOTE_MAX)
- return true;
- else
- return HasSpecialNote(note);
-}
-
-bool CSoundFile::HasSpecialNote(MODCOMMAND::NOTE note) const
-//----------------------------------------------------------
-{
- if(note < NOTE_MIN_SPECIAL || note > NOTE_MAX_SPECIAL)
- return false;
-
- if(GetType() == MOD_TYPE_MPT)
- return true;
-
- if(note == NOTE_PC || note == NOTE_PCS)
- return false;
-
- if(GetType() == MOD_TYPE_IT)
- return true;
- if(GetType() == MOD_TYPE_XM)
- return (note != NOTE_NOTECUT) ? true : false;
- if(GetType() == MOD_TYPE_S3M)
- return (note != NOTE_KEYOFF) ? true : false;
-
- return false;
-}
-
Modified: branches/devBranch_1_17_03/soundlib/Sndfile.h
===================================================================
--- branches/devBranch_1_17_03/soundlib/Sndfile.h 2008-08-22 18:08:38 UTC (rev 221)
+++ branches/devBranch_1_17_03/soundlib/Sndfile.h 2008-08-24 20:33:31 UTC (rev 222)
@@ -99,8 +99,8 @@
};
+using ModSpecs::CModSpecifications;
-
class CTuningCollection;
//==============
@@ -113,13 +113,6 @@
public: //Misc
void ChangeModTypeTo(const MODTYPE& newType);
-
- // Return true iff current module format has given note.
- // Possible note values: [1, NOTE_MAX], [NOTE_MIN_SPECIAL, NOTE_MAX_SPECIAL]
- bool HasNote(MODCOMMAND::NOTE) const;
-
- // Return true iff current module format has given special note(such as note cut).
- bool HasSpecialNote(MODCOMMAND::NOTE) const;
//Return value in seconds.
double GetPlaybackTimeAt(ORDERINDEX, ROWINDEX);
Added: branches/devBranch_1_17_03/soundlib/modspecifications.cpp
===================================================================
--- branches/devBranch_1_17_03/soundlib/modspecifications.cpp (rev 0)
+++ branches/devBranch_1_17_03/soundlib/modspecifications.cpp 2008-08-24 20:33:31 UTC (rev 222)
@@ -0,0 +1,25 @@
+#include <stdafx.h>
+#include "modspecifications.h"
+
+namespace ModSpecs
+{
+
+bool CModSpecifications::HasNote(MODCOMMAND::NOTE note) const
+//------------------------------------------------------------
+{
+ if(note >= noteMin && note <= noteMax)
+ return true;
+ else if(note >= NOTE_MIN_SPECIAL && note <= NOTE_MAX_SPECIAL)
+ {
+ if(note == NOTE_NOTECUT)
+ return hasNoteCut;
+ else if(note == NOTE_KEYOFF)
+ return hasNoteOff;
+ else
+ return (memcmp(fileExtension, mptm.fileExtension, 4) == 0);
+ }
+ return false;
+}
+
+} //namespace ModSpecs
+
Modified: branches/devBranch_1_17_03/soundlib/modspecifications.h
===================================================================
--- branches/devBranch_1_17_03/soundlib/modspecifications.h 2008-08-22 18:08:38 UTC (rev 221)
+++ branches/devBranch_1_17_03/soundlib/modspecifications.h 2008-08-24 20:33:31 UTC (rev 222)
@@ -1,7 +1,10 @@
#ifndef MOD_SPECIFICATIONS_H
#define MOD_SPECIFICATIONS_H
+#include "modcommand.h"
+#include "../mptrack/SoundFilePlayConfig.h"
+
//Module IDs
#define MOD_TYPE_NONE 0x00
#define MOD_TYPE_MOD 0x01
@@ -38,20 +41,28 @@
const BYTE MSF_OLDVOLSWING = 1; //IT/MPT
const BYTE MSF_MIDICC_BUGEMULATION = 2; //IT/MPT/XM
-//Simple struct to gather various modspecifications in one place.
+namespace ModSpecs
+{
+
+// Struct to gather various modspecifications in one place.
+
struct CModSpecifications
//=======================
{
+ // Return true iff format has given note.
+ bool HasNote(MODCOMMAND::NOTE note) const;
+
//NOTE: If changing order, update all initializations below.
- char fileExtension[5];
+ char fileExtension[5]; // File extension without dot.
+ MODCOMMAND::NOTE noteMin; // Minimum note index (indecing starts from 1)
+ MODCOMMAND::NOTE noteMax; // Maximum note index (indecing starts from 1)
+ bool hasNoteCut; // True iff format has notecut.
+ bool hasNoteOff; // True iff format has noteoff.
PATTERNINDEX patternsMax;
ORDERINDEX ordersMax;
- CHANNELINDEX channelsMin;
- CHANNELINDEX channelsMax;
- //Note: The two above refer to the user editable pattern channels,
- //not to the internal sound channels. Maybe there should be a separate
- //setting for those(January 2007).
+ CHANNELINDEX channelsMin; // Minimum number of editable channels in pattern.
+ CHANNELINDEX channelsMax; // Maximum number of editable channels in pattern.
TEMPO tempoMin;
TEMPO tempoMax;
ROWINDEX patternRowsMin;
@@ -64,7 +75,7 @@
};
-const CModSpecifications MPTM_SPECS =
+const CModSpecifications mptm =
{
/*
TODO: Proper, less arbitrarily chosen, values here.
@@ -72,6 +83,10 @@
-savefile format and GUI methods can handle new values(might not be a small task :).
*/
"MPTm", //File extension
+ 1, //Minimum note index
+ NOTE_MAX, //Maximum note index
+ true, //Has notecut.
+ true, //Has noteoff.
4000, //Pattern max.
4000, //Order max.
4, //Channel min
@@ -90,10 +105,14 @@
-const CModSpecifications MOD_STD_SPECS =
+const CModSpecifications mod =
{
//TODO: Set correct values.
"mod", //File extension
+ 37, //Minimum note index
+ 108, //Maximum note index
+ false, //Has notecut.
+ false, //Has noteoff.
64, //Pattern max.
128, //Order max.
4, //Channel min
@@ -109,10 +128,15 @@
0, //Max MIDI mapping directives
};
-const CModSpecifications MOD_MPTEXT_SPECS =
+// MOD with MPT extensions.
+const CModSpecifications mod_ext =
{
//TODO: Set correct values.
"mod", //File extension
+ 37, //Minimum note index
+ 108, //Maximum note index
+ false, //Has notecut.
+ false, //Has noteoff.
64, //Pattern max.
128, //Order max.
4, //Channel min
@@ -128,10 +152,14 @@
0 //Max MIDI mapping directives
};
-const CModSpecifications XM_STD_SPECS =
+const CModSpecifications xm =
{
//TODO: Set correct values.
"xm", //File extension
+ 13, //Minimum note index
+ 108, //Maximum note index
+ false, //Has notecut.
+ true, //Has noteoff.
64, //Pattern max.
128, //Order max.
4, //Channel min
@@ -147,11 +175,15 @@
0 //Max MIDI mapping directives
};
-
-const CModSpecifications XM_MPTEXT_SPECS =
+// XM with MPT extensions
+const CModSpecifications xm_ext =
{
//TODO: Set correct values.
"xm", //File extension
+ 13, //Minimum note index
+ 108, //Maximum note index
+ false, //Has notecut.
+ true, //Has noteoff.
240, //Pattern max.
256, //Order max.
4, //Channel min
@@ -167,10 +199,14 @@
200 //Max MIDI mapping directives
};
-const CModSpecifications S3M_STD_SPECS =
+const CModSpecifications s3m =
{
//TODO: Set correct values.
"s3m", //File extension
+ 13, //Minimum note index
+ NOTE_MAX, //Maximum note index
+ true, //Has notecut.
+ false, //Has noteoff.
240, //Pattern max.
256, //Order max.
4, //Channel min
@@ -186,10 +222,15 @@
0 //Max MIDI mapping directives
};
-const CModSpecifications S3M_MPTEXT_SPECS =
+// S3M with MPT extensions
+const CModSpecifications s3m_ext =
{
//TODO: Set correct values.
"s3m", //File extension
+ 13, //Minimum note index
+ NOTE_MAX, //Maximum note index
+ true, //Has notecut.
+ false, //Has noteoff.
240, //Pattern max.
256, //Order max.
4, //Channel min
@@ -205,10 +246,14 @@
0 //Max MIDI mapping directives
};
-const CModSpecifications IT_STD_SPECS =
+const CModSpecifications it =
{
//TODO: Set correct values.
"it", //File extension
+ 1, //Minimum note index
+ NOTE_MAX, //Maximum note index
+ true, //Has notecut.
+ true, //Has noteoff.
240, //Pattern max.
200, //Order max.
4, //Channel min
@@ -224,10 +269,14 @@
0 //Max MIDI mapping directives
};
-const CModSpecifications IT_MPTEXT_SPECS =
+const CModSpecifications it_ext =
{
//TODO: Set correct values.
"it", //File extension
+ 1, //Minimum note index
+ NOTE_MAX, //Maximum note index
+ true, //Has notecut.
+ true, //Has noteoff.
240, //Pattern max.
256, //Order max.
4, //Channel min
@@ -243,7 +292,7 @@
200 //Max MIDI mapping directives
};
+} //namespace ModSpecs
-
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|