annotate src/modplug/snd_fx.cxx @ 2216:3673c7ec4ea2

Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
author William Pitcock <nenolod@atheme.org>
date Fri, 07 Dec 2007 12:08:47 -0600
parents 6b5a52635b3b
children 6907fc39b53f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1 /*
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2 * This source code is public domain.
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
3 *
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
4 * Authors: Olivier Lapicque <olivierl@jps.net>
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
5 */
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
6
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
7 #include "stdafx.h"
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
8 #include "sndfile.h"
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
9
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
10 #ifdef MSC_VER
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
11 #pragma warning(disable:4244)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
12 #endif
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
13
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
14 // Tables defined in tables.cpp
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
15 extern BYTE ImpulseTrackerPortaVolCmd[16];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
16 extern WORD S3MFineTuneTable[16];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
17 extern WORD ProTrackerPeriodTable[6*12];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
18 extern WORD ProTrackerTunedPeriods[15*12];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
19 extern WORD FreqS3MTable[];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
20 extern WORD XMPeriodTable[96+8];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
21 extern UINT XMLinearTable[768];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
22 extern DWORD FineLinearSlideUpTable[16];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
23 extern DWORD FineLinearSlideDownTable[16];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
24 extern DWORD LinearSlideUpTable[256];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
25 extern DWORD LinearSlideDownTable[256];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
26 extern signed char retrigTable1[16];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
27 extern signed char retrigTable2[16];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
28 extern short int ModRandomTable[64];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
29
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
30
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
31 ////////////////////////////////////////////////////////////
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
32 // Length
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
33
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
34 DWORD CSoundFile::GetLength(BOOL bAdjust, BOOL bTotal)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
35 //----------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
36 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
37 UINT dwElapsedTime=0, nRow=0, nCurrentPattern=0, nNextPattern=0, nPattern=Order[0];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
38 UINT nMusicSpeed=m_nDefaultSpeed, nMusicTempo=m_nDefaultTempo, nNextRow=0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
39 UINT nMaxRow = 0, nMaxPattern = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
40 LONG nGlbVol = m_nDefaultGlobalVolume, nOldGlbVolSlide = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
41 BYTE samples[MAX_CHANNELS];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
42 BYTE instr[MAX_CHANNELS];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
43 BYTE notes[MAX_CHANNELS];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
44 BYTE vols[MAX_CHANNELS];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
45 BYTE oldparam[MAX_CHANNELS];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
46 BYTE chnvols[MAX_CHANNELS];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
47 DWORD patloop[MAX_CHANNELS];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
48
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
49 memset(instr, 0, sizeof(instr));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
50 memset(notes, 0, sizeof(notes));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
51 memset(vols, 0xFF, sizeof(vols));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
52 memset(patloop, 0, sizeof(patloop));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
53 memset(oldparam, 0, sizeof(oldparam));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
54 memset(chnvols, 64, sizeof(chnvols));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
55 memset(samples, 0, sizeof(samples));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
56 for (UINT icv=0; icv<m_nChannels; icv++) chnvols[icv] = ChnSettings[icv].nVolume;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
57 nMaxRow = m_nNextRow;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
58 nMaxPattern = m_nNextPattern;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
59 nCurrentPattern = nNextPattern = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
60 nPattern = Order[0];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
61 nRow = nNextRow = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
62 for (;;)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
63 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
64 UINT nSpeedCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
65 nRow = nNextRow;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
66 nCurrentPattern = nNextPattern;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
67
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
68 // Check if pattern is valid
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
69 nPattern = Order[nCurrentPattern];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
70 while (nPattern >= MAX_PATTERNS)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
71 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
72 // End of song ?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
73 if ((nPattern == 0xFF) || (nCurrentPattern >= MAX_ORDERS))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
74 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
75 goto EndMod;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
76 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
77 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
78 nCurrentPattern++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
79 nPattern = (nCurrentPattern < MAX_ORDERS) ? Order[nCurrentPattern] : 0xFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
80 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
81 nNextPattern = nCurrentPattern;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
82 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
83 // Weird stuff?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
84 if ((nPattern >= MAX_PATTERNS) || (!Patterns[nPattern])) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
85 // Should never happen
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
86 if (nRow >= PatternSize[nPattern]) nRow = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
87 // Update next position
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
88 nNextRow = nRow + 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
89 if (nNextRow >= PatternSize[nPattern])
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
90 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
91 nNextPattern = nCurrentPattern + 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
92 nNextRow = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
93 }
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
94 /* muahahaha */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
95 if (stop_at_order > -1 && stop_at_row > -1) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
96 if (stop_at_order <= (signed) nCurrentPattern && stop_at_row <= (signed) nRow)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
97 goto EndMod;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
98 if (stop_at_time > 0) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
99 /* stupid api decision */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
100 if (((dwElapsedTime+500) / 1000) >= stop_at_time) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
101 stop_at_order = nCurrentPattern;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
102 stop_at_row = nRow;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
103 goto EndMod;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
104 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
105 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
106 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
107
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
108 if (!nRow)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
109 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
110 for (UINT ipck=0; ipck<m_nChannels; ipck++) patloop[ipck] = dwElapsedTime;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
111 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
112 if (!bTotal)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
113 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
114 if ((nCurrentPattern > nMaxPattern) || ((nCurrentPattern == nMaxPattern) && (nRow >= nMaxRow)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
115 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
116 if (bAdjust)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
117 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
118 m_nMusicSpeed = nMusicSpeed;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
119 m_nMusicTempo = nMusicTempo;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
120 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
121 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
122 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
123 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
124 MODCHANNEL *pChn = Chn;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
125 MODCOMMAND *p = Patterns[nPattern] + nRow * m_nChannels;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
126 for (UINT nChn=0; nChn<m_nChannels; p++,pChn++, nChn++) if (*((DWORD *)p))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
127 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
128 UINT command = p->command;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
129 UINT param = p->param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
130 UINT note = p->note;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
131 if (p->instr) { instr[nChn] = p->instr; notes[nChn] = 0; vols[nChn] = 0xFF; }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
132 if ((note) && (note <= 120)) notes[nChn] = note;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
133 if (p->volcmd == VOLCMD_VOLUME) { vols[nChn] = p->vol; }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
134 if (command) switch (command)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
135 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
136 // Position Jump
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
137 case CMD_POSITIONJUMP:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
138 if (param <= nCurrentPattern) goto EndMod;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
139 nNextPattern = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
140 nNextRow = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
141 if (bAdjust)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
142 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
143 pChn->nPatternLoopCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
144 pChn->nPatternLoop = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
145 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
146 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
147 // Pattern Break
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
148 case CMD_PATTERNBREAK:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
149 nNextRow = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
150 nNextPattern = nCurrentPattern + 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
151 if (bAdjust)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
152 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
153 pChn->nPatternLoopCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
154 pChn->nPatternLoop = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
155 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
156 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
157 // Set Speed
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
158 case CMD_SPEED:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
159 if (!param) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
160 if ((param <= 0x20) || (m_nType != MOD_TYPE_MOD))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
161 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
162 if (param < 128) nMusicSpeed = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
163 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
164 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
165 // Set Tempo
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
166 case CMD_TEMPO:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
167 if ((bAdjust) && (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
168 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
169 if (param) pChn->nOldTempo = param; else param = pChn->nOldTempo;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
170 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
171 if (param >= 0x20) nMusicTempo = param; else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
172 // Tempo Slide
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
173 // FIXME: this is totally wrong!
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
174 if ((param & 0xF0) == 0x10)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
175 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
176 nMusicTempo += param & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
177 if (nMusicTempo > 255) nMusicTempo = 255;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
178 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
179 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
180 nMusicTempo -= param & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
181 if (nMusicTempo < 32) nMusicTempo = 32;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
182 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
183 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
184 // Pattern Delay
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
185 case CMD_S3MCMDEX:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
186 if ((param & 0xF0) == 0x60) { nSpeedCount = param & 0x0F; break; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
187 if ((param & 0xF0) == 0xB0) { param &= 0x0F; param |= 0x60; }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
188 case CMD_MODCMDEX:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
189 if ((param & 0xF0) == 0xE0) nSpeedCount = (param & 0x0F) * nMusicSpeed; else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
190 if ((param & 0xF0) == 0x60)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
191 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
192 if (param & 0x0F) dwElapsedTime += (dwElapsedTime - patloop[nChn]) * (param & 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
193 else patloop[nChn] = dwElapsedTime;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
194 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
195 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
196 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
197 if (!bAdjust) continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
198 switch(command)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
199 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
200 // Portamento Up/Down
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
201 case CMD_PORTAMENTOUP:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
202 case CMD_PORTAMENTODOWN:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
203 if (param) pChn->nOldPortaUpDown = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
204 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
205 // Tone-Portamento
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
206 case CMD_TONEPORTAMENTO:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
207 if (param) pChn->nPortamentoSlide = param << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
208 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
209 // Offset
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
210 case CMD_OFFSET:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
211 if (param) pChn->nOldOffset = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
212 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
213 // Volume Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
214 case CMD_VOLUMESLIDE:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
215 case CMD_TONEPORTAVOL:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
216 case CMD_VIBRATOVOL:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
217 if (param) pChn->nOldVolumeSlide = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
218 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
219 // Set Volume
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
220 case CMD_VOLUME:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
221 vols[nChn] = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
222 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
223 // Global Volume
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
224 case CMD_GLOBALVOLUME:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
225 if (m_nType != MOD_TYPE_IT) param <<= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
226 if (param > 128) param = 128;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
227 nGlbVol = param << 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
228 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
229 // Global Volume Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
230 case CMD_GLOBALVOLSLIDE:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
231 if (param) nOldGlbVolSlide = param; else param = nOldGlbVolSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
232 if (((param & 0x0F) == 0x0F) && (param & 0xF0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
233 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
234 param >>= 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
235 if (m_nType != MOD_TYPE_IT) param <<= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
236 nGlbVol += param << 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
237 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
238 if (((param & 0xF0) == 0xF0) && (param & 0x0F))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
239 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
240 param = (param & 0x0F) << 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
241 if (m_nType != MOD_TYPE_IT) param <<= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
242 nGlbVol -= param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
243 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
244 if (param & 0xF0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
245 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
246 param >>= 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
247 param <<= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
248 if (m_nType != MOD_TYPE_IT) param <<= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
249 nGlbVol += param * nMusicSpeed;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
250 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
251 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
252 param = (param & 0x0F) << 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
253 if (m_nType != MOD_TYPE_IT) param <<= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
254 nGlbVol -= param * nMusicSpeed;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
255 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
256 if (nGlbVol < 0) nGlbVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
257 if (nGlbVol > 256) nGlbVol = 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
258 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
259 case CMD_CHANNELVOLUME:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
260 if (param <= 64) chnvols[nChn] = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
261 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
262 case CMD_CHANNELVOLSLIDE:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
263 if (param) oldparam[nChn] = param; else param = oldparam[nChn];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
264 pChn->nOldChnVolSlide = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
265 if (((param & 0x0F) == 0x0F) && (param & 0xF0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
266 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
267 param = (param >> 4) + chnvols[nChn];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
268 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
269 if (((param & 0xF0) == 0xF0) && (param & 0x0F))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
270 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
271 if (chnvols[nChn] > (int)(param & 0x0F)) param = chnvols[nChn] - (param & 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
272 else param = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
273 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
274 if (param & 0x0F)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
275 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
276 param = (param & 0x0F) * nMusicSpeed;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
277 param = (chnvols[nChn] > param) ? chnvols[nChn] - param : 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
278 } else param = ((param & 0xF0) >> 4) * nMusicSpeed + chnvols[nChn];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
279 if (param > 64) param = 64;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
280 chnvols[nChn] = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
281 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
282 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
283 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
284 nSpeedCount += nMusicSpeed;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
285 dwElapsedTime += (2500 * nSpeedCount) / nMusicTempo;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
286 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
287 EndMod:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
288 if ((bAdjust) && (!bTotal))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
289 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
290 m_nGlobalVolume = nGlbVol;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
291 m_nOldGlbVolSlide = nOldGlbVolSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
292 for (UINT n=0; n<m_nChannels; n++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
293 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
294 Chn[n].nGlobalVol = chnvols[n];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
295 if (notes[n]) Chn[n].nNewNote = notes[n];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
296 if (instr[n]) Chn[n].nNewIns = instr[n];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
297 if (vols[n] != 0xFF)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
298 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
299 if (vols[n] > 64) vols[n] = 64;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
300 Chn[n].nVolume = vols[n] << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
301 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
302 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
303 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
304 return (dwElapsedTime+500) / 1000;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
305 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
306
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
307
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
308 //////////////////////////////////////////////////////////////////////////////////////////////////
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
309 // Effects
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
310
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
311 void CSoundFile::InstrumentChange(MODCHANNEL *pChn, UINT instr, BOOL bPorta, BOOL bUpdVol, BOOL bResetEnv)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
312 //--------------------------------------------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
313 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
314 BOOL bInstrumentChanged = FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
315
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
316 if (instr >= MAX_INSTRUMENTS) return;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
317 INSTRUMENTHEADER *penv = (m_dwSongFlags & SONG_INSTRUMENTMODE) ? Headers[instr] : NULL;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
318 MODINSTRUMENT *psmp = &Ins[instr];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
319 UINT note = pChn->nNewNote;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
320 if ((penv) && (note) && (note <= 128))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
321 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
322 if (penv->NoteMap[note-1] >= 0xFE) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
323 UINT n = penv->Keyboard[note-1];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
324 psmp = ((n) && (n < MAX_SAMPLES)) ? &Ins[n] : NULL;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
325 pChn->dwFlags &= ~CHN_SUSTAINLOOP; // turn off sustain
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
326 } else
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
327 if (m_dwSongFlags & SONG_INSTRUMENTMODE)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
328 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
329 if (note >= 0xFE) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
330 psmp = NULL;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
331 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
332 // Update Volume
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
333 if (bUpdVol) pChn->nVolume = (psmp) ? psmp->nVolume : 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
334 // bInstrumentChanged is used for IT carry-on env option
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
335 if (penv != pChn->pHeader)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
336 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
337 bInstrumentChanged = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
338 pChn->pHeader = penv;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
339 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
340 // Special XM hack
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
341 if ((bPorta) && (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2)) && (penv)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
342 && (pChn->pInstrument) && (psmp != pChn->pInstrument))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
343 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
344 // FT2 doesn't change the sample in this case,
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
345 // but still uses the sample info from the old one (bug?)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
346 return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
347 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
348 // Instrument adjust
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
349 pChn->nNewIns = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
350 if (psmp)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
351 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
352 psmp->played = 1;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
353 if (penv)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
354 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
355 penv->played = 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
356 pChn->nInsVol = (psmp->nGlobalVol * penv->nGlobalVol) >> 7;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
357 if (penv->dwFlags & ENV_SETPANNING) pChn->nPan = penv->nPan;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
358 pChn->nNNA = penv->nNNA;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
359 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
360 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
361 pChn->nInsVol = psmp->nGlobalVol;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
362 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
363 if (psmp->uFlags & CHN_PANNING) pChn->nPan = psmp->nPan;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
364 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
365 // Reset envelopes
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
366 if (bResetEnv)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
367 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
368 if ((!bPorta) || (!(m_nType & MOD_TYPE_IT)) || (m_dwSongFlags & SONG_ITCOMPATMODE)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
369 || (!pChn->nLength) || ((pChn->dwFlags & CHN_NOTEFADE) && (!pChn->nFadeOutVol)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
370 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
371 pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
372 if ((m_nType & MOD_TYPE_IT) && (!bInstrumentChanged) && (penv) && (!(pChn->dwFlags & (CHN_KEYOFF|CHN_NOTEFADE))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
373 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
374 if (!(penv->dwFlags & ENV_VOLCARRY)) pChn->nVolEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
375 if (!(penv->dwFlags & ENV_PANCARRY)) pChn->nPanEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
376 if (!(penv->dwFlags & ENV_PITCHCARRY)) pChn->nPitchEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
377 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
378 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
379 pChn->nVolEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
380 pChn->nPanEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
381 pChn->nPitchEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
382 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
383 pChn->nAutoVibDepth = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
384 pChn->nAutoVibPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
385 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
386 if ((penv) && (!(penv->dwFlags & ENV_VOLUME)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
387 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
388 pChn->nVolEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
389 pChn->nAutoVibDepth = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
390 pChn->nAutoVibPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
391 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
392 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
393 // Invalid sample ?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
394 if (!psmp)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
395 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
396 pChn->pInstrument = NULL;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
397 pChn->nInsVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
398 return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
399 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
400 // Tone-Portamento doesn't reset the pingpong direction flag
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
401 if ((bPorta) && (psmp == pChn->pInstrument))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
402 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
403 if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT)) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
404 pChn->dwFlags &= ~(CHN_KEYOFF|CHN_NOTEFADE);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
405 pChn->dwFlags = (pChn->dwFlags & (0xFFFFFF00 | CHN_PINGPONGFLAG)) | (psmp->uFlags);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
406 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
407 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
408 pChn->dwFlags &= ~(CHN_KEYOFF|CHN_NOTEFADE|CHN_VOLENV|CHN_PANENV|CHN_PITCHENV);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
409 pChn->dwFlags = (pChn->dwFlags & 0xFFFFFF00) | (psmp->uFlags);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
410 if (penv)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
411 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
412 if (penv->dwFlags & ENV_VOLUME) pChn->dwFlags |= CHN_VOLENV;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
413 if (penv->dwFlags & ENV_PANNING) pChn->dwFlags |= CHN_PANENV;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
414 if (penv->dwFlags & ENV_PITCH) pChn->dwFlags |= CHN_PITCHENV;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
415 if ((penv->dwFlags & ENV_PITCH) && (penv->dwFlags & ENV_FILTER))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
416 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
417 if (!pChn->nCutOff) pChn->nCutOff = 0x7F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
418 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
419 if (penv->nIFC & 0x80) pChn->nCutOff = penv->nIFC & 0x7F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
420 if (penv->nIFR & 0x80) pChn->nResonance = penv->nIFR & 0x7F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
421 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
422 pChn->nVolSwing = pChn->nPanSwing = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
423 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
424 pChn->pInstrument = psmp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
425 pChn->nLength = psmp->nLength;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
426 pChn->nLoopStart = psmp->nLoopStart;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
427 pChn->nLoopEnd = psmp->nLoopEnd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
428 pChn->nC4Speed = psmp->nC4Speed;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
429 pChn->pSample = psmp->pSample;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
430 pChn->nTranspose = psmp->RelativeTone;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
431 pChn->nFineTune = psmp->nFineTune;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
432 if (pChn->dwFlags & CHN_SUSTAINLOOP)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
433 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
434 pChn->nLoopStart = psmp->nSustainStart;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
435 pChn->nLoopEnd = psmp->nSustainEnd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
436 pChn->dwFlags |= CHN_LOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
437 if (pChn->dwFlags & CHN_PINGPONGSUSTAIN) pChn->dwFlags |= CHN_PINGPONGLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
438 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
439 if ((pChn->dwFlags & CHN_LOOP) && (pChn->nLoopEnd < pChn->nLength)) pChn->nLength = pChn->nLoopEnd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
440 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
441
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
442
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
443 void CSoundFile::NoteChange(UINT nChn, int note, BOOL bPorta, BOOL bResetEnv, BOOL bManual)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
444 //-----------------------------------------------------------------------------------------
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
445 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
446 if (note < 1) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
447 MODCHANNEL * const pChn = &Chn[nChn];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
448 MODINSTRUMENT *pins = pChn->pInstrument;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
449 INSTRUMENTHEADER *penv = (m_dwSongFlags & SONG_INSTRUMENTMODE) ? pChn->pHeader : NULL;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
450 if ((penv) && (note <= 0x80))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
451 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
452 UINT n = penv->Keyboard[note - 1];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
453 if ((n) && (n < MAX_SAMPLES)) pins = &Ins[n];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
454 note = penv->NoteMap[note-1];
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
455 pChn->dwFlags &= ~CHN_SUSTAINLOOP; // turn off sustain
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
456 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
457 // Key Off
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
458 if (note >= 0x80) // 0xFE or invalid note => key off
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
459 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
460 // technically this is "wrong", as anything besides ^^^, ===, and a valid note
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
461 // should cause a note fade... (oh well, it's just a quick hack anyway.)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
462 if (note == 0xFD) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
463 pChn->dwFlags |= CHN_NOTEFADE;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
464 return;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
465 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
466
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
467 // Key Off
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
468 KeyOff(nChn);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
469 // Note Cut
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
470 if (note == 0xFE)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
471 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
472 pChn->dwFlags |= (CHN_NOTEFADE|CHN_FASTVOLRAMP);
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
473 if ((!(m_nType & MOD_TYPE_IT)) || (m_dwSongFlags & SONG_INSTRUMENTMODE))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
474 pChn->nVolume = 0;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
475 pChn->nFadeOutVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
476 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
477 return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
478 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
479 if (!pins) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
480 if ((!bPorta) && (m_nType & (MOD_TYPE_XM|MOD_TYPE_MED|MOD_TYPE_MT2)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
481 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
482 pChn->nTranspose = pins->RelativeTone;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
483 pChn->nFineTune = pins->nFineTune;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
484 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
485 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2|MOD_TYPE_MED)) note += pChn->nTranspose;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
486 if (note < 1) note = 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
487 if (note > 132) note = 132;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
488 pChn->nNote = note;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
489 if ((!bPorta) || (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT))) pChn->nNewIns = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
490 UINT period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC4Speed);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
491 if (period)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
492 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
493 if ((!bPorta) || (!pChn->nPeriod)) pChn->nPeriod = period;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
494 pChn->nPortamentoDest = period;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
495 if ((!bPorta) || ((!pChn->nLength) && (!(m_nType & MOD_TYPE_S3M))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
496 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
497 pChn->pInstrument = pins;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
498 pChn->pSample = pins->pSample;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
499 pChn->nLength = pins->nLength;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
500 pChn->nLoopEnd = pins->nLength;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
501 pChn->nLoopStart = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
502 pChn->dwFlags = (pChn->dwFlags & 0xFFFFFF00) | (pins->uFlags);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
503 if (pChn->dwFlags & CHN_SUSTAINLOOP)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
504 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
505 pChn->nLoopStart = pins->nSustainStart;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
506 pChn->nLoopEnd = pins->nSustainEnd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
507 pChn->dwFlags &= ~CHN_PINGPONGLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
508 pChn->dwFlags |= CHN_LOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
509 if (pChn->dwFlags & CHN_PINGPONGSUSTAIN) pChn->dwFlags |= CHN_PINGPONGLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
510 if (pChn->nLength > pChn->nLoopEnd) pChn->nLength = pChn->nLoopEnd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
511 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
512 if (pChn->dwFlags & CHN_LOOP)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
513 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
514 pChn->nLoopStart = pins->nLoopStart;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
515 pChn->nLoopEnd = pins->nLoopEnd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
516 if (pChn->nLength > pChn->nLoopEnd) pChn->nLength = pChn->nLoopEnd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
517 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
518 pChn->nPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
519 pChn->nPosLo = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
520 if (pChn->nVibratoType < 4) pChn->nVibratoPos = ((m_nType & MOD_TYPE_IT) && (!(m_dwSongFlags & SONG_ITOLDEFFECTS))) ? 0x10 : 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
521 if (pChn->nTremoloType < 4) pChn->nTremoloPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
522 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
523 if (pChn->nPos >= pChn->nLength) pChn->nPos = pChn->nLoopStart;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
524 } else bPorta = FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
525 if ((!bPorta) || (!(m_nType & MOD_TYPE_IT))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
526 || ((pChn->dwFlags & CHN_NOTEFADE) && (!pChn->nFadeOutVol))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
527 || ((m_dwSongFlags & SONG_ITCOMPATMODE) && (pChn->nRowInstr)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
528 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
529 if ((m_nType & MOD_TYPE_IT) && (pChn->dwFlags & CHN_NOTEFADE) && (!pChn->nFadeOutVol))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
530 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
531 pChn->nVolEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
532 pChn->nPanEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
533 pChn->nPitchEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
534 pChn->nAutoVibDepth = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
535 pChn->nAutoVibPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
536 pChn->dwFlags &= ~CHN_NOTEFADE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
537 pChn->nFadeOutVol = 65536;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
538 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
539 if ((!bPorta) || (!(m_dwSongFlags & SONG_ITCOMPATMODE)) || (pChn->nRowInstr))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
540 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
541 if ((!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) || (pChn->nRowInstr))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
542 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
543 pChn->dwFlags &= ~CHN_NOTEFADE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
544 pChn->nFadeOutVol = 65536;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
545 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
546 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
547 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
548 pChn->dwFlags &= ~(CHN_EXTRALOUD|CHN_KEYOFF);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
549 // Enable Ramping
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
550 if (!bPorta)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
551 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
552 pChn->nVUMeter = 0x100;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
553 pChn->nLeftVU = pChn->nRightVU = 0xFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
554 pChn->dwFlags &= ~CHN_FILTER;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
555 pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
556 pChn->nRetrigCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
557 pChn->nTremorCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
558 if (bResetEnv)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
559 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
560 pChn->nVolSwing = pChn->nPanSwing = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
561 if (penv)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
562 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
563 if (!(penv->dwFlags & ENV_VOLCARRY)) pChn->nVolEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
564 if (!(penv->dwFlags & ENV_PANCARRY)) pChn->nPanEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
565 if (!(penv->dwFlags & ENV_PITCHCARRY)) pChn->nPitchEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
566 if (m_nType & MOD_TYPE_IT)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
567 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
568 // Volume Swing
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
569 if (penv->nVolSwing)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
570 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
571 /* this was wrong */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
572 int d = ((LONG)penv->nVolSwing*(LONG)((rand() & 0xFF) - 0x7F)) / 256;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
573 pChn->nVolSwing = (signed short)((d * pChn->nVolume + 1)/256);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
574 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
575 // Pan Swing
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
576 if (penv->nPanSwing)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
577 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
578 int d = ((LONG)penv->nPanSwing*(LONG)((rand() & 0xFF) - 0x7F)) / 128;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
579 pChn->nPanSwing = (signed short)d;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
580 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
581 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
582 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
583 pChn->nAutoVibDepth = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
584 pChn->nAutoVibPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
585 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
586 pChn->nLeftVol = pChn->nRightVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
587 BOOL bFlt = (m_dwSongFlags & SONG_MPTFILTERMODE) ? FALSE : TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
588 // Setup Initial Filter for this note
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
589 if (penv)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
590 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
591 if (penv->nIFR & 0x80) { pChn->nResonance = penv->nIFR & 0x7F; bFlt = TRUE; }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
592 if (penv->nIFC & 0x80) { pChn->nCutOff = penv->nIFC & 0x7F; bFlt = TRUE; }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
593 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
594 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
595 pChn->nVolSwing = pChn->nPanSwing = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
596 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
597 #ifndef NO_FILTER
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
598 if ((pChn->nCutOff < 0x7F) && (bFlt)) SetupChannelFilter(pChn, TRUE);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
599 #endif // NO_FILTER
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
600 }
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
601 // Special case for MPT
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
602 if (bManual) pChn->dwFlags &= ~CHN_MUTE;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
603 if (((pChn->dwFlags & CHN_MUTE) && (gdwSoundSetup & SNDMIX_MUTECHNMODE))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
604 || ((pChn->pInstrument) && (pChn->pInstrument->uFlags & CHN_MUTE) && (!bManual))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
605 || ((m_dwSongFlags & SONG_INSTRUMENTMODE) && (pChn->pHeader)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
606 && (pChn->pHeader->dwFlags & ENV_MUTE) && (!bManual)))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
607 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
608 if (!bManual) pChn->nPeriod = 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
609 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
610 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
611
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
612
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
613 UINT CSoundFile::GetNNAChannel(UINT nChn)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
614 //---------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
615 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
616 MODCHANNEL *pChn = &Chn[nChn];
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
617 // Check for empty channel
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
618 MODCHANNEL *pi = &Chn[m_nChannels];
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
619 for (UINT i=m_nChannels; i<MAX_CHANNELS; i++, pi++) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
620 if (!pi->nLength) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
621 if (pi->dwFlags & CHN_MUTE) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
622 if (pi->dwFlags & CHN_NNAMUTE) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
623 pi->dwFlags &= ~(CHN_NNAMUTE|CHN_MUTE);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
624 } else {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
625 /* this channel is muted; skip */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
626 continue;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
627 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
628 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
629 return i;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
630 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
631 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
632 if (!pChn->nFadeOutVol) return 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
633 // All channels are used: check for lowest volume
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
634 UINT result = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
635 DWORD vol = 64*65536; // 25%
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
636 int envpos = 0xFFFFFF;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
637 const MODCHANNEL *pj = &Chn[m_nChannels];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
638 for (UINT j=m_nChannels; j<MAX_CHANNELS; j++, pj++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
639 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
640 if (!pj->nFadeOutVol) return j;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
641 DWORD v = pj->nVolume;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
642 if (pj->dwFlags & CHN_NOTEFADE)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
643 v = v * pj->nFadeOutVol;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
644 else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
645 v <<= 16;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
646 if (pj->dwFlags & CHN_LOOP) v >>= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
647 if ((v < vol) || ((v == vol) && (pj->nVolEnvPosition > envpos)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
648 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
649 envpos = pj->nVolEnvPosition;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
650 vol = v;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
651 result = j;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
652 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
653 }
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
654 if (result) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
655 /* unmute new nna channel */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
656 Chn[result].dwFlags &= ~(CHN_MUTE|CHN_NNAMUTE);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
657 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
658 return result;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
659 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
660
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
661
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
662 void CSoundFile::CheckNNA(UINT nChn, UINT instr, int note, BOOL bForceCut)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
663 //------------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
664 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
665 MODCHANNEL *p;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
666 MODCHANNEL *pChn = &Chn[nChn];
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
667 INSTRUMENTHEADER *penv = (m_dwSongFlags & SONG_INSTRUMENTMODE) ? pChn->pHeader : NULL;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
668 INSTRUMENTHEADER *pHeader;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
669 signed char *pSample;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
670 if (note > 0x80) note = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
671 if (note < 1) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
672 // Always NNA cut - using
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
673 if ((!(m_nType & (MOD_TYPE_IT|MOD_TYPE_MT2))) || (!(m_dwSongFlags & SONG_INSTRUMENTMODE)) || (bForceCut))
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
674 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
675 if ((m_dwSongFlags & SONG_CPUVERYHIGH)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
676 || (!pChn->nLength) || (pChn->dwFlags & CHN_MUTE)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
677 || ((!pChn->nLeftVol) && (!pChn->nRightVol))) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
678 UINT n = GetNNAChannel(nChn);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
679 if (!n) return;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
680 p = &Chn[n];
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
681 // Copy Channel
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
682 *p = *pChn;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
683 p->dwFlags &= ~(CHN_VIBRATO|CHN_TREMOLO|CHN_PANBRELLO|CHN_PORTAMENTO);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
684 p->nMasterChn = nChn+1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
685 p->nCommand = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
686 // Cut the note
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
687 p->nFadeOutVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
688 p->dwFlags |= (CHN_NOTEFADE|CHN_FASTVOLRAMP);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
689 // Stop this channel
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
690 pChn->nLength = pChn->nPos = pChn->nPosLo = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
691 pChn->nROfs = pChn->nLOfs = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
692 pChn->nLeftVol = pChn->nRightVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
693 return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
694 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
695 if (instr >= MAX_INSTRUMENTS) instr = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
696 pSample = pChn->pSample;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
697 pHeader = pChn->pHeader;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
698 if ((instr) && (note))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
699 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
700 pHeader = (m_dwSongFlags & SONG_INSTRUMENTMODE) ? Headers[instr] : NULL;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
701 if (pHeader)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
702 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
703 UINT n = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
704 if (note <= 0x80)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
705 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
706 n = pHeader->Keyboard[note-1];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
707 note = pHeader->NoteMap[note-1];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
708 if ((n) && (n < MAX_SAMPLES)) pSample = Ins[n].pSample;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
709 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
710 } else pSample = NULL;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
711 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
712 if (!penv) return;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
713 p = pChn;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
714 for (UINT i=nChn; i<MAX_CHANNELS; p++, i++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
715 if ((i >= m_nChannels) || (p == pChn))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
716 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
717 if (((p->nMasterChn == nChn+1) || (p == pChn)) && (p->pHeader))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
718 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
719 BOOL bOk = FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
720 // Duplicate Check Type
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
721 switch(p->pHeader->nDCT)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
722 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
723 // Note
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
724 case DCT_NOTE:
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
725 if ((note) && ((int)p->nNote == note) && (pHeader == p->pHeader)) bOk = TRUE;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
726 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
727 // Sample
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
728 case DCT_SAMPLE:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
729 if ((pSample) && (pSample == p->pSample)) bOk = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
730 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
731 // Instrument
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
732 case DCT_INSTRUMENT:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
733 if (pHeader == p->pHeader) bOk = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
734 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
735 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
736 // Duplicate Note Action
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
737 if (bOk)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
738 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
739 switch(p->pHeader->nDNA)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
740 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
741 // Cut
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
742 case DNA_NOTECUT:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
743 KeyOff(i);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
744 p->nVolume = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
745 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
746 // Note Off
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
747 case DNA_NOTEOFF:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
748 KeyOff(i);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
749 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
750 // Note Fade
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
751 case DNA_NOTEFADE:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
752 p->dwFlags |= CHN_NOTEFADE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
753 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
754 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
755 if (!p->nVolume)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
756 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
757 p->nFadeOutVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
758 p->dwFlags |= (CHN_NOTEFADE|CHN_FASTVOLRAMP);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
759 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
760 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
761 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
762 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
763 if (pChn->dwFlags & CHN_MUTE) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
764 // New Note Action
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
765 if ((pChn->nVolume) && (pChn->nLength))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
766 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
767 UINT n = GetNNAChannel(nChn);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
768 if (n)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
769 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
770 p = &Chn[n];
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
771 // Copy Channel
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
772 *p = *pChn;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
773 p->dwFlags &= ~(CHN_VIBRATO|CHN_TREMOLO|CHN_PANBRELLO|CHN_PORTAMENTO);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
774 p->nMasterChn = nChn+1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
775 p->nCommand = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
776 // Key Off the note
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
777 switch(pChn->nNNA)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
778 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
779 case NNA_NOTEOFF: KeyOff(n); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
780 case NNA_NOTECUT:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
781 p->nFadeOutVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
782 case NNA_NOTEFADE: p->dwFlags |= CHN_NOTEFADE; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
783 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
784 if (!p->nVolume)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
785 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
786 p->nFadeOutVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
787 p->dwFlags |= (CHN_NOTEFADE|CHN_FASTVOLRAMP);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
788 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
789 // Stop this channel
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
790 pChn->nLength = pChn->nPos = pChn->nPosLo = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
791 pChn->nROfs = pChn->nLOfs = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
792 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
793 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
794 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
795
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
796
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
797 BOOL CSoundFile::ProcessEffects()
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
798 //-------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
799 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
800 int nBreakRow = -1, nPosJump = -1, nPatLoopRow = -1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
801 MODCHANNEL *pChn = Chn;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
802 for (UINT nChn=0; nChn<m_nChannels; nChn++, pChn++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
803 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
804 pChn->nCommand=0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
805
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
806 UINT instr = pChn->nRowInstr;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
807 UINT volcmd = pChn->nRowVolCmd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
808 UINT vol = pChn->nRowVolume;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
809 UINT cmd = pChn->nRowCommand;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
810 UINT param = pChn->nRowParam;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
811 BOOL bPorta = ((cmd != CMD_TONEPORTAMENTO) && (cmd != CMD_TONEPORTAVOL) && (volcmd != VOLCMD_TONEPORTAMENTO)) ? FALSE : TRUE;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
812 UINT nStartTick = pChn->nTickStart;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
813
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
814 pChn->dwFlags &= ~CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
815 // Process special effects (note delay, pattern delay, pattern loop)
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
816 if (((cmd == CMD_MODCMDEX) || (cmd == CMD_S3MCMDEX)))
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
817 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
818 if ((!param) && (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT))) param = pChn->nOldCmdEx; else pChn->nOldCmdEx = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
819 // Note Delay ?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
820 if ((param & 0xF0) == 0xD0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
821 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
822 nStartTick = param & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
823 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
824 if (!m_nTickCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
825 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
826 // Pattern Loop ?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
827 if ((((param & 0xF0) == 0x60) && (cmd == CMD_MODCMDEX))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
828 || (((param & 0xF0) == 0xB0) && (cmd == CMD_S3MCMDEX)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
829 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
830 int nloop = PatternLoop(pChn, param & 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
831 if (nloop >= 0) nPatLoopRow = nloop;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
832 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
833 // Pattern Delay
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
834 if ((param & 0xF0) == 0xE0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
835 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
836 m_nPatternDelay = param & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
837 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
838 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
839 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
840
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
841 // Handles note/instrument/volume changes
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
842 if (m_nTickCount == nStartTick) // can be delayed by a note delay effect
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
843 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
844 UINT note = pChn->nRowNote;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
845 if (instr) pChn->nNewIns = instr;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
846 // XM: Key-Off + Sample == Note Cut
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
847 if (m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
848 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
849 if ((note == 0xFF) && ((!pChn->pHeader) || (!(pChn->pHeader->dwFlags & ENV_VOLUME))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
850 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
851 pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
852 pChn->nVolume = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
853 note = instr = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
854 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
855 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
856 if ((!note) && (instr))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
857 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
858 if (m_dwSongFlags & SONG_INSTRUMENTMODE)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
859 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
860 if (pChn->pInstrument) pChn->nVolume = pChn->pInstrument->nVolume;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
861 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
862 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
863 pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
864 pChn->nVolEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
865 pChn->nPanEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
866 pChn->nPitchEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
867 pChn->nAutoVibDepth = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
868 pChn->nAutoVibPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
869 pChn->dwFlags &= ~CHN_NOTEFADE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
870 pChn->nFadeOutVol = 65536;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
871 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
872 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
873 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
874 if (instr < MAX_SAMPLES) pChn->nVolume = Ins[instr].nVolume;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
875 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
876 if (!(m_nType & MOD_TYPE_IT)) instr = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
877 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
878 // Invalid Instrument ?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
879 if (instr >= MAX_INSTRUMENTS) instr = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
880 // Note Cut/Off => ignore instrument
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
881 if (note >= 0xFE) instr = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
882 if ((note) && (note <= 128)) pChn->nNewNote = note;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
883 // New Note Action ? (not when paused!!!)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
884 if ((note) && (note <= 128) && (!bPorta))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
885 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
886 CheckNNA(nChn, instr, note, FALSE);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
887 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
888 // Instrument Change ?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
889 if (instr)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
890 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
891 MODINSTRUMENT *psmp = pChn->pInstrument;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
892 InstrumentChange(pChn, instr, bPorta, TRUE);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
893 pChn->nNewIns = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
894 // Special IT case: portamento+note causes sample change -> ignore portamento
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
895 if ((m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
896 && (psmp != pChn->pInstrument) && (note) && (note < 0x80))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
897 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
898 bPorta = FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
899 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
900 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
901 // New Note ?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
902 if (note)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
903 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
904 if ((!instr) && (pChn->nNewIns) && (note < 0x80))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
905 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
906 InstrumentChange(pChn, pChn->nNewIns, bPorta, FALSE, (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2)) ? FALSE : TRUE);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
907 pChn->nNewIns = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
908 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
909 NoteChange(nChn, note, bPorta, (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2)) ? FALSE : TRUE);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
910 if ((bPorta) && (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2)) && (instr))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
911 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
912 pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
913 pChn->nVolEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
914 pChn->nPanEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
915 pChn->nPitchEnvPosition = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
916 pChn->nAutoVibDepth = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
917 pChn->nAutoVibPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
918 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
919 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
920 // Tick-0 only volume commands
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
921 if (volcmd == VOLCMD_VOLUME)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
922 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
923 if (vol > 64) vol = 64;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
924 pChn->nVolume = vol << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
925 pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
926 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
927 if (volcmd == VOLCMD_PANNING)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
928 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
929 if (vol > 64) vol = 64;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
930 pChn->nPan = vol << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
931 pChn->dwFlags |= CHN_FASTVOLRAMP;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
932 pChn->dwFlags &= ~CHN_SURROUND;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
933 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
934 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
935
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
936 // Volume Column Effect (except volume & panning)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
937 if ((volcmd > VOLCMD_PANNING) && (m_nTickCount >= nStartTick))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
938 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
939 if (volcmd == VOLCMD_TONEPORTAMENTO)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
940 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
941 if (m_nType & MOD_TYPE_IT)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
942 TonePortamento(pChn, ImpulseTrackerPortaVolCmd[vol & 0x0F]);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
943 else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
944 TonePortamento(pChn, vol * 16);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
945 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
946 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
947 if (vol) pChn->nOldVolParam = vol; else vol = pChn->nOldVolParam;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
948 switch(volcmd)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
949 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
950 case VOLCMD_VOLSLIDEUP:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
951 VolumeSlide(pChn, vol << 4);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
952 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
953
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
954 case VOLCMD_VOLSLIDEDOWN:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
955 VolumeSlide(pChn, vol);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
956 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
957
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
958 case VOLCMD_FINEVOLUP:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
959 if (m_nType & MOD_TYPE_IT)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
960 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
961 if (m_nTickCount == nStartTick) VolumeSlide(pChn, (vol << 4) | 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
962 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
963 FineVolumeUp(pChn, vol);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
964 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
965
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
966 case VOLCMD_FINEVOLDOWN:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
967 if (m_nType & MOD_TYPE_IT)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
968 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
969 if (m_nTickCount == nStartTick) VolumeSlide(pChn, 0xF0 | vol);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
970 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
971 FineVolumeDown(pChn, vol);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
972 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
973
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
974 case VOLCMD_VIBRATOSPEED:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
975 Vibrato(pChn, vol << 4);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
976 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
977
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
978 case VOLCMD_VIBRATO:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
979 Vibrato(pChn, vol);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
980 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
981
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
982 case VOLCMD_PANSLIDELEFT:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
983 PanningSlide(pChn, vol);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
984 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
985
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
986 case VOLCMD_PANSLIDERIGHT:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
987 PanningSlide(pChn, vol << 4);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
988 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
989
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
990 case VOLCMD_PORTAUP:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
991 PortamentoUp(pChn, vol << 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
992 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
993
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
994 case VOLCMD_PORTADOWN:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
995 PortamentoDown(pChn, vol << 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
996 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
997 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
998 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
999 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1000
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1001 // Effects
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1002 if (cmd) switch (cmd)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1003 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1004 // Set Volume
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1005 case CMD_VOLUME:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1006 if (!m_nTickCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1007 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1008 pChn->nVolume = (param < 64) ? param*4 : 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1009 pChn->dwFlags |= CHN_FASTVOLRAMP;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1010 for (UINT i=m_nChannels; i<MAX_CHANNELS; i++)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1011 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1012 MODCHANNEL *c = &Chn[i];
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1013 if (c->nMasterChn == (nChn+1)) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1014 c->nVolume = pChn->nVolume;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1015 c->dwFlags |= CHN_FASTVOLRAMP;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1016 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1017 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1018 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1019 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1020
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1021 // Portamento Up
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1022 case CMD_PORTAMENTOUP:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1023 if ((!param) && (m_nType & MOD_TYPE_MOD)) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1024 PortamentoUp(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1025 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1026
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1027 // Portamento Down
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1028 case CMD_PORTAMENTODOWN:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1029 if ((!param) && (m_nType & MOD_TYPE_MOD)) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1030 PortamentoDown(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1031 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1032
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1033 // Volume Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1034 case CMD_VOLUMESLIDE:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1035 if ((param) || (m_nType != MOD_TYPE_MOD)) VolumeSlide(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1036 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1037
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1038 // Tone-Portamento
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1039 case CMD_TONEPORTAMENTO:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1040 TonePortamento(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1041 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1042
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1043 // Tone-Portamento + Volume Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1044 case CMD_TONEPORTAVOL:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1045 if ((param) || (m_nType != MOD_TYPE_MOD)) VolumeSlide(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1046 TonePortamento(pChn, 0);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1047 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1048
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1049 // Vibrato
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1050 case CMD_VIBRATO:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1051 Vibrato(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1052 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1053
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1054 // Vibrato + Volume Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1055 case CMD_VIBRATOVOL:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1056 if ((param) || (m_nType != MOD_TYPE_MOD)) VolumeSlide(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1057 Vibrato(pChn, 0);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1058 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1059
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1060 // Set Speed
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1061 case CMD_SPEED:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1062 if (!m_nTickCount) SetSpeed(param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1063 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1064
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1065 // Set Tempo
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1066 case CMD_TEMPO:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1067 if (!m_nTickCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1068 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1069 if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1070 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1071 if (param) pChn->nOldTempo = param; else param = pChn->nOldTempo;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1072 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1073 SetTempo(param);
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1074 } else {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1075 param = pChn->nOldTempo; // this just got set on tick zero
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1076
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1077 switch (param >> 4) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1078 case 0:
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1079 m_nMusicTempo -= param & 0xf;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1080 if (m_nMusicTempo < 32)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1081 m_nMusicTempo = 32;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1082 break;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1083 case 1:
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1084 m_nMusicTempo += param & 0xf;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1085 if (m_nMusicTempo > 255)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1086 m_nMusicTempo = 255;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1087 break;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1088 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1089 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1090 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1091
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1092 // Set Offset
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1093 case CMD_OFFSET:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1094 if (m_nTickCount) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1095 if (param) pChn->nOldOffset = param; else param = pChn->nOldOffset;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1096 param <<= 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1097 param |= (UINT)(pChn->nOldHiOffset) << 16;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1098 if ((pChn->nRowNote) && (pChn->nRowNote < 0x80))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1099 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1100 if (bPorta)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1101 pChn->nPos = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1102 else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1103 pChn->nPos += param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1104 if (pChn->nPos >= pChn->nLength)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1105 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1106 if (!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1107 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1108 pChn->nPos = pChn->nLoopStart;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1109 if ((m_dwSongFlags & SONG_ITOLDEFFECTS) && (pChn->nLength > 4))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1110 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1111 pChn->nPos = pChn->nLength - 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1112 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1113 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1114 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1115 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1116 if ((param < pChn->nLength) && (m_nType & (MOD_TYPE_MTM|MOD_TYPE_DMF)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1117 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1118 pChn->nPos = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1119 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1120 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1121
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1122 // Arpeggio
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1123 case CMD_ARPEGGIO:
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1124 pChn->nCommand = CMD_ARPEGGIO;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1125 if ((m_nTickCount) || (!pChn->nPeriod) || (!pChn->nNote)) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1126 if ((!param) && (!(m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT)))) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1127 if (param) pChn->nArpeggio = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1128 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1129
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1130 // Retrig
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1131 case CMD_RETRIG:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1132 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1133 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1134 if (!(param & 0xF0)) param |= pChn->nRetrigParam & 0xF0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1135 if (!(param & 0x0F)) param |= pChn->nRetrigParam & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1136 param |= 0x100; // increment retrig count on first row
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1137 }
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1138 // various bits of retriggery commented out here & below, reverting to old method...
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1139 // -Storlek 04aug07
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1140 // if (pChn->nRowNote && !m_nTickCount) pChn->nRetrigCount = 0;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1141 if (param) pChn->nRetrigParam = (BYTE)(param & 0xFF); else param = pChn->nRetrigParam;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1142 // pChn->nCommand = CMD_RETRIG;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1143 RetrigNote(nChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1144 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1145
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1146 // Tremor
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1147 case CMD_TREMOR:
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1148 pChn->nCommand = CMD_TREMOR;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1149 if (m_nTickCount) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1150 if (param) pChn->nTremorParam = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1151 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1152
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1153 // Set Global Volume
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1154 case CMD_GLOBALVOLUME:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1155 if (m_nTickCount) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1156 if (m_nType != MOD_TYPE_IT) param <<= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1157 if (param > 128) param = 128;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1158 m_nGlobalVolume = param << 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1159 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1160
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1161 // Global Volume Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1162 case CMD_GLOBALVOLSLIDE:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1163 GlobalVolSlide(param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1164 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1165
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1166 // Set 8-bit Panning
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1167 case CMD_PANNING8:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1168 if (m_nTickCount) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1169 if (!(m_dwSongFlags & SONG_SURROUNDPAN)) pChn->dwFlags &= ~CHN_SURROUND;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1170 if (m_nType & (MOD_TYPE_IT|MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1171 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1172 pChn->nPan = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1173 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1174 if (param <= 0x80)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1175 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1176 pChn->nPan = param << 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1177 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1178 if (param == 0xA4)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1179 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1180 pChn->dwFlags |= CHN_SURROUND;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1181 pChn->nPan = 0x80;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1182 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1183 pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1184 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1185
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1186 // Panning Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1187 case CMD_PANNINGSLIDE:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1188 PanningSlide(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1189 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1190
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1191 // Tremolo
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1192 case CMD_TREMOLO:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1193 Tremolo(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1194 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1195
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1196 // Fine Vibrato
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1197 case CMD_FINEVIBRATO:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1198 FineVibrato(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1199 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1200
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1201 // MOD/XM Exx Extended Commands
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1202 case CMD_MODCMDEX:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1203 ExtendedMODCommands(nChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1204 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1205
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1206 // S3M/IT Sxx Extended Commands
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1207 case CMD_S3MCMDEX:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1208 ExtendedS3MCommands(nChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1209 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1210
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1211 // Key Off
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1212 case CMD_KEYOFF:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1213 if (!m_nTickCount) KeyOff(nChn);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1214 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1215
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1216 // Extra-fine porta up/down
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1217 case CMD_XFINEPORTAUPDOWN:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1218 switch(param & 0xF0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1219 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1220 case 0x10: ExtraFinePortamentoUp(pChn, param & 0x0F); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1221 case 0x20: ExtraFinePortamentoDown(pChn, param & 0x0F); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1222 // Modplug XM Extensions
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1223 case 0x50:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1224 case 0x60:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1225 case 0x70:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1226 case 0x90:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1227 case 0xA0: ExtendedS3MCommands(nChn, param); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1228 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1229 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1230
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1231 // Set Channel Global Volume
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1232 case CMD_CHANNELVOLUME:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1233 if (m_nTickCount) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1234 if (param <= 64)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1235 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1236 pChn->nGlobalVol = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1237 pChn->dwFlags |= CHN_FASTVOLRAMP;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1238 for (UINT i=m_nChannels; i<MAX_CHANNELS; i++)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1239 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1240 MODCHANNEL *c = &Chn[i];
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1241 if (c->nMasterChn == (nChn+1)) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1242 c->nGlobalVol = param;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1243 c->dwFlags |= CHN_FASTVOLRAMP;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1244 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1245 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1246 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1247 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1248
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1249 // Channel volume slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1250 case CMD_CHANNELVOLSLIDE:
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1251 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1252 int saw_self = 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1253
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1254 for (UINT i=m_nChannels; i<MAX_CHANNELS; i++)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1255 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1256 MODCHANNEL *c = &Chn[i];
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1257 if (c->nMasterChn == (nChn+1)) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1258 if (c == pChn) saw_self = 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1259 ChannelVolSlide(c, param);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1260 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1261 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1262 if (!saw_self) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1263 ChannelVolSlide(pChn, param);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1264 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1265 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1266
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1267 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1268
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1269 // Panbrello (IT)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1270 case CMD_PANBRELLO:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1271 Panbrello(pChn, param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1272 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1273
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1274 // Set Envelope Position
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1275 case CMD_SETENVPOSITION:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1276 if (!m_nTickCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1277 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1278 pChn->nVolEnvPosition = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1279 pChn->nPanEnvPosition = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1280 pChn->nPitchEnvPosition = param;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1281 if ((m_dwSongFlags & SONG_INSTRUMENTMODE) && pChn->pHeader)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1282 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1283 INSTRUMENTHEADER *penv = pChn->pHeader;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1284 if ((pChn->dwFlags & CHN_PANENV) && (penv->PanEnv.nNodes) && ((int)param > penv->PanEnv.Ticks[penv->PanEnv.nNodes-1]))
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1285 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1286 pChn->dwFlags &= ~CHN_PANENV;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1287 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1288 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1289 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1290 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1291
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1292 // Position Jump
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1293 case CMD_POSITIONJUMP:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1294 nPosJump = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1295 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1296
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1297 // Pattern Break
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1298 case CMD_PATTERNBREAK:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1299 nBreakRow = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1300 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1301
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1302 // Midi Controller
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1303 case CMD_MIDI:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1304 if (m_nTickCount) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1305 if (param < 0x80)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1306 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1307 ProcessMidiMacro(nChn, &m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro << 5], param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1308 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1309 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1310 ProcessMidiMacro(nChn, &m_MidiCfg.szMidiZXXExt[(param & 0x7F) << 5], 0);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1311 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1312 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1313 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1314 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1315
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1316 // Navigation Effects
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1317 if (!m_nTickCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1318 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1319 // Pattern Loop
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1320 if (nPatLoopRow >= 0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1321 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1322 m_nNextPattern = m_nCurrentPattern;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1323 m_nNextRow = nPatLoopRow;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1324 if (m_nPatternDelay) m_nNextRow++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1325 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1326 // Pattern Break / Position Jump only if no loop running
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1327 if ((nBreakRow >= 0) || (nPosJump >= 0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1328 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1329 BOOL bNoLoop = FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1330 if (nPosJump < 0) nPosJump = m_nCurrentPattern+1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1331 if (nBreakRow < 0) nBreakRow = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1332 // Modplug Tracker & ModPlugin allow backward jumps
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1333 #ifndef MODPLUG_FASTSOUNDLIB
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1334 if ((nPosJump < (int)m_nCurrentPattern)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1335 || ((nPosJump == (int)m_nCurrentPattern) && (nBreakRow <= (int)m_nRow)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1336 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1337 if (!IsValidBackwardJump(m_nCurrentPattern, m_nRow, nPosJump, nBreakRow))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1338 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1339 if (m_nRepeatCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1340 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1341 if (m_nRepeatCount > 0) m_nRepeatCount--;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1342 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1343 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1344 #ifdef MODPLUG_TRACKER
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1345 if (gdwSoundSetup & SNDMIX_NOBACKWARDJUMPS)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1346 #endif
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1347 // Backward jump disabled
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1348 bNoLoop = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1349 //reset repeat count incase there are multiple loops.
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1350 //(i.e. Unreal tracks)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1351 m_nRepeatCount = m_nInitialRepeatCount;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1352 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1353 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1354 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1355 #endif // MODPLUG_FASTSOUNDLIB
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1356 if (((!bNoLoop) && (nPosJump < MAX_ORDERS))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1357 && ((nPosJump != (int)m_nCurrentPattern) || (nBreakRow != (int)m_nRow)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1358 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1359 if (nPosJump != (int)m_nCurrentPattern)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1360 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1361 for (UINT i=0; i<m_nChannels; i++) Chn[i].nPatternLoopCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1362 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1363 m_nNextPattern = nPosJump;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1364 m_nNextRow = (UINT)nBreakRow;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1365 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1366 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1367 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1368 return TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1369 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1370
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1371
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1372 ////////////////////////////////////////////////////////////
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1373 // Channels effects
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1374
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1375 void CSoundFile::PortamentoUp(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1376 //---------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1377 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1378 if (param) pChn->nOldPortaUpDown = param; else param = pChn->nOldPortaUpDown;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1379 if (m_dwSongFlags & SONG_ITCOMPATMODE) pChn->nPortamentoSlide=param*4;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1380 else pChn->nPortamentoDest=0;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1381 if ((m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_STM)) && ((param & 0xF0) >= 0xE0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1382 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1383 if (param & 0x0F)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1384 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1385 if ((param & 0xF0) == 0xF0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1386 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1387 FinePortamentoUp(pChn, param & 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1388 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1389 if ((param & 0xF0) == 0xE0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1390 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1391 ExtraFinePortamentoUp(pChn, param & 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1392 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1393 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1394 return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1395 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1396 // Regular Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1397 if (!(m_dwSongFlags & SONG_FIRSTTICK))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1398 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1399 DoFreqSlide(pChn, -(int)(param * 4));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1400 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1401 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1402
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1403
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1404 void CSoundFile::PortamentoDown(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1405 //-----------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1406 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1407 if (param) pChn->nOldPortaUpDown = param; else param = pChn->nOldPortaUpDown;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1408 if (m_dwSongFlags & SONG_ITCOMPATMODE) pChn->nPortamentoSlide=param*4;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1409 else pChn->nPortamentoDest=0;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1410 if ((m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_STM)) && ((param & 0xF0) >= 0xE0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1411 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1412 if (param & 0x0F)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1413 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1414 if ((param & 0xF0) == 0xF0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1415 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1416 FinePortamentoDown(pChn, param & 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1417 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1418 if ((param & 0xF0) == 0xE0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1419 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1420 ExtraFinePortamentoDown(pChn, param & 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1421 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1422 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1423 return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1424 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1425 if (!(m_dwSongFlags & SONG_FIRSTTICK)) DoFreqSlide(pChn, (int)(param << 2));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1426 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1427
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1428
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1429 void CSoundFile::FinePortamentoUp(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1430 //-------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1431 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1432 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1433 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1434 if (param) pChn->nOldFinePortaUpDown = param; else param = pChn->nOldFinePortaUpDown;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1435 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1436 if (m_dwSongFlags & SONG_FIRSTTICK)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1437 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1438 if ((pChn->nPeriod) && (param))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1439 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1440 if ((m_dwSongFlags & SONG_LINEARSLIDES) && (!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1441 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1442 pChn->nPeriod = _muldivr(pChn->nPeriod, LinearSlideDownTable[param & 0x0F], 65536);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1443 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1444 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1445 pChn->nPeriod -= (int)(param * 4);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1446 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1447 if (pChn->nPeriod < 1) pChn->nPeriod = 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1448 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1449 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1450 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1451
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1452
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1453 void CSoundFile::FinePortamentoDown(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1454 //---------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1455 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1456 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1457 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1458 if (param) pChn->nOldFinePortaUpDown = param; else param = pChn->nOldFinePortaUpDown;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1459 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1460 if (m_dwSongFlags & SONG_FIRSTTICK)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1461 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1462 if ((pChn->nPeriod) && (param))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1463 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1464 if ((m_dwSongFlags & SONG_LINEARSLIDES) && (!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1465 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1466 pChn->nPeriod = _muldivr(pChn->nPeriod, LinearSlideUpTable[param & 0x0F], 65536);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1467 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1468 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1469 pChn->nPeriod += (int)(param * 4);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1470 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1471 if (pChn->nPeriod > 0xFFFF) pChn->nPeriod = 0xFFFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1472 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1473 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1474 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1475
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1476
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1477 void CSoundFile::ExtraFinePortamentoUp(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1478 //------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1479 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1480 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1481 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1482 if (param) pChn->nOldFinePortaUpDown = param; else param = pChn->nOldFinePortaUpDown;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1483 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1484 if (m_dwSongFlags & SONG_FIRSTTICK)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1485 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1486 if ((pChn->nPeriod) && (param))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1487 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1488 if ((m_dwSongFlags & SONG_LINEARSLIDES) && (!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1489 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1490 pChn->nPeriod = _muldivr(pChn->nPeriod, FineLinearSlideDownTable[param & 0x0F], 65536);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1491 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1492 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1493 pChn->nPeriod -= (int)(param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1494 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1495 if (pChn->nPeriod < 1) pChn->nPeriod = 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1496 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1497 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1498 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1499
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1500
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1501 void CSoundFile::ExtraFinePortamentoDown(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1502 //--------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1503 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1504 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1505 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1506 if (param) pChn->nOldFinePortaUpDown = param; else param = pChn->nOldFinePortaUpDown;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1507 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1508 if (m_dwSongFlags & SONG_FIRSTTICK)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1509 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1510 if ((pChn->nPeriod) && (param))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1511 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1512 if ((m_dwSongFlags & SONG_LINEARSLIDES) && (!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1513 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1514 pChn->nPeriod = _muldivr(pChn->nPeriod, FineLinearSlideUpTable[param & 0x0F], 65536);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1515 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1516 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1517 pChn->nPeriod += (int)(param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1518 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1519 if (pChn->nPeriod > 0xFFFF) pChn->nPeriod = 0xFFFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1520 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1521 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1522 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1523
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1524
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1525 // Portamento Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1526 void CSoundFile::TonePortamento(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1527 //-----------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1528 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1529 if (param) pChn->nPortamentoSlide = param * 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1530 pChn->dwFlags |= CHN_PORTAMENTO;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1531 if ((pChn->nPeriod) && (pChn->nPortamentoDest) && (!(m_dwSongFlags & SONG_FIRSTTICK)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1532 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1533 if (pChn->nPeriod < pChn->nPortamentoDest)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1534 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1535 LONG delta = (int)pChn->nPortamentoSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1536 if ((m_dwSongFlags & SONG_LINEARSLIDES) && (!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1537 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1538 UINT n = pChn->nPortamentoSlide >> 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1539 if (n > 255) n = 255;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1540 delta = _muldivr(pChn->nPeriod, LinearSlideUpTable[n], 65536) - pChn->nPeriod;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1541 if (delta < 1) delta = 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1542 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1543 pChn->nPeriod += delta;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1544 if (pChn->nPeriod > pChn->nPortamentoDest) pChn->nPeriod = pChn->nPortamentoDest;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1545 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1546 if (pChn->nPeriod > pChn->nPortamentoDest)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1547 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1548 LONG delta = - (int)pChn->nPortamentoSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1549 if ((m_dwSongFlags & SONG_LINEARSLIDES) && (!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1550 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1551 UINT n = pChn->nPortamentoSlide >> 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1552 if (n > 255) n = 255;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1553 delta = _muldivr(pChn->nPeriod, LinearSlideDownTable[n], 65536) - pChn->nPeriod;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1554 if (delta > -1) delta = -1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1555 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1556 pChn->nPeriod += delta;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1557 if (pChn->nPeriod < pChn->nPortamentoDest) pChn->nPeriod = pChn->nPortamentoDest;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1558 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1559 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1560 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1561
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1562
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1563 void CSoundFile::Vibrato(MODCHANNEL *p, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1564 //-------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1565 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1566 if (param & 0x0F) p->nVibratoDepth = (param & 0x0F) * 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1567 if (param & 0xF0) p->nVibratoSpeed = (param >> 4) & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1568 p->dwFlags |= CHN_VIBRATO;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1569 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1570
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1571
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1572 void CSoundFile::FineVibrato(MODCHANNEL *p, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1573 //-----------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1574 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1575 if (param & 0x0F) p->nVibratoDepth = param & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1576 if (param & 0xF0) p->nVibratoSpeed = (param >> 4) & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1577 p->dwFlags |= CHN_VIBRATO;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1578 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1579
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1580
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1581 void CSoundFile::Panbrello(MODCHANNEL *p, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1582 //---------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1583 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1584 if (param & 0x0F) p->nPanbrelloDepth = param & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1585 if (param & 0xF0) p->nPanbrelloSpeed = (param >> 4) & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1586 p->dwFlags |= CHN_PANBRELLO;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1587 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1588
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1589
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1590 void CSoundFile::VolumeSlide(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1591 //--------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1592 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1593 if (param) pChn->nOldVolumeSlide = param; else param = pChn->nOldVolumeSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1594 LONG newvolume = pChn->nVolume;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1595 if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_STM|MOD_TYPE_AMF))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1596 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1597 if ((param & 0x0F) == 0x0F)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1598 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1599 if (param & 0xF0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1600 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1601 FineVolumeUp(pChn, (param >> 4));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1602 return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1603 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1604 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1605 if ((m_dwSongFlags & SONG_FIRSTTICK) && (!(m_dwSongFlags & SONG_FASTVOLSLIDES)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1606 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1607 newvolume -= 0x0F * 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1608 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1609 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1610 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1611 if ((param & 0xF0) == 0xF0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1612 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1613 if (param & 0x0F)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1614 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1615 FineVolumeDown(pChn, (param & 0x0F));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1616 return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1617 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1618 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1619 if ((m_dwSongFlags & SONG_FIRSTTICK) && (!(m_dwSongFlags & SONG_FASTVOLSLIDES)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1620 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1621 newvolume += 0x0F * 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1622 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1623 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1624 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1625 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1626 if ((!(m_dwSongFlags & SONG_FIRSTTICK)) || (m_dwSongFlags & SONG_FASTVOLSLIDES))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1627 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1628 if (param & 0x0F) newvolume -= (int)((param & 0x0F) * 4);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1629 else newvolume += (int)((param & 0xF0) >> 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1630 if (m_nType & MOD_TYPE_MOD) pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1631 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1632 if (newvolume < 0) newvolume = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1633 if (newvolume > 256) newvolume = 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1634 pChn->nVolume = newvolume;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1635 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1636
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1637
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1638 void CSoundFile::PanningSlide(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1639 //---------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1640 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1641 LONG nPanSlide = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1642 if (param) pChn->nOldPanSlide = param; else param = pChn->nOldPanSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1643 if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_STM))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1644 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1645 if (((param & 0x0F) == 0x0F) && (param & 0xF0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1646 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1647 if (m_dwSongFlags & SONG_FIRSTTICK)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1648 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1649 param = (param & 0xF0) >> 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1650 nPanSlide = - (int)param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1651 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1652 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1653 if (((param & 0xF0) == 0xF0) && (param & 0x0F))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1654 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1655 if (m_dwSongFlags & SONG_FIRSTTICK)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1656 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1657 nPanSlide = (param & 0x0F) << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1658 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1659 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1660 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1661 if (!(m_dwSongFlags & SONG_FIRSTTICK))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1662 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1663 if (param & 0x0F) nPanSlide = (int)((param & 0x0F) << 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1664 else nPanSlide = -(int)((param & 0xF0) >> 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1665 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1666 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1667 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1668 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1669 if (!(m_dwSongFlags & SONG_FIRSTTICK))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1670 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1671 if (param & 0x0F) nPanSlide = -(int)((param & 0x0F) << 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1672 else nPanSlide = (int)((param & 0xF0) >> 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1673 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1674 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1675 if (nPanSlide)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1676 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1677 nPanSlide += pChn->nPan;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1678 if (nPanSlide < 0) nPanSlide = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1679 if (nPanSlide > 256) nPanSlide = 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1680 pChn->nPan = nPanSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1681 }
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1682 pChn->dwFlags &= ~CHN_SURROUND;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1683 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1684
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1685
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1686 void CSoundFile::FineVolumeUp(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1687 //---------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1688 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1689 if (param) pChn->nOldFineVolUpDown = param; else param = pChn->nOldFineVolUpDown;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1690 if (m_dwSongFlags & SONG_FIRSTTICK)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1691 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1692 pChn->nVolume += param * 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1693 if (pChn->nVolume > 256) pChn->nVolume = 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1694 if (m_nType & MOD_TYPE_MOD) pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1695 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1696 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1697
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1698
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1699 void CSoundFile::FineVolumeDown(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1700 //-----------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1701 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1702 if (param) pChn->nOldFineVolUpDown = param; else param = pChn->nOldFineVolUpDown;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1703 if (m_dwSongFlags & SONG_FIRSTTICK)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1704 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1705 pChn->nVolume -= param * 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1706 if (pChn->nVolume < 0) pChn->nVolume = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1707 if (m_nType & MOD_TYPE_MOD) pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1708 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1709 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1710
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1711
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1712 void CSoundFile::Tremolo(MODCHANNEL *p, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1713 //-------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1714 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1715 if (param & 0x0F) p->nTremoloDepth = (param & 0x0F) << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1716 if (param & 0xF0) p->nTremoloSpeed = (param >> 4) & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1717 p->dwFlags |= CHN_TREMOLO;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1718 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1719
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1720
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1721 void CSoundFile::ChannelVolSlide(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1722 //------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1723 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1724 LONG nChnSlide = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1725 if (param) pChn->nOldChnVolSlide = param; else param = pChn->nOldChnVolSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1726 if (((param & 0x0F) == 0x0F) && (param & 0xF0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1727 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1728 if (m_dwSongFlags & SONG_FIRSTTICK) nChnSlide = param >> 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1729 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1730 if (((param & 0xF0) == 0xF0) && (param & 0x0F))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1731 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1732 if (m_dwSongFlags & SONG_FIRSTTICK) nChnSlide = - (int)(param & 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1733 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1734 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1735 if (!(m_dwSongFlags & SONG_FIRSTTICK))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1736 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1737 if (param & 0x0F) nChnSlide = -(int)(param & 0x0F);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1738 else nChnSlide = (int)((param & 0xF0) >> 4);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1739 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1740 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1741 if (nChnSlide)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1742 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1743 nChnSlide += pChn->nGlobalVol;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1744 if (nChnSlide < 0) nChnSlide = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1745 if (nChnSlide > 64) nChnSlide = 64;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1746 pChn->nGlobalVol = nChnSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1747 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1748 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1749
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1750
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1751 void CSoundFile::ExtendedMODCommands(UINT nChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1752 //---------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1753 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1754 MODCHANNEL *pChn = &Chn[nChn];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1755 UINT command = param & 0xF0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1756 param &= 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1757 switch(command)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1758 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1759 // E0x: Set Filter
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1760 // E1x: Fine Portamento Up
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1761 case 0x10: if ((param) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) FinePortamentoUp(pChn, param); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1762 // E2x: Fine Portamento Down
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1763 case 0x20: if ((param) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) FinePortamentoDown(pChn, param); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1764 // E3x: Set Glissando Control
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1765 case 0x30: pChn->dwFlags &= ~CHN_GLISSANDO; if (param) pChn->dwFlags |= CHN_GLISSANDO; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1766 // E4x: Set Vibrato WaveForm
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1767 case 0x40: pChn->nVibratoType = param & 0x07; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1768 // E5x: Set FineTune
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1769 case 0x50: if (m_nTickCount) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1770 pChn->nC4Speed = S3MFineTuneTable[param];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1771 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1772 pChn->nFineTune = param*2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1773 else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1774 pChn->nFineTune = MOD2XMFineTune(param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1775 if (pChn->nPeriod) pChn->nPeriod = GetPeriodFromNote(pChn->nNote, pChn->nFineTune, pChn->nC4Speed);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1776 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1777 // E6x: Pattern Loop
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1778 // E7x: Set Tremolo WaveForm
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1779 case 0x70: pChn->nTremoloType = param & 0x07; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1780 // E8x: Set 4-bit Panning
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1781 case 0x80: if (!m_nTickCount) { pChn->nPan = (param << 4) + 8; pChn->dwFlags |= CHN_FASTVOLRAMP; } break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1782 // E9x: Retrig
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1783 case 0x90: RetrigNote(nChn, param); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1784 // EAx: Fine Volume Up
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1785 case 0xA0: if ((param) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) FineVolumeUp(pChn, param); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1786 // EBx: Fine Volume Down
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1787 case 0xB0: if ((param) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) FineVolumeDown(pChn, param); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1788 // ECx: Note Cut
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1789 case 0xC0: NoteCut(nChn, param); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1790 // EDx: Note Delay
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1791 // EEx: Pattern Delay
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1792 // EFx: MOD: Invert Loop, XM: Set Active Midi Macro
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1793 case 0xF0: pChn->nActiveMacro = param; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1794 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1795 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1796
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1797
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1798 void CSoundFile::ExtendedS3MCommands(UINT nChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1799 //---------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1800 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1801 MODCHANNEL *pChn = &Chn[nChn];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1802 UINT command = param & 0xF0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1803 param &= 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1804 switch(command)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1805 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1806 // S0x: Set Filter
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1807 // S1x: Set Glissando Control
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1808 case 0x10: pChn->dwFlags &= ~CHN_GLISSANDO; if (param) pChn->dwFlags |= CHN_GLISSANDO; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1809 // S2x: Set FineTune
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1810 case 0x20: if (m_nTickCount) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1811 pChn->nC4Speed = S3MFineTuneTable[param & 0x0F];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1812 pChn->nFineTune = MOD2XMFineTune(param);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1813 if (pChn->nPeriod) pChn->nPeriod = GetPeriodFromNote(pChn->nNote, pChn->nFineTune, pChn->nC4Speed);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1814 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1815 // S3x: Set Vibrato WaveForm
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1816 case 0x30: pChn->nVibratoType = param & 0x07; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1817 // S4x: Set Tremolo WaveForm
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1818 case 0x40: pChn->nTremoloType = param & 0x07; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1819 // S5x: Set Panbrello WaveForm
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1820 case 0x50: pChn->nPanbrelloType = param & 0x07; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1821 // S6x: Pattern Delay for x frames
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1822 case 0x60: m_nFrameDelay = param; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1823 // S7x: Envelope Control
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1824 case 0x70: if (m_nTickCount) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1825 switch(param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1826 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1827 case 0:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1828 case 1:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1829 case 2:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1830 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1831 MODCHANNEL *bkp = &Chn[m_nChannels];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1832 for (UINT i=m_nChannels; i<MAX_CHANNELS; i++, bkp++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1833 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1834 if (bkp->nMasterChn == nChn+1)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1835 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1836 if (param == 1) KeyOff(i); else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1837 if (param == 2) bkp->dwFlags |= CHN_NOTEFADE; else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1838 { bkp->dwFlags |= CHN_NOTEFADE; bkp->nFadeOutVol = 0; }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1839 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1840 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1841 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1842 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1843 case 3: pChn->nNNA = NNA_NOTECUT; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1844 case 4: pChn->nNNA = NNA_CONTINUE; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1845 case 5: pChn->nNNA = NNA_NOTEOFF; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1846 case 6: pChn->nNNA = NNA_NOTEFADE; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1847 case 7: pChn->dwFlags &= ~CHN_VOLENV; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1848 case 8: pChn->dwFlags |= CHN_VOLENV; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1849 case 9: pChn->dwFlags &= ~CHN_PANENV; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1850 case 10: pChn->dwFlags |= CHN_PANENV; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1851 case 11: pChn->dwFlags &= ~CHN_PITCHENV; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1852 case 12: pChn->dwFlags |= CHN_PITCHENV; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1853 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1854 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1855 // S8x: Set 4-bit Panning
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1856 case 0x80:
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1857 pChn->dwFlags &= ~CHN_SURROUND;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1858 if (!m_nTickCount) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1859 pChn->nPan = (param << 4) + 8;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1860 pChn->dwFlags |= CHN_FASTVOLRAMP;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1861 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1862 break;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1863 // S9x: Set Surround
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1864 case 0x90: ExtendedChannelEffect(pChn, param & 0x0F); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1865 // SAx: Set 64k Offset
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1866 case 0xA0: if (!m_nTickCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1867 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1868 if (m_nType & MOD_TYPE_S3M) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1869 pChn->nPan = ((param ^ 8) << 4) + 8;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1870 pChn->dwFlags &= ~CHN_SURROUND;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1871 pChn->dwFlags |= CHN_FASTVOLRAMP;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1872 } else {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1873 pChn->nOldHiOffset = param;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1874 if ((pChn->nRowNote) && (pChn->nRowNote < 0x80))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1875 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1876 DWORD pos = param << 16;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1877 if (pos < pChn->nLength) pChn->nPos = pos;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1878 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1879 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1880 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1881 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1882 // SBx: Pattern Loop
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1883 // SCx: Note Cut
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1884 case 0xC0: NoteCut(nChn, param); break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1885 // SDx: Note Delay
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1886 // case 0xD0: break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1887 // SEx: Pattern Delay for x rows
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1888 // SFx: S3M: Funk Repeat, IT: Set Active Midi Macro
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1889 case 0xF0: pChn->nActiveMacro = param; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1890 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1891 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1892
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1893
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1894 void CSoundFile::ExtendedChannelEffect(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1895 //------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1896 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1897 // S9x and X9x commands (S3M/XM/IT only)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1898 if (m_nTickCount) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1899 switch(param & 0x0F)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1900 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1901 // S91: Surround On
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1902 case 0x01: pChn->dwFlags |= CHN_SURROUND; pChn->nPan = 128; break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1903 ////////////////////////////////////////////////////////////
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1904 // Modplug Extensions
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1905 // S90: Surround Off
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1906 case 0x00: pChn->dwFlags &= ~CHN_SURROUND; break;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1907 // S98: Reverb Off
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1908 case 0x08:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1909 pChn->dwFlags &= ~CHN_REVERB;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1910 pChn->dwFlags |= CHN_NOREVERB;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1911 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1912 // S99: Reverb On
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1913 case 0x09:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1914 pChn->dwFlags &= ~CHN_NOREVERB;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1915 pChn->dwFlags |= CHN_REVERB;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1916 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1917 // S9A: 2-Channels surround mode
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1918 case 0x0A:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1919 m_dwSongFlags &= ~SONG_SURROUNDPAN;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1920 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1921 // S9B: 4-Channels surround mode
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1922 case 0x0B:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1923 m_dwSongFlags |= SONG_SURROUNDPAN;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1924 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1925 // S9C: IT Filter Mode
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1926 case 0x0C:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1927 m_dwSongFlags &= ~SONG_MPTFILTERMODE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1928 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1929 // S9D: MPT Filter Mode
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1930 case 0x0D:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1931 m_dwSongFlags |= SONG_MPTFILTERMODE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1932 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1933 // S9E: Go forward
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1934 case 0x0E:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1935 pChn->dwFlags &= ~(CHN_PINGPONGFLAG);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1936 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1937 // S9F: Go backward (set position at the end for non-looping samples)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1938 case 0x0F:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1939 if ((!(pChn->dwFlags & CHN_LOOP)) && (!pChn->nPos) && (pChn->nLength))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1940 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1941 pChn->nPos = pChn->nLength - 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1942 pChn->nPosLo = 0xFFFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1943 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1944 pChn->dwFlags |= CHN_PINGPONGFLAG;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1945 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1946 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1947 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1948
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1949 // this is all brisby
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1950 void CSoundFile::MidiSend(unsigned char *data, unsigned int len, UINT nChn, int fake)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1951 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1952 MODCHANNEL *pChn = &Chn[nChn];
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1953 int oldcutoff;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1954
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1955 if (len > 2 && data[0] == 0xF0 && data[1] == 0xF0) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1956 /* impulse tracker filter control (mfg. 0xF0) */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1957 if (len == 5) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1958 switch (data[2]) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1959 case 0x00: /* set cutoff */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1960 oldcutoff = pChn->nCutOff;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1961 if (data[3] < 0x80) pChn->nCutOff = data[3];
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1962 #ifndef NO_FILTER
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1963 oldcutoff -= pChn->nCutOff;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1964
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1965 if (oldcutoff < 0) oldcutoff = -oldcutoff;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1966 if ((pChn->nVolume > 0) || (oldcutoff < 0x10)
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1967 || (!(pChn->dwFlags & CHN_FILTER))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1968 || (!(pChn->nLeftVol|pChn->nRightVol)))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1969 SetupChannelFilter(pChn, (pChn->dwFlags & CHN_FILTER)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1970 ? FALSE : TRUE);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1971 #endif // NO_FILTER
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1972 break;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1973 case 0x01: /* set resonance */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1974 if (data[3] < 0x80) pChn->nResonance = data[3];
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1975 #ifndef NO_FILTER
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1976 SetupChannelFilter(pChn, (pChn->dwFlags & CHN_FILTER) ? FALSE : TRUE);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1977 #endif // NO_FILTER
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1978 break;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1979 };
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1980 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1981 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1982
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1983 if (!fake && _midi_out_raw) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1984 /* okay, this is kind of how it works.
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1985 we pass m_nBufferCount as here because while
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1986 1000 * ((8((buffer_size/2) - m_nBufferCount)) / sample_rate)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1987 is the number of msec we need to delay by, libmodplug simply doesn't know
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1988 what the buffer size is at this point so m_nBufferCount simply has no
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1989 frame of reference.
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1990
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1991 fortunately, schism does and can complete this (tags: _schism_midi_out_raw )
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1992
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1993 */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1994 _midi_out_raw(data, len, m_nBufferCount);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1995 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1996 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1997
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1998 static int _was_complete_midi(unsigned char *q, unsigned int len, int nextc)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
1999 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2000 if (len == 0) return 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2001 if (*q == 0xF0) return (q[len-1] == 0xF7 ? 1 : 0);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2002 return ((nextc & 0x80) ? 1 : 0);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2003 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2004
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2005 void CSoundFile::ProcessMidiMacro(UINT nChn, LPCSTR pszMidiMacro, UINT param,
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2006 UINT note, UINT velocity, UINT use_instr)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2007 //---------------------------------------------------------------------------
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2008 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2009 /* this was all wrong. -mrsb */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2010 MODCHANNEL *pChn = &Chn[nChn];
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2011 INSTRUMENTHEADER *penv = (m_dwSongFlags & SONG_INSTRUMENTMODE)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2012 ? Headers[use_instr
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2013 ?use_instr
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2014 :pChn->nLastInstr]
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2015 : NULL;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2016 unsigned char outbuffer[64];
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2017 unsigned char cx;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2018 int mc, fake = 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2019 int saw_c;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2020 int i, j, x;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2021
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2022 saw_c = 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2023 if (!penv || penv->nMidiChannel == 0) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2024 /* okay, there _IS_ no real midi channel. forget this for now... */
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2025 mc = 15;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2026 fake = 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2027
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2028 } else if (penv->nMidiChannel > 16) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2029 mc = (nChn-1) % 16;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2030 } else {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2031 mc = (penv->nMidiChannel-1);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2032 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2033
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2034 for (i = j = x = 0, cx =0; i <= 32 && pszMidiMacro[i]; i++) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2035 int c, cw;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2036 if (pszMidiMacro[i] >= '0' && pszMidiMacro[i] <= '9') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2037 c = pszMidiMacro[i] - '0';
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2038 cw = 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2039 } else if (pszMidiMacro[i] >= 'A' && pszMidiMacro[i] <= 'F') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2040 c = (pszMidiMacro[i] - 'A') + 10;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2041 cw = 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2042 } else if (pszMidiMacro[i] == 'c') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2043 c = mc;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2044 cw = 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2045 saw_c = 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2046 } else if (pszMidiMacro[i] == 'n') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2047 c = (note-1);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2048 cw = 2;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2049 } else if (pszMidiMacro[i] == 'v') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2050 c = velocity;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2051 cw = 2;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2052 } else if (pszMidiMacro[i] == 'u') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2053 c = (pChn->nVolume >> 1);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2054 if (c > 127) c = 127;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2055 cw = 2;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2056 } else if (pszMidiMacro[i] == 'x') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2057 c = pChn->nPan;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2058 if (c > 127) c = 127;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2059 cw = 2;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2060 } else if (pszMidiMacro[i] == 'y') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2061 c = pChn->nRealPan;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2062 if (c > 127) c = 127;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2063 cw = 2;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2064 } else if (pszMidiMacro[i] == 'a') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2065 if (!penv)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2066 c = 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2067 else
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2068 c = (penv->wMidiBank >> 7) & 127;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2069 cw = 2;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2070 } else if (pszMidiMacro[i] == 'b') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2071 if (!penv)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2072 c = 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2073 else
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2074 c = penv->wMidiBank & 127;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2075 cw = 2;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2076 } else if (pszMidiMacro[i] == 'z' || pszMidiMacro[i] == 'p') {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2077 c = param & 0x7F;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2078 cw = 2;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2079 } else {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2080 continue;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2081 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2082 if (j == 0 && cw == 1) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2083 cx = c;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2084 j = 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2085 continue;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2086 } else if (j == 1 && cw == 1) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2087 cx = (cx << 4) | c;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2088 j = 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2089 } else if (j == 0) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2090 cx = c;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2091 } else if (j == 1) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2092 outbuffer[x] = cx;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2093 x++;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2094
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2095 cx = c;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2096 j = 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2097 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2098 // start of midi message
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2099 if (_was_complete_midi(outbuffer,x,cx)) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2100 MidiSend(outbuffer, x, nChn,saw_c && fake);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2101 x = 0;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2102 }
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2103 outbuffer[x] = cx;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2104 x++;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2105 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2106 if (j == 1) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2107 outbuffer[x] = cx;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2108 x++;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2109 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2110 if (x) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2111 // terminate sysex
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2112 if (!_was_complete_midi(outbuffer,x,0xFF)) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2113 if (*outbuffer == 0xF0) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2114 outbuffer[x] = 0xF7;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2115 x++;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2116 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2117 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2118 MidiSend(outbuffer, x, nChn,saw_c && fake);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2119 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2120 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2121
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2122
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2123 void CSoundFile::RetrigNote(UINT nChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2124 //------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2125 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2126 // Retrig: bit 8 is set if it's the new XM retrig
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2127 MODCHANNEL *pChn = &Chn[nChn];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2128 UINT nRetrigSpeed = param & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2129 UINT nRetrigCount = pChn->nRetrigCount;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2130 BOOL bDoRetrig = FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2131
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2132 if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2133 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2134 if (!nRetrigSpeed) nRetrigSpeed = 1;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2135 if (m_nMusicSpeed < nRetrigSpeed) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2136 if (nRetrigCount >= nRetrigSpeed) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2137 bDoRetrig = TRUE;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2138 nRetrigCount = 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2139 } else {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2140 nRetrigCount++;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2141 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2142 } else {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2143 if ((nRetrigCount) && (!(nRetrigCount % nRetrigSpeed))) bDoRetrig = TRUE;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2144 nRetrigCount++;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2145 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2146 } else {
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2147 UINT realspeed = nRetrigSpeed;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2148 if ((param & 0x100) && (pChn->nRowVolCmd == VOLCMD_VOLUME) && (pChn->nRowParam & 0xF0)) realspeed++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2149 if ((m_nTickCount) || (param & 0x100))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2150 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2151 if (!realspeed) realspeed = 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2152 if ((!(param & 0x100)) && (m_nMusicSpeed) && (!(m_nTickCount % realspeed))) bDoRetrig = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2153 nRetrigCount++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2154 } else if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2)) nRetrigCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2155 if (nRetrigCount >= realspeed)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2156 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2157 if ((m_nTickCount) || ((param & 0x100) && (!pChn->nRowNote))) bDoRetrig = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2158 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2159 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2160 if (bDoRetrig)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2161 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2162 UINT dv = (param >> 4) & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2163 if (dv)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2164 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2165 int vol = pChn->nVolume;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2166 if (retrigTable1[dv])
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2167 vol = (vol * retrigTable1[dv]) >> 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2168 else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2169 vol += ((int)retrigTable2[dv]) << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2170 if (vol < 0) vol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2171 if (vol > 256) vol = 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2172 pChn->nVolume = vol;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2173 pChn->dwFlags |= CHN_FASTVOLRAMP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2174 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2175 UINT nNote = pChn->nNewNote;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2176 LONG nOldPeriod = pChn->nPeriod;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2177 if ((nNote) && (nNote <= 120) && (pChn->nLength)) CheckNNA(nChn, 0, nNote, TRUE);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2178 BOOL bResetEnv = FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2179 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2180 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2181 if ((pChn->nRowInstr) && (param < 0x100)) { InstrumentChange(pChn, pChn->nRowInstr, FALSE, FALSE); bResetEnv = TRUE; }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2182 if (param < 0x100) bResetEnv = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2183 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2184 NoteChange(nChn, nNote, FALSE, bResetEnv);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2185 if ((m_nType & MOD_TYPE_IT) && (!pChn->nRowNote) && (nOldPeriod)) pChn->nPeriod = nOldPeriod;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2186 if (!(m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT))) nRetrigCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2187 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2188 pChn->nRetrigCount = (BYTE)nRetrigCount;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2189 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2190
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2191
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2192 void CSoundFile::DoFreqSlide(MODCHANNEL *pChn, LONG nFreqSlide)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2193 //-------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2194 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2195 // IT Linear slides
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2196 if (!pChn->nPeriod) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2197 if ((m_dwSongFlags & SONG_LINEARSLIDES) && (!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2198 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2199 if (nFreqSlide < 0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2200 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2201 UINT n = (- nFreqSlide) >> 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2202 if (n > 255) n = 255;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2203 pChn->nPeriod = _muldivr(pChn->nPeriod, LinearSlideDownTable[n], 65536);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2204 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2205 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2206 UINT n = (nFreqSlide) >> 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2207
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2208 if (n > 255) n = 255;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2209 pChn->nPeriod = _muldivr(pChn->nPeriod, LinearSlideUpTable[n], 65536);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2210 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2211 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2212 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2213 pChn->nPeriod += nFreqSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2214 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2215 if (pChn->nPeriod < 1)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2216 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2217 pChn->nPeriod = 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2218 if (m_nType & MOD_TYPE_IT)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2219 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2220 pChn->dwFlags |= CHN_NOTEFADE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2221 pChn->nFadeOutVol = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2222 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2223 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2224 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2225
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2226
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2227 void CSoundFile::NoteCut(UINT nChn, UINT nTick)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2228 //---------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2229 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2230 if (m_nTickCount == nTick)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2231 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2232 MODCHANNEL *pChn = &Chn[nChn];
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2233 // if (m_dwSongFlags & SONG_INSTRUMENTMODE) KeyOff(pChn); ?
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2234 pChn->nVolume = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2235 pChn->dwFlags |= CHN_FASTVOLRAMP;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2236 pChn->nLength = 0;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2237 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2238 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2239
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2240
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2241 void CSoundFile::KeyOff(UINT nChn)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2242 //--------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2243 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2244 MODCHANNEL *pChn = &Chn[nChn];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2245 BOOL bKeyOn = (pChn->dwFlags & CHN_KEYOFF) ? FALSE : TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2246 pChn->dwFlags |= CHN_KEYOFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2247 //if ((!pChn->pHeader) || (!(pChn->dwFlags & CHN_VOLENV)))
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2248 if ((m_dwSongFlags & SONG_INSTRUMENTMODE) && (pChn->pHeader) && (!(pChn->dwFlags & CHN_VOLENV)))
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2249 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2250 pChn->dwFlags |= CHN_NOTEFADE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2251 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2252 if (!pChn->nLength) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2253 if ((pChn->dwFlags & CHN_SUSTAINLOOP) && (pChn->pInstrument) && (bKeyOn))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2254 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2255 MODINSTRUMENT *psmp = pChn->pInstrument;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2256 if (psmp->uFlags & CHN_LOOP)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2257 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2258 if (psmp->uFlags & CHN_PINGPONGLOOP)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2259 pChn->dwFlags |= CHN_PINGPONGLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2260 else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2261 pChn->dwFlags &= ~(CHN_PINGPONGLOOP|CHN_PINGPONGFLAG);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2262 pChn->dwFlags |= CHN_LOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2263 pChn->nLength = psmp->nLength;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2264 pChn->nLoopStart = psmp->nLoopStart;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2265 pChn->nLoopEnd = psmp->nLoopEnd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2266 if (pChn->nLength > pChn->nLoopEnd) pChn->nLength = pChn->nLoopEnd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2267 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2268 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2269 pChn->dwFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP|CHN_PINGPONGFLAG);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2270 pChn->nLength = psmp->nLength;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2271 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2272 }
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2273 if ((m_dwSongFlags & SONG_INSTRUMENTMODE) && pChn->pHeader)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2274 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2275 INSTRUMENTHEADER *penv = pChn->pHeader;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2276 if (((penv->dwFlags & ENV_VOLLOOP) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) && (penv->nFadeOut))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2277 pChn->dwFlags |= CHN_NOTEFADE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2278 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2279 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2280
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2281
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2282 //////////////////////////////////////////////////////////
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2283 // CSoundFile: Global Effects
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2284
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2285
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2286 void CSoundFile::SetSpeed(UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2287 //-----------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2288 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2289 if (param)
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2290 m_nMusicSpeed = param;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2291 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2292
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2293
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2294 void CSoundFile::SetTempo(UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2295 //-----------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2296 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2297 if (param < 0x20)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2298 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2299 #if 0 // argh... this is completely wrong
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2300 // Tempo Slide
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2301 if ((param & 0xF0) == 0x10)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2302 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2303 m_nMusicTempo += (param & 0x0F) * 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2304 if (m_nMusicTempo > 255) m_nMusicTempo = 255;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2305 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2306 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2307 m_nMusicTempo -= (param & 0x0F) * 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2308 if ((LONG)m_nMusicTempo < 32) m_nMusicTempo = 32;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2309 }
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2310 #endif
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2311 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2312 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2313 m_nMusicTempo = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2314 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2315 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2316
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2317
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2318 int CSoundFile::PatternLoop(MODCHANNEL *pChn, UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2319 //-------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2320 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2321 if (param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2322 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2323 if (pChn->nPatternLoopCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2324 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2325 pChn->nPatternLoopCount--;
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2326 if (!pChn->nPatternLoopCount) {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2327 // this should get rid of that nasty infinite loop for cases like
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2328 // ... .. .. SB0
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2329 // ... .. .. SB1
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2330 // ... .. .. SB1
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2331 // it still doesn't work right in a few strange cases, but oh well :P
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2332 pChn->nPatternLoop = m_nRow + 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2333 return -1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2334 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2335 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2336 {
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2337 // hmm. the pattern loop shouldn't care about
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2338 // other channels at all... i'm not really
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2339 // sure what this code is doing :/
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2340 #if 0
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2341 MODCHANNEL *p = Chn;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2342 for (UINT i=0; i<m_nChannels; i++, p++) if (p != pChn)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2343 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2344 // Loop already done
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2345 if (p->nPatternLoopCount) return -1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2346 }
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2347 #endif
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2348 pChn->nPatternLoopCount = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2349 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2350 return pChn->nPatternLoop;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2351 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2352 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2353 pChn->nPatternLoop = m_nRow;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2354 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2355 return -1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2356 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2357
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2358
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2359 void CSoundFile::GlobalVolSlide(UINT param)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2360 //-----------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2361 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2362 LONG nGlbSlide = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2363 if (param) m_nOldGlbVolSlide = param; else param = m_nOldGlbVolSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2364 if (((param & 0x0F) == 0x0F) && (param & 0xF0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2365 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2366 if (m_dwSongFlags & SONG_FIRSTTICK) nGlbSlide = (param >> 4) * 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2367 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2368 if (((param & 0xF0) == 0xF0) && (param & 0x0F))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2369 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2370 if (m_dwSongFlags & SONG_FIRSTTICK) nGlbSlide = - (int)((param & 0x0F) * 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2371 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2372 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2373 if (!(m_dwSongFlags & SONG_FIRSTTICK))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2374 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2375 if (param & 0xF0) nGlbSlide = (int)((param & 0xF0) >> 4) * 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2376 else nGlbSlide = -(int)((param & 0x0F) * 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2377 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2378 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2379 if (nGlbSlide)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2380 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2381 if (m_nType != MOD_TYPE_IT) nGlbSlide *= 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2382 nGlbSlide += m_nGlobalVolume;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2383 if (nGlbSlide < 0) nGlbSlide = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2384 if (nGlbSlide > 256) nGlbSlide = 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2385 m_nGlobalVolume = nGlbSlide;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2386 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2387 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2388
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2389
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2390 DWORD CSoundFile::IsSongFinished(UINT nStartOrder, UINT nStartRow) const
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2391 //----------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2392 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2393 UINT nOrd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2394
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2395 for (nOrd=nStartOrder; nOrd<MAX_ORDERS; nOrd++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2396 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2397 UINT nPat = Order[nOrd];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2398 if (nPat != 0xFE)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2399 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2400 MODCOMMAND *p;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2401
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2402 if (nPat >= MAX_PATTERNS) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2403 p = Patterns[nPat];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2404 if (p)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2405 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2406 UINT len = PatternSize[nPat] * m_nChannels;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2407 UINT pos = (nOrd == nStartOrder) ? nStartRow : 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2408 pos *= m_nChannels;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2409 while (pos < len)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2410 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2411 UINT cmd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2412 if ((p[pos].note) || (p[pos].volcmd)) return 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2413 cmd = p[pos].command;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2414 if (cmd == CMD_MODCMDEX)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2415 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2416 UINT cmdex = p[pos].param & 0xF0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2417 if ((!cmdex) || (cmdex == 0x60) || (cmdex == 0xE0) || (cmdex == 0xF0)) cmd = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2418 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2419 if ((cmd) && (cmd != CMD_SPEED) && (cmd != CMD_TEMPO)) return 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2420 pos++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2421 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2422 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2423 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2424 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2425 return (nOrd < MAX_ORDERS) ? nOrd : MAX_ORDERS-1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2426 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2427
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2428
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2429 BOOL CSoundFile::IsValidBackwardJump(UINT nStartOrder, UINT nStartRow, UINT nJumpOrder, UINT nJumpRow) const
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2430 //----------------------------------------------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2431 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2432 while ((nJumpOrder < MAX_PATTERNS) && (Order[nJumpOrder] == 0xFE)) nJumpOrder++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2433 if ((nStartOrder >= MAX_PATTERNS) || (nJumpOrder >= MAX_PATTERNS)) return FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2434 // Treat only case with jumps in the same pattern
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2435 if (nJumpOrder > nStartOrder) return TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2436 if ((nJumpOrder < nStartOrder) || (nJumpRow >= PatternSize[nStartOrder])
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2437 || (!Patterns[nStartOrder]) || (nStartRow >= 256) || (nJumpRow >= 256)) return FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2438 // See if the pattern is being played backward
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2439 BYTE row_hist[256];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2440 memset(row_hist, 0, sizeof(row_hist));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2441 UINT nRows = PatternSize[nStartOrder], row = nJumpRow;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2442 if (nRows > 256) nRows = 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2443 row_hist[nStartRow] = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2444 while ((row < 256) && (!row_hist[row]))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2445 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2446 if (row >= nRows) return TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2447 row_hist[row] = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2448 MODCOMMAND *p = Patterns[nStartOrder] + row * m_nChannels;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2449 row++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2450 int breakrow = -1, posjump = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2451 for (UINT i=0; i<m_nChannels; i++, p++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2452 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2453 if (p->command == CMD_POSITIONJUMP)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2454 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2455 if (p->param < nStartOrder) return FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2456 if (p->param > nStartOrder) return TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2457 posjump = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2458 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2459 if (p->command == CMD_PATTERNBREAK)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2460 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2461 breakrow = p->param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2462 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2463 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2464 if (breakrow >= 0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2465 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2466 if (!posjump) return TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2467 row = breakrow;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2468 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2469 if (row >= nRows) return TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2470 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2471 return FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2472 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2473
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2474
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2475 //////////////////////////////////////////////////////
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2476 // Note/Period/Frequency functions
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2477
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2478 UINT CSoundFile::GetNoteFromPeriod(UINT period) const
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2479 //---------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2480 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2481 if (!period) return 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2482 if (m_nType & (MOD_TYPE_MED|MOD_TYPE_MOD|MOD_TYPE_MTM|MOD_TYPE_669|MOD_TYPE_OKT|MOD_TYPE_AMF0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2483 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2484 period >>= 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2485 for (UINT i=0; i<6*12; i++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2486 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2487 if (period >= ProTrackerPeriodTable[i])
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2488 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2489 if ((period != ProTrackerPeriodTable[i]) && (i))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2490 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2491 UINT p1 = ProTrackerPeriodTable[i-1];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2492 UINT p2 = ProTrackerPeriodTable[i];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2493 if (p1 - period < (period - p2)) return i+36;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2494 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2495 return i+1+36;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2496 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2497 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2498 return 6*12+36;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2499 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2500 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2501 for (UINT i=1; i<120; i++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2502 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2503 LONG n = GetPeriodFromNote(i, 0, 0);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2504 if ((n > 0) && (n <= (LONG)period)) return i;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2505 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2506 return 120;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2507 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2508 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2509
2216
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2510 // this last param was nC4Speed
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2511 UINT CSoundFile::GetLinearPeriodFromNote(UINT note, int nFineTune, UINT) const
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2512 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2513 if ((!note) || (note > 0xF0)) return 0;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2514 if (m_nType & (MOD_TYPE_IT|MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_MDL|MOD_TYPE_ULT|MOD_TYPE_WAV
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2515 |MOD_TYPE_FAR|MOD_TYPE_DMF|MOD_TYPE_PTM|MOD_TYPE_AMS|MOD_TYPE_DBM|MOD_TYPE_AMF|MOD_TYPE_PSM))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2516 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2517 note--;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2518 return (FreqS3MTable[note % 12] << 5) >> (note / 12);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2519 } else
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2520 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2521 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2522 if (note < 13) note = 13;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2523 note -= 13;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2524 LONG l = ((120 - note) << 6) - (nFineTune / 2);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2525 if (l < 1) l = 1;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2526 return (UINT)l;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2527 } else
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2528 {
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2529 note--;
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2530 nFineTune = XM2MODFineTune(nFineTune);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2531 if ((nFineTune) || (note < 36) || (note >= 36+6*12))
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2532 return (ProTrackerTunedPeriods[nFineTune*12 + note % 12] << 5) >> (note / 12);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2533 else
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2534 return (ProTrackerPeriodTable[note-36] << 2);
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2535 }
3673c7ec4ea2 Sync with schism's modplug engine. Suggested by G¸«ärkan Seng¸«än.
William Pitcock <nenolod@atheme.org>
parents: 136
diff changeset
2536 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2537
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2538
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2539 UINT CSoundFile::GetPeriodFromNote(UINT note, int nFineTune, UINT nC4Speed) const
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2540 //-------------------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2541 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2542 if ((!note) || (note > 0xF0)) return 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2543 if (m_nType & (MOD_TYPE_IT|MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_MDL|MOD_TYPE_ULT|MOD_TYPE_WAV
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2544 |MOD_TYPE_FAR|MOD_TYPE_DMF|MOD_TYPE_PTM|MOD_TYPE_AMS|MOD_TYPE_DBM|MOD_TYPE_AMF|MOD_TYPE_PSM))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2545 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2546 note--;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2547 if (m_dwSongFlags & SONG_LINEARSLIDES)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2548 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2549 return (FreqS3MTable[note % 12] << 5) >> (note / 12);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2550 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2551 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2552 if (!nC4Speed) nC4Speed = 8363;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2553 return _muldiv(8363, (FreqS3MTable[note % 12] << 5), nC4Speed << (note / 12));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2554 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2555 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2556 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2557 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2558 if (note < 13) note = 13;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2559 note -= 13;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2560 if (m_dwSongFlags & SONG_LINEARSLIDES)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2561 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2562 LONG l = ((120 - note) << 6) - (nFineTune / 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2563 if (l < 1) l = 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2564 return (UINT)l;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2565 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2566 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2567 int finetune = nFineTune;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2568 UINT rnote = (note % 12) << 3;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2569 UINT roct = note / 12;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2570 int rfine = finetune / 16;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2571 int i = rnote + rfine + 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2572 if (i < 0) i = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2573 if (i >= 104) i = 103;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2574 UINT per1 = XMPeriodTable[i];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2575 if ( finetune < 0 )
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2576 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2577 rfine--;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2578 finetune = -finetune;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2579 } else rfine++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2580 i = rnote+rfine+8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2581 if (i < 0) i = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2582 if (i >= 104) i = 103;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2583 UINT per2 = XMPeriodTable[i];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2584 rfine = finetune & 0x0F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2585 per1 *= 16-rfine;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2586 per2 *= rfine;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2587 return ((per1 + per2) << 1) >> roct;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2588 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2589 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2590 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2591 note--;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2592 nFineTune = XM2MODFineTune(nFineTune);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2593 if ((nFineTune) || (note < 36) || (note >= 36+6*12))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2594 return (ProTrackerTunedPeriods[nFineTune*12 + note % 12] << 5) >> (note / 12);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2595 else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2596 return (ProTrackerPeriodTable[note-36] << 2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2597 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2598 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2599
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2600
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2601 UINT CSoundFile::GetFreqFromPeriod(UINT period, UINT nC4Speed, int nPeriodFrac) const
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2602 //-----------------------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2603 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2604 if (!period) return 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2605 if (m_nType & (MOD_TYPE_MED|MOD_TYPE_MOD|MOD_TYPE_MTM|MOD_TYPE_669|MOD_TYPE_OKT|MOD_TYPE_AMF0))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2606 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2607 return (3546895L*4) / period;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2608 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2609 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2610 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2611 if (m_dwSongFlags & SONG_LINEARSLIDES)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2612 return XMLinearTable[period % 768] >> (period / 768);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2613 else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2614 return 8363 * 1712L / period;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2615 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2616 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2617 if (m_dwSongFlags & SONG_LINEARSLIDES)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2618 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2619 if (!nC4Speed) nC4Speed = 8363;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2620 return _muldiv(nC4Speed, 1712L << 8, (period << 8)+nPeriodFrac);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2621 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2622 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2623 return _muldiv(8363, 1712L << 8, (period << 8)+nPeriodFrac);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2624 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2625 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2626 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2627
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2628