Mercurial > audlegacy-plugins
annotate src/modplug/sndmix.cxx @ 136:6b5a52635b3b trunk
[svn] - like with so many other things, modplug is now maintained by us.
author | nenolod |
---|---|
date | Sun, 29 Oct 2006 01:04:52 -0700 |
parents | |
children | 4095ceb0440b |
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 <libmodplug/stdafx.h> |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
8 #include <libmodplug/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 MODPLUG_TRACKER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
11 #define ENABLE_STEREOVU |
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 // Volume ramp length, in 1/10 ms |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
15 #define VOLUMERAMPLEN 146 // 1.46ms = 64 samples at 44.1kHz |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
16 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
17 // VU-Meter |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
18 #define VUMETER_DECAY 4 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
19 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
20 // SNDMIX: These are global flags for playback control |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
21 UINT CSoundFile::m_nStereoSeparation = 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
22 LONG CSoundFile::m_nStreamVolume = 0x8000; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
23 UINT CSoundFile::m_nMaxMixChannels = 32; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
24 // Mixing Configuration (SetWaveConfig) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
25 DWORD CSoundFile::gdwSysInfo = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
26 DWORD CSoundFile::gnChannels = 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
27 DWORD CSoundFile::gdwSoundSetup = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
28 DWORD CSoundFile::gdwMixingFreq = 44100; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
29 DWORD CSoundFile::gnBitsPerSample = 16; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
30 // Mixing data initialized in |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
31 UINT CSoundFile::gnAGC = AGC_UNITY; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
32 UINT CSoundFile::gnVolumeRampSamples = 64; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
33 UINT CSoundFile::gnVUMeter = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
34 UINT CSoundFile::gnCPUUsage = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
35 LPSNDMIXHOOKPROC CSoundFile::gpSndMixHook = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
36 PMIXPLUGINCREATEPROC CSoundFile::gpMixPluginCreateProc = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
37 LONG gnDryROfsVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
38 LONG gnDryLOfsVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
39 LONG gnRvbROfsVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
40 LONG gnRvbLOfsVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
41 int gbInitPlugins = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
42 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
43 typedef DWORD (MPPASMCALL * LPCONVERTPROC)(LPVOID, int *, DWORD, LPLONG, LPLONG); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
44 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
45 extern DWORD MPPASMCALL X86_Convert32To8(LPVOID lpBuffer, int *, DWORD nSamples, LPLONG, LPLONG); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
46 extern DWORD MPPASMCALL X86_Convert32To16(LPVOID lpBuffer, int *, DWORD nSamples, LPLONG, LPLONG); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
47 extern DWORD MPPASMCALL X86_Convert32To24(LPVOID lpBuffer, int *, DWORD nSamples, LPLONG, LPLONG); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
48 extern DWORD MPPASMCALL X86_Convert32To32(LPVOID lpBuffer, int *, DWORD nSamples, LPLONG, LPLONG); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
49 extern UINT MPPASMCALL X86_AGC(int *pBuffer, UINT nSamples, UINT nAGC); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
50 extern VOID MPPASMCALL X86_Dither(int *pBuffer, UINT nSamples, UINT nBits); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
51 extern VOID MPPASMCALL X86_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nSamples); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
52 extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
53 extern VOID MPPASMCALL X86_MonoFromStereo(int *pMixBuf, UINT nSamples); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
54 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
55 extern short int ModSinusTable[64]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
56 extern short int ModRampDownTable[64]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
57 extern short int ModSquareTable[64]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
58 extern short int ModRandomTable[64]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
59 extern DWORD LinearSlideUpTable[256]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
60 extern DWORD LinearSlideDownTable[256]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
61 extern DWORD FineLinearSlideUpTable[16]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
62 extern DWORD FineLinearSlideDownTable[16]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
63 extern signed char ft2VibratoTable[256]; // -64 .. +64 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
64 extern int MixSoundBuffer[MIXBUFFERSIZE*4]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
65 extern int MixRearBuffer[MIXBUFFERSIZE*2]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
66 UINT gnReverbSend; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
67 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
68 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
69 // Log tables for pre-amp |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
70 // We don't want the tracker to get too loud |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
71 const UINT PreAmpTable[16] = |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
72 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
73 0x60, 0x60, 0x60, 0x70, // 0-7 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
74 0x80, 0x88, 0x90, 0x98, // 8-15 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
75 0xA0, 0xA4, 0xA8, 0xB0, // 16-23 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
76 0xB4, 0xB8, 0xBC, 0xC0, // 24-31 |
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 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
79 const UINT PreAmpAGCTable[16] = |
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 0x60, 0x60, 0x60, 0x60, |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
82 0x68, 0x70, 0x78, 0x80, |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
83 0x84, 0x88, 0x8C, 0x90, |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
84 0x94, 0x98, 0x9C, 0xA0, |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
85 }; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
86 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
87 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
88 // Return (a*b)/c - no divide error |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
89 int _muldiv(long a, long b, long c) |
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 #ifdef MSC_VER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
92 int sign, result; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
93 _asm { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
94 mov eax, a |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
95 mov ebx, b |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
96 or eax, eax |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
97 mov edx, eax |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
98 jge aneg |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
99 neg eax |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
100 aneg: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
101 xor edx, ebx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
102 or ebx, ebx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
103 mov ecx, c |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
104 jge bneg |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
105 neg ebx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
106 bneg: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
107 xor edx, ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
108 or ecx, ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
109 mov sign, edx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
110 jge cneg |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
111 neg ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
112 cneg: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
113 mul ebx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
114 cmp edx, ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
115 jae diverr |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
116 div ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
117 jmp ok |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
118 diverr: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
119 mov eax, 0x7fffffff |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
120 ok: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
121 mov edx, sign |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
122 or edx, edx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
123 jge rneg |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
124 neg eax |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
125 rneg: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
126 mov result, eax |
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 return result; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
129 #else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
130 return ((unsigned long long) a * (unsigned long long) b ) / c; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
131 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
132 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
133 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
134 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
135 // Return (a*b+c/2)/c - no divide error |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
136 int _muldivr(long a, long b, long c) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
137 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
138 #ifdef MSC_VER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
139 int sign, result; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
140 _asm { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
141 mov eax, a |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
142 mov ebx, b |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
143 or eax, eax |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
144 mov edx, eax |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
145 jge aneg |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
146 neg eax |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
147 aneg: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
148 xor edx, ebx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
149 or ebx, ebx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
150 mov ecx, c |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
151 jge bneg |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
152 neg ebx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
153 bneg: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
154 xor edx, ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
155 or ecx, ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
156 mov sign, edx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
157 jge cneg |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
158 neg ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
159 cneg: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
160 mul ebx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
161 mov ebx, ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
162 shr ebx, 1 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
163 add eax, ebx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
164 adc edx, 0 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
165 cmp edx, ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
166 jae diverr |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
167 div ecx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
168 jmp ok |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
169 diverr: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
170 mov eax, 0x7fffffff |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
171 ok: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
172 mov edx, sign |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
173 or edx, edx |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
174 jge rneg |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
175 neg eax |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
176 rneg: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
177 mov result, eax |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
178 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
179 return result; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
180 #else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
181 return ((unsigned long long) a * (unsigned long long) b + (c >> 1)) / c; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
182 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
183 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
184 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
185 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
186 BOOL CSoundFile::InitPlayer(BOOL bReset) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
187 //-------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
188 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
189 if (m_nMaxMixChannels > MAX_CHANNELS) m_nMaxMixChannels = MAX_CHANNELS; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
190 if (gdwMixingFreq < 4000) gdwMixingFreq = 4000; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
191 if (gdwMixingFreq > MAX_SAMPLE_RATE) gdwMixingFreq = MAX_SAMPLE_RATE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
192 gnVolumeRampSamples = (gdwMixingFreq * VOLUMERAMPLEN) / 100000; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
193 if (gnVolumeRampSamples < 8) gnVolumeRampSamples = 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
194 gnDryROfsVol = gnDryLOfsVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
195 gnRvbROfsVol = gnRvbLOfsVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
196 if (bReset) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
197 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
198 gnVUMeter = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
199 gnCPUUsage = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
200 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
201 gbInitPlugins = (bReset) ? 3 : 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
202 InitializeDSP(bReset); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
203 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
204 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
205 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
206 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
207 BOOL CSoundFile::FadeSong(UINT msec) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
208 //---------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
209 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
210 LONG nsamples = _muldiv(msec, gdwMixingFreq, 1000); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
211 if (nsamples <= 0) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
212 if (nsamples > 0x100000) nsamples = 0x100000; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
213 m_nBufferCount = nsamples; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
214 LONG nRampLength = m_nBufferCount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
215 // Ramp everything down |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
216 for (UINT noff=0; noff < m_nMixChannels; noff++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
217 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
218 MODCHANNEL *pramp = &Chn[ChnMix[noff]]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
219 if (!pramp) continue; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
220 pramp->nNewLeftVol = pramp->nNewRightVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
221 pramp->nRightRamp = (-pramp->nRightVol << VOLUMERAMPPRECISION) / nRampLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
222 pramp->nLeftRamp = (-pramp->nLeftVol << VOLUMERAMPPRECISION) / nRampLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
223 pramp->nRampRightVol = pramp->nRightVol << VOLUMERAMPPRECISION; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
224 pramp->nRampLeftVol = pramp->nLeftVol << VOLUMERAMPPRECISION; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
225 pramp->nRampLength = nRampLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
226 pramp->dwFlags |= CHN_VOLUMERAMP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
227 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
228 m_dwSongFlags |= SONG_FADINGSONG; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
229 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
230 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
231 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
232 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
233 BOOL CSoundFile::GlobalFadeSong(UINT msec) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
234 //---------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
235 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
236 if (m_dwSongFlags & SONG_GLOBALFADE) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
237 m_nGlobalFadeMaxSamples = _muldiv(msec, gdwMixingFreq, 1000); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
238 m_nGlobalFadeSamples = m_nGlobalFadeMaxSamples; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
239 m_dwSongFlags |= SONG_GLOBALFADE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
240 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
241 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
242 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
243 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
244 UINT CSoundFile::Read(LPVOID lpDestBuffer, UINT cbBuffer) |
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 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
247 LPBYTE lpBuffer = (LPBYTE)lpDestBuffer; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
248 LPCONVERTPROC pCvt = X86_Convert32To8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
249 UINT lRead, lMax, lSampleSize, lCount, lSampleCount, nStat=0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
250 LONG nVUMeterMin = 0x7FFFFFFF, nVUMeterMax = -0x7FFFFFFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
251 UINT nMaxPlugins; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
252 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
253 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
254 nMaxPlugins = MAX_MIXPLUGINS; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
255 while ((nMaxPlugins > 0) && (!m_MixPlugins[nMaxPlugins-1].pMixPlugin)) nMaxPlugins--; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
256 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
257 m_nMixStat = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
258 lSampleSize = gnChannels; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
259 if (gnBitsPerSample == 16) { lSampleSize *= 2; pCvt = X86_Convert32To16; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
260 #ifndef MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
261 else if (gnBitsPerSample == 24) { lSampleSize *= 3; pCvt = X86_Convert32To24; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
262 else if (gnBitsPerSample == 32) { lSampleSize *= 4; pCvt = X86_Convert32To32; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
263 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
264 lMax = cbBuffer / lSampleSize; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
265 if ((!lMax) || (!lpBuffer) || (!m_nChannels)) return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
266 lRead = lMax; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
267 if (m_dwSongFlags & SONG_ENDREACHED) goto MixDone; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
268 while (lRead > 0) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
269 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
270 // Update Channel Data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
271 if (!m_nBufferCount) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
272 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
273 #ifndef MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
274 if (m_dwSongFlags & SONG_FADINGSONG) |
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 m_dwSongFlags |= SONG_ENDREACHED; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
277 m_nBufferCount = lRead; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
278 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
279 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
280 if (!ReadNote()) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
281 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
282 #ifndef MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
283 if (!FadeSong(FADESONGDELAY)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
284 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
285 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
286 m_dwSongFlags |= SONG_ENDREACHED; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
287 if (lRead == lMax) goto MixDone; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
288 m_nBufferCount = lRead; |
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 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
291 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
292 lCount = m_nBufferCount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
293 if (lCount > MIXBUFFERSIZE) lCount = MIXBUFFERSIZE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
294 if (lCount > lRead) lCount = lRead; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
295 if (!lCount) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
296 lSampleCount = lCount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
297 #ifndef MODPLUG_NO_REVERB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
298 gnReverbSend = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
299 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
300 // Resetting sound buffer |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
301 X86_StereoFill(MixSoundBuffer, lSampleCount, &gnDryROfsVol, &gnDryLOfsVol); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
302 if (gnChannels >= 2) |
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 lSampleCount *= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
305 m_nMixStat += CreateStereoMix(lCount); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
306 ProcessStereoDSP(lCount); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
307 } else |
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 m_nMixStat += CreateStereoMix(lCount); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
310 if (nMaxPlugins) ProcessPlugins(lCount); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
311 ProcessStereoDSP(lCount); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
312 X86_MonoFromStereo(MixSoundBuffer, lCount); |
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 nStat++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
315 #ifndef NO_AGC |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
316 // Automatic Gain Control |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
317 if (gdwSoundSetup & SNDMIX_AGC) ProcessAGC(lSampleCount); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
318 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
319 UINT lTotalSampleCount = lSampleCount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
320 #ifndef MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
321 // Multichannel |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
322 if (gnChannels > 2) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
323 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
324 X86_InterleaveFrontRear(MixSoundBuffer, MixRearBuffer, lSampleCount); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
325 lTotalSampleCount *= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
326 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
327 // Hook Function |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
328 if (gpSndMixHook) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
329 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
330 gpSndMixHook(MixSoundBuffer, lTotalSampleCount, gnChannels); |
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 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
333 // Perform clipping + VU-Meter |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
334 lpBuffer += pCvt(lpBuffer, MixSoundBuffer, lTotalSampleCount, &nVUMeterMin, &nVUMeterMax); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
335 // Buffer ready |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
336 lRead -= lCount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
337 m_nBufferCount -= lCount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
338 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
339 MixDone: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
340 if (lRead) memset(lpBuffer, (gnBitsPerSample == 8) ? 0x80 : 0, lRead * lSampleSize); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
341 // VU-Meter |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
342 nVUMeterMin >>= (24-MIXING_ATTENUATION); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
343 nVUMeterMax >>= (24-MIXING_ATTENUATION); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
344 if (nVUMeterMax < nVUMeterMin) nVUMeterMax = nVUMeterMin; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
345 if ((gnVUMeter = (UINT)(nVUMeterMax - nVUMeterMin)) > 0xFF) gnVUMeter = 0xFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
346 if (nStat) { m_nMixStat += nStat-1; m_nMixStat /= nStat; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
347 return lMax - lRead; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
348 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
349 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
350 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
351 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
352 ///////////////////////////////////////////////////////////////////////////// |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
353 // Handles navigation/effects |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
354 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
355 BOOL CSoundFile::ProcessRow() |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
356 //--------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
357 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
358 if (++m_nTickCount >= m_nMusicSpeed * (m_nPatternDelay+1) + m_nFrameDelay) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
359 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
360 m_nPatternDelay = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
361 m_nFrameDelay = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
362 m_nTickCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
363 m_nRow = m_nNextRow; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
364 // Reset Pattern Loop Effect |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
365 if (m_nCurrentPattern != m_nNextPattern) m_nCurrentPattern = m_nNextPattern; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
366 // Check if pattern is valid |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
367 if (!(m_dwSongFlags & SONG_PATTERNLOOP)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
368 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
369 m_nPattern = (m_nCurrentPattern < MAX_ORDERS) ? Order[m_nCurrentPattern] : 0xFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
370 if ((m_nPattern < MAX_PATTERNS) && (!Patterns[m_nPattern])) m_nPattern = 0xFE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
371 while (m_nPattern >= MAX_PATTERNS) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
372 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
373 // End of song ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
374 if ((m_nPattern == 0xFF) || (m_nCurrentPattern >= MAX_ORDERS)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
375 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
376 //if (!m_nRepeatCount) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
377 return FALSE; //never repeat entire song |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
378 if (!m_nRestartPos) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
379 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
380 m_nMusicSpeed = m_nDefaultSpeed; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
381 m_nMusicTempo = m_nDefaultTempo; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
382 m_nGlobalVolume = m_nDefaultGlobalVolume; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
383 for (UINT i=0; i<MAX_CHANNELS; i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
384 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
385 Chn[i].dwFlags |= CHN_NOTEFADE | CHN_KEYOFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
386 Chn[i].nFadeOutVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
387 if (i < m_nChannels) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
388 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
389 Chn[i].nGlobalVol = ChnSettings[i].nVolume; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
390 Chn[i].nVolume = ChnSettings[i].nVolume; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
391 Chn[i].nPan = ChnSettings[i].nPan; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
392 Chn[i].nPanSwing = Chn[i].nVolSwing = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
393 Chn[i].nOldVolParam = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
394 Chn[i].nOldOffset = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
395 Chn[i].nOldHiOffset = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
396 Chn[i].nPortamentoDest = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
397 if (!Chn[i].nLength) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
398 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
399 Chn[i].dwFlags = ChnSettings[i].dwFlags; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
400 Chn[i].nLoopStart = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
401 Chn[i].nLoopEnd = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
402 Chn[i].pHeader = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
403 Chn[i].pSample = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
404 Chn[i].pInstrument = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
405 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
406 } |
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 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
409 // if (m_nRepeatCount > 0) m_nRepeatCount--; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
410 m_nCurrentPattern = m_nRestartPos; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
411 m_nRow = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
412 if ((Order[m_nCurrentPattern] >= MAX_PATTERNS) || (!Patterns[Order[m_nCurrentPattern]])) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
413 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
414 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
415 m_nCurrentPattern++; |
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 m_nPattern = (m_nCurrentPattern < MAX_ORDERS) ? Order[m_nCurrentPattern] : 0xFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
418 if ((m_nPattern < MAX_PATTERNS) && (!Patterns[m_nPattern])) m_nPattern = 0xFE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
419 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
420 m_nNextPattern = m_nCurrentPattern; |
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 // Weird stuff? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
423 if ((m_nPattern >= MAX_PATTERNS) || (!Patterns[m_nPattern])) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
424 // Should never happen |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
425 if (m_nRow >= PatternSize[m_nPattern]) m_nRow = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
426 m_nNextRow = m_nRow + 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
427 if (m_nNextRow >= PatternSize[m_nPattern]) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
428 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
429 if (!(m_dwSongFlags & SONG_PATTERNLOOP)) m_nNextPattern = m_nCurrentPattern + 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
430 m_nNextRow = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
431 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
432 // Reset channel values |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
433 MODCHANNEL *pChn = Chn; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
434 MODCOMMAND *m = Patterns[m_nPattern] + m_nRow * m_nChannels; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
435 for (UINT nChn=0; nChn<m_nChannels; pChn++, nChn++, m++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
436 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
437 pChn->nRowNote = m->note; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
438 pChn->nRowInstr = m->instr; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
439 pChn->nRowVolCmd = m->volcmd; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
440 pChn->nRowVolume = m->vol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
441 pChn->nRowCommand = m->command; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
442 pChn->nRowParam = m->param; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
443 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
444 pChn->nLeftVol = pChn->nNewLeftVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
445 pChn->nRightVol = pChn->nNewRightVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
446 pChn->dwFlags &= ~(CHN_PORTAMENTO | CHN_VIBRATO | CHN_TREMOLO | CHN_PANBRELLO); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
447 pChn->nCommand = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
448 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
449 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
450 // Should we process tick0 effects? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
451 if (!m_nMusicSpeed) m_nMusicSpeed = 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
452 m_dwSongFlags |= SONG_FIRSTTICK; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
453 if (m_nTickCount) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
454 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
455 m_dwSongFlags &= ~SONG_FIRSTTICK; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
456 if ((!(m_nType & MOD_TYPE_XM)) && (m_nTickCount < m_nMusicSpeed * (1 + m_nPatternDelay))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
457 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
458 if (!(m_nTickCount % m_nMusicSpeed)) m_dwSongFlags |= SONG_FIRSTTICK; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
459 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
460 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
461 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
462 // Update Effects |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
463 return ProcessEffects(); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
464 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
465 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
466 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
467 //////////////////////////////////////////////////////////////////////////////////////////// |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
468 // Handles envelopes & mixer setup |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
469 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
470 BOOL CSoundFile::ReadNote() |
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 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
473 if (!ProcessRow()) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
474 //////////////////////////////////////////////////////////////////////////////////// |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
475 m_nTotalCount++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
476 if (!m_nMusicTempo) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
477 m_nBufferCount = (gdwMixingFreq * 5 * m_nTempoFactor) / (m_nMusicTempo << 8); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
478 // Master Volume + Pre-Amplification / Attenuation setup |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
479 DWORD nMasterVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
480 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
481 int nchn32 = (m_nChannels < 32) ? m_nChannels : 31; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
482 if ((m_nType & MOD_TYPE_IT) && (m_nInstruments) && (nchn32 < 6)) nchn32 = 6; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
483 int realmastervol = m_nMasterVolume; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
484 if (realmastervol > 0x80) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
485 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
486 realmastervol = 0x80 + ((realmastervol - 0x80) * (nchn32+4)) / 16; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
487 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
488 UINT attenuation = (gdwSoundSetup & SNDMIX_AGC) ? PreAmpAGCTable[nchn32>>1] : PreAmpTable[nchn32>>1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
489 DWORD mastervol = (realmastervol * (m_nSongPreAmp + 0x10)) >> 6; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
490 if (mastervol > 0x200) mastervol = 0x200; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
491 if ((m_dwSongFlags & SONG_GLOBALFADE) && (m_nGlobalFadeMaxSamples)) |
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 mastervol = _muldiv(mastervol, m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
494 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
495 nMasterVol = (mastervol << 7) / attenuation; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
496 if (nMasterVol > 0x180) nMasterVol = 0x180; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
497 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
498 //////////////////////////////////////////////////////////////////////////////////// |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
499 // Update channels data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
500 m_nMixChannels = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
501 MODCHANNEL *pChn = Chn; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
502 for (UINT nChn=0; nChn<MAX_CHANNELS; nChn++,pChn++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
503 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
504 if ((pChn->dwFlags & CHN_NOTEFADE) && (!(pChn->nFadeOutVol|pChn->nRightVol|pChn->nLeftVol))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
505 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
506 pChn->nLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
507 pChn->nROfs = pChn->nLOfs = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
508 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
509 // Check for unused channel |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
510 if ((pChn->dwFlags & CHN_MUTE) || ((nChn >= m_nChannels) && (!pChn->nLength))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
511 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
512 pChn->nVUMeter = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
513 #ifdef ENABLE_STEREOVU |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
514 pChn->nLeftVU = pChn->nRightVU = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
515 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
516 continue; |
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 // Reset channel data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
519 pChn->nInc = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
520 pChn->nRealVolume = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
521 pChn->nRealPan = pChn->nPan + pChn->nPanSwing; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
522 if (pChn->nRealPan < 0) pChn->nRealPan = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
523 if (pChn->nRealPan > 256) pChn->nRealPan = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
524 pChn->nRampLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
525 // Calc Frequency |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
526 if ((pChn->nPeriod) && (pChn->nLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
527 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
528 int vol = pChn->nVolume + pChn->nVolSwing; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
529 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
530 if (vol < 0) vol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
531 if (vol > 256) vol = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
532 // Tremolo |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
533 if (pChn->dwFlags & CHN_TREMOLO) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
534 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
535 UINT trempos = pChn->nTremoloPos & 0x3F; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
536 if (vol > 0) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
537 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
538 int tremattn = (m_nType & MOD_TYPE_XM) ? 5 : 6; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
539 switch (pChn->nTremoloType & 0x03) |
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 case 1: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
542 vol += (ModRampDownTable[trempos] * (int)pChn->nTremoloDepth) >> tremattn; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
543 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
544 case 2: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
545 vol += (ModSquareTable[trempos] * (int)pChn->nTremoloDepth) >> tremattn; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
546 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
547 case 3: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
548 vol += (ModRandomTable[trempos] * (int)pChn->nTremoloDepth) >> tremattn; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
549 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
550 default: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
551 vol += (ModSinusTable[trempos] * (int)pChn->nTremoloDepth) >> tremattn; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
552 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
553 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
554 if ((m_nTickCount) || ((m_nType & (MOD_TYPE_STM|MOD_TYPE_S3M|MOD_TYPE_IT)) && (!(m_dwSongFlags & SONG_ITOLDEFFECTS)))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
555 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
556 pChn->nTremoloPos = (trempos + pChn->nTremoloSpeed) & 0x3F; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
557 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
558 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
559 // Tremor |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
560 if (pChn->nCommand == CMD_TREMOR) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
561 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
562 UINT n = (pChn->nTremorParam >> 4) + (pChn->nTremorParam & 0x0F); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
563 UINT ontime = pChn->nTremorParam >> 4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
564 if ((!(m_nType & MOD_TYPE_IT)) || (m_dwSongFlags & SONG_ITOLDEFFECTS)) { n += 2; ontime++; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
565 UINT tremcount = (UINT)pChn->nTremorCount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
566 if (tremcount >= n) tremcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
567 if ((m_nTickCount) || (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
|
568 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
569 if (tremcount >= ontime) vol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
570 pChn->nTremorCount = (BYTE)(tremcount + 1); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
571 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
572 pChn->dwFlags |= CHN_FASTVOLRAMP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
573 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
574 // Clip volume |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
575 if (vol < 0) vol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
576 if (vol > 0x100) vol = 0x100; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
577 vol <<= 6; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
578 // Process Envelopes |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
579 if (pChn->pHeader) |
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 INSTRUMENTHEADER *penv = pChn->pHeader; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
582 // Volume Envelope |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
583 if ((pChn->dwFlags & CHN_VOLENV) && (penv->nVolEnv)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
584 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
585 int envpos = pChn->nVolEnvPosition; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
586 UINT pt = penv->nVolEnv - 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
587 for (UINT i=0; i<(UINT)(penv->nVolEnv-1); i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
588 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
589 if (envpos <= penv->VolPoints[i]) |
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 pt = i; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
592 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
593 } |
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 int x2 = penv->VolPoints[pt]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
596 int x1, envvol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
597 if (envpos >= x2) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
598 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
599 envvol = penv->VolEnv[pt] << 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
600 x1 = x2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
601 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
602 if (pt) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
603 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
604 envvol = penv->VolEnv[pt-1] << 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
605 x1 = penv->VolPoints[pt-1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
606 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
607 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
608 envvol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
609 x1 = 0; |
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 if (envpos > x2) envpos = x2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
612 if ((x2 > x1) && (envpos > x1)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
613 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
614 envvol += ((envpos - x1) * (((int)penv->VolEnv[pt]<<2) - envvol)) / (x2 - x1); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
615 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
616 if (envvol < 0) envvol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
617 if (envvol > 256) envvol = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
618 vol = (vol * envvol) >> 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
619 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
620 // Panning Envelope |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
621 if ((pChn->dwFlags & CHN_PANENV) && (penv->nPanEnv)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
622 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
623 int envpos = pChn->nPanEnvPosition; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
624 UINT pt = penv->nPanEnv - 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
625 for (UINT i=0; i<(UINT)(penv->nPanEnv-1); i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
626 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
627 if (envpos <= penv->PanPoints[i]) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
628 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
629 pt = i; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
630 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
631 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
632 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
633 int x2 = penv->PanPoints[pt], y2 = penv->PanEnv[pt]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
634 int x1, envpan; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
635 if (envpos >= x2) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
636 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
637 envpan = y2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
638 x1 = x2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
639 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
640 if (pt) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
641 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
642 envpan = penv->PanEnv[pt-1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
643 x1 = penv->PanPoints[pt-1]; |
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 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
646 envpan = 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
647 x1 = 0; |
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 if ((x2 > x1) && (envpos > x1)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
650 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
651 envpan += ((envpos - x1) * (y2 - envpan)) / (x2 - x1); |
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 if (envpan < 0) envpan = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
654 if (envpan > 64) envpan = 64; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
655 int pan = pChn->nPan; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
656 if (pan >= 128) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
657 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
658 pan += ((envpan - 32) * (256 - pan)) / 32; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
659 } else |
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 pan += ((envpan - 32) * (pan)) / 32; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
662 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
663 if (pan < 0) pan = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
664 if (pan > 256) pan = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
665 pChn->nRealPan = pan; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
666 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
667 // FadeOut volume |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
668 if (pChn->dwFlags & CHN_NOTEFADE) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
669 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
670 UINT fadeout = penv->nFadeOut; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
671 if (fadeout) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
672 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
673 pChn->nFadeOutVol -= fadeout << 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
674 if (pChn->nFadeOutVol <= 0) pChn->nFadeOutVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
675 vol = (vol * pChn->nFadeOutVol) >> 16; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
676 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
677 if (!pChn->nFadeOutVol) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
678 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
679 vol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
680 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
681 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
682 // Pitch/Pan separation |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
683 if ((penv->nPPS) && (pChn->nRealPan) && (pChn->nNote)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
684 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
685 int pandelta = (int)pChn->nRealPan + (int)((int)(pChn->nNote - penv->nPPC - 1) * (int)penv->nPPS) / (int)8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
686 if (pandelta < 0) pandelta = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
687 if (pandelta > 256) pandelta = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
688 pChn->nRealPan = pandelta; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
689 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
690 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
691 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
692 // No Envelope: key off => note cut |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
693 if (pChn->dwFlags & CHN_NOTEFADE) // 1.41-: CHN_KEYOFF|CHN_NOTEFADE |
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 pChn->nFadeOutVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
696 vol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
697 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
698 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
699 // vol is 14-bits |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
700 if (vol) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
701 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
702 // IMPORTANT: pChn->nRealVolume is 14 bits !!! |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
703 // -> _muldiv( 14+8, 6+6, 18); => RealVolume: 14-bit result (22+12-20) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
704 pChn->nRealVolume = _muldiv(vol * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 20); |
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 if (pChn->nPeriod < m_nMinPeriod) pChn->nPeriod = m_nMinPeriod; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
707 int period = pChn->nPeriod; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
708 if ((pChn->dwFlags & (CHN_GLISSANDO|CHN_PORTAMENTO)) == (CHN_GLISSANDO|CHN_PORTAMENTO)) |
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 period = GetPeriodFromNote(GetNoteFromPeriod(period), pChn->nFineTune, pChn->nC4Speed); |
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 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
713 // Arpeggio ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
714 if (pChn->nCommand == CMD_ARPEGGIO) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
715 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
716 switch(m_nTickCount % 3) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
717 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
718 case 1: period = GetPeriodFromNote(pChn->nNote + (pChn->nArpeggio >> 4), pChn->nFineTune, pChn->nC4Speed); break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
719 case 2: period = GetPeriodFromNote(pChn->nNote + (pChn->nArpeggio & 0x0F), pChn->nFineTune, pChn->nC4Speed); break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
720 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
721 } |
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 if (m_dwSongFlags & SONG_AMIGALIMITS) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
724 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
725 if (period < 113*4) period = 113*4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
726 if (period > 856*4) period = 856*4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
727 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
728 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
729 // Pitch/Filter Envelope |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
730 if ((pChn->pHeader) && (pChn->dwFlags & CHN_PITCHENV) && (pChn->pHeader->nPitchEnv)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
731 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
732 INSTRUMENTHEADER *penv = pChn->pHeader; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
733 int envpos = pChn->nPitchEnvPosition; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
734 UINT pt = penv->nPitchEnv - 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
735 for (UINT i=0; i<(UINT)(penv->nPitchEnv-1); i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
736 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
737 if (envpos <= penv->PitchPoints[i]) |
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 pt = i; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
740 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
741 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
742 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
743 int x2 = penv->PitchPoints[pt]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
744 int x1, envpitch; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
745 if (envpos >= x2) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
746 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
747 envpitch = (((int)penv->PitchEnv[pt]) - 32) * 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
748 x1 = x2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
749 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
750 if (pt) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
751 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
752 envpitch = (((int)penv->PitchEnv[pt-1]) - 32) * 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
753 x1 = penv->PitchPoints[pt-1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
754 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
755 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
756 envpitch = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
757 x1 = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
758 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
759 if (envpos > x2) envpos = x2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
760 if ((x2 > x1) && (envpos > x1)) |
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 int envpitchdest = (((int)penv->PitchEnv[pt]) - 32) * 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
763 envpitch += ((envpos - x1) * (envpitchdest - envpitch)) / (x2 - x1); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
764 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
765 if (envpitch < -256) envpitch = -256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
766 if (envpitch > 256) envpitch = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
767 // Filter Envelope: controls cutoff frequency |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
768 if (penv->dwFlags & ENV_FILTER) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
769 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
770 #ifndef NO_FILTER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
771 SetupChannelFilter(pChn, (pChn->dwFlags & CHN_FILTER) ? FALSE : TRUE, envpitch); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
772 #endif // NO_FILTER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
773 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
774 // Pitch Envelope |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
775 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
776 int l = envpitch; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
777 if (l < 0) |
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 l = -l; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
780 if (l > 255) l = 255; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
781 period = _muldiv(period, LinearSlideUpTable[l], 0x10000); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
782 } else |
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 (l > 255) l = 255; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
785 period = _muldiv(period, LinearSlideDownTable[l], 0x10000); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
786 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
787 } |
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 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
790 // Vibrato |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
791 if (pChn->dwFlags & CHN_VIBRATO) |
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 UINT vibpos = pChn->nVibratoPos; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
794 LONG vdelta; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
795 switch (pChn->nVibratoType & 0x03) |
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 case 1: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
798 vdelta = ModRampDownTable[vibpos]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
799 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
800 case 2: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
801 vdelta = ModSquareTable[vibpos]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
802 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
803 case 3: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
804 vdelta = ModRandomTable[vibpos]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
805 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
806 default: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
807 vdelta = ModSinusTable[vibpos]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
808 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
809 UINT vdepth = ((m_nType != MOD_TYPE_IT) || (m_dwSongFlags & SONG_ITOLDEFFECTS)) ? 6 : 7; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
810 vdelta = (vdelta * (int)pChn->nVibratoDepth) >> vdepth; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
811 if ((m_dwSongFlags & SONG_LINEARSLIDES) && (m_nType & MOD_TYPE_IT)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
812 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
813 LONG l = vdelta; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
814 if (l < 0) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
815 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
816 l = -l; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
817 vdelta = _muldiv(period, LinearSlideDownTable[l >> 2], 0x10000) - period; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
818 if (l & 0x03) vdelta += _muldiv(period, FineLinearSlideDownTable[l & 0x03], 0x10000) - period; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
819 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
820 } else |
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 vdelta = _muldiv(period, LinearSlideUpTable[l >> 2], 0x10000) - period; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
823 if (l & 0x03) vdelta += _muldiv(period, FineLinearSlideUpTable[l & 0x03], 0x10000) - period; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
824 |
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 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
827 period += vdelta; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
828 if ((m_nTickCount) || ((m_nType & MOD_TYPE_IT) && (!(m_dwSongFlags & SONG_ITOLDEFFECTS)))) |
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 pChn->nVibratoPos = (vibpos + pChn->nVibratoSpeed) & 0x3F; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
831 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
832 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
833 // Panbrello |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
834 if (pChn->dwFlags & CHN_PANBRELLO) |
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 UINT panpos = ((pChn->nPanbrelloPos+0x10) >> 2) & 0x3F; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
837 LONG pdelta; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
838 switch (pChn->nPanbrelloType & 0x03) |
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 case 1: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
841 pdelta = ModRampDownTable[panpos]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
842 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
843 case 2: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
844 pdelta = ModSquareTable[panpos]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
845 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
846 case 3: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
847 pdelta = ModRandomTable[panpos]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
848 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
849 default: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
850 pdelta = ModSinusTable[panpos]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
851 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
852 pChn->nPanbrelloPos += pChn->nPanbrelloSpeed; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
853 pdelta = ((pdelta * (int)pChn->nPanbrelloDepth) + 2) >> 3; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
854 pdelta += pChn->nRealPan; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
855 if (pdelta < 0) pdelta = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
856 if (pdelta > 256) pdelta = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
857 pChn->nRealPan = pdelta; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
858 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
859 int nPeriodFrac = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
860 // Instrument Auto-Vibrato |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
861 if ((pChn->pInstrument) && (pChn->pInstrument->nVibDepth)) |
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 MODINSTRUMENT *pins = pChn->pInstrument; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
864 if (pins->nVibSweep == 0) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
865 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
866 pChn->nAutoVibDepth = pins->nVibDepth << 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
867 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
868 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
869 if (m_nType & MOD_TYPE_IT) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
870 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
871 pChn->nAutoVibDepth += pins->nVibSweep << 3; |
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 if (!(pChn->dwFlags & CHN_KEYOFF)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
874 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
875 pChn->nAutoVibDepth += (pins->nVibDepth << 8) / pins->nVibSweep; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
876 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
877 if ((pChn->nAutoVibDepth >> 8) > pins->nVibDepth) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
878 pChn->nAutoVibDepth = pins->nVibDepth << 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
879 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
880 pChn->nAutoVibPos += pins->nVibRate; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
881 int val; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
882 switch(pins->nVibType) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
883 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
884 case 4: // Random |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
885 val = ModRandomTable[pChn->nAutoVibPos & 0x3F]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
886 pChn->nAutoVibPos++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
887 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
888 case 3: // Ramp Down |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
889 val = ((0x40 - (pChn->nAutoVibPos >> 1)) & 0x7F) - 0x40; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
890 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
891 case 2: // Ramp Up |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
892 val = ((0x40 + (pChn->nAutoVibPos >> 1)) & 0x7f) - 0x40; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
893 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
894 case 1: // Square |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
895 val = (pChn->nAutoVibPos & 128) ? +64 : -64; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
896 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
897 default: // Sine |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
898 val = ft2VibratoTable[pChn->nAutoVibPos & 255]; |
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 int n = ((val * pChn->nAutoVibDepth) >> 8); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
901 if (m_nType & MOD_TYPE_IT) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
902 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
903 int df1, df2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
904 if (n < 0) |
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 n = -n; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
907 UINT n1 = n >> 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
908 df1 = LinearSlideUpTable[n1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
909 df2 = LinearSlideUpTable[n1+1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
910 } else |
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 UINT n1 = n >> 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
913 df1 = LinearSlideDownTable[n1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
914 df2 = LinearSlideDownTable[n1+1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
915 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
916 n >>= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
917 period = _muldiv(period, df1 + ((df2-df1)*(n&0x3F)>>6), 256); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
918 nPeriodFrac = period & 0xFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
919 period >>= 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
920 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
921 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
922 period += (n >> 6); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
923 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
924 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
925 // Final Period |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
926 if (period <= m_nMinPeriod) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
927 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
928 if (m_nType & MOD_TYPE_S3M) pChn->nLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
929 period = m_nMinPeriod; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
930 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
931 if (period > m_nMaxPeriod) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
932 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
933 if ((m_nType & MOD_TYPE_IT) || (period >= 0x100000)) |
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 pChn->nFadeOutVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
936 pChn->dwFlags |= CHN_NOTEFADE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
937 pChn->nRealVolume = 0; |
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 period = m_nMaxPeriod; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
940 nPeriodFrac = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
941 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
942 UINT freq = GetFreqFromPeriod(period, pChn->nC4Speed, nPeriodFrac); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
943 if ((m_nType & MOD_TYPE_IT) && (freq < 256)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
944 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
945 pChn->nFadeOutVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
946 pChn->dwFlags |= CHN_NOTEFADE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
947 pChn->nRealVolume = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
948 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
949 UINT ninc = _muldiv(freq, 0x10000, gdwMixingFreq); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
950 if ((ninc >= 0xFFB0) && (ninc <= 0x10090)) ninc = 0x10000; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
951 if (m_nFreqFactor != 128) ninc = (ninc * m_nFreqFactor) >> 7; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
952 if (ninc > 0xFF0000) ninc = 0xFF0000; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
953 pChn->nInc = (ninc+1) & ~3; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
954 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
955 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
956 // Increment envelope position |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
957 if (pChn->pHeader) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
958 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
959 INSTRUMENTHEADER *penv = pChn->pHeader; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
960 // Volume Envelope |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
961 if (pChn->dwFlags & CHN_VOLENV) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
962 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
963 // Increase position |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
964 pChn->nVolEnvPosition++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
965 // Volume Loop ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
966 if (penv->dwFlags & ENV_VOLLOOP) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
967 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
968 UINT volloopend = penv->VolPoints[penv->nVolLoopEnd]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
969 if (m_nType != MOD_TYPE_XM) volloopend++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
970 if (pChn->nVolEnvPosition == volloopend) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
971 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
972 pChn->nVolEnvPosition = penv->VolPoints[penv->nVolLoopStart]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
973 if ((penv->nVolLoopEnd == penv->nVolLoopStart) && (!penv->VolEnv[penv->nVolLoopStart]) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
974 && ((!(m_nType & MOD_TYPE_XM)) || (penv->nVolLoopEnd+1 == penv->nVolEnv))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
975 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
976 pChn->dwFlags |= CHN_NOTEFADE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
977 pChn->nFadeOutVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
978 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
979 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
980 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
981 // Volume Sustain ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
982 if ((penv->dwFlags & ENV_VOLSUSTAIN) && (!(pChn->dwFlags & CHN_KEYOFF))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
983 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
984 if (pChn->nVolEnvPosition == (UINT)penv->VolPoints[penv->nVolSustainEnd]+1) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
985 pChn->nVolEnvPosition = penv->VolPoints[penv->nVolSustainBegin]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
986 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
987 // End of Envelope ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
988 if (pChn->nVolEnvPosition > penv->VolPoints[penv->nVolEnv - 1]) |
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 if ((m_nType & MOD_TYPE_IT) || (pChn->dwFlags & CHN_KEYOFF)) pChn->dwFlags |= CHN_NOTEFADE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
991 pChn->nVolEnvPosition = penv->VolPoints[penv->nVolEnv - 1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
992 if ((!penv->VolEnv[penv->nVolEnv-1]) && ((nChn >= m_nChannels) || (m_nType & MOD_TYPE_IT))) |
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 pChn->dwFlags |= CHN_NOTEFADE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
995 pChn->nFadeOutVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
996 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
997 pChn->nRealVolume = 0; |
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 // Panning Envelope |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1002 if (pChn->dwFlags & CHN_PANENV) |
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 pChn->nPanEnvPosition++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1005 if (penv->dwFlags & ENV_PANLOOP) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1006 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1007 UINT panloopend = penv->PanPoints[penv->nPanLoopEnd]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1008 if (m_nType != MOD_TYPE_XM) panloopend++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1009 if (pChn->nPanEnvPosition == panloopend) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1010 pChn->nPanEnvPosition = penv->PanPoints[penv->nPanLoopStart]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1011 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1012 // Panning Sustain ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1013 if ((penv->dwFlags & ENV_PANSUSTAIN) && (pChn->nPanEnvPosition == (UINT)penv->PanPoints[penv->nPanSustainEnd]+1) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1014 && (!(pChn->dwFlags & CHN_KEYOFF))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1015 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1016 // Panning sustained |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1017 pChn->nPanEnvPosition = penv->PanPoints[penv->nPanSustainBegin]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1018 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1019 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1020 if (pChn->nPanEnvPosition > penv->PanPoints[penv->nPanEnv - 1]) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1021 pChn->nPanEnvPosition = penv->PanPoints[penv->nPanEnv - 1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1022 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1023 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1024 // Pitch Envelope |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1025 if (pChn->dwFlags & CHN_PITCHENV) |
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 // Increase position |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1028 pChn->nPitchEnvPosition++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1029 // Pitch Loop ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1030 if (penv->dwFlags & ENV_PITCHLOOP) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1031 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1032 if (pChn->nPitchEnvPosition >= penv->PitchPoints[penv->nPitchLoopEnd]) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1033 pChn->nPitchEnvPosition = penv->PitchPoints[penv->nPitchLoopStart]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1034 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1035 // Pitch Sustain ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1036 if ((penv->dwFlags & ENV_PITCHSUSTAIN) && (!(pChn->dwFlags & CHN_KEYOFF))) |
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 if (pChn->nPitchEnvPosition == (UINT)penv->PitchPoints[penv->nPitchSustainEnd]+1) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1039 pChn->nPitchEnvPosition = penv->PitchPoints[penv->nPitchSustainBegin]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1040 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1041 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1042 if (pChn->nPitchEnvPosition > penv->PitchPoints[penv->nPitchEnv - 1]) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1043 pChn->nPitchEnvPosition = penv->PitchPoints[penv->nPitchEnv - 1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1044 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1045 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1046 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1047 #ifdef MODPLUG_PLAYER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1048 // Limit CPU -> > 80% -> don't ramp |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1049 if ((gnCPUUsage >= 80) && (!pChn->nRealVolume)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1050 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1051 pChn->nLeftVol = pChn->nRightVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1052 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1053 #endif // MODPLUG_PLAYER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1054 // Volume ramping |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1055 pChn->dwFlags &= ~CHN_VOLUMERAMP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1056 if ((pChn->nRealVolume) || (pChn->nLeftVol) || (pChn->nRightVol)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1057 pChn->dwFlags |= CHN_VOLUMERAMP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1058 #ifdef MODPLUG_PLAYER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1059 // Decrease VU-Meter |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1060 if (pChn->nVUMeter > VUMETER_DECAY) pChn->nVUMeter -= VUMETER_DECAY; else pChn->nVUMeter = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1061 #endif // MODPLUG_PLAYER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1062 #ifdef ENABLE_STEREOVU |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1063 if (pChn->nLeftVU > VUMETER_DECAY) pChn->nLeftVU -= VUMETER_DECAY; else pChn->nLeftVU = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1064 if (pChn->nRightVU > VUMETER_DECAY) pChn->nRightVU -= VUMETER_DECAY; else pChn->nRightVU = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1065 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1066 // Check for too big nInc |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1067 if (((pChn->nInc >> 16) + 1) >= (LONG)(pChn->nLoopEnd - pChn->nLoopStart)) pChn->dwFlags &= ~CHN_LOOP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1068 pChn->nNewRightVol = pChn->nNewLeftVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1069 pChn->pCurrentSample = ((pChn->pSample) && (pChn->nLength) && (pChn->nInc)) ? pChn->pSample : NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1070 if (pChn->pCurrentSample) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1071 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1072 // Update VU-Meter (nRealVolume is 14-bit) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1073 #ifdef MODPLUG_PLAYER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1074 UINT vutmp = pChn->nRealVolume >> (14 - 8); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1075 if (vutmp > 0xFF) vutmp = 0xFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1076 if (pChn->nVUMeter >= 0x100) pChn->nVUMeter = vutmp; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1077 vutmp >>= 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1078 if (pChn->nVUMeter < vutmp) pChn->nVUMeter = vutmp; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1079 #endif // MODPLUG_PLAYER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1080 #ifdef ENABLE_STEREOVU |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1081 UINT vul = (pChn->nRealVolume * pChn->nRealPan) >> 14; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1082 if (vul > 127) vul = 127; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1083 if (pChn->nLeftVU > 127) pChn->nLeftVU = (BYTE)vul; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1084 vul >>= 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1085 if (pChn->nLeftVU < vul) pChn->nLeftVU = (BYTE)vul; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1086 UINT vur = (pChn->nRealVolume * (256-pChn->nRealPan)) >> 14; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1087 if (vur > 127) vur = 127; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1088 if (pChn->nRightVU > 127) pChn->nRightVU = (BYTE)vur; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1089 vur >>= 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1090 if (pChn->nRightVU < vur) pChn->nRightVU = (BYTE)vur; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1091 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1092 #ifdef MODPLUG_TRACKER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1093 UINT kChnMasterVol = (pChn->dwFlags & CHN_EXTRALOUD) ? 0x100 : nMasterVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1094 #else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1095 #define kChnMasterVol nMasterVol |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1096 #endif // MODPLUG_TRACKER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1097 // Adjusting volumes |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1098 if (gnChannels >= 2) |
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 int pan = ((int)pChn->nRealPan) - 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1101 pan *= (int)m_nStereoSeparation; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1102 pan /= 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1103 pan += 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1104 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1105 if (pan < 0) pan = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1106 if (pan > 256) pan = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1107 #ifndef MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1108 if (gdwSoundSetup & SNDMIX_REVERSESTEREO) pan = 256 - pan; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1109 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1110 LONG realvol = (pChn->nRealVolume * kChnMasterVol) >> (8-1); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1111 if (gdwSoundSetup & SNDMIX_SOFTPANNING) |
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 if (pan < 128) |
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 pChn->nNewLeftVol = (realvol * pan) >> 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1116 pChn->nNewRightVol = (realvol * 128) >> 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1117 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1118 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1119 pChn->nNewLeftVol = (realvol * 128) >> 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1120 pChn->nNewRightVol = (realvol * (256 - pan)) >> 8; |
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 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1123 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1124 pChn->nNewLeftVol = (realvol * pan) >> 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1125 pChn->nNewRightVol = (realvol * (256 - pan)) >> 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1126 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1127 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1128 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1129 pChn->nNewRightVol = (pChn->nRealVolume * kChnMasterVol) >> 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1130 pChn->nNewLeftVol = pChn->nNewRightVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1131 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1132 // Clipping volumes |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1133 if (pChn->nNewRightVol > 0xFFFF) pChn->nNewRightVol = 0xFFFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1134 if (pChn->nNewLeftVol > 0xFFFF) pChn->nNewLeftVol = 0xFFFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1135 // Check IDO |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1136 if (gdwSoundSetup & SNDMIX_NORESAMPLING) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1137 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1138 pChn->dwFlags |= CHN_NOIDO; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1139 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1140 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1141 pChn->dwFlags &= ~(CHN_NOIDO|CHN_HQSRC); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1142 if( pChn->nInc == 0x10000 ) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1143 { pChn->dwFlags |= CHN_NOIDO; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1144 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1145 else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1146 { if( ((gdwSoundSetup & SNDMIX_HQRESAMPLER) == 0) && ((gdwSoundSetup & SNDMIX_ULTRAHQSRCMODE) == 0) ) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1147 { if (pChn->nInc >= 0xFF00) pChn->dwFlags |= CHN_NOIDO; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1148 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1149 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1150 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1151 pChn->nNewRightVol >>= MIXING_ATTENUATION; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1152 pChn->nNewLeftVol >>= MIXING_ATTENUATION; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1153 pChn->nRightRamp = pChn->nLeftRamp = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1154 // Dolby Pro-Logic Surround |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1155 if ((pChn->dwFlags & CHN_SURROUND) && (gnChannels <= 2)) pChn->nNewLeftVol = - pChn->nNewLeftVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1156 // Checking Ping-Pong Loops |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1157 if (pChn->dwFlags & CHN_PINGPONGFLAG) pChn->nInc = -pChn->nInc; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1158 // Setting up volume ramp |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1159 if ((pChn->dwFlags & CHN_VOLUMERAMP) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1160 && ((pChn->nRightVol != pChn->nNewRightVol) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1161 || (pChn->nLeftVol != pChn->nNewLeftVol))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1162 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1163 LONG nRampLength = gnVolumeRampSamples; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1164 LONG nRightDelta = ((pChn->nNewRightVol - pChn->nRightVol) << VOLUMERAMPPRECISION); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1165 LONG nLeftDelta = ((pChn->nNewLeftVol - pChn->nLeftVol) << VOLUMERAMPPRECISION); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1166 #ifndef MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1167 if ((gdwSoundSetup & SNDMIX_DIRECTTODISK) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1168 || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1169 && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 20))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1170 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1171 if ((pChn->nRightVol|pChn->nLeftVol) && (pChn->nNewRightVol|pChn->nNewLeftVol) && (!(pChn->dwFlags & CHN_FASTVOLRAMP))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1172 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1173 nRampLength = m_nBufferCount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1174 if (nRampLength > (1 << (VOLUMERAMPPRECISION-1))) nRampLength = (1 << (VOLUMERAMPPRECISION-1)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1175 if (nRampLength < (LONG)gnVolumeRampSamples) nRampLength = gnVolumeRampSamples; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1176 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1177 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1178 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1179 pChn->nRightRamp = nRightDelta / nRampLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1180 pChn->nLeftRamp = nLeftDelta / nRampLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1181 pChn->nRightVol = pChn->nNewRightVol - ((pChn->nRightRamp * nRampLength) >> VOLUMERAMPPRECISION); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1182 pChn->nLeftVol = pChn->nNewLeftVol - ((pChn->nLeftRamp * nRampLength) >> VOLUMERAMPPRECISION); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1183 if (pChn->nRightRamp|pChn->nLeftRamp) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1184 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1185 pChn->nRampLength = nRampLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1186 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1187 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1188 pChn->dwFlags &= ~CHN_VOLUMERAMP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1189 pChn->nRightVol = pChn->nNewRightVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1190 pChn->nLeftVol = pChn->nNewLeftVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1191 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1192 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1193 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1194 pChn->dwFlags &= ~CHN_VOLUMERAMP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1195 pChn->nRightVol = pChn->nNewRightVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1196 pChn->nLeftVol = pChn->nNewLeftVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1197 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1198 pChn->nRampRightVol = pChn->nRightVol << VOLUMERAMPPRECISION; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1199 pChn->nRampLeftVol = pChn->nLeftVol << VOLUMERAMPPRECISION; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1200 // Adding the channel in the channel list |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1201 ChnMix[m_nMixChannels++] = nChn; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1202 if (m_nMixChannels >= MAX_CHANNELS) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1203 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1204 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1205 #ifdef ENABLE_STEREOVU |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1206 // Note change but no sample |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1207 if (pChn->nLeftVU > 128) pChn->nLeftVU = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1208 if (pChn->nRightVU > 128) pChn->nRightVU = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1209 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1210 if (pChn->nVUMeter > 0xFF) pChn->nVUMeter = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1211 pChn->nLeftVol = pChn->nRightVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1212 pChn->nLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1213 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1214 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1215 // Checking Max Mix Channels reached: ordering by volume |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1216 if ((m_nMixChannels >= m_nMaxMixChannels) && (!(gdwSoundSetup & SNDMIX_DIRECTTODISK))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1217 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1218 for (UINT i=0; i<m_nMixChannels; i++) |
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 UINT j=i; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1221 while ((j+1<m_nMixChannels) && (Chn[ChnMix[j]].nRealVolume < Chn[ChnMix[j+1]].nRealVolume)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1222 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1223 UINT n = ChnMix[j]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1224 ChnMix[j] = ChnMix[j+1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1225 ChnMix[j+1] = n; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1226 j++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1227 } |
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 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1230 if (m_dwSongFlags & SONG_GLOBALFADE) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1231 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1232 if (!m_nGlobalFadeSamples) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1233 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1234 m_dwSongFlags |= SONG_ENDREACHED; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1235 return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1236 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1237 if (m_nGlobalFadeSamples > m_nBufferCount) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1238 m_nGlobalFadeSamples -= m_nBufferCount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1239 else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1240 m_nGlobalFadeSamples = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1241 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1242 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1243 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1244 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1245 |