From: <sag...@us...> - 2010-02-17 14:49:57
|
Revision: 498 http://modplug.svn.sourceforge.net/modplug/?rev=498&view=rev Author: saga-games Date: 2010-02-17 14:49:47 +0000 (Wed, 17 Feb 2010) Log Message: ----------- [Imp] Sample Editor: When enabling (sustain) loop and no loop points are set yet, automatically set loop to full sample length. [Ref] Added some useful stuff from SchismTracker to the code that will be necessary for further backports. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/modcommand.h Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2010-02-17 09:10:14 UTC (rev 497) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2010-02-17 14:49:47 UTC (rev 498) @@ -2540,6 +2540,7 @@ if ((IsLocked()) || (!m_pSndFile)) return; int n = m_ComboLoopType.GetCurSel(); MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + bool wasDisabled = (pSmp->uFlags & CHN_LOOP) == 0; switch(n) { case 0: // Off @@ -2553,6 +2554,12 @@ pSmp->uFlags |= CHN_LOOP|CHN_PINGPONGLOOP; break; } + // set loop points if theren't any + if(wasDisabled && ((pSmp->uFlags & CHN_LOOP) != 0) && (pSmp->nLoopStart == pSmp->nLoopEnd) && (pSmp->nLoopStart == 0)) + { + pSmp->nLoopEnd = pSmp->nLength; + m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL); + } m_pModDoc->AdjustEndOfSample(m_nSample); m_pModDoc->SetModified(); } @@ -2608,6 +2615,7 @@ if ((IsLocked()) || (!m_pSndFile)) return; int n = m_ComboSustainType.GetCurSel(); MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + bool wasDisabled = (pSmp->uFlags & CHN_SUSTAINLOOP) == 0; switch(n) { case 0: // Off @@ -2621,6 +2629,12 @@ pSmp->uFlags |= CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN; break; } + // set sustain loop points if theren't any + if(wasDisabled && ((pSmp->uFlags & CHN_SUSTAINLOOP) != 0) && (pSmp->nSustainStart == pSmp->nSustainEnd) && (pSmp->nSustainStart == 0)) + { + pSmp->nSustainEnd = pSmp->nLength; + m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL); + } m_pModDoc->SetModified(); } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-02-17 09:10:14 UTC (rev 497) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-02-17 14:49:47 UTC (rev 498) @@ -3776,4 +3776,53 @@ if(CSoundFile::GetModSpecifications(nNewType).HasVolCommand(m->volcmd) == false) m->volcmd = CMD_NONE; +} + + +// "importance" of every FX command. Table is used for importing from formats with multiple effect colums +// and is approximately the same as in SchismTracker. +uint16 CSoundFile::GetEffectWeight(MODCOMMAND::COMMAND cmd) +//--------------------------------------------------------- +{ + switch(cmd) + { + case CMD_PATTERNBREAK: return 288; + case CMD_POSITIONJUMP: return 280; + case CMD_SPEED: return 272; + case CMD_TEMPO: return 264; + case CMD_GLOBALVOLUME: return 256; + case CMD_GLOBALVOLSLIDE: return 248; + case CMD_CHANNELVOLUME: return 240; + case CMD_CHANNELVOLSLIDE: return 232; + case CMD_TONEPORTAVOL: return 224; + case CMD_TONEPORTAMENTO: return 216; + case CMD_ARPEGGIO: return 208; + case CMD_RETRIG: return 200; + case CMD_TREMOR: return 192; + case CMD_OFFSET: return 184; + case CMD_VOLUME: return 176; + case CMD_VIBRATOVOL: return 168; + case CMD_VOLUMESLIDE: return 160; + case CMD_PORTAMENTODOWN: return 152; + case CMD_PORTAMENTOUP: return 133; + case CMD_NOTESLIDEDOWN: return 136; + case CMD_NOTESLIDEUP: return 128; + case CMD_PANNING8: return 120; + case CMD_PANNINGSLIDE: return 112; + case CMD_SMOOTHMIDI: return 104; + case CMD_MIDI: return 96; + case CMD_MODCMDEX: return 88; + case CMD_S3MCMDEX: return 80; + case CMD_PANBRELLO: return 72; + case CMD_XFINEPORTAUPDOWN: return 64; + case CMD_VIBRATO: return 56; + case CMD_FINEVIBRATO: return 48; + case CMD_TREMOLO: return 40; + case CMD_KEYOFF: return 32; + case CMD_SETENVPOSITION: return 24; + case CMD_VELOCITY: return 16; + case CMD_XPARAM: return 8; + case CMD_NONE: + default: return 0; + } } \ No newline at end of file Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2010-02-17 09:10:14 UTC (rev 497) +++ trunk/OpenMPT/soundlib/Sndfile.h 2010-02-17 14:49:47 UTC (rev 498) @@ -964,6 +964,11 @@ void HandlePatternTransitionEvents(); void BuildDefaultInstrument(); long GetSampleOffset(); + +public: + // "importance" of every FX command. Table is used for importing from formats with multiple effect colums + // and is approximately the same as in SchismTracker. + static uint16 CSoundFile::GetEffectWeight(MODCOMMAND::COMMAND cmd); }; #pragma warning(default : 4324) //structure was padded due to __declspec(align()) Modified: trunk/OpenMPT/soundlib/modcommand.h =================================================================== --- trunk/OpenMPT/soundlib/modcommand.h 2010-02-17 09:10:14 UTC (rev 497) +++ trunk/OpenMPT/soundlib/modcommand.h 2010-02-17 14:49:47 UTC (rev 498) @@ -59,6 +59,17 @@ // Returns true if and only if note is NOTE_PC or NOTE_PCS. bool IsPcNote() const {return note == NOTE_PC || note == NOTE_PCS;} + // Swap volume and effect column (doesn't do any conversion as it's mainly for importing formats with multiple effect columns, so beware!) + void SwapEffects() + { + VOLCMD vcold = volcmd; + VOL vold = vol; + volcmd = command; + vol = param; + command = vcold; + param = vold; + } + public: BYTE note; BYTE instr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |