|
From: <rel...@us...> - 2008-08-17 11:30:26
|
Revision: 220
http://modplug.svn.sourceforge.net/modplug/?rev=220&view=rev
Author: relabsoluness
Date: 2008-08-17 11:30:18 +0000 (Sun, 17 Aug 2008)
Log Message:
-----------
[Ref(refactoring)] sndfile.h refactoring: among other things, created files for sample, instrument(header), channel, mixplugin and mixer code and moved related code from sndfile.h.
[Ref] Moved pattern, playbackeventer and sequence files from mptrack to soundlib.
Modified Paths:
--------------
branches/devBranch_1_17_03/mptrack/mptrack.vcproj
branches/devBranch_1_17_03/mptrack/test/test.cpp
branches/devBranch_1_17_03/mptrack/test/test.h
branches/devBranch_1_17_03/soundlib/Sndfile.cpp
branches/devBranch_1_17_03/soundlib/Sndfile.h
branches/devBranch_1_17_03/soundlib/midi.h
branches/devBranch_1_17_03/soundlib/modcommand.h
Added Paths:
-----------
branches/devBranch_1_17_03/soundlib/OrderToPatternTable.cpp
branches/devBranch_1_17_03/soundlib/OrderToPatternTable.h
branches/devBranch_1_17_03/soundlib/PlaybackEventer.cpp
branches/devBranch_1_17_03/soundlib/PlaybackEventer.h
branches/devBranch_1_17_03/soundlib/mixer.h
branches/devBranch_1_17_03/soundlib/mixplug.h
branches/devBranch_1_17_03/soundlib/modchannel.h
branches/devBranch_1_17_03/soundlib/modins.h
branches/devBranch_1_17_03/soundlib/modsmp.h
branches/devBranch_1_17_03/soundlib/modspecifications.h
branches/devBranch_1_17_03/soundlib/pattern.cpp
branches/devBranch_1_17_03/soundlib/pattern.h
branches/devBranch_1_17_03/soundlib/patternContainer.cpp
branches/devBranch_1_17_03/soundlib/patternContainer.h
Removed Paths:
-------------
branches/devBranch_1_17_03/mptrack/OrderToPatternTable.cpp
branches/devBranch_1_17_03/mptrack/OrderToPatternTable.h
branches/devBranch_1_17_03/mptrack/PlaybackEventer.cpp
branches/devBranch_1_17_03/mptrack/PlaybackEventer.h
branches/devBranch_1_17_03/mptrack/pattern.cpp
branches/devBranch_1_17_03/mptrack/pattern.h
branches/devBranch_1_17_03/mptrack/patternContainer.cpp
branches/devBranch_1_17_03/mptrack/patternContainer.h
branches/devBranch_1_17_03/soundlib/mod_specifications.h
Deleted: branches/devBranch_1_17_03/mptrack/OrderToPatternTable.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/OrderToPatternTable.cpp 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/OrderToPatternTable.cpp 2008-08-17 11:30:18 UTC (rev 220)
@@ -1,180 +0,0 @@
-#include "stdafx.h"
-#include "sndfile.h"
-#include "ordertopatterntable.h"
-
-DWORD COrderToPatternTable::Unserialize(const BYTE* const src, const DWORD memLength)
-//-------------------------------------------------------------------------
-{
- if(memLength < 2 + 4) return 0;
- uint16 version = 0;
- uint32 s = 0;
- DWORD memPos = 0;
- memcpy(&version, src, sizeof(version));
- memPos += sizeof(version);
- if(version != 0) return memPos;
- memcpy(&s, src+memPos, sizeof(s));
- memPos += sizeof(s);
- if(s > 65000) return true;
- if(memLength < memPos+s*4) return memPos;
-
- resize(s);
- for(size_t i = 0; i<s; i++, memPos +=4 )
- {
- uint32 temp;
- memcpy(&temp, src+memPos, 4);
- (*this)[i] = static_cast<PATTERNINDEX>(temp);
- }
- return memPos;
-}
-
-
-size_t COrderToPatternTable::WriteToByteArray(BYTE* dest, const UINT numOfBytes, const UINT destSize)
-//-----------------------------------------------------------------------------
-{
- if(numOfBytes > destSize) return true;
- if(size() < numOfBytes) resize(numOfBytes, 0xFF);
- UINT i = 0;
- for(i = 0; i<numOfBytes; i++)
- {
- dest[i] = static_cast<BYTE>((*this)[i]);
- }
- return i; //Returns the number of bytes written.
-}
-
-
-size_t COrderToPatternTable::WriteAsByte(FILE* f, const UINT count)
-//---------------------------------------------------------------
-{
- if(size() < count) resize(count, GetInvalidPatIndex());
-
- size_t i = 0;
-
- for(i = 0; i<count; i++)
- {
- const PATTERNINDEX pat = (*this)[i];
- BYTE temp = static_cast<BYTE>((*this)[i]);
-
- if(pat > 0xFD)
- {
- if(pat == GetInvalidPatIndex()) temp = 0xFF;
- else temp = 0xFE;
- }
- fwrite(&temp, 1, 1, f);
- }
- return i; //Returns the number of bytes written.
-}
-
-bool COrderToPatternTable::ReadAsByte(const BYTE* pFrom, const int howMany, const int memLength)
-//-------------------------------------------------------------------------
-{
- if(howMany < 0 || howMany > memLength) return true;
- if(m_rSndFile.GetType() != MOD_TYPE_MPT && howMany > MAX_ORDERS) return true;
-
- if(size() < static_cast<size_t>(howMany))
- resize(howMany, GetInvalidPatIndex());
-
- for(int i = 0; i<howMany; i++, pFrom++)
- (*this)[i] = *pFrom;
- return false;
-}
-
-
-bool COrderToPatternTable::NeedsExtraDatafield() const
-//----------------------------------------------
-{
- if(m_rSndFile.GetType() == MOD_TYPE_MPT && m_rSndFile.Patterns.Size() > 0xFD)
- return true;
- else
- return false;
-}
-
-
-void COrderToPatternTable::OnModTypeChanged(const MODTYPE oldtype)
-//----------------------------------------------------------------
-{
- const CModSpecifications specs = m_rSndFile.GetModSpecifications();
-
- //Resize orderlist if needed. Because old orderlist had MAX_ORDERS(256) elements, not making it
- //smaller than that even if the modtype doesn't support that many orders.
- if(specs.ordersMax < GetCount())
- {
- resize(max(MAX_ORDERS, specs.ordersMax));
- for(ORDERINDEX i = GetCount(); i>specs.ordersMax; --i) (*this)[i-1] = GetInvalidPatIndex();
- }
-
- //Replace items used to denote end of song/skip order.
- replace(begin(), end(), GetInvalidPatIndex(oldtype), GetInvalidPatIndex());
- replace(begin(), end(), GetIgnoreIndex(oldtype), GetIgnoreIndex());
-}
-
-
-ORDERINDEX COrderToPatternTable::GetNextOrderIgnoringSkips(const ORDERINDEX start) const
-//-------------------------------------------------------------------------------------
-{
- const ORDERINDEX count = GetCount();
- if(count == 0) return 0;
- ORDERINDEX next = min(count-1, start+1);
- while(next+1 < count && (*this)[next] == GetIgnoreIndex()) next++;
- return next;
-}
-
-ORDERINDEX COrderToPatternTable::GetPreviousOrderIgnoringSkips(const ORDERINDEX start) const
-//-------------------------------------------------------------------------------------
-{
- const ORDERINDEX count = GetCount();
- if(start == 0 || count == 0) return 0;
- ORDERINDEX prev = min(start-1, count-1);
- while(prev > 0 && (*this)[prev] == GetIgnoreIndex()) prev--;
- return prev;
-}
-
-
-PATTERNINDEX COrderToPatternTable::GetInvalidPatIndex(const MODTYPE type) {return type == MOD_TYPE_MPT ? 65535 : 0xFF;}
-PATTERNINDEX COrderToPatternTable::GetIgnoreIndex(const MODTYPE type) {return type == MOD_TYPE_MPT ? 65534 : 0xFE;}
-
-PATTERNINDEX COrderToPatternTable::GetInvalidPatIndex() const {return GetInvalidPatIndex(m_rSndFile.GetType());}
-PATTERNINDEX COrderToPatternTable::GetIgnoreIndex() const {return GetIgnoreIndex(m_rSndFile.GetType());}
-
-
-
-
-//--------------------------------------------------
-//--------------------------------------------------
-//--------------------------------------------------
-
-using namespace srlztn;
-
-void COrderSerialization::ProWrite(OUTSTREAM& ostrm) const
-//--------------------------------------------------------
-{
- uint16 size = static_cast<uint16>(m_rOrders.size());
- ostrm.write(reinterpret_cast<const char*>(&size), 2);
- const COrderToPatternTable::const_iterator endIter = m_rOrders.end();
- for(COrderToPatternTable::const_iterator citer = m_rOrders.begin(); citer != endIter; citer++)
- {
- const uint16 temp = static_cast<uint16>(*citer);
- ostrm.write(reinterpret_cast<const char*>(&temp), 2);
- }
-}
-
-
-void COrderSerialization::ProRead(INSTREAM& istrm, const uint64 /*datasize*/)
-//---------------------------------------------------------------------------
-{
- uint16 size;
- istrm.read(reinterpret_cast<char*>(&size), 2);
- if(size > MPTM_SPECS.ordersMax) size = MPTM_SPECS.ordersMax;
- m_rOrders.resize(size);
- if(size == 0) {m_rOrders.assign(MAX_ORDERS, m_rOrders.GetInvalidPatIndex()); return;}
-
- const COrderToPatternTable::const_iterator endIter = m_rOrders.end();
- for(COrderToPatternTable::iterator iter = m_rOrders.begin(); iter != endIter; iter++)
- {
- uint16 temp;
- istrm.read(reinterpret_cast<char*>(&temp), 2);
- *iter = temp;
- }
-}
-
-
-
Deleted: branches/devBranch_1_17_03/mptrack/OrderToPatternTable.h
===================================================================
--- branches/devBranch_1_17_03/mptrack/OrderToPatternTable.h 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/OrderToPatternTable.h 2008-08-17 11:30:18 UTC (rev 220)
@@ -1,68 +0,0 @@
-#ifndef ORDERTOPATTERNTABLE_H
-#define ORDERTOPATTERNTABLE_H
-
-#include "serialization_utils.h"
-#include <vector>
-using std::vector;
-
-class CSoundFile;
-class COrderToPatternTable;
-
-#pragma warning(disable:4244) //conversion from 'type1' to 'type2', possible loss of data
-
-class COrderSerialization : public srlztn::ABCSerializationStreamer
-//=========================================================
-{
-public:
- COrderSerialization(COrderToPatternTable& ordertable) : m_rOrders(ordertable) {}
- virtual void ProWrite(srlztn::OUTSTREAM& ostrm) const;
- virtual void ProRead(srlztn::INSTREAM& istrm, const uint64 /*datasize*/);
-private:
- COrderToPatternTable& m_rOrders;
-};
-
-//==============================================
-class COrderToPatternTable : public vector<PATTERNINDEX>
-//==============================================
-{
-public:
- COrderToPatternTable(const CSoundFile& sndFile) : m_rSndFile(sndFile) {}
-
- bool ReadAsByte(const BYTE* pFrom, const int howMany, const int memLength);
-
- size_t WriteAsByte(FILE* f, const UINT count);
-
- size_t WriteToByteArray(BYTE* dest, const UINT numOfBytes, const UINT destSize);
-
- ORDERINDEX GetCount() const {return size();}
-
- //Deprecated function used for MPTm's created in 1.17.02.46 - 1.17.02.48.
- DWORD Unserialize(const BYTE* const src, const DWORD memLength);
-
- //Returns true if the IT orderlist datafield is not sufficient to store orderlist information.
- bool NeedsExtraDatafield() const;
-
- void OnModTypeChanged(const MODTYPE oldtype);
-
- PATTERNINDEX GetInvalidPatIndex() const; //To correspond 0xFF
- static PATTERNINDEX GetInvalidPatIndex(const MODTYPE type);
-
- PATTERNINDEX GetIgnoreIndex() const; //To correspond 0xFE
- static PATTERNINDEX GetIgnoreIndex(const MODTYPE type);
-
- //Returns the previous/next order ignoring skip indeces(+++).
- //If no previous/next order exists, return first/last order, and zero
- //when orderlist is empty.
- ORDERINDEX GetNextOrderIgnoringSkips(const ORDERINDEX start) const;
- ORDERINDEX GetPreviousOrderIgnoringSkips(const ORDERINDEX start) const;
-
- COrderSerialization* NewReadWriteObject() {return new COrderSerialization(*this);}
-
-private:
- const CSoundFile& m_rSndFile;
-};
-
-#pragma warning(default:4244)
-
-#endif
-
Deleted: branches/devBranch_1_17_03/mptrack/PlaybackEventer.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/PlaybackEventer.cpp 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/PlaybackEventer.cpp 2008-08-17 11:30:18 UTC (rev 220)
@@ -1,31 +0,0 @@
-#include "stdafx.h"
-#include "PlaybackEventer.h"
-#include "sndfile.h"
-
-CPlaybackEventer::~CPlaybackEventer()
-//---------------------------------
-{
-}
-
-void CPlaybackEventer::PatternTranstionChnSolo(const CHANNELINDEX chnIndex)
-//-------------------------------------------------------------------------
-{
- if(chnIndex >= m_rSndFile.m_nChannels)
- return;
-
- for(CHANNELINDEX i = 0; i<m_rSndFile.m_nChannels; i++)
- {
- m_rSndFile.m_bChannelMuteTogglePending[i] = (m_rSndFile.ChnSettings[i].dwFlags & CHN_MUTE) ? false : true;
- }
- m_rSndFile.m_bChannelMuteTogglePending[chnIndex] = (m_rSndFile.ChnSettings[chnIndex].dwFlags & CHN_MUTE) ? true : false;
-}
-
-
-void CPlaybackEventer::PatternTransitionChnUnmuteAll()
-//----------------------------------------------------
-{
- for(CHANNELINDEX i = 0; i<m_rSndFile.m_nChannels; i++)
- {
- m_rSndFile.m_bChannelMuteTogglePending[i] = (m_rSndFile.ChnSettings[i].dwFlags & CHN_MUTE) ? true : false;
- }
-}
\ No newline at end of file
Deleted: branches/devBranch_1_17_03/mptrack/PlaybackEventer.h
===================================================================
--- branches/devBranch_1_17_03/mptrack/PlaybackEventer.h 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/PlaybackEventer.h 2008-08-17 11:30:18 UTC (rev 220)
@@ -1,25 +0,0 @@
-#ifndef PLAYBACKEVENTER_H
-#define PLAYBACKEVENTER_H
-
-#include "pattern.h"
-
-class CSoundFile;
-
-//====================
-class CPlaybackEventer
-//====================
-{
-public:
- CPlaybackEventer(CSoundFile& sndf) : m_rSndFile(sndf) {}
- ~CPlaybackEventer();
-
- //SetPatternEvent(const PATTERNINDEX pattern, const ROWINDEX row, const CHANNELINDEX column);
-
- void PatternTranstionChnSolo(const CHANNELINDEX chnIndex);
- void PatternTransitionChnUnmuteAll();
-
-private:
- CSoundFile& m_rSndFile;
-};
-
-#endif
Modified: branches/devBranch_1_17_03/mptrack/mptrack.vcproj
===================================================================
--- branches/devBranch_1_17_03/mptrack/mptrack.vcproj 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/mptrack.vcproj 2008-08-17 11:30:18 UTC (rev 220)
@@ -377,13 +377,13 @@
RelativePath=".\OpenGLEditor.cpp">
</File>
<File
- RelativePath=".\OrderToPatternTable.cpp">
+ RelativePath="..\soundlib\OrderToPatternTable.cpp">
</File>
<File
- RelativePath=".\pattern.cpp">
+ RelativePath="..\soundlib\pattern.cpp">
</File>
<File
- RelativePath=".\patternContainer.cpp">
+ RelativePath="..\soundlib\patternContainer.cpp">
</File>
<File
RelativePath=".\PatternGotoDialog.cpp">
@@ -392,7 +392,7 @@
RelativePath=".\PerformanceCounter.cpp">
</File>
<File
- RelativePath=".\PlaybackEventer.cpp">
+ RelativePath="..\soundlib\PlaybackEventer.cpp">
</File>
<File
RelativePath=".\PSRatioCalc.cpp">
@@ -748,13 +748,19 @@
RelativePath=".\misc_util.h">
</File>
<File
+ RelativePath="..\soundlib\mixer.h">
+ </File>
+ <File
+ RelativePath="..\soundlib\mixplug.h">
+ </File>
+ <File
RelativePath=".\mod2midi.h">
</File>
<File
RelativePath=".\mod2wave.h">
</File>
<File
- RelativePath="..\soundlib\mod_specifications.h">
+ RelativePath="..\soundlib\modchannel.h">
</File>
<File
RelativePath="..\soundlib\modcommand.h">
@@ -763,6 +769,15 @@
RelativePath=".\moddoc.h">
</File>
<File
+ RelativePath="..\soundlib\modins.h">
+ </File>
+ <File
+ RelativePath="..\soundlib\modsmp.h">
+ </File>
+ <File
+ RelativePath="..\soundlib\modspecifications.h">
+ </File>
+ <File
RelativePath=".\Moptions.h">
</File>
<File
@@ -787,13 +802,13 @@
RelativePath=".\order.h">
</File>
<File
- RelativePath=".\OrderToPatternTable.h">
+ RelativePath="..\soundlib\OrderToPatternTable.h">
</File>
<File
- RelativePath=".\pattern.h">
+ RelativePath="..\soundlib\pattern.h">
</File>
<File
- RelativePath=".\patternContainer.h">
+ RelativePath="..\soundlib\patternContainer.h">
</File>
<File
RelativePath=".\PatternGotoDialog.h">
@@ -802,7 +817,7 @@
RelativePath=".\PerformanceCounter.h">
</File>
<File
- RelativePath=".\PlaybackEventer.h">
+ RelativePath="..\soundlib\PlaybackEventer.h">
</File>
<File
RelativePath=".\PSRatioCalc.h">
Deleted: branches/devBranch_1_17_03/mptrack/pattern.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/pattern.cpp 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/pattern.cpp 2008-08-17 11:30:18 UTC (rev 220)
@@ -1,232 +0,0 @@
-#include "stdafx.h"
-#include "pattern.h"
-#include "patternContainer.h"
-#include "mainfrm.h"
-#include "moddoc.h"
-
-
-CHANNELINDEX CPattern::GetNumChannels() const
-//-------------------------------------------
-{
- return m_rPatternContainer.GetSoundFile().GetNumChannels();
-}
-
-bool CPattern::Resize(const ROWINDEX newRowCount, const bool showDataLossWarning)
-//-------------------------------------------
-{
- if(m_ModCommands == NULL)
- {
- //For Mimicing old behavior of setting patternsize before even having the
- //actual pattern allocated.
- m_Rows = newRowCount;
- return false;
- }
-
-
- CSoundFile& sndFile = m_rPatternContainer.GetSoundFile();
- const CModSpecifications& specs = sndFile.GetModSpecifications();
- if(sndFile.m_pModDoc == NULL) return true;
- CModDoc& rModDoc = *sndFile.m_pModDoc;
- if(newRowCount > specs.patternRowsMax || newRowCount < specs.patternRowsMin)
- return true;
-
- if (newRowCount == m_Rows) return false;
- rModDoc.BeginWaitCursor();
- BEGIN_CRITICAL();
- if (newRowCount > m_Rows)
- {
- MODCOMMAND *p = CSoundFile::AllocatePattern(newRowCount, sndFile.m_nChannels);
- if (p)
- {
- memcpy(p, m_ModCommands, sndFile.m_nChannels*m_Rows*sizeof(MODCOMMAND));
- CSoundFile::FreePattern(m_ModCommands);
- m_ModCommands = p;
- m_Rows = newRowCount;
- }
- } else
- {
- BOOL bOk = TRUE;
- MODCOMMAND *p = m_ModCommands;
- UINT ndif = (m_Rows - newRowCount) * sndFile.m_nChannels;
- UINT npos = newRowCount * sndFile.m_nChannels;
- if(showDataLossWarning)
- {
- for (UINT i=0; i<ndif; i++)
- {
- if (*((DWORD *)(p+i+npos)))
- {
- bOk = FALSE;
- break;
- }
- }
- if (!bOk && showDataLossWarning)
- {
- END_CRITICAL();
- rModDoc.EndWaitCursor();
- if (CMainFrame::GetMainFrame()->MessageBox("Data at the end of the pattern will be lost.\nDo you want to continue",
- "Shrink Pattern", MB_YESNO|MB_ICONQUESTION) == IDYES) bOk = TRUE;
- rModDoc.BeginWaitCursor();
- BEGIN_CRITICAL();
- }
- }
- if (bOk)
- {
- MODCOMMAND *pnew = CSoundFile::AllocatePattern(newRowCount, sndFile.m_nChannels);
- if (pnew)
- {
- memcpy(pnew, m_ModCommands, sndFile.m_nChannels*newRowCount*sizeof(MODCOMMAND));
- CSoundFile::FreePattern(m_ModCommands);
- m_ModCommands = pnew;
- m_Rows = newRowCount;
- }
- }
- }
- END_CRITICAL();
- rModDoc.EndWaitCursor();
- rModDoc.SetModified();
- return (newRowCount == m_Rows) ? false : true;
-}
-
-
-bool CPattern::ClearData()
-//------------------------
-{
- BEGIN_CRITICAL();
- m_Rows = 0;
- CSoundFile::FreePattern(m_ModCommands);
- m_ModCommands = NULL;
- END_CRITICAL();
- return false;
-}
-
-bool CPattern::Expand()
-//---------------------
-{
- MODCOMMAND *newPattern, *oldPattern;
- UINT nRows, nChns;
-
- CSoundFile& sndFile = m_rPatternContainer.GetSoundFile();
- if(sndFile.m_pModDoc == NULL) return true;
-
- CModDoc& rModDoc = *sndFile.m_pModDoc;
-
- if ((!m_ModCommands) || (m_Rows > sndFile.GetModSpecifications().patternRowsMax / 2)) return true;
-
- rModDoc.BeginWaitCursor();
- nRows = m_Rows;
- nChns = sndFile.m_nChannels;
- newPattern = CSoundFile::AllocatePattern(nRows*2, nChns);
- if (!newPattern) return true;
-
- const UINT nPattern = m_rPatternContainer.GetIndex(this);
- rModDoc.PrepareUndo(nPattern, 0,0, nChns, nRows);
- oldPattern = m_ModCommands;
- for (UINT y=0; y<nRows; y++)
- {
- memcpy(newPattern+y*2*nChns, oldPattern+y*nChns, nChns*sizeof(MODCOMMAND));
- }
- m_ModCommands = newPattern;
- m_Rows = nRows * 2;
- CSoundFile::FreePattern(oldPattern); oldPattern= NULL;
- rModDoc.SetModified();
- rModDoc.UpdateAllViews(NULL, HINT_PATTERNDATA | (nPattern << HINT_SHIFT_PAT), NULL);
- rModDoc.EndWaitCursor();
- return false;
-}
-
-bool CPattern::Shrink()
-//---------------------
-{
- UINT nRows, nChns;
-
- if (!m_ModCommands || m_Rows < 32) return true;
-
- CSoundFile& sndFile = m_rPatternContainer.GetSoundFile();
- if(sndFile.m_pModDoc == NULL) return true;
-
- CModDoc& rModDoc = *sndFile.m_pModDoc;
-
- rModDoc.BeginWaitCursor();
- nRows = m_Rows;
- nChns = sndFile.m_nChannels;
- const UINT nPattern = m_rPatternContainer.GetIndex(this);
- rModDoc.PrepareUndo(nPattern, 0,0, nChns, nRows);
- nRows /= 2;
- for (UINT y=0; y<nRows; y++)
- {
- MODCOMMAND *psrc = sndFile.Patterns[nPattern] + (y * 2 * nChns);
- MODCOMMAND *pdest = sndFile.Patterns[nPattern] + (y * nChns);
- for (UINT x=0; x<nChns; x++)
- {
- pdest[x] = psrc[x];
- if ((!pdest[x].note) && (!pdest[x].instr))
- {
- pdest[x].note = psrc[x+nChns].note;
- pdest[x].instr = psrc[x+nChns].instr;
- if (psrc[x+nChns].volcmd)
- {
- pdest[x].volcmd = psrc[x+nChns].volcmd;
- pdest[x].vol = psrc[x+nChns].vol;
- }
- if (!pdest[x].command)
- {
- pdest[x].command = psrc[x+nChns].command;
- pdest[x].param = psrc[x+nChns].param;
- }
- }
- }
- }
- m_Rows = nRows;
- rModDoc.SetModified();
- rModDoc.UpdateAllViews(NULL, HINT_PATTERNDATA | (nPattern << HINT_SHIFT_PAT), NULL);
- rModDoc.EndWaitCursor();
- return false;
-}
-
-
-
-bool CPattern::WriteITPdata(FILE* f) const
-//----------------------------------------
-{
- for(ROWINDEX r = 0; r<GetNumRows(); r++)
- {
- for(CHANNELINDEX c = 0; c<GetNumChannels(); c++)
- {
- MODCOMMAND mc = GetModCommand(r,c);
- fwrite(&mc, sizeof(MODCOMMAND), 1, f);
- }
- }
- return false;
-}
-
-bool CPattern::ReadITPdata(const BYTE* const lpStream, DWORD& streamPos, const DWORD datasize, const DWORD dwMemLength)
-//-----------------------------------------------------------------------------------------------
-{
- if(streamPos > dwMemLength || datasize >= dwMemLength - streamPos || datasize < sizeof(MODCOMMAND_ORIGINAL))
- return true;
-
- const DWORD startPos = streamPos;
- ROWINDEX counter = 0;
- while(streamPos - startPos + sizeof(MODCOMMAND_ORIGINAL) <= datasize)
- {
- MODCOMMAND_ORIGINAL temp;
- memcpy(&temp, lpStream+streamPos, sizeof(MODCOMMAND_ORIGINAL));
- MODCOMMAND& mc = GetModCommand(counter);
- mc.command = temp.command;
- mc.instr = temp.instr;
- mc.note = temp.note;
- mc.param = temp.param;
- mc.vol = temp.vol;
- mc.volcmd = temp.volcmd;
- streamPos += sizeof(MODCOMMAND_ORIGINAL);
- counter++;
- }
- if(streamPos != startPos + datasize)
- {
- ASSERT(false);
- return true;
- }
- else
- return false;
-}
-
Deleted: branches/devBranch_1_17_03/mptrack/pattern.h
===================================================================
--- branches/devBranch_1_17_03/mptrack/pattern.h 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/pattern.h 2008-08-17 11:30:18 UTC (rev 220)
@@ -1,82 +0,0 @@
-#ifndef PATTERN_H
-#define PATTERN_H
-
-#include <vector>
-#include "modcommand.h"
-
-using std::vector;
-
-class CPatternContainer;
-
-
-//============
-class CPattern
-//============
-{
- friend class CPatternContainer;
-
-public:
-//BEGIN: OPERATORS
- //To mimic MODCOMMAND*
- operator MODCOMMAND*() {return m_ModCommands;}
- operator const MODCOMMAND*() const {return m_ModCommands;}
- CPattern& operator=(MODCOMMAND* const p) {m_ModCommands = p; return *this;}
- CPattern& operator=(const CPattern& pat)
- {
- m_ModCommands = pat.m_ModCommands;
- m_Rows = pat.m_Rows;
- return *this;
- }
-//END: OPERATORS
-
-//BEGIN: INTERFACE METHODS
-public:
- MODCOMMAND* GetpModCommand(const ROWINDEX r, const CHANNELINDEX c) {return &m_ModCommands[r*GetNumChannels()+c];}
- const MODCOMMAND* GetpModCommand(const ROWINDEX r, const CHANNELINDEX c) const {return &m_ModCommands[r*GetNumChannels()+c];}
-
- ROWINDEX GetNumRows() const {return m_Rows;}
-
- CHANNELINDEX GetNumChannels() const;
-
- bool Resize(const ROWINDEX newRowCount, const bool showDataLossWarning = true);
-
- bool ClearData();
-
- bool SetData(MODCOMMAND* p, const ROWINDEX rows) {m_ModCommands = p; m_Rows = rows; return false;}
-
- bool Expand();
-
- bool Shrink();
-
- bool WriteITPdata(FILE* f) const;
- bool ReadITPdata(const BYTE* const lpStream, DWORD& streamPos, const DWORD datasize, const DWORD dwMemLength);
- //Parameters:
- //1. Pointer to the beginning of the stream
- //2. Tells where to start(lpStream+streamPos) and number of bytes read is added to it.
- //3. How many bytes to read
- //4. Length of the stream.
- //Returns true on error.
-
-//END: INTERFACE METHODS
-
- CPattern(CPatternContainer& patCont) : m_ModCommands(0), m_Rows(64), m_rPatternContainer(patCont) {}
-
-private:
- MODCOMMAND& GetModCommand(ROWINDEX i) {return m_ModCommands[i];}
- //Returns modcommand from (floor[i/channelCount], i%channelCount)
-
- MODCOMMAND& GetModCommand(ROWINDEX r, CHANNELINDEX c) {return m_ModCommands[r*GetNumChannels()+c];}
- const MODCOMMAND& GetModCommand(ROWINDEX r, CHANNELINDEX c) const {return m_ModCommands[r*GetNumChannels()+c];}
-
-
-//BEGIN: DATA
-private:
- MODCOMMAND* m_ModCommands;
- ROWINDEX m_Rows;
- CPatternContainer& m_rPatternContainer;
-//END: DATA
-};
-
-
-
-#endif
Deleted: branches/devBranch_1_17_03/mptrack/patternContainer.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/patternContainer.cpp 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/patternContainer.cpp 2008-08-17 11:30:18 UTC (rev 220)
@@ -1,87 +0,0 @@
-#include "stdafx.h"
-#include "patternContainer.h"
-#include "sndfile.h"
-#include "mainfrm.h"
-
-int CPatternContainer::Insert(const ROWINDEX rows)
-//---------------------------------------------
-{
- PATTERNINDEX i = 0;
- for(i = 0; i<m_Patterns.size(); i++)
- if(!m_Patterns[i]) break;
- if(Insert(i, rows))
- return -1;
- else return i;
-
-}
-
-
-bool CPatternContainer::Insert(const PATTERNINDEX index, const ROWINDEX rows)
-//---------------------------------------------------------------
-{
- const CModSpecifications& specs = m_rSndFile.GetModSpecifications();
- if(index >= specs.patternsMax || index > m_Patterns.size() || rows > specs.patternRowsMax)
- return true;
- if(index < m_Patterns.size() && m_Patterns[index])
- return true;
-
- if(index == m_Patterns.size())
- {
- if(index < specs.patternsMax)
- m_Patterns.push_back(MODPATTERN(*this));
- else
- {
- ErrorBox(IDS_ERR_TOOMANYPAT, CMainFrame::GetMainFrame());
- return true;
- }
- }
-
- m_Patterns[index] = CSoundFile::AllocatePattern(rows, m_rSndFile.m_nChannels);
- m_Patterns[index].m_Rows = rows;
-
- if(!m_Patterns[index]) return true;
-
- return false;
-}
-
-bool CPatternContainer::Remove(const PATTERNINDEX ipat)
-//----------------------------------------------
-{
- if(ipat >= m_Patterns.size())
- return true;
-
- return m_Patterns[ipat].ClearData();
-}
-
-PATTERNINDEX CPatternContainer::GetIndex(const MODPATTERN* const pPat) const
-//------------------------------------------------------------------
-{
- const PATTERNINDEX endI = static_cast<PATTERNINDEX>(m_Patterns.size());
- for(PATTERNINDEX i = 0; i<endI; i++)
- if(&m_Patterns[i] == pPat) return i;
-
- return endI;
-}
-
-
-void CPatternContainer::ResizeArray(const PATTERNINDEX newSize)
-//-------------------------------------------------------------
-{
- if(Size() <= newSize)
- m_Patterns.resize(newSize, MODPATTERN(*this));
- else
- {
- for(PATTERNINDEX i = Size(); i > newSize; i--) Remove(i-1);
- m_Patterns.resize(newSize, MODPATTERN(*this));
- }
-}
-
-
-void CPatternContainer::OnModTypeChanged(const MODTYPE /*oldtype*/)
-//----------------------------------------------------------
-{
- const CModSpecifications specs = m_rSndFile.GetModSpecifications();
- if(specs.patternsMax < Size()) ResizeArray(max(MAX_PATTERNS, specs.patternsMax));
- else if(Size() < MAX_PATTERNS) ResizeArray(MAX_PATTERNS);
-}
-
Deleted: branches/devBranch_1_17_03/mptrack/patternContainer.h
===================================================================
--- branches/devBranch_1_17_03/mptrack/patternContainer.h 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/patternContainer.h 2008-08-17 11:30:18 UTC (rev 220)
@@ -1,71 +0,0 @@
-#ifdef __SNDFILE_H
-
-#ifndef PATTERNCONTAINER_H
-#define PATTERNCONTAINER_H
-
-#include "pattern.h"
-#include <limits>
-
-class CSoundFile;
-typedef CPattern MODPATTERN;
-
-//=====================
-class CPatternContainer
-//=====================
-{
-//BEGIN: TYPEDEFS
-public:
- typedef vector<MODPATTERN> PATTERNVECTOR;
-//END: TYPEDEFS
-
-
-//BEGIN: OPERATORS
-public:
- //To mimic old pattern == MODCOMMAND* behavior.
- MODPATTERN& operator[](const int pat) {return m_Patterns[pat];}
- const MODPATTERN& operator[](const int pat) const {return m_Patterns[pat];}
-//END: OPERATORS
-
-//BEGIN: INTERFACE METHODS
-public:
- CPatternContainer(CSoundFile& sndFile) : m_rSndFile(sndFile) {m_Patterns.assign(MAX_PATTERNS, MODPATTERN(*this));}
-
- //Note: No memory handling here.
- void ClearPatterns() {m_Patterns.assign(m_Patterns.size(), MODPATTERN(*this));}
-
- //Insert (default)pattern to given position. If pattern already exists at that position,
- //ignoring request.
- bool Insert(const PATTERNINDEX index, const ROWINDEX rows);
-
- //Insert pattern to position with the lowest index, and return that index, -1
- //on failure.
- int Insert(const ROWINDEX rows);
-
- //Remove pattern from given position. Currently it actually makes the pattern
- //'invisible' - the pattern data is cleared but the actual pattern object won't get removed.
- bool Remove(const PATTERNINDEX index);
-
- PATTERNINDEX Size() const {return static_cast<PATTERNINDEX>(m_Patterns.size());}
-
- CSoundFile& GetSoundFile() {return m_rSndFile;}
-
- //Returns the index of given pattern, Size() if not found.
- PATTERNINDEX GetIndex(const MODPATTERN* const pPat) const;
-
- void ResizeArray(const PATTERNINDEX newSize);
-
- void OnModTypeChanged(const MODTYPE oldtype);
-
-//END: INTERFACE METHODS
-
-
-//BEGIN: DATA MEMBERS
-private:
- PATTERNVECTOR m_Patterns;
- CSoundFile& m_rSndFile;
-//END: DATA MEMBERS
-
-};
-
-#endif
-#endif
Modified: branches/devBranch_1_17_03/mptrack/test/test.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/test/test.cpp 2008-08-16 17:24:05 UTC (rev 219)
+++ branches/devBranch_1_17_03/mptrack/test/test.cpp 2008-08-17 11:30:18 UTC (rev 220)
@@ -5,6 +5,7 @@
#include "stdafx.h"
#include "test.h"
+#include "../../soundlib/Sndfile.h"
#include "../version.h"
#include "../misc_util.h"
@...
[truncated message content] |
|
From: <rel...@us...> - 2008-08-22 18:08:48
|
Revision: 221
http://modplug.svn.sourceforge.net/modplug/?rev=221&view=rev
Author: relabsoluness
Date: 2008-08-22 18:08:38 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
[New] Experimental parameter control 'notes' for controlling plug params(only in MPTm). Is more or less fully functional with the big exception that there's no saving or loading. Among other things, includes modifications/additions to: keyshortcuts, various GUI components, pattern draw methods, clipboard handling, pattern editing functions, ProcessEffects().
[Fix] Some checks added to pattern editing to prevent entering notes which are not supported by the module format.
Internal:
[Ref] Find/Replace dialog: Added enums for special items.
[Mod] Disabled keyconfig log messages which filled the debug output.
[Mod] Modification to IMixPlugin for easier parameter modification.
[Ref] Created new note name arrays and functions for populating comboboxes with note names.
[Mod] Removed constructor from modcommand and instrumentheader.
[Mod] ProcessMidiOut() now takes modcommand data from modchannel rowdata instead from pattern.
[Misc] Various smaller changes (new asserts here and there etc.)
Modified Paths:
--------------
branches/devBranch_1_17_03/mptrack/CommandSet.cpp
branches/devBranch_1_17_03/mptrack/CommandSet.h
branches/devBranch_1_17_03/mptrack/Ctrl_ins.cpp
branches/devBranch_1_17_03/mptrack/Ctrl_pat.cpp
branches/devBranch_1_17_03/mptrack/Ctrl_smp.cpp
branches/devBranch_1_17_03/mptrack/Draw_pat.cpp
branches/devBranch_1_17_03/mptrack/Modedit.cpp
branches/devBranch_1_17_03/mptrack/Mptrack.cpp
branches/devBranch_1_17_03/mptrack/Mptrack.h
branches/devBranch_1_17_03/mptrack/View_pat.cpp
branches/devBranch_1_17_03/mptrack/View_pat.h
branches/devBranch_1_17_03/mptrack/View_smp.cpp
branches/devBranch_1_17_03/mptrack/View_tre.cpp
branches/devBranch_1_17_03/mptrack/Vstplug.cpp
branches/devBranch_1_17_03/mptrack/Vstplug.h
branches/devBranch_1_17_03/mptrack/dlg_misc.cpp
branches/devBranch_1_17_03/mptrack/dlg_misc.h
branches/devBranch_1_17_03/mptrack/misc_util.h
branches/devBranch_1_17_03/mptrack/mod2midi.cpp
branches/devBranch_1_17_03/mptrack/res/view_pat.bmp
branches/devBranch_1_17_03/mptrack/test/test.cpp
branches/devBranch_1_17_03/mptrack/typedefs.h
branches/devBranch_1_17_03/mptrack/version.h
branches/devBranch_1_17_03/soundlib/LOAD_DMF.CPP
branches/devBranch_1_17_03/soundlib/Mmx_mix.cpp
branches/devBranch_1_17_03/soundlib/Snd_fx.cpp
branches/devBranch_1_17_03/soundlib/Sndfile.cpp
branches/devBranch_1_17_03/soundlib/Sndfile.h
branches/devBranch_1_17_03/soundlib/Sndmix.cpp
branches/devBranch_1_17_03/soundlib/mixplug.h
branches/devBranch_1_17_03/soundlib/modchannel.h
branches/devBranch_1_17_03/soundlib/modcommand.h
branches/devBranch_1_17_03/soundlib/modins.h
Modified: branches/devBranch_1_17_03/mptrack/CommandSet.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/CommandSet.cpp 2008-08-17 11:30:18 UTC (rev 220)
+++ branches/devBranch_1_17_03/mptrack/CommandSet.cpp 2008-08-22 18:08:38 UTC (rev 221)
@@ -5,6 +5,15 @@
#include <stdio.h>
#include <stdlib.h>
+#define ENABLE_LOGGING 0
+
+#if(ENABLE_LOGGING)
+ //
+#else
+ #define Log
+#endif
+
+
bool CCommandSet::s_bShowErrorOnUnknownKeybinding = true;
CCommandSet::CCommandSet(void)
@@ -2289,6 +2298,16 @@
commands[kcVSTGUINextPresetJump].isDummy = false;
commands[kcVSTGUINextPresetJump].Message = "Plugin preset forward jump";
+ commands[kcNotePC].UID = 1784;
+ commands[kcNotePC].isHidden = false;
+ commands[kcNotePC].isDummy = false;
+ commands[kcNotePC].Message = "Parameter control(MPTm only)";
+
+ commands[kcNotePCS].UID = 1785;
+ commands[kcNotePCS].isHidden = false;
+ commands[kcNotePCS].isDummy = false;
+ commands[kcNotePCS].Message = "Parameter control(smooth)(MPTm only)";
+
#ifdef _DEBUG
for (int i=0; i<kcNumCommands; i++) {
if (commands[i].UID != 0) { // ignore unset UIDs
Modified: branches/devBranch_1_17_03/mptrack/CommandSet.h
===================================================================
--- branches/devBranch_1_17_03/mptrack/CommandSet.h 2008-08-17 11:30:18 UTC (rev 220)
+++ branches/devBranch_1_17_03/mptrack/CommandSet.h 2008-08-22 18:08:38 UTC (rev 221)
@@ -431,7 +431,9 @@
kcNoteOff,
kcNoteCutOld,
kcNoteOffOld,
- kcEndNoteMisc=kcNoteOffOld,
+ kcNotePC,
+ kcNotePCS,
+ kcEndNoteMisc=kcNotePCS,
//Set instruments
Modified: branches/devBranch_1_17_03/mptrack/Ctrl_ins.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/Ctrl_ins.cpp 2008-08-17 11:30:18 UTC (rev 220)
+++ branches/devBranch_1_17_03/mptrack/Ctrl_ins.cpp 2008-08-22 18:08:38 UTC (rev 221)
@@ -822,11 +822,7 @@
// Pitch/Pan Separation
m_SpinPPS.SetRange(-32, +32);
// Pitch/Pan Center
- for (UINT n=0; n<=NOTE_MAX; n++)
- {
- wsprintf(s, "%s%d", szNoteNames[n % 12], n/12);
- m_ComboPPC.SetItemData(m_ComboPPC.AddString(s), n);
- }
+ AppendNotesToControl(m_ComboPPC, 0, NOTE_MAX-1);
// -> CODE#0027
// -> DESC="per-instrument volume ramping setup (refered as attack)"
Modified: branches/devBranch_1_17_03/mptrack/Ctrl_pat.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/Ctrl_pat.cpp 2008-08-17 11:30:18 UTC (rev 220)
+++ branches/devBranch_1_17_03/mptrack/Ctrl_pat.cpp 2008-08-22 18:08:38 UTC (rev 221)
@@ -189,11 +189,8 @@
//CHAR s[8];
CHAR s[10];
- for(int i = 0 ; i < NOTE_MAX ; i++){
- wsprintf(s, "%s%d", szNoteNames[i % 12], i/12);
- int n = m_CbnSplitNote.AddString(s);
- m_CbnSplitNote.SetItemData(n, i);
- }
+ AppendNotesToControl(m_CbnSplitNote, 0, NOTE_MAX - 1);
+
m_nSplitInstrument = 0;
m_nSplitNote = 60;
m_CbnSplitNote.SetCurSel(m_nSplitNote);
Modified: branches/devBranch_1_17_03/mptrack/Ctrl_smp.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/Ctrl_smp.cpp 2008-08-17 11:30:18 UTC (rev 220)
+++ branches/devBranch_1_17_03/mptrack/Ctrl_smp.cpp 2008-08-22 18:08:38 UTC (rev 221)
@@ -235,13 +235,9 @@
m_SpinVibSweep.SetRange(0, 64);
m_SpinVibDepth.SetRange(0, 64);
m_SpinVibRate.SetRange(0, 64);
- for (UINT i=BASENOTE_MIN; i<BASENOTE_MAX; i++)
- {
- CHAR s[32];
- wsprintf(s, "%s%d", szNoteNames[i%12], i/12);
- m_CbnBaseNote.AddString(s);
- }
+ AppendNotesToControl(m_CbnBaseNote, BASENOTE_MIN, BASENOTE_MAX-1);
+
// -> CODE#0029
// -> DESC="pitch shifting - time stretching"
CHAR str[16];
Modified: branches/devBranch_1_17_03/mptrack/Draw_pat.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/Draw_pat.cpp 2008-08-17 11:30:18 UTC (rev 220)
+++ branches/devBranch_1_17_03/mptrack/Draw_pat.cpp 2008-08-22 18:08:38 UTC (rev 221)
@@ -329,7 +329,15 @@
{
m_Dib.TextBlt(x, y, dx, COLUMN_HEIGHT, xsrc, ysrc + 14*COLUMN_HEIGHT);
} else
+ if(note >= NOTE_PC)
{
+ m_Dib.TextBlt(x, y, dx, COLUMN_HEIGHT, xsrc, ysrc + 15*COLUMN_HEIGHT);
+ } else
+ if(note >= NOTE_PCS)
+ {
+ m_Dib.TextBlt(x, y, dx, COLUMN_HEIGHT, xsrc, ysrc + 16*COLUMN_HEIGHT);
+ } else
+ {
if(pTuning)
{ // Drawing custom note names
string noteStr = pTuning->GetNoteName(note-NOTE_MIDDLEC);
@@ -387,24 +395,40 @@
}
-void CViewPattern::DrawVolumeCommand(int x, int y, UINT volcmd, UINT vol)
-//-----------------------------------------------------------------------
+void CViewPattern::DrawVolumeCommand(int x, int y, const MODCOMMAND mc)
+//---------------------------------------------------------------------
{
PCPATTERNFONT pfnt = GetCurrentPatternFont();
- if (volcmd)
- {
- volcmd &= 0x0F;
- vol &= 0x7F;
- m_Dib.TextBlt(x, y, pfnt->nVolCmdWidth, COLUMN_HEIGHT,
- pfnt->nVolX, pfnt->nVolY+volcmd*COLUMN_HEIGHT);
+
+ if(mc.note == NOTE_PCS || mc.note == NOTE_PC)
+ { //If note is parameter control 'note', drawing volume command differently.
+ const int val = min(MODCOMMAND::maxColumnValue, mc.GetValueVolCol());
+
+ m_Dib.TextBlt(x, y, 1, COLUMN_HEIGHT, pfnt->nClrX, pfnt->nClrY);
+ m_Dib.TextBlt(x + 1, y, pfnt->nVolCmdWidth, COLUMN_HEIGHT,
+ pfnt->nNumX, pfnt->nNumY+(val / 100)*COLUMN_HEIGHT);
m_Dib.TextBlt(x+pfnt->nVolCmdWidth, y, pfnt->nVolHiWidth, COLUMN_HEIGHT,
- pfnt->nNumX, pfnt->nNumY+(vol / 10)*COLUMN_HEIGHT);
+ pfnt->nNumX, pfnt->nNumY+((val / 10)%10)*COLUMN_HEIGHT);
m_Dib.TextBlt(x+pfnt->nVolCmdWidth+pfnt->nVolHiWidth, y, pfnt->nEltWidths[2]-(pfnt->nVolCmdWidth+pfnt->nVolHiWidth), COLUMN_HEIGHT,
- pfnt->nNumX, pfnt->nNumY+(vol % 10)*COLUMN_HEIGHT);
- } else
+ pfnt->nNumX, pfnt->nNumY+(val % 10)*COLUMN_HEIGHT);
+ }
+ else
{
- int srcx = pfnt->nEltWidths[0] + pfnt->nEltWidths[1];
- m_Dib.TextBlt(x, y, pfnt->nEltWidths[2], COLUMN_HEIGHT, pfnt->nClrX+srcx, pfnt->nClrY);
+ if (mc.volcmd)
+ {
+ const int volcmd = (mc.volcmd & 0x0F);
+ const int vol = (mc.vol & 0x7F);
+ m_Dib.TextBlt(x, y, pfnt->nVolCmdWidth, COLUMN_HEIGHT,
+ pfnt->nVolX, pfnt->nVolY+volcmd*COLUMN_HEIGHT);
+ m_Dib.TextBlt(x+pfnt->nVolCmdWidth, y, pfnt->nVolHiWidth, COLUMN_HEIGHT,
+ pfnt->nNumX, pfnt->nNumY+(vol / 10)*COLUMN_HEIGHT);
+ m_Dib.TextBlt(x+pfnt->nVolCmdWidth+pfnt->nVolHiWidth, y, pfnt->nEltWidths[2]-(pfnt->nVolCmdWidth+pfnt->nVolHiWidth), COLUMN_HEIGHT,
+ pfnt->nNumX, pfnt->nNumY+(vol % 10)*COLUMN_HEIGHT);
+ } else
+ {
+ int srcx = pfnt->nEltWidths[0] + pfnt->nEltWidths[1];
+ m_Dib.TextBlt(x, y, pfnt->nEltWidths[2], COLUMN_HEIGHT, pfnt->nClrX+srcx, pfnt->nClrY);
+ }
}
}
@@ -780,8 +804,19 @@
MODCOMMAND *mold = m - ncols;
if (m->note == mold->note) dwSpeedUpMask |= 0x01;
if ((m->instr == mold->instr) || (m_nDetailLevel < 1)) dwSpeedUpMask |= 0x02;
- if (((m->volcmd == mold->volcmd) && ((!m->volcmd) || (m->vol == mold->vol))) || (m_nDetailLevel < 2)) dwSpeedUpMask |= 0x04;
- if ((m->command == mold->command) || (m_nDetailLevel < 3)) dwSpeedUpMask |= (m->command) ? 0x08 : 0x18;
+ if ( m->note == NOTE_PCS || m->note == NOTE_PC || mold->note == NOTE_PCS || mold->note == NOTE_PC )
+ { // Handle speedup mask for PC notes.
+ if(m->note == mold->note)
+ {
+ if(m->GetValueVolCol() == mold->GetValueVolCol() || (m_nDetailLevel < 2)) dwSpeedUpMask |= 0x04;
+ if(m->GetValueEffectCol() == mold->GetValueEffectCol() || (m_nDetailLevel < 3)) dwSpeedUpMask |= 0x18;
+ }
+ }
+ else
+ {
+ if (((m->volcmd == mold->volcmd) && ((!m->volcmd) || (m->vol == mold->vol))) || (m_nDetailLevel < 2)) dwSpeedUpMask |= 0x04;
+ if ((m->command == mold->command) || (m_nDetailLevel < 3)) dwSpeedUpMask |= (m->command) ? 0x08 : 0x18;
+ }
if (dwSpeedUpMask == 0x1F) goto DoBlit;
}
bColSel[col] |= 0x40;
@@ -857,7 +892,7 @@
tx_col = MODCOLOR_TEXTSELECTED;
bk_col = MODCOLOR_BACKSELECTED;
} else
- if ((m->volcmd) && (CMainFrame::m_dwPatternSetup & PATTERN_EFFECTHILIGHT))
+ if (m->note != NOTE_PCS && m->note != NOTE_PC && (m->volcmd) && (CMainFrame::m_dwPatternSetup & PATTERN_EFFECTHILIGHT))
{
switch(m->volcmd)
{
@@ -886,15 +921,18 @@
}
// Drawing Volume
m_Dib.SetTextColor(tx_col, bk_col);
- DrawVolumeCommand(xbmp+x, 0, m->volcmd, m->vol);
+ DrawVolumeCommand(xbmp+x, 0, *m);
}
x += pfnt->nEltWidths[2];
}
// Command & param
if (m_nDetailLevel > 2)
{
+ const bool isPCnote = (m->note == NOTE_PC || m->note == NOTE_PCS);
+ uint16 val = m->GetValueEffectCol();
+ if(val > MODCOMMAND::maxColumnValue) val = MODCOMMAND::maxColumnValue;
fx_col = row_col;
- if ((m->command) && (m->command < MAX_EFFECTS) && (CMainFrame::m_dwPatternSetup & PATTERN_EFFECTHILIGHT))
+ if (!isPCnote && (m->command) && (m->command < MAX_EFFECTS) && (CMainFrame::m_dwPatternSetup & PATTERN_EFFECTHILIGHT))
{
switch(gEffectColors[m->command])
{
@@ -921,17 +959,26 @@
tx_col = MODCOLOR_TEXTSELECTED;
bk_col = MODCOLOR_BACKSELECTED;
}
+
// Drawing Command
m_Dib.SetTextColor(tx_col, bk_col);
- if (m->command)
+ if(isPCnote)
{
- UINT command = m->command & 0x3F;
- int n = (pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) ? gszModCommands[command] : gszS3mCommands[command];
- if (n <= ' ') n = '?';
- DrawLetter(xbmp+x, 0, (char)n, pfnt->nEltWidths[3], pfnt->nCmdOfs);
- } else
+ m_Dib.TextBlt(xbmp + x, 0, 2, COLUMN_HEIGHT, pfnt->nClrX+x, pfnt->nClrY);
+ m_Dib.TextBlt(xbmp + x + 2, 0, pfnt->nEltWidths[3], m_szCell.cy, pfnt->nNumX, pfnt->nNumY+(val / 100)*COLUMN_HEIGHT);
+ }
+ else
{
- m_Dib.TextBlt(xbmp+x, 0, pfnt->nEltWidths[3], COLUMN_HEIGHT, pfnt->nClrX+x, pfnt->nClrY);
+ if (m->command)
+ {
+ UINT command = m->command & 0x3F;
+ int n = (pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) ? gszModCommands[command] : gszS3mCommands[command];
+ if (n <= ' ') n = '?';
+ DrawLetter(xbmp+x, 0, (char)n, pfnt->nEltWidths[3], pfnt->nCmdOfs);
+ } else
+ {
+ m_Dib.TextBlt(xbmp+x, 0, pfnt->nEltWidths[3], COLUMN_HEIGHT, pfnt->nClrX+x, pfnt->nClrY);
+ }
}
}
x += pfnt->nEltWidths[3];
@@ -945,15 +992,24 @@
tx_col = MODCOLOR_TEXTSELECTED;
bk_col = MODCOLOR_BACKSELECTED;
}
+
// Drawing param
m_Dib.SetTextColor(tx_col, bk_col);
- if (m->command)
+ if(isPCnote)
{
- m_Dib.TextBlt(xbmp+x, 0, pfnt->nParamHiWidth, m_szCell.cy, pfnt->nNumX, pfnt->nNumY+(m->param >> 4)*COLUMN_HEIGHT);
- m_Dib.TextBlt(xbmp+x+pfnt->nParamHiWidth, 0, pfnt->nEltWidths[4]-pfnt->nParamHiWidth, m_szCell.cy, pfnt->nNumX+1, pfnt->nNumY+(m->param & 0x0F)*COLUMN_HEIGHT);
- } else
+ m_Dib.TextBlt(xbmp + x, 0, pfnt->nParamHiWidth, m_szCell.cy, pfnt->nNumX, pfnt->nNumY+((val / 10) % 10)*COLUMN_HEIGHT);
+ m_Dib.TextBlt(xbmp + x + pfnt->nParamHiWidth, 0, pfnt->nEltWidths[4]-pfnt->nParamHiWidth, m_szCell.cy, pfnt->nNumX+1, pfnt->nNumY+(val % 10)*COLUMN_HEIGHT);
+ }
+ else
{
- m_Dib.TextBlt(xbmp+x, 0, pfnt->nEltWidths[4], m_szCell.cy, pfnt->nClrX+x, pfnt->nClrY);
+ if (m->command)
+ {
+ m_Dib.TextBlt(xbmp+x, 0, pfnt->nParamHiWidth, m_szCell.cy, pfnt->nNumX, pfnt->nNumY+(m->param >> 4)*COLUMN_HEIGHT);
+ m_Dib.TextBlt(xbmp+x+pfnt->nParamHiWidth, 0, pfnt->nEltWidths[4]-pfnt->nParamHiWidth, m_szCell.cy, pfnt->nNumX+1, pfnt->nNumY+(m->param & 0x0F)*COLUMN_HEIGHT);
+ } else
+ {
+ m_Dib.TextBlt(xbmp+x, 0, pfnt->nEltWidths[4], m_szCell.cy, pfnt->nClrX+x, pfnt->nClrY);
+ }
}
}
}
@@ -1396,59 +1452,65 @@
pMainFrm->SetUserText(s);
if (::GetFocus() == m_hWnd)
{
- nChn = (m_dwCursor & 0xFFFF) >> 3;
+ nChn = GetChanFromCursor(m_dwCursor);
s[0] = 0;
if ((!(m_dwStatus & (PATSTATUS_KEYDRAGSEL/*|PATSTATUS_MOUSEDRAGSEL*/))) //rewbs.xinfo: update indicator even when dragging
&& (m_dwBeginSel == m_dwEndSel) && (pSndFile->Patterns[m_nPattern])
&& (m_nRow < pSndFile->PatternSize[m_nPattern]) && (nChn < pSndFile->m_nChannels))
{
MODCOMMAND *m = &pSndFile->Patterns[m_nPattern][m_nRow*pSndFile->m_nChannels+nChn];
- switch (m_dwCursor & 7)
+
+ //For now, ignore update if using PC or PCs notes because instrument, volcol and effect values
+ //are meaningless for these notes.
+ if(m->note != NOTE_PC && m->note != NOTE_PCS)
{
- case 1:
- if (m->instr)
+ switch (GetColTypeFromCursor(m_dwCursor))
{
- CHAR sztmp[128] = "";
- if (pSndFile->m_nInstruments)
+ case 1:
+ if (m->instr)
{
- if ((m->instr <= pSndFile->m_nInstruments) && (pSndFile->Headers[m->instr]))
+ CHAR sztmp[128] = "";
+ if (pSndFile->m_nInstruments)
{
- INSTRUMENTHEADER *penv = pSndFile->Headers[m->instr];
- memcpy(sztmp, penv->name, 32);
- sztmp[32] = 0;
- if ((m->note) && (m->note <= NOTE_MAX))
+ if ((m->instr <= pSndFile->m_nInstruments) && (pSndFile->Headers[m->instr]))
{
- UINT nsmp = penv->Keyboard[m->note-1];
- if ((nsmp) && (nsmp <= pSndFile->m_nSamples))
+ INSTRUMENTHEADER *penv = pSndFile->Headers[m->instr];
+ memcpy(sztmp, penv->name, 32);
+ sztmp[32] = 0;
+ if ((m->note) && (m->note <= NOTE_MAX))
{
- CHAR sztmp2[64] = "";
- memcpy(sztmp2, pSndFile->m_szNames[nsmp], 32);
- sztmp2[32] = 0;
- if (sztmp2[0])
+ UINT nsmp = penv->Keyboard[m->note-1];
+ if ((nsmp) && (nsmp <= pSndFile->m_nSamples))
{
- wsprintf(sztmp+strlen(sztmp), " (%d: %s)", nsmp, sztmp2);
+ CHAR sztmp2[64] = "";
+ memcpy(sztmp2, pSndFile->m_szNames[nsmp], 32);
+ sztmp2[32] = 0;
+ if (sztmp2[0])
+ {
+ wsprintf(sztmp+strlen(sztmp), " (%d: %s)", nsmp, sztmp2);
+ }
}
}
}
- }
- } else
- {
- if (m->instr <= pSndFile->m_nSamples)
+ } else
{
- memcpy(sztmp, pSndFile->m_szNames[m->instr], 32);
- sztmp[32] = 0;
+ if (m->instr <= pSndFile->m_nSamples)
+ {
+ memcpy(sztmp, pSndFile->m_szNames[m->instr], 32);
+ sztmp[32] = 0;
+ }
}
+ if (sztmp[0]) wsprintf(s, "%d: %s", m->instr, sztmp);
}
- if (sztmp[0]) wsprintf(s, "%d: %s", m->instr, sztmp);
+ break;
+ case 2:
+ if (!pModDoc->GetVolCmdInfo(pModDoc->GetIndexFromVolCmd(m->volcmd), s)) s[0] = 0;
+ break;
+ case 3:
+ case 4:
+ if (!pModDoc->GetEffectName(s, m->command, m->param, FALSE, nChn)) s[0] = 0;
+ break;
}
- break;
- case 2:
- if (!pModDoc->GetVolCmdInfo(pModDoc->GetIndexFromVolCmd(m->volcmd), s)) s[0] = 0;
- break;
- case 3:
- case 4:
- if (!pModDoc->GetEffectName(s, m->command, m->param, FALSE, nChn)) s[0] = 0;
- break;
}
}
pMainFrm->SetInfoText(s);
Modified: branches/devBranch_1_17_03/mptrack/Modedit.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/Modedit.cpp 2008-08-17 11:30:18 UTC (rev 220)
+++ branches/devBranch_1_17_03/mptrack/Modedit.cpp 2008-08-22 18:08:38 UTC (rev 221)
@@ -19,7 +19,19 @@
#define str_mptm_conversion_warning GetStrI18N(_TEXT("Conversion from mptm to any other moduletype may makes certain features unavailable and is not guaranteed to work properly. Do the conversion anyway?"))
+const size_t Pow10Table[10] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
+// Return D'th digit(character) of given value.
+// GetDigit<0>(123) == '3'
+// GetDigit<1>(123) == '2'
+// GetDigit<2>(123) == '1'
+template<BYTE D>
+inline TCHAR GetDigit(const size_t val)
+{
+ return (D > 9) ? '0' : 48 + ((val / Pow10Table[D]) % 10);
+}
+
+
//////////////////////////////////////////////////////////////////////
// Module type conversion
@@ -1492,6 +1504,8 @@
case 0: p[1] = p[2] = p[3] = '.'; break;
case NOTE_KEYOFF: p[1] = p[2] = p[3] = '='; break;
case NOTE_NOTECUT: p[1] = p[2] = p[3] = '^'; break;
+ case NOTE_PC: p[1] = 'P'; p[2] = 'C'; p[3] = ' '; break;
+ case NOTE_PCS: p[1] = 'P'; p[2] = 'C'; p[3] = 'S'; break;
default:
p[1] = szNoteNames[(note-1) % 12][0];
p[2] = szNoteNames[(note-1) % 12][1];
@@ -1519,12 +1533,22 @@
ncursor++;
if ((ncursor >= colmin) && (ncursor <= colmax))
{
- if ((m->volcmd) && (m->volcmd <= MAX_VOLCMDS))
+ if(m->note == NOTE_PC || m->note == NOTE_PCS)
{
- p[6] = gszVolCommands[m->volcmd];
- p[7] = '0' + (m->vol / 10);
- p[8] = '0' + (m->vol % 10);
- } else p[6] = p[7] = p[8] = '.';
+ const uint16 val = m->GetValueVolCol();
+ p[6] = GetDigit<2>(val);
+ p[7] = GetDigit<1>(val);
+ p[8] = GetDigit<0>(val);
+ }
+ else
+ {
+ if ((m->volcmd) && (m->volcmd <= MAX_VOLCMDS))
+ {
+ p[6] = gszVolCommands[m->volcmd];
+ p[7] = '0' + (m->vol / 10);
+ p[8] = '0' + (m->vol % 10);
+ } else p[6] = p[7] = p[8] = '.';
+ }
} else
{
p[6] = p[7] = p[8] = ' ';
@@ -1534,18 +1558,28 @@
if (((ncursor >= colmin) && (ncursor <= colmax))
|| ((ncursor+1 >= colmin) && (ncursor+1 <= colmax)))
{
- if (m->command)
+ if(m->note == NOTE_PC || m->note == NOTE_PCS)
{
- if (m_SndFile.m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT))
- p[9] = gszS3mCommands[m->command];
- else
- p[9] = gszModCommands[m->command];
- } else p[9] = '.';
- if (m->param)
+ const uint16 val = m->GetValueEffectCol();
+ p[9] = GetDigit<2>(val);
+ p[10] = GetDigit<1>(val);
+ p[11] = GetDigit<0>(val);
+ }
+ else
{
- p[10] = szHexChar[m->param >> 4];
- p[11] = szHexChar[m->param & 0x0F];
- } else p[10] = p[11] = '.';
+ if (m->command)
+ {
+ if (m_SndFile.m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT))
+ p[9] = gszS3mCommands[m->command];
+ else
+ p[9] = gszModCommands[m->command];
+ } else p[9] = '.';
+ if (m->param)
+ {
+ p[10] = szHexChar[m->param >> 4];
+ p[11] = szHexChar[m->param & 0x0F];
+ } else p[10] = p[11] = '.';
+ }
} else
{
p[9] = p[10] = p[11] = ' ';
@@ -1636,6 +1670,13 @@
m[col].note = 0;
if (s[0] == '=') m[col].note = NOTE_KEYOFF; else
if (s[0] == '^') m[col].note = NOTE_NOTECUT; else
+ if (s[0] == 'P')
+ {
+ if(s[2] == 'S')
+ m[col].note = NOTE_PCS;
+ else
+ m[col].note = NOTE_PC;
+ } else
if (s[0] != '.')
{
for (UINT i=0; i<12; i++)
@@ -1663,68 +1704,92 @@
{
if (s[5] != '.')
{
- m[col].volcmd = 0;
- for (UINT i=1; i<MAX_VOLCMDS; i++)
+ if(m[col].note == NOTE_PCS || m[col].note == NOTE_PC)
{
- if (s[5] == gszVolCommands[i])
+ char val[4];
+ memcpy(val, s+5, 3);
+ val[3] = 0;
+ m[col].SetValueVolCol(ConvertStrTo<uint16>(val));
+ }
+ else
+ {
+ m[col].volcmd = 0;
+ for (UINT i=1; i<MAX_VOLCMDS; i++)
{
- m[col].volcmd = i;
- break;
+ if (s[5] == gszVolCommands[i])
+ {
+ m[col].volcmd = i;
+ break;
+ }
}
+ m[col].vol = (s[6]-'0')*10 + (s[7]-'0');
}
- m[col].vol = (s[6]-'0')*10 + (s[7]-'0');
} else m[col].volcmd = m[col].vol = 0;
}
- if (s[8] > ' ' && (!mix || ((!ITStyleMix && origModCmd.command==0) ||
- (ITStyleMix && origModCmd.command==0 && origModCmd.param==0))))
+
+ if(m[col].note == NOTE_PCS || m[col].note == NOTE_PC)
{
- m[col].command = 0;
- if (s[8] != '.')
+ if(s[8] != '.')
{
- LPCSTR psc = (bS3M) ? gszS3mCommands : gszModCommands;
- for (UINT i=1; i<MAX_EFFECTS; i++)
- {
- if ((s[8] == psc[i]) && (psc[i] != '?')) m[col].command = i;
- }
+ char val[4];
+ memcpy(val, s+8, 3);
+ val[3] = 0;
+ m[col].SetValueEffectCol(ConvertStrTo<uint16>(val));
}
}
- // Effect value
- if (s[9] > ' ' && (!mix || ((!ITStyleMix && origModCmd.param==0) ||
- (ITStyleMix && origModCmd.command==0 && origModCmd.param==0))))
+ else
{
- m[col].param = 0;
- if (s[9] != '.')
+ if (s[8] > ' ' && (!mix || ((!ITStyleMix && origModCmd.command==0) ||
+ (ITStyleMix && origModCmd.command==0 && origModCmd.param==0))))
{
- for (UINT i=0; i<16; i++)
+ m[col].command = 0;
+ if (s[8] != '.')
{
- if (s[9] == szHexChar[i]) m[col].param |= (i<<4);
- if (s[10] == szHexChar[i]) m[col].param |= i;
+ LPCSTR psc = (bS3M) ? gszS3mCommands : gszModCommands;
+ for (UINT i=1; i<MAX_EFFECTS; i++)
+ {
+ if ((s[8] == psc[i]) && (psc[i] != '?')) m[col].command = i;
+ }
}
}
- }
- // Checking command
- if (m_SndFile.m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM))
- {
- switch (m[col].command)
+ // Effect value
+ if (s[9] > ' ' && (!mix || ((!ITStyleMix && origModCmd.param==0) ||
+ (ITStyleMix && origModCmd.command==0 && origModCmd.param==0))))
{
- case CMD_SPEED:
- case CMD_TEMPO:
- if (!bS3M) m[col].command = (m[col].param <= spdmax) ? CMD_SPEED : CMD_TEMPO;
- else
+ m[col].param = 0;
+ if (s[9] != '.')
{
- if ((m[col].command == CMD_SPEED) && (m[col].param > spdmax)) m[col].param = CMD_TEMPO; else
- if ((m[col].command == CMD_TEMPO) && (m[col].param <= spdmax)) m[col].param = CMD_SPEED;
+ for (UINT i=0; i<16; i++)
+ {
+ if (s[9] == szHexChar[i]) m[col].param |= (i<<4);
+ if (s[10] == szHexChar[i]) m[col].param |= i;
+ }
}
- break;
}
- } else
- {
- switch (m[col].command)
+ // Checking command
+ if (m_SndFile.m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM))
{
- case CMD_SPEED:
- case CMD_TEMPO:
- if (!bS3M) m[col].command = (m[col].param <= spdmax) ? CMD_SPEED : CMD_TEMPO;
- break;
+ switch (m[col].command)
+ {
+ case CMD_SPEED:
+ case CMD_TEMPO:
+ if (!bS3M) m[col].command = (m[col].param <= spdmax) ? CMD_SPEED : CMD_TEMPO;
+ else
+ {
+ if ((m[col].command == CMD_SPEED) && (m[col].param > spdmax)) m[col].param = CMD_TEMPO; else
+ if ((m[col].command == CMD_TEMPO) && (m[col].param <= spdmax)) m[col].param = CMD_SPEED;
+ }
+ break;
+ }
+ } else
+ {
+ switch (m[col].command)
+ {
+ case CMD_SPEED:
+ case CMD_TEMPO:
+ if (!bS3M) m[col].command = (m[col].param <= spdmax) ? CMD_SPEED : CMD_TEMPO;
+ break;
+ }
}
}
}
Modified: branches/devBranch_1_17_03/mptrack/Mptrack.cpp
===================================================================
--- branches/devBranch_1_17_03/mptrack/Mptrack.cpp 2008-08-17 11:30:18 UTC (rev 220)
+++ branches/devBranch_1_17_03/mptrack/Mptrack.cpp 2008-08-22 18:08:38 UTC (rev 221)
@@ -172,6 +172,19 @@
"F#", "G-", "G#", "A-", "A#", "B-"
};
+LPCSTR szDefaultNoteNames[NOTE_MAX] = {
+ "C-0", "C#0", "D-0", "D#0", "E-0", "F-0", "F#0", "G-0", "G#0", "A-0", "A#0", "B-0",
+ "C-1", "C#1", "D-1", "D#1", "E-1", "F-1", "F#1", "G-1", "G#1", "A-1", "A#1", "B-1",
+ "C-2", "C#2", "D-2", "D#2", "E-2", "F-2", "F#2", "G-2", "G#2", "A-2", "A#2", "B-2",
+ "C-3", "C#3", "D-3", "D#3", "E-3", "F-3", "F#3", "G-3", "G#3", "A-3", "A#3", "B-3",
+ "C-4", "C#4", "D-4", "D#4", "E-4", "F-4", "F#4", "G-4", "G#4", "A-4", "A#4", "B-4",
+ "C-5", "C#5", "D-5", "D#5", "E-5", "F-5", "F#5", "G-5", "G#5", "A-5", "A#5", "B-5",
+ "C-6", "C#6", "D-6", "D#6", "E-6", "F-6", "F#6", "G-6", "G#6", "A-6", "A#6", "B-6",
+ "C-7", "C#7", "D-7", "D#7", "E-7", "F-7", "F#7", "G-7", "G#7", "A-7", "A#7", "B-7",
+ "C-8", "C#8", "D-8", "D#8", "E-8", "F-8", "F#8", "G-8", "G#8", "A-8", "A#8", "B-8",
+ "C-9", "C#9", "D-9", "D#9", "E-9", "F-9", "F#9", "G-9", "G#9", "A-9", "A#9", "B-9",
+};
+
LPCSTR szHexChar = "0123456789ABCDEF";
LPCSTR gszModCommands = " 0123456789ABCDRFFTE???GHK?YXPLZ\\:#"; //rewbs.smoothVST: added last \ (written as \\); rewbs.velocity: added last :
LPCSTR gszS3mCommands = " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\:#"; //rewbs.smoothVST: added last \ (written as \\); rewbs.velocity: added last :
@@ -663,7 +676,7 @@
m_pDocManager = new CModDocManager();
#ifdef _DEBUG
- // ASSERT((sizeof(MODCHANNEL)&7) == 0);
+ ASSERT((sizeof(MODCHANNEL)&7) == 0);
// Disabled by rewbs for smoothVST. Might cause minor perf issues due to increased cache misses?
#endif
@@ -1082,15 +1095,12 @@
void CTrackApp::LoadChords(PMPTCHORD pChords)
//-------------------------------------------
-{
- CHAR snam[32];
-
+{
if (!m_szConfigFileName[0]) return;
for (UINT i=0; i<3*12; i++)
{
LONG chord;
- wsprintf(snam, "%s%d", szNoteNames[i%12], i/12);
- if ((chord = GetPrivateProfileInt("Chords", snam, -1, m_szConfigFileName)) >= 0)
+ if ((chord = GetPrivateProfileInt("Chords", szDefaultNoteNames[i], -1, m_szConfigFileName)) >= 0)
{
if ((chord & 0xFFFFFFC0) || (!pChords[i].notes[0]))
{
@@ -1107,14 +1117,13 @@
void CTrackApp::SaveChords(PMPTCHORD pChords)
//-------------------------------------------
{
- CHAR s[64], snam[32];
+ CHAR s[64];
if (!m_szConfigFileName[0]) return;
for (UINT i=0; i<3*12; i++)
{
- wsprintf(snam, "%s%d", szNoteNames[i%12], i/12);
wsprintf(s, "%d", (pChords[i].key) | (pChords[i].notes[0] << 6) | (pChords[i].notes[1] << 12) | (pChords[i].notes[2] << 18));
- if (!WritePrivateProfileString("Chords", snam, s, m_szConfigFileName)) break;
+ if (!WritePrivateProfileString("Chords", szDefaultNoteNames[i], s, m_szConfigFileName)) break;
}
}
Modified: branches/devBranch_1_17_03/mptrack/Mptrack.h
===================================================================
--- branches/devBranch_1_17_03/mptrack/Mptrack.h 2008-08-17 11:30:18 UTC (rev 220)
+++ branches/devBranch_1_17_03/mptrack/Mptrack.h 2008-08-22 18:08:38 UTC (rev 221)
@@ -379,10 +379,25 @@
void Log(LPCSTR format,...);
UINT MsgBox(UINT nStringID, CWnd *p=NULL, LPCSTR lpszTitle=NULL, UINT n=MB_OK);
void ErrorBox(UINT nStringID, CWnd*p=NULL);
+
+// Helper function declarations.
void AddPluginNamesToCombobox(CComboBox& CBox, SNDMIXPLUGIN* plugarray, const bool librarynames = false);
void AddPluginParameternamesToCombobox(CComboBox& CBox, SNDMIXPLUGIN& plugarray);
void AddPluginParameternamesToCombobox(CComboBox& CBox, CVstPlugin& plug);
+// Append note names from zero-based range [noteStart, noteEnd] to given combobox.
+void AppendNotesToControl(CComboBox& combobox, const MODCOMMAND::NOTE noteStart, const MODCOMMAND::NOTE noteEnd);
+
+// ...
[truncated message content] |
|
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.
|